chain-insights 0.57.4 → 0.57.6
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 +24 -53
- package/dist/cli.cjs +1 -76
- package/dist/cli.mjs +1 -76
- package/dist/cli.mjs.map +1 -1
- package/dist/mcp-proxy.cjs +1 -1
- package/dist/mcp-proxy.mjs +1 -1
- package/dist/subscription-status-DA9DCFrC.mjs +32 -0
- package/dist/subscription-status-DA9DCFrC.mjs.map +1 -0
- package/dist/subscription-status-ru99UCPZ.cjs +40 -0
- package/docs/graph-tools.md +3 -3
- package/docs/mcp-proxy.md +3 -3
- package/package.json +1 -1
- package/dist/subscription-status-CJ-DaMW9.mjs +0 -142
- package/dist/subscription-status-CJ-DaMW9.mjs.map +0 -1
- package/dist/subscription-status-Cm7LqY_h.cjs +0 -150
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Chain Insights is open-source AML and forensics infrastructure for AI agents
|
|
|
17
17
|
and analysts: a hosted Chain Insights Graph you reach over MCP, screened
|
|
18
18
|
through one CLI. It screens blockchain addresses for risk, explores fund flows
|
|
19
19
|
through read-only graph queries, and returns structured investigation facts.
|
|
20
|
-
The hosted graph has a free
|
|
20
|
+
The hosted graph has a free tier — 5,000 units a day per address,
|
|
21
21
|
no key and no payment setup — so you can run a first screen in minutes.
|
|
22
22
|
|
|
23
23
|
## Quickstart
|
|
@@ -37,7 +37,9 @@ cia mcp tools # list remote graph tools
|
|
|
37
37
|
Sixty seconds gets you the CLI, a network overview, and the available remote
|
|
38
38
|
graph tools for Robinhood.
|
|
39
39
|
To call the same tools from an agent, register the MCP proxy:
|
|
40
|
-
`cia setup claude-code` (or `claude-desktop` / `codex` / `hermes`).
|
|
40
|
+
`cia setup claude-code` (or `claude-desktop` / `codex` / `chatgpt` / `hermes`).
|
|
41
|
+
The `chatgpt` target is for Codex chats inside the ChatGPT app: ask there,
|
|
42
|
+
not in a plain ChatGPT chat.
|
|
41
43
|
|
|
42
44
|
CLI results are human-readable by default. Add `--json` when another tool or
|
|
43
45
|
script needs indented JSON:
|
|
@@ -61,35 +63,20 @@ the balance), and reaches the Chain Insights Graph for the data.
|
|
|
61
63
|
- **Cannot start it:** claude.ai on the web, the Claude mobile apps and Cowork
|
|
62
64
|
cloud sessions. They run no program on your computer.
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Without the plugin, register the installed proxy in Claude Desktop directly:
|
|
68
|
-
|
|
69
|
-
1. Quit Claude Desktop fully. Closing the window is not enough: it keeps
|
|
70
|
-
running and writes its settings file back, which can remove the new entry.
|
|
71
|
-
- macOS: Claude menu > Quit Claude (Cmd+Q).
|
|
72
|
-
- Windows: right-click the Claude icon in the taskbar tray > Quit.
|
|
73
|
-
- Linux: File menu > Quit, or the tray icon > Quit.
|
|
74
|
-
2. Run `npm install -g chain-insights`, then `cia setup claude-desktop`.
|
|
75
|
-
It warns if Claude Desktop is still running.
|
|
76
|
-
3. Start Claude Desktop. `chain-insights` shows under Settings > Developer.
|
|
66
|
+
In Claude Code the plugin also ships a Stop hook that checks every answer
|
|
67
|
+
against the Chain Insights answer rules (full addresses, tokens are not
|
|
68
|
+
dollars) and sends the model back once when one is broken.
|
|
77
69
|
|
|
78
|
-
The
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
The plugin skills are copies of `skills/`. After editing a skill, run
|
|
84
|
-
`node scripts/sync-plugin-skills.mjs`; a test fails while the copies differ.
|
|
70
|
+
The plugin needs Node.js 22 or newer. Add this repository as a plugin
|
|
71
|
+
marketplace, then install the `chain-insights` plugin from it. Setup for
|
|
72
|
+
Claude Desktop without the plugin, and the plugin's own layout, are in
|
|
73
|
+
[plugin/README.md](plugin/README.md).
|
|
85
74
|
|
|
86
75
|
## Purpose And Ownership
|
|
87
76
|
|
|
88
77
|
One public npm package (`chain-insights`) providing the `cia` CLI and a
|
|
89
78
|
stdio MCP proxy over a Chain Insights Graph endpoint.
|
|
90
79
|
|
|
91
|
-
Owning group: chainswarm org, infra group.
|
|
92
|
-
|
|
93
80
|
## What It Does
|
|
94
81
|
|
|
95
82
|
Owns:
|
|
@@ -119,7 +106,9 @@ Never touches:
|
|
|
119
106
|
| `graph_query_batch` | Run related read-only graph queries as one MCP call |
|
|
120
107
|
| `meta_network_capabilities` | Check supported Chain Insights networks and graph tools |
|
|
121
108
|
| `meta_schema` | Read the live graph schema of a network: labels, link types, fields, indexes |
|
|
122
|
-
| `meta_usage_status` | Check the caller's daily free-
|
|
109
|
+
| `meta_usage_status` | Check the caller's daily free-tier graph query allowance |
|
|
110
|
+
| `meta_subscription_status` | Check the caller's $CIA subscription window and allowance |
|
|
111
|
+
| `meta_rules` | Read the answer rules when the `chain-insights-cypher` skill is not loaded |
|
|
123
112
|
| `meta_help` | Show Chain Insights tool and workflow guidance |
|
|
124
113
|
| `wallet_balance` | Show the local payment wallet amount |
|
|
125
114
|
| `wallet_topup` | Show the local payment wallet address and its QR code for a USDC top-up on Base |
|
|
@@ -205,7 +194,7 @@ Chain Insights Graph bills by **billable units**.
|
|
|
205
194
|
|
|
206
195
|
| Door | Price | Limits |
|
|
207
196
|
| --- | --- | --- |
|
|
208
|
-
| Free
|
|
197
|
+
| Free tier | Free | 5,000 units a day per address, 30 requests a minute, resets at midnight UTC |
|
|
209
198
|
| Pay as you go (USDC per call, and the ACP offering) | One cent per 100 units, rounded up to the next cent, one cent minimum per call. A batch is one call. | No daily limit, no rate limit for paying agents |
|
|
210
199
|
| Subscription in $CIA (not yet live) | Paid in $CIA | 100,000 units a day, 60 requests a minute |
|
|
211
200
|
|
|
@@ -340,33 +329,17 @@ a prepared wallet. For paid access, run `cia wallet ready` — it checks
|
|
|
340
329
|
funding and finishes one-time payment setup. Setup commands live in
|
|
341
330
|
[MCP proxy](docs/mcp-proxy.md).
|
|
342
331
|
|
|
343
|
-
The hosted graph includes a free
|
|
332
|
+
The hosted graph includes a free tier for `graph_query` and
|
|
344
333
|
`graph_query_batch`: 5,000 units a day per address (an IP address block),
|
|
345
334
|
no key, 30 requests a minute, reset at midnight UTC. Schema reads
|
|
346
335
|
(`meta_schema`) cost nothing on every door. Use `meta_usage_status` to see
|
|
347
|
-
the current caller allowance. Prepared wallet users receive the free
|
|
336
|
+
the current caller allowance. Prepared wallet users receive the free tier
|
|
348
337
|
first, then paid access continues automatically.
|
|
349
338
|
|
|
350
339
|
## Test
|
|
351
340
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
npm run typecheck
|
|
356
|
-
npm run build
|
|
357
|
-
npm test
|
|
358
|
-
npm run release:check # PR-only step in verify.yml
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
CI install step, when reproducing CI:
|
|
362
|
-
|
|
363
|
-
```bash
|
|
364
|
-
npm ci --ignore-scripts --audit=false --fund=false
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
CI workflows: `.github/workflows/verify.yml` (typecheck, build,
|
|
368
|
-
release:check, tests, npm pack contents), `security.yml`, `scorecard.yml`,
|
|
369
|
-
`docs.yml`.
|
|
341
|
+
The local gate, the CI install step and the workflows are in
|
|
342
|
+
[docs/development.md](docs/development.md).
|
|
370
343
|
|
|
371
344
|
## Debug
|
|
372
345
|
|
|
@@ -394,6 +367,9 @@ cia mcp tools --refresh
|
|
|
394
367
|
# Installed CLI sanity
|
|
395
368
|
cia --version && cia update --check
|
|
396
369
|
|
|
370
|
+
# Endpoint, wallet and access mode in one view
|
|
371
|
+
cia status
|
|
372
|
+
|
|
397
373
|
```
|
|
398
374
|
|
|
399
375
|
If network or tool discovery fails, check the endpoint and access mode
|
|
@@ -402,13 +378,8 @@ the command.
|
|
|
402
378
|
|
|
403
379
|
## Pre-staging / Release
|
|
404
380
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
verification checks. Before pre-staging or release, run the full local gate
|
|
408
|
-
and confirm the release metadata is consistent.
|
|
409
|
-
|
|
410
|
-
See [Release Discipline](docs/contributing.md#release-discipline) for the
|
|
411
|
-
complete contributor requirements.
|
|
381
|
+
Contributor rules, the version bump and the changelog entry every pull
|
|
382
|
+
request carries: [Release Discipline](docs/contributing.md#release-discipline).
|
|
412
383
|
|
|
413
384
|
## Documentation Links
|
|
414
385
|
|
package/dist/cli.cjs
CHANGED
|
@@ -162,66 +162,6 @@ async function printNetworkSchema(name, opts) {
|
|
|
162
162
|
});
|
|
163
163
|
console.log(opts.json ? JSON.stringify(schema, null, 2) : formatGraphSchemaText(schema));
|
|
164
164
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Fetches the caller's subscription facts for the deposit pre-sign guard.
|
|
167
|
-
* The extension math is server-authoritative: the printed values come from
|
|
168
|
-
* `subscription_status`. Any failure (no wallet, unreachable endpoint,
|
|
169
|
-
* missing tool, error result) degrades to an unavailable lookup — the guard
|
|
170
|
-
* must never block the flow on a server that lacks the tool.
|
|
171
|
-
*/
|
|
172
|
-
async function fetchSubscriptionStatusForCli() {
|
|
173
|
-
try {
|
|
174
|
-
const { getWalletAccount } = await Promise.resolve().then(() => require("./tools-BHfphgy9.cjs")).then((n) => n.tools_exports);
|
|
175
|
-
const account = await getWalletAccount();
|
|
176
|
-
return await withGraphMcpClient("chain-insights-cli-subscription-status", async (client) => {
|
|
177
|
-
const result = await client.callTool({
|
|
178
|
-
name: "subscription_status",
|
|
179
|
-
arguments: { wallet: account.address }
|
|
180
|
-
});
|
|
181
|
-
const { parseSubscriptionStatusToolResult } = await Promise.resolve().then(() => require("./subscription-status-Cm7LqY_h.cjs")).then((n) => n.subscription_status_exports);
|
|
182
|
-
const facts = parseSubscriptionStatusToolResult(result);
|
|
183
|
-
if (!facts) return {
|
|
184
|
-
kind: "unavailable",
|
|
185
|
-
reason: "the graph endpoint returned no subscription facts"
|
|
186
|
-
};
|
|
187
|
-
return {
|
|
188
|
-
kind: "available",
|
|
189
|
-
facts
|
|
190
|
-
};
|
|
191
|
-
});
|
|
192
|
-
} catch (err) {
|
|
193
|
-
return {
|
|
194
|
-
kind: "unavailable",
|
|
195
|
-
reason: err.message
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
async function printSubscriptionPassGuidance(pass) {
|
|
200
|
-
const { formatDepositGuardLine, formatDepositIrreversibilityWarning, formatSubscriptionPassHint, isDepositConfirmed, resolveSubscriptionMonthUsd } = await Promise.resolve().then(() => require("./subscription-status-Cm7LqY_h.cjs")).then((n) => n.subscription_status_exports);
|
|
201
|
-
const hint = formatSubscriptionPassHint(pass, resolveSubscriptionMonthUsd());
|
|
202
|
-
const status = await fetchSubscriptionStatusForCli();
|
|
203
|
-
if (status.kind === "available") {
|
|
204
|
-
process.stderr.write(`${formatDepositGuardLine(status.facts, pass)}\n`);
|
|
205
|
-
process.stderr.write("The no-admin subscription sink cannot refund deposits. Type DEPOSIT to continue:\n");
|
|
206
|
-
const { createInterface } = await import("node:readline/promises");
|
|
207
|
-
const prompt = createInterface({
|
|
208
|
-
input: process.stdin,
|
|
209
|
-
output: process.stderr
|
|
210
|
-
});
|
|
211
|
-
let answer;
|
|
212
|
-
try {
|
|
213
|
-
answer = await prompt.question("> ");
|
|
214
|
-
} finally {
|
|
215
|
-
prompt.close();
|
|
216
|
-
}
|
|
217
|
-
process.stderr.write("\n");
|
|
218
|
-
if (!isDepositConfirmed(answer)) throw new Error("Deposit cancelled. No deposit was made.");
|
|
219
|
-
console.log(hint);
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
process.stderr.write(`${formatDepositIrreversibilityWarning(status.reason)}\n`);
|
|
223
|
-
console.log(hint);
|
|
224
|
-
}
|
|
225
165
|
function addAmlAddressRiskCommand(parent, networksCommand) {
|
|
226
166
|
parent.addCommand(createCliCommand("aml-address-risk").description("CIA workflow: screen an address for AML risk, exchange behavior, and optional comparison with another address").requiredOption("--address <address>", "Full blockchain address to screen").requiredOption("--network <network>", `Network to query. Run \`${networksCommand}\` for supported networks.`).option("--compare-address <address>", "Optional second address to compare against the screened address").option("--json", "Print machine-readable JSON output").option("--version <version>", "AML tool contract version. Omit to use the latest version (currently v1)").addOption(new commander.Option("--tool-version <version>", "Internal alias for the AML tool version").hideHelp()).action(async (opts) => {
|
|
227
167
|
try {
|
|
@@ -548,21 +488,6 @@ program.command("wallet").description("Manage the local Base USDC payment wallet
|
|
|
548
488
|
process.exit(1);
|
|
549
489
|
}
|
|
550
490
|
}));
|
|
551
|
-
program.command("buy").description("Show CIA subscription pass deposit guidance (the sink cannot refund deposits)").addCommand(createCliCommand("day").description("Show day-pass deposit guidance (SUBSCRIPTION_MONTH_USD / 30)").action(async () => {
|
|
552
|
-
try {
|
|
553
|
-
await printSubscriptionPassGuidance("day");
|
|
554
|
-
} catch (err) {
|
|
555
|
-
console.error(err.message);
|
|
556
|
-
process.exit(1);
|
|
557
|
-
}
|
|
558
|
-
})).addCommand(createCliCommand("month").description("Show month-pass deposit guidance at the list price").action(async () => {
|
|
559
|
-
try {
|
|
560
|
-
await printSubscriptionPassGuidance("month");
|
|
561
|
-
} catch (err) {
|
|
562
|
-
console.error(err.message);
|
|
563
|
-
process.exit(1);
|
|
564
|
-
}
|
|
565
|
-
}));
|
|
566
491
|
program.command("mcp").description("Low-level access to the Chain Insights MCP endpoint").allowExcessArguments(false).addCommand(createCliCommand("networks").description("List the detailed Chain Insights capability matrix and tool support").option("--json", "Print raw capability JSON").action(async (opts) => {
|
|
567
492
|
try {
|
|
568
493
|
await printNetworkCapabilities(opts);
|
|
@@ -661,7 +586,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
661
586
|
json: opts.json
|
|
662
587
|
});
|
|
663
588
|
} catch (err) {
|
|
664
|
-
const { isMissingSubscriptionStatusToolError, unavailableSubscriptionStatus, subscriptionStatusText } = await Promise.resolve().then(() => require("./subscription-status-
|
|
589
|
+
const { isMissingSubscriptionStatusToolError, unavailableSubscriptionStatus, subscriptionStatusText } = await Promise.resolve().then(() => require("./subscription-status-ru99UCPZ.cjs")).then((n) => n.subscription_status_exports);
|
|
665
590
|
if (!isMissingSubscriptionStatusToolError(err)) throw err;
|
|
666
591
|
const { resolveGraphMcpEndpoint } = await Promise.resolve().then(() => require("./client-Ypw9BNbn.cjs")).then((n) => n.client_exports);
|
|
667
592
|
console.log(subscriptionStatusText(unavailableSubscriptionStatus(resolveGraphMcpEndpoint(config), `subscription_status failed: ${err.message}`)));
|
package/dist/cli.mjs
CHANGED
|
@@ -160,66 +160,6 @@ async function printNetworkSchema(name, opts) {
|
|
|
160
160
|
});
|
|
161
161
|
console.log(opts.json ? JSON.stringify(schema, null, 2) : formatGraphSchemaText(schema));
|
|
162
162
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Fetches the caller's subscription facts for the deposit pre-sign guard.
|
|
165
|
-
* The extension math is server-authoritative: the printed values come from
|
|
166
|
-
* `subscription_status`. Any failure (no wallet, unreachable endpoint,
|
|
167
|
-
* missing tool, error result) degrades to an unavailable lookup — the guard
|
|
168
|
-
* must never block the flow on a server that lacks the tool.
|
|
169
|
-
*/
|
|
170
|
-
async function fetchSubscriptionStatusForCli() {
|
|
171
|
-
try {
|
|
172
|
-
const { getWalletAccount } = await import("./tools-BnThuvE2.mjs").then((n) => n.p);
|
|
173
|
-
const account = await getWalletAccount();
|
|
174
|
-
return await withGraphMcpClient("chain-insights-cli-subscription-status", async (client) => {
|
|
175
|
-
const result = await client.callTool({
|
|
176
|
-
name: "subscription_status",
|
|
177
|
-
arguments: { wallet: account.address }
|
|
178
|
-
});
|
|
179
|
-
const { parseSubscriptionStatusToolResult } = await import("./subscription-status-CJ-DaMW9.mjs").then((n) => n.t);
|
|
180
|
-
const facts = parseSubscriptionStatusToolResult(result);
|
|
181
|
-
if (!facts) return {
|
|
182
|
-
kind: "unavailable",
|
|
183
|
-
reason: "the graph endpoint returned no subscription facts"
|
|
184
|
-
};
|
|
185
|
-
return {
|
|
186
|
-
kind: "available",
|
|
187
|
-
facts
|
|
188
|
-
};
|
|
189
|
-
});
|
|
190
|
-
} catch (err) {
|
|
191
|
-
return {
|
|
192
|
-
kind: "unavailable",
|
|
193
|
-
reason: err.message
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
async function printSubscriptionPassGuidance(pass) {
|
|
198
|
-
const { formatDepositGuardLine, formatDepositIrreversibilityWarning, formatSubscriptionPassHint, isDepositConfirmed, resolveSubscriptionMonthUsd } = await import("./subscription-status-CJ-DaMW9.mjs").then((n) => n.t);
|
|
199
|
-
const hint = formatSubscriptionPassHint(pass, resolveSubscriptionMonthUsd());
|
|
200
|
-
const status = await fetchSubscriptionStatusForCli();
|
|
201
|
-
if (status.kind === "available") {
|
|
202
|
-
process.stderr.write(`${formatDepositGuardLine(status.facts, pass)}\n`);
|
|
203
|
-
process.stderr.write("The no-admin subscription sink cannot refund deposits. Type DEPOSIT to continue:\n");
|
|
204
|
-
const { createInterface } = await import("node:readline/promises");
|
|
205
|
-
const prompt = createInterface({
|
|
206
|
-
input: process.stdin,
|
|
207
|
-
output: process.stderr
|
|
208
|
-
});
|
|
209
|
-
let answer;
|
|
210
|
-
try {
|
|
211
|
-
answer = await prompt.question("> ");
|
|
212
|
-
} finally {
|
|
213
|
-
prompt.close();
|
|
214
|
-
}
|
|
215
|
-
process.stderr.write("\n");
|
|
216
|
-
if (!isDepositConfirmed(answer)) throw new Error("Deposit cancelled. No deposit was made.");
|
|
217
|
-
console.log(hint);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
process.stderr.write(`${formatDepositIrreversibilityWarning(status.reason)}\n`);
|
|
221
|
-
console.log(hint);
|
|
222
|
-
}
|
|
223
163
|
function addAmlAddressRiskCommand(parent, networksCommand) {
|
|
224
164
|
parent.addCommand(createCliCommand("aml-address-risk").description("CIA workflow: screen an address for AML risk, exchange behavior, and optional comparison with another address").requiredOption("--address <address>", "Full blockchain address to screen").requiredOption("--network <network>", `Network to query. Run \`${networksCommand}\` for supported networks.`).option("--compare-address <address>", "Optional second address to compare against the screened address").option("--json", "Print machine-readable JSON output").option("--version <version>", "AML tool contract version. Omit to use the latest version (currently v1)").addOption(new Option("--tool-version <version>", "Internal alias for the AML tool version").hideHelp()).action(async (opts) => {
|
|
225
165
|
try {
|
|
@@ -546,21 +486,6 @@ program.command("wallet").description("Manage the local Base USDC payment wallet
|
|
|
546
486
|
process.exit(1);
|
|
547
487
|
}
|
|
548
488
|
}));
|
|
549
|
-
program.command("buy").description("Show CIA subscription pass deposit guidance (the sink cannot refund deposits)").addCommand(createCliCommand("day").description("Show day-pass deposit guidance (SUBSCRIPTION_MONTH_USD / 30)").action(async () => {
|
|
550
|
-
try {
|
|
551
|
-
await printSubscriptionPassGuidance("day");
|
|
552
|
-
} catch (err) {
|
|
553
|
-
console.error(err.message);
|
|
554
|
-
process.exit(1);
|
|
555
|
-
}
|
|
556
|
-
})).addCommand(createCliCommand("month").description("Show month-pass deposit guidance at the list price").action(async () => {
|
|
557
|
-
try {
|
|
558
|
-
await printSubscriptionPassGuidance("month");
|
|
559
|
-
} catch (err) {
|
|
560
|
-
console.error(err.message);
|
|
561
|
-
process.exit(1);
|
|
562
|
-
}
|
|
563
|
-
}));
|
|
564
489
|
program.command("mcp").description("Low-level access to the Chain Insights MCP endpoint").allowExcessArguments(false).addCommand(createCliCommand("networks").description("List the detailed Chain Insights capability matrix and tool support").option("--json", "Print raw capability JSON").action(async (opts) => {
|
|
565
490
|
try {
|
|
566
491
|
await printNetworkCapabilities(opts);
|
|
@@ -659,7 +584,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
659
584
|
json: opts.json
|
|
660
585
|
});
|
|
661
586
|
} catch (err) {
|
|
662
|
-
const { isMissingSubscriptionStatusToolError, unavailableSubscriptionStatus, subscriptionStatusText } = await import("./subscription-status-
|
|
587
|
+
const { isMissingSubscriptionStatusToolError, unavailableSubscriptionStatus, subscriptionStatusText } = await import("./subscription-status-DA9DCFrC.mjs").then((n) => n.t);
|
|
663
588
|
if (!isMissingSubscriptionStatusToolError(err)) throw err;
|
|
664
589
|
const { resolveGraphMcpEndpoint } = await import("./client-gsLi528K.mjs").then((n) => n.r);
|
|
665
590
|
console.log(subscriptionStatusText(unavailableSubscriptionStatus(resolveGraphMcpEndpoint(config), `subscription_status failed: ${err.message}`)));
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/investigation/workflows.ts","../src/cli.ts"],"sourcesContent":["export interface CiaWorkflow {\n name: string\n tool: string\n network: string\n description: string\n command: string\n}\n\nexport const CIA_WORKFLOWS: readonly CiaWorkflow[] = [\n {\n name: 'aml-address-risk',\n tool: 'aml_address_risk',\n network: 'robinhood',\n description: 'Screen one address for AML risk, behavior, and exchange exposure.',\n command: 'cia workflow aml-address-risk',\n },\n]\n\nconst NAME_WIDTH = 22\nconst NETWORK_WIDTH = 12\nconst COMMAND_WIDTH = 34\n\nfunction formatRow(values: string[]): string {\n return [\n values[0]?.padEnd(NAME_WIDTH),\n values[1]?.padEnd(NETWORK_WIDTH),\n values[2]?.padEnd(COMMAND_WIDTH),\n ].join(' ')\n}\n\nexport function formatCiaWorkflows(workflows: readonly CiaWorkflow[]): string {\n if (workflows.length === 0) return 'No CIA workflow tools available.'\n\n const rows = workflows.flatMap((workflow) => [\n formatRow([workflow.name, workflow.network, workflow.command]),\n ` ${workflow.description}`,\n ])\n\n return [\n 'CIA workflow tools',\n '',\n formatRow(['Workflow', 'Network', 'Run with']),\n formatRow(['-'.repeat(NAME_WIDTH), '-'.repeat(NETWORK_WIDTH), '-'.repeat(COMMAND_WIDTH)]),\n ...rows,\n ].join('\\n')\n}\n","import { Command, Option } from 'commander'\nimport { execFileSync } from 'node:child_process'\nimport { fileURLToPath } from 'node:url'\nimport path from 'node:path'\nimport { PACKAGE_INFO, PACKAGE_VERSION } from './version.js'\nimport { CIA_WORKFLOWS, formatCiaWorkflows } from './investigation/workflows.js'\nimport { printMcpTextContent } from './mcp/print-result.js'\nimport type { SubscriptionPass, SubscriptionStatusFacts } from './mcp/subscription-status.js'\n\n// Resolve bin/install.cjs relative to this file's location in dist/\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst installerPath = path.resolve(__dirname, '..', 'bin', 'install.cjs')\n\nconst program = new Command()\n\nfunction createCliCommand(name: string): Command {\n return new Command(name).showHelpAfterError()\n}\n\nprogram\n .name('cia')\n .description('AML investigation toolkit for blockchain analysis')\n .version(PACKAGE_INFO.version)\n .showHelpAfterError()\n .option('--claude', 'Install Claude Code skills globally to ~/.claude/skills/')\n .option('--claude-desktop', 'Register the MCP proxy in Claude Desktop')\n .option('--codex', 'Install Codex skills globally to ~/.codex/skills/ and register MCP')\n .option(\n '--hermes',\n 'Install Hermes skills globally to ~/.hermes/skills/chain-insights/ and register MCP'\n )\n\n// Handle installer flags when invoked with no subcommand (bare `chain-insights --claude`)\nconst rawArgs = process.argv.slice(2)\nconst installerFlags = rawArgs.filter(\n (a) => a === '--claude' || a === '--claude-desktop' || a === '--codex' || a === '--hermes'\n)\n\n// Commander treats the root package `--version` option as global, so it would\n// consume the same flag on the AML workflow command before the child can route\n// a tool contract. Rewrite only the child-command form to a hidden alias. The\n// visible child help still documents `--version`, while root `cia --version`\n// remains the package version.\nfunction normalizeAmlToolVersionArgv(argv: string[]): string[] {\n const commandIndex = rawArgs.findIndex(\n (arg, index) => arg === 'aml-address-risk' && index === 1 && rawArgs[0] === 'workflow'\n )\n if (commandIndex === -1) return argv\n\n return argv.map((arg, index) => {\n const userArgIndex = index - 2\n if (userArgIndex <= commandIndex) return arg\n if (arg === '--version') return '--tool-version'\n if (arg.startsWith('--version=')) return `--tool-version=${arg.slice('--version='.length)}`\n return arg\n })\n}\n// A help/version request must never trigger a global install side effect — let\n// commander handle it and print help/version instead.\nconst wantsHelpOrVersion = rawArgs.some(\n (a) => a === '--help' || a === '-h' || a === '--version' || a === '-V'\n)\nif (installerFlags.length > 0 && !wantsHelpOrVersion && !rawArgs.some((a) => !a.startsWith('-'))) {\n try {\n execFileSync(process.execPath, [installerPath, ...installerFlags], { stdio: 'inherit' })\n } catch (err) {\n console.error('Installation failed:', (err as Error).message)\n process.exit(1)\n }\n process.exit(0)\n}\n\n// Legacy mcp aliases for retired graph tools are not commands; reject them\n// before Commander can mis-parse them. Members are built by concatenation so\n// retired names never appear as literal source strings.\nconst retiredMcpAliases = new Set([['trace', '-funds'].join(''), ['track', '-funds'].join('')])\nif (rawArgs[0] === 'mcp' && retiredMcpAliases.has(rawArgs[1] ?? '')) {\n console.error(`error: unknown command '${rawArgs[1]}'`)\n process.exit(1)\n}\n\nfunction runInstaller(flag: '--claude' | '--claude-desktop' | '--codex' | '--hermes'): void {\n try {\n execFileSync(process.execPath, [installerPath, flag], { stdio: 'inherit' })\n } catch (err) {\n console.error('Installation failed:', (err as Error).message)\n process.exit(1)\n }\n}\n\nasync function withGraphMcpClient<T>(\n name: string,\n fn: (\n client: import('@modelcontextprotocol/sdk/client/index.js').Client,\n config: Awaited<ReturnType<typeof import('./config/index.js').loadConfig>>\n ) => Promise<T>\n): Promise<T> {\n const { loadConfig } = await import('./config/index.js')\n const config = await loadConfig()\n const { createConfiguredGraphMcpFetch, resolveGraphMcpEndpoint } = await import('./mcp/client.js')\n // A dead or wrong endpoint (e.g. a stale `debug` config pointing at a stopped\n // local server) otherwise surfaces as a bare \"fetch failed\"; toGraphMcpEndpointError\n // names the endpoint and the cause, and passes real backend errors through.\n const { toGraphMcpEndpointError } = await import('./mcp/transport-error.js')\n const endpoint = resolveGraphMcpEndpoint(config)\n const paymentFetch = await createConfiguredGraphMcpFetch(config)\n const { Client } = await import('@modelcontextprotocol/sdk/client/index.js')\n const { StreamableHTTPClientTransport } =\n await import('@modelcontextprotocol/sdk/client/streamableHttp.js')\n const client = new Client({ name, version: PACKAGE_VERSION })\n try {\n await client.connect(\n new StreamableHTTPClientTransport(new URL(endpoint), {\n fetch: paymentFetch,\n })\n )\n } catch (err) {\n throw toGraphMcpEndpointError(err, endpoint)\n }\n // Every CLI command builds its own client, separate from the MCP proxy's\n // one, so unattended scheduled CLI runs also write to the action log.\n const { installActionLogging } = await import('./mcp/action-log.js')\n installActionLogging(client)\n try {\n return await fn(client, config)\n } catch (err) {\n throw toGraphMcpEndpointError(err, endpoint)\n } finally {\n await client.close()\n }\n}\n\nasync function printNetworkCapabilities(opts: { json?: boolean }): Promise<void> {\n const { loadConfig } = await import('./config/index.js')\n const { fetchNetworkCapabilities, formatNetworkCapabilities } =\n await import('./mcp/capabilities.js')\n const document = await fetchNetworkCapabilities(await loadConfig())\n if (opts.json) {\n console.log(JSON.stringify(document, null, 2))\n } else {\n console.log(formatNetworkCapabilities(document))\n }\n}\n\nasync function printNetworkOverview(opts: { json?: boolean }): Promise<void> {\n const { loadConfig } = await import('./config/index.js')\n const { fetchNetworkCapabilities, formatNetworkOverview } = await import('./mcp/capabilities.js')\n const document = await fetchNetworkCapabilities(await loadConfig())\n if (opts.json) {\n console.log(JSON.stringify(document, null, 2))\n } else {\n console.log(formatNetworkOverview(document))\n }\n}\n\nasync function printNetworkCapability(name: string, opts: { json?: boolean }): Promise<void> {\n const { loadConfig } = await import('./config/index.js')\n const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } =\n await import('./mcp/capabilities.js')\n const document = await fetchNetworkCapabilities(await loadConfig())\n const network = findNetworkCapability(document, name)\n if (!network) {\n const available = document.networks.map((candidate) => candidate.network).join(', ')\n const suffix = available ? ` Available networks: ${available}.` : ''\n throw new Error(\n `Network \"${name}\" is not supported.${suffix} Run \\`cia networks\\` to list supported networks.`\n )\n }\n if (opts.json) {\n console.log(JSON.stringify(network, null, 2))\n } else {\n console.log(formatNetworkCapability(network))\n }\n}\n\n/**\n * The live graph schema of one network (meta_schema). A fresh cache answers with\n * no request; a build opens one session and reads through it.\n */\nasync function printNetworkSchema(\n name: string,\n opts: { json?: boolean; refresh?: boolean }\n): Promise<void> {\n const { loadConfig } = await import('./config/index.js')\n const { resolveGraphMcpEndpoint } = await import('./mcp/client.js')\n const { formatGraphSchemaText, getGraphSchema } = await import('./mcp/graph-schema.js')\n const config = await loadConfig()\n const schema = await getGraphSchema({\n network: name,\n refresh: opts.refresh === true,\n endpoint: resolveGraphMcpEndpoint(config),\n withClient: (fn) => withGraphMcpClient('chain-insights-cli-schema', (client) => fn(client)),\n })\n console.log(opts.json ? JSON.stringify(schema, null, 2) : formatGraphSchemaText(schema))\n}\n\ntype SubscriptionStatusLookup =\n { kind: 'available'; facts: SubscriptionStatusFacts } | { kind: 'unavailable'; reason: string }\n\n/**\n * Fetches the caller's subscription facts for the deposit pre-sign guard.\n * The extension math is server-authoritative: the printed values come from\n * `subscription_status`. Any failure (no wallet, unreachable endpoint,\n * missing tool, error result) degrades to an unavailable lookup — the guard\n * must never block the flow on a server that lacks the tool.\n */\nasync function fetchSubscriptionStatusForCli(): Promise<SubscriptionStatusLookup> {\n try {\n const { getWalletAccount } = await import('./wallet/tools.js')\n const account = await getWalletAccount()\n return await withGraphMcpClient(\n 'chain-insights-cli-subscription-status',\n async (client): Promise<SubscriptionStatusLookup> => {\n const result = (await client.callTool({\n name: 'subscription_status',\n arguments: { wallet: account.address },\n })) as {\n content?: Array<{ type: string; text?: string }>\n structuredContent?: Record<string, unknown>\n isError?: boolean\n }\n const { parseSubscriptionStatusToolResult } = await import('./mcp/subscription-status.js')\n const facts = parseSubscriptionStatusToolResult(result)\n if (!facts) {\n return {\n kind: 'unavailable',\n reason: 'the graph endpoint returned no subscription facts',\n }\n }\n return { kind: 'available', facts }\n }\n )\n } catch (err) {\n return { kind: 'unavailable', reason: (err as Error).message }\n }\n}\n\nasync function printSubscriptionPassGuidance(pass: SubscriptionPass): Promise<void> {\n const {\n formatDepositGuardLine,\n formatDepositIrreversibilityWarning,\n formatSubscriptionPassHint,\n isDepositConfirmed,\n resolveSubscriptionMonthUsd,\n } = await import('./mcp/subscription-status.js')\n const hint = formatSubscriptionPassHint(pass, resolveSubscriptionMonthUsd())\n const status = await fetchSubscriptionStatusForCli()\n\n if (status.kind === 'available') {\n process.stderr.write(`${formatDepositGuardLine(status.facts, pass)}\\n`)\n process.stderr.write(\n 'The no-admin subscription sink cannot refund deposits. Type DEPOSIT to continue:\\n'\n )\n const { createInterface } = await import('node:readline/promises')\n const prompt = createInterface({ input: process.stdin, output: process.stderr })\n let answer: string\n try {\n answer = await prompt.question('> ')\n } finally {\n prompt.close()\n }\n process.stderr.write('\\n')\n if (!isDepositConfirmed(answer)) {\n throw new Error('Deposit cancelled. No deposit was made.')\n }\n console.log(hint)\n return\n }\n\n // Server lacks the tool (or is unreachable): generic irreversibility\n // warning, then proceed with the guidance.\n process.stderr.write(`${formatDepositIrreversibilityWarning(status.reason)}\\n`)\n console.log(hint)\n}\n\nfunction addAmlAddressRiskCommand(parent: Command, networksCommand: string): void {\n parent.addCommand(\n createCliCommand('aml-address-risk')\n .description(\n 'CIA workflow: screen an address for AML risk, exchange behavior, and optional comparison with another address'\n )\n .requiredOption('--address <address>', 'Full blockchain address to screen')\n .requiredOption(\n '--network <network>',\n `Network to query. Run \\`${networksCommand}\\` for supported networks.`\n )\n .option(\n '--compare-address <address>',\n 'Optional second address to compare against the screened address'\n )\n .option('--json', 'Print machine-readable JSON output')\n .option(\n '--version <version>',\n 'AML tool contract version. Omit to use the latest version (currently v1)'\n )\n .addOption(\n new Option('--tool-version <version>', 'Internal alias for the AML tool version').hideHelp()\n )\n .action(\n async (opts: {\n address: string\n network: string\n compareAddress?: string\n json?: boolean\n version?: string\n toolVersion?: string\n }) => {\n try {\n const { resolveAmlAddressRiskVersion } = await import('./investigation/public-tools.js')\n const requestedVersion = opts.toolVersion ?? opts.version\n resolveAmlAddressRiskVersion(requestedVersion)\n await withGraphMcpClient('chain-insights-cli-aml-address-risk', async (client) => {\n const { runAmlAddressRisk } = await import('./investigation/public-tools.js')\n const result = await runAmlAddressRisk(\n client,\n {\n address: opts.address,\n network: opts.network,\n compareAddress: opts.compareAddress,\n },\n requestedVersion\n )\n console.log(\n opts.json ? JSON.stringify(result.structuredContent, null, 2) : result.summaryText\n )\n })\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n }\n )\n )\n}\n\nprogram\n .command('networks')\n .description('Show supported network status and dataset overview')\n .option('--json', 'Print raw capability JSON')\n .action(async (opts: { json?: boolean }) => {\n try {\n await printNetworkOverview(opts)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n\nprogram\n .command('network')\n .description('Show details for one supported graph network')\n .argument('<name>', 'Network identifier or display name (for example: robinhood)')\n .option('--json', 'Print raw capability JSON for this network (with --schema: the schema JSON)')\n .option(\n '--schema',\n 'Show the live graph schema: labels, link types, fields and indexes (cached for 24 hours)'\n )\n .option('--refresh', 'With --schema: rebuild the schema now instead of reading the cache')\n .action(async (name: string, opts: { json?: boolean; schema?: boolean; refresh?: boolean }) => {\n try {\n if (opts.refresh && !opts.schema) {\n throw new Error('--refresh needs --schema: run `cia network <name> --schema --refresh`.')\n }\n if (opts.schema) {\n await printNetworkSchema(name, opts)\n } else {\n await printNetworkCapability(name, opts)\n }\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n\nprogram\n .command('workflows')\n .description('List CIA workflow tools')\n .option('--json', 'Print the workflow catalog as JSON')\n .action((opts: { json?: boolean }) => {\n if (opts.json) {\n console.log(JSON.stringify(CIA_WORKFLOWS, null, 2))\n return\n }\n console.log(formatCiaWorkflows(CIA_WORKFLOWS))\n })\n\nconst workflowCommand = program.command('workflow').description('Run a high-level CIA workflow')\n\naddAmlAddressRiskCommand(workflowCommand, 'cia networks')\n\nprogram\n .command('status')\n .description('Show toolkit status and configuration')\n .action(async () => {\n const { loadConfig } = await import('./config/index.js')\n const config = await loadConfig()\n const graphMcpStatus =\n config.graphMcpMode === 'debug' && config.graphMcpAuthToken?.trim()\n ? 'bearer access mode'\n : `${config.graphMcpMode} mode`\n console.log('Config: ', config.dataDir)\n console.log('Chain Insights Graph:', graphMcpStatus)\n console.log('Graph endpoint:', config.graphMcpEndpoint)\n })\n\nprogram\n .command('update')\n .description('Check npmjs for a newer Chain Insights release and update this CLI')\n .option('--check', 'Only check for a newer release')\n .option('--dry-run', 'Print the update command without running it')\n .action(async (opts: { check?: boolean; dryRun?: boolean }) => {\n try {\n const { checkForUpdate, runPackageUpdate } = await import('./update.js')\n const result = await checkForUpdate()\n if (result.error) {\n throw new Error(`Could not check npmjs for updates: ${result.error}`)\n }\n if (!result.updateAvailable || !result.latestVersion) {\n console.log(`Chain Insights is up to date (${result.currentVersion}).`)\n return\n }\n\n console.log(\n `Chain Insights ${result.latestVersion} is available (current ${result.currentVersion}).`\n )\n if (opts.check) {\n console.log(`Run: ${result.updateCommand}`)\n return\n }\n if (opts.dryRun) {\n console.log(`Would run: ${result.updateCommand}`)\n return\n }\n\n console.log(`Running: ${result.updateCommand}`)\n runPackageUpdate(result.packageName)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n\nprogram\n .command('debug')\n .description('Configure Chain Insights Graph debug mode')\n .addCommand(\n createCliCommand('on')\n .description('Enable Chain Insights Graph debug mode without x402 payments')\n .requiredOption('--token <token>', 'Debug bearer token')\n .option('--endpoint <url>', 'Chain Insights Graph endpoint')\n .action(async (opts: { token: string; endpoint?: string }) => {\n try {\n const { saveConfig } = await import('./config/index.js')\n await saveConfig({\n graphMcpMode: 'debug',\n graphMcpAuthToken: opts.token,\n ...(opts.endpoint ? { graphMcpEndpoint: opts.endpoint } : {}),\n })\n console.log('Chain Insights Graph debug mode enabled')\n if (opts.endpoint) console.log(`Graph endpoint: ${opts.endpoint}`)\n console.log('Payments: disabled for Chain Insights Graph calls')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('off')\n .description('Disable Chain Insights Graph debug mode and use paid x402 calls')\n .action(async () => {\n try {\n const { saveConfig } = await import('./config/index.js')\n await saveConfig({ graphMcpMode: 'paid', graphMcpAuthToken: '' })\n console.log('Chain Insights Graph debug mode disabled')\n console.log('Payments: enabled for Chain Insights Graph calls')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('status')\n .description('Show Chain Insights Graph payment/debug mode')\n .action(async () => {\n try {\n const { loadConfig } = await import('./config/index.js')\n const config = await loadConfig()\n console.log(`Chain Insights Graph mode: ${config.graphMcpMode}`)\n console.log(`Graph endpoint: ${config.graphMcpEndpoint}`)\n console.log(\n `Debug token: ${config.graphMcpAuthToken?.trim() ? 'configured' : 'not configured'}`\n )\n console.log(`Payments: ${config.graphMcpMode === 'debug' ? 'disabled' : 'enabled'}`)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nprogram\n .command('access-key')\n .description('Configure Chain Insights Graph test access key mode')\n .addCommand(\n createCliCommand('set')\n .description('Use a Chain Insights Graph test access key without x402 payments')\n .argument('<key>', 'Test access key')\n .option('--endpoint <url>', 'Chain Insights Graph endpoint')\n .action(async (key: string, opts: { endpoint?: string }) => {\n try {\n const normalizedKey = key.trim()\n if (!normalizedKey) throw new Error('Test access key is required')\n const { saveConfig } = await import('./config/index.js')\n await saveConfig({\n graphMcpMode: 'debug',\n graphMcpAuthToken: normalizedKey,\n ...(opts.endpoint ? { graphMcpEndpoint: opts.endpoint } : {}),\n })\n console.log('Chain Insights Graph test access key configured')\n if (opts.endpoint) console.log(`Graph endpoint: ${opts.endpoint}`)\n console.log('Payments: disabled when the server accepts this key')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('clear')\n .description('Remove the Chain Insights Graph test access key and use paid x402 calls')\n .action(async () => {\n try {\n const { saveConfig } = await import('./config/index.js')\n await saveConfig({ graphMcpMode: 'paid', graphMcpAuthToken: '' })\n console.log('Chain Insights Graph test access key cleared')\n console.log('Payments: enabled for Chain Insights Graph calls')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('status')\n .description('Show Chain Insights Graph test access key status')\n .action(async () => {\n try {\n const { loadConfig } = await import('./config/index.js')\n const config = await loadConfig()\n console.log(`Graph endpoint: ${config.graphMcpEndpoint}`)\n console.log(\n `Access key: ${config.graphMcpAuthToken?.trim() ? 'configured' : 'not configured'}`\n )\n console.log(\n `Payments: ${config.graphMcpAuthToken?.trim() ? 'disabled when accepted by server' : 'enabled'}`\n )\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nprogram\n .command('setup')\n .description('Configure external MCP clients')\n .addCommand(\n createCliCommand('claude-code')\n .alias('claude')\n .description('Install Claude Code skills and register the MCP proxy')\n .action(() => {\n runInstaller('--claude')\n })\n )\n .addCommand(\n createCliCommand('claude-desktop')\n .description('Register the MCP proxy in Claude Desktop, which draws the money-flow views')\n .action(() => {\n runInstaller('--claude-desktop')\n })\n )\n .addCommand(\n createCliCommand('codex')\n .description('Install Codex skills and register the MCP proxy')\n .action(() => {\n runInstaller('--codex')\n })\n )\n .addCommand(\n createCliCommand('chatgpt')\n .description('Set up the ChatGPT desktop app: its Codex chats run Chain Insights')\n .action(() => {\n runInstaller('--codex')\n // The ChatGPT chat itself runs in the cloud and cannot reach a server on\n // this computer. Only the app's Codex chats can.\n console.log(\n '\\n In the ChatGPT app, ask in a Codex chat (Codex in the sidebar), not in a ChatGPT chat.\\n'\n )\n })\n )\n .addCommand(\n createCliCommand('hermes')\n .description('Install Hermes skills and register the MCP proxy')\n .action(() => {\n runInstaller('--hermes')\n })\n )\n\nprogram\n .command('config')\n .description('Read or write configuration values')\n .addCommand(\n createCliCommand('get')\n .description('Read one Chain Insights configuration value')\n .argument('<key>', 'Config key to read')\n .action(async (key: string) => {\n const { loadConfig } = await import('./config/index.js')\n const { CONFIG_KEYS } = await import('./config/schema.js')\n if (!CONFIG_KEYS.includes(key as (typeof CONFIG_KEYS)[number])) {\n console.error(`Unknown config key: ${key}`)\n process.exit(1)\n }\n const config = await loadConfig()\n const value = (config as Record<string, unknown>)[key]\n console.log(value ?? '')\n })\n )\n .addCommand(\n createCliCommand('reset')\n .description(\n 'Put every setting back to its default (production endpoint, paid mode, no test key); the wallet stays'\n )\n .action(async () => {\n try {\n const { resetConfig, loadConfig } = await import('./config/index.js')\n const { backupPath } = await resetConfig()\n const config = await loadConfig()\n if (backupPath) console.log(`Previous settings saved to ${backupPath}`)\n console.log('Settings reset to defaults.')\n console.log(`Graph endpoint: ${config.graphMcpEndpoint}`)\n console.log(`Mode: ${config.graphMcpMode}`)\n console.log('Test access: off')\n console.log('Wallet: unchanged (~/.chain-insights/wallet.json)')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('set')\n .description('Write one Chain Insights configuration value')\n .argument('<key>', 'Config key to write')\n .argument('<value>', 'Value to set')\n .action(async (key: string, value: string) => {\n // D-01: walletPrivateKey is intercepted before saveConfig — the raw private key\n // must NEVER be written to config.json.\n if (key === 'walletPrivateKey') {\n try {\n const { setWalletPrivateKey } = await import('./wallet/index.js')\n const address = await setWalletPrivateKey(value)\n console.log('Wallet private key encrypted and stored in ~/.chain-insights/wallet.json')\n console.log(`Wallet address: ${address}`)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n return // MUST return — walletPrivateKey must never reach saveConfig or config.json\n }\n const { loadConfig, saveConfig } = await import('./config/index.js')\n const { CONFIG_KEYS, DEFAULT_CONFIG } = await import('./config/schema.js')\n const current = await loadConfig()\n if (!CONFIG_KEYS.includes(key as (typeof CONFIG_KEYS)[number])) {\n console.error(`Unknown config key: ${key}`)\n process.exit(1)\n }\n const existing = (current as Record<string, unknown>)[key]\n const defaultValue = (DEFAULT_CONFIG as Record<string, unknown>)[key]\n const coerced =\n typeof existing === 'number' || typeof defaultValue === 'number' ? Number(value) : value\n await saveConfig({ [key]: coerced } as Parameters<typeof saveConfig>[0])\n const displayed = key.toLowerCase().includes('token') ? '[redacted]' : coerced\n console.log(`Set ${key} = ${displayed}`)\n })\n )\n\nprogram\n .command('wallet')\n .description('Manage the local Base USDC payment wallet')\n .addCommand(\n createCliCommand('create')\n .description('Generate a new local Base payment wallet')\n .action(async () => {\n try {\n const { isWalletConfigured, setWalletPrivateKey, walletPath } =\n await import('./wallet/index.js')\n const { createInterface } = await import('node:readline/promises')\n const { formatWalletBackupWarning, generateWalletPrivateKey, isWalletBackupConfirmed } =\n await import('./wallet/create.js')\n\n if (await isWalletConfigured()) {\n throw new Error(\n 'A payment wallet already exists. Run `cia wallet address` to view it or use `cia wallet import <private-key> --force` to replace it.'\n )\n }\n\n const privateKey = generateWalletPrivateKey()\n const color = process.stderr.isTTY === true && process.env['NO_COLOR'] === undefined\n process.stderr.write(`${formatWalletBackupWarning(privateKey, { color })}\\n`)\n const prompt = createInterface({ input: process.stdin, output: process.stderr })\n let answer: string\n try {\n answer = await prompt.question('> ')\n } finally {\n prompt.close()\n }\n process.stderr.write('\\n')\n if (!isWalletBackupConfirmed(answer)) {\n throw new Error('Wallet creation cancelled. The wallet was not saved.')\n }\n\n const address = await setWalletPrivateKey(privateKey)\n console.log(`Wallet created: ${address}`)\n console.log(`Encrypted local copy: ${walletPath()}`)\n console.log('Next: cia wallet ready')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('import')\n .description('Import a Base payment wallet')\n .argument('<private-key>', '0x-prefixed EVM private key')\n .option(\n '--force',\n 'Replace an existing wallet (the previous key is backed up next to wallet.json)'\n )\n .action(async (privateKey: string, opts: { force?: boolean }) => {\n try {\n const { setWalletPrivateKey, isWalletConfigured } = await import('./wallet/index.js')\n const replacing = opts.force === true && (await isWalletConfigured())\n const address = await setWalletPrivateKey(privateKey, { force: opts.force })\n if (replacing) {\n console.log('Previous wallet key backed up next to ~/.chain-insights/wallet.json')\n }\n console.log(`Wallet imported: ${address}`)\n console.log(\n 'Keep your original private key backed up securely; it cannot be recovered from the encrypted local copy.'\n )\n console.log('Encrypted local copy: ~/.chain-insights/wallet.json')\n console.log('Next: cia wallet ready')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('address')\n .description('Print the local payment wallet address')\n .action(async () => {\n try {\n const { getWalletAccount } = await import('./wallet/tools.js')\n const account = await getWalletAccount()\n console.log(account.address)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('balance')\n .description('Show the local payment wallet Base USDC balance')\n .action(async () => {\n try {\n const { getWalletBalanceText } = await import('./wallet/tools.js')\n console.log(await getWalletBalanceText())\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('ready')\n .description('Check and prepare the wallet for paid Chain Insights Graph calls')\n .option('--check-only', 'Only check readiness; do not submit the one-time payment setup')\n .addOption(new Option('--no-approve', 'Deprecated alias for --check-only').hideHelp())\n .option('--payment-usdc <amount>', 'USDC setup cap to prepare for paid calls', '1')\n .addOption(\n new Option('--approval-usdc <amount>', 'Deprecated alias for --payment-usdc').hideHelp()\n )\n .option('--json', 'Print machine-readable readiness metadata')\n .action(\n async (opts: {\n checkOnly?: boolean\n approve?: boolean\n paymentUsdc?: string\n approvalUsdc?: string\n json?: boolean\n }) => {\n try {\n const { formatWalletReadiness, parsePaymentApprovalUnits, prepareWalletForPaidCalls } =\n await import('./wallet/tools.js')\n const minimumApprovalUnits = parsePaymentApprovalUnits(\n opts.paymentUsdc ?? opts.approvalUsdc ?? '1'\n )\n const result = await prepareWalletForPaidCalls({\n minimumApprovalUnits,\n approve: opts.checkOnly ? false : opts.approve !== false,\n })\n\n if (opts.json) {\n console.log(\n JSON.stringify(\n result,\n (_key, value) => (typeof value === 'bigint' ? value.toString() : value),\n 2\n )\n )\n return\n }\n\n console.log(formatWalletReadiness(result.readiness, result.approval))\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n }\n )\n )\n .addCommand(\n createCliCommand('topup')\n .description('Open a local browser page to top up the payment wallet')\n .option('--no-open', 'Print the top-up URL without opening a browser')\n .option('--json', 'Print machine-readable top-up metadata')\n .action(async (opts: { open?: boolean; json?: boolean }) => {\n try {\n const { buildTopupInfo, getWalletAccount } = await import('./wallet/tools.js')\n const { startTopupServer } = await import('./wallet/topup-server.js')\n const account = await getWalletAccount()\n const url = await startTopupServer(account)\n const info = buildTopupInfo(account.address, url)\n\n if (opts.json) {\n console.log(JSON.stringify(info, null, 2))\n } else {\n console.log(`Top-up URL: ${url}`)\n console.log(`Wallet: ${account.address}`)\n console.log('Network: Base')\n console.log('Token: USDC')\n console.log('Press Ctrl+C to stop the top-up server.')\n }\n\n if (opts.open !== false) {\n const open = (await import('open')).default\n await open(url)\n }\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nprogram\n .command('buy')\n .description('Show CIA subscription pass deposit guidance (the sink cannot refund deposits)')\n .addCommand(\n createCliCommand('day')\n .description('Show day-pass deposit guidance (SUBSCRIPTION_MONTH_USD / 30)')\n .action(async () => {\n try {\n await printSubscriptionPassGuidance('day')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('month')\n .description('Show month-pass deposit guidance at the list price')\n .action(async () => {\n try {\n await printSubscriptionPassGuidance('month')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nconst mcpCommand = program\n .command('mcp')\n .description('Low-level access to the Chain Insights MCP endpoint')\n .allowExcessArguments(false)\n .addCommand(\n createCliCommand('networks')\n .description('List the detailed Chain Insights capability matrix and tool support')\n .option('--json', 'Print raw capability JSON')\n .action(async (opts: { json?: boolean }) => {\n try {\n await printNetworkCapabilities(opts)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('tools')\n .description('List the remote GraphRAG MCP tools (cached for 24 hours)')\n .option('--refresh', 'Force refresh schema cache')\n .action(async (opts: { refresh?: boolean }) => {\n try {\n const { loadSchema, saveSchema } = await import('./mcp/schema-cache.js')\n const { formatToolsTable } = await import('./mcp/format.js')\n const { visibleRemoteTools } = await import('./mcp/tool-visibility.js')\n const { loadConfig } = await import('./config/index.js')\n const { createConfiguredGraphMcpFetch, resolveGraphMcpEndpoint } =\n await import('./mcp/client.js')\n const config = await loadConfig()\n const graphMcpEndpoint = resolveGraphMcpEndpoint(config)\n let tools = opts.refresh ? null : await loadSchema(graphMcpEndpoint)\n if (!tools) {\n const paymentFetch = await createConfiguredGraphMcpFetch(config)\n const { Client } = await import('@modelcontextprotocol/sdk/client/index.js')\n const { StreamableHTTPClientTransport } =\n await import('@modelcontextprotocol/sdk/client/streamableHttp.js')\n const client = new Client({ name: 'chain-insights-cli', version: PACKAGE_VERSION })\n await client.connect(\n new StreamableHTTPClientTransport(new URL(graphMcpEndpoint), { fetch: paymentFetch })\n )\n try {\n const result = await client.listTools()\n tools = result.tools as Array<{ name: string; description?: string }>\n await saveSchema(tools, graphMcpEndpoint)\n } finally {\n await client.close()\n }\n }\n console.log(formatToolsTable(visibleRemoteTools(tools)))\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nmcpCommand.addCommand(\n createCliCommand('call')\n .description('Call a low-level MCP tool directly (advanced)')\n .option('--json', 'Print machine-readable JSON output')\n .argument('<tool>', 'Tool name to call')\n .argument('[args...]', 'Key=value arguments (e.g. address=0x1234... network=robinhood)')\n .action(async (tool: string, rawArgs: string[], opts: { json?: boolean }) => {\n try {\n const { parseMcpCallArgs } = await import('./mcp/call-args.js')\n const { assertPublicMcpToolName, validatePublicMcpToolArguments } =\n await import('./mcp/tool-visibility.js')\n const args = parseMcpCallArgs(rawArgs)\n assertPublicMcpToolName(tool)\n validatePublicMcpToolArguments(tool, args)\n\n if (tool === 'wallet_balance') {\n const { getWalletBalanceText } = await import('./wallet/tools.js')\n console.log(await getWalletBalanceText())\n return\n }\n\n if (tool === 'meta_network_capabilities') {\n await printNetworkCapabilities({ json: opts.json })\n return\n }\n\n if (tool === 'meta_schema') {\n await printNetworkSchema(String(args['network'] ?? ''), {\n json: opts.json,\n refresh: String(args['refresh'] ?? '').toLowerCase() === 'true',\n })\n return\n }\n\n if (tool === 'graph_expand') {\n throw new Error(\n 'graph_expand is used only by the Chain Insights view in Claude. Run `cia mcp call graph_query` with your own query instead.'\n )\n }\n\n if (tool === 'meta_help') {\n console.log(\n 'Graph tools: graph_query and graph_query_batch. Metadata and payment tools: meta_* and wallet_balance.'\n )\n return\n }\n\n await withGraphMcpClient('chain-insights-cli-call', async (client, config) => {\n if (tool === 'meta_usage_status') {\n try {\n const result = await client.callTool({ name: 'usage_status', arguments: {} })\n printMcpTextContent(\n result as { content?: Array<{ type: string; text?: string }>; isError?: boolean },\n { tool, json: opts.json }\n )\n } catch (err) {\n const {\n isMissingUsageStatusToolError,\n primitiveBackendUsageStatus,\n usageStatusText,\n } = await import('./mcp/usage-status.js')\n if (!isMissingUsageStatusToolError(err)) throw err\n const { resolveGraphMcpEndpoint } = await import('./mcp/client.js')\n console.log(\n usageStatusText(primitiveBackendUsageStatus(resolveGraphMcpEndpoint(config)))\n )\n }\n return\n }\n if (tool === 'meta_subscription_status') {\n try {\n const { getWalletAccount } = await import('./wallet/tools.js')\n const account = await getWalletAccount()\n const result = await client.callTool({\n name: 'subscription_status',\n arguments: { wallet: account.address },\n })\n printMcpTextContent(\n result as { content?: Array<{ type: string; text?: string }>; isError?: boolean },\n { tool, json: opts.json }\n )\n } catch (err) {\n const {\n isMissingSubscriptionStatusToolError,\n unavailableSubscriptionStatus,\n subscriptionStatusText,\n } = await import('./mcp/subscription-status.js')\n if (!isMissingSubscriptionStatusToolError(err)) throw err\n const { resolveGraphMcpEndpoint } = await import('./mcp/client.js')\n console.log(\n subscriptionStatusText(\n unavailableSubscriptionStatus(\n resolveGraphMcpEndpoint(config),\n `subscription_status failed: ${(err as Error).message}`\n )\n )\n )\n }\n return\n }\n // graph_query and graph_query_batch can run past the SDK's 60 s default\n // while the server is still answering. Other tools keep that default.\n const { graphToolRequestOptions } = await import('./mcp/request-timeout.js')\n const requestOptions = graphToolRequestOptions(tool)\n const result = requestOptions\n ? await client.callTool({ name: tool, arguments: args }, undefined, requestOptions)\n : await client.callTool({ name: tool, arguments: args })\n printMcpTextContent(\n result as { content?: Array<{ type: string; text?: string }>; isError?: boolean },\n { tool, json: opts.json }\n )\n })\n } catch (err) {\n const { formatMcpCallError } = await import('./mcp/tool-visibility.js')\n console.error(formatMcpCallError(tool, err))\n process.exit(1)\n }\n })\n)\n\n// parseAsync (not parse) so a rejected async action surfaces as a clean\n// one-line error and a non-zero exit, instead of an unhandled-rejection stack\n// trace. Commands with their own try/catch still exit(1) before this fires.\nprogram.parseAsync(normalizeAmlToolVersionArgv(process.argv)).catch((err) => {\n console.error((err as Error).message)\n process.exit(1)\n})\n"],"mappings":";;;;;;AAQA,MAAa,gBAAwC,CACnD;CACE,MAAM;CACN,MAAM;CACN,SAAS;CACT,aAAa;CACb,SAAS;AACX,CACF;AAEA,MAAM,aAAa;AACnB,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AAEtB,SAAS,UAAU,QAA0B;CAC3C,OAAO;EACL,OAAO,EAAE,EAAE,OAAO,UAAU;EAC5B,OAAO,EAAE,EAAE,OAAO,aAAa;EAC/B,OAAO,EAAE,EAAE,OAAO,aAAa;CACjC,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAgB,mBAAmB,WAA2C;CAC5E,IAAI,UAAU,WAAW,GAAG,OAAO;CAEnC,MAAM,OAAO,UAAU,SAAS,aAAa,CAC3C,UAAU;EAAC,SAAS;EAAM,SAAS;EAAS,SAAS;CAAO,CAAC,GAC7D,KAAK,SAAS,aAChB,CAAC;CAED,OAAO;EACL;EACA;EACA,UAAU;GAAC;GAAY;GAAW;EAAU,CAAC;EAC7C,UAAU;GAAC,IAAI,OAAO,UAAU;GAAG,IAAI,OAAO,aAAa;GAAG,IAAI,OAAO,aAAa;EAAC,CAAC;EACxF,GAAG;CACL,CAAC,CAAC,KAAK,IAAI;AACb;;;ACnCA,MAAM,YAAY,KAAK,Q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ACZ,MAAM,EAAE,uBAAuB,MAAM,OAAO,iCAA2B,CAAA,MAAA,MAAA,EAAA,CAAA;EACvE,QAAQ,MAAM,mBAAmB,MAAM,GAAG,CAAC;EAC3C,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC,CACL;AAKA,QAAQ,WAAW,4BAA4B,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,QAAQ;CAC3E,QAAQ,MAAO,IAAc,OAAO;CACpC,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/investigation/workflows.ts","../src/cli.ts"],"sourcesContent":["export interface CiaWorkflow {\n name: string\n tool: string\n network: string\n description: string\n command: string\n}\n\nexport const CIA_WORKFLOWS: readonly CiaWorkflow[] = [\n {\n name: 'aml-address-risk',\n tool: 'aml_address_risk',\n network: 'robinhood',\n description: 'Screen one address for AML risk, behavior, and exchange exposure.',\n command: 'cia workflow aml-address-risk',\n },\n]\n\nconst NAME_WIDTH = 22\nconst NETWORK_WIDTH = 12\nconst COMMAND_WIDTH = 34\n\nfunction formatRow(values: string[]): string {\n return [\n values[0]?.padEnd(NAME_WIDTH),\n values[1]?.padEnd(NETWORK_WIDTH),\n values[2]?.padEnd(COMMAND_WIDTH),\n ].join(' ')\n}\n\nexport function formatCiaWorkflows(workflows: readonly CiaWorkflow[]): string {\n if (workflows.length === 0) return 'No CIA workflow tools available.'\n\n const rows = workflows.flatMap((workflow) => [\n formatRow([workflow.name, workflow.network, workflow.command]),\n ` ${workflow.description}`,\n ])\n\n return [\n 'CIA workflow tools',\n '',\n formatRow(['Workflow', 'Network', 'Run with']),\n formatRow(['-'.repeat(NAME_WIDTH), '-'.repeat(NETWORK_WIDTH), '-'.repeat(COMMAND_WIDTH)]),\n ...rows,\n ].join('\\n')\n}\n","import { Command, Option } from 'commander'\nimport { execFileSync } from 'node:child_process'\nimport { fileURLToPath } from 'node:url'\nimport path from 'node:path'\nimport { PACKAGE_INFO, PACKAGE_VERSION } from './version.js'\nimport { CIA_WORKFLOWS, formatCiaWorkflows } from './investigation/workflows.js'\nimport { printMcpTextContent } from './mcp/print-result.js'\n\n// Resolve bin/install.cjs relative to this file's location in dist/\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\nconst installerPath = path.resolve(__dirname, '..', 'bin', 'install.cjs')\n\nconst program = new Command()\n\nfunction createCliCommand(name: string): Command {\n return new Command(name).showHelpAfterError()\n}\n\nprogram\n .name('cia')\n .description('AML investigation toolkit for blockchain analysis')\n .version(PACKAGE_INFO.version)\n .showHelpAfterError()\n .option('--claude', 'Install Claude Code skills globally to ~/.claude/skills/')\n .option('--claude-desktop', 'Register the MCP proxy in Claude Desktop')\n .option('--codex', 'Install Codex skills globally to ~/.codex/skills/ and register MCP')\n .option(\n '--hermes',\n 'Install Hermes skills globally to ~/.hermes/skills/chain-insights/ and register MCP'\n )\n\n// Handle installer flags when invoked with no subcommand (bare `chain-insights --claude`)\nconst rawArgs = process.argv.slice(2)\nconst installerFlags = rawArgs.filter(\n (a) => a === '--claude' || a === '--claude-desktop' || a === '--codex' || a === '--hermes'\n)\n\n// Commander treats the root package `--version` option as global, so it would\n// consume the same flag on the AML workflow command before the child can route\n// a tool contract. Rewrite only the child-command form to a hidden alias. The\n// visible child help still documents `--version`, while root `cia --version`\n// remains the package version.\nfunction normalizeAmlToolVersionArgv(argv: string[]): string[] {\n const commandIndex = rawArgs.findIndex(\n (arg, index) => arg === 'aml-address-risk' && index === 1 && rawArgs[0] === 'workflow'\n )\n if (commandIndex === -1) return argv\n\n return argv.map((arg, index) => {\n const userArgIndex = index - 2\n if (userArgIndex <= commandIndex) return arg\n if (arg === '--version') return '--tool-version'\n if (arg.startsWith('--version=')) return `--tool-version=${arg.slice('--version='.length)}`\n return arg\n })\n}\n// A help/version request must never trigger a global install side effect — let\n// commander handle it and print help/version instead.\nconst wantsHelpOrVersion = rawArgs.some(\n (a) => a === '--help' || a === '-h' || a === '--version' || a === '-V'\n)\nif (installerFlags.length > 0 && !wantsHelpOrVersion && !rawArgs.some((a) => !a.startsWith('-'))) {\n try {\n execFileSync(process.execPath, [installerPath, ...installerFlags], { stdio: 'inherit' })\n } catch (err) {\n console.error('Installation failed:', (err as Error).message)\n process.exit(1)\n }\n process.exit(0)\n}\n\n// Legacy mcp aliases for retired graph tools are not commands; reject them\n// before Commander can mis-parse them. Members are built by concatenation so\n// retired names never appear as literal source strings.\nconst retiredMcpAliases = new Set([['trace', '-funds'].join(''), ['track', '-funds'].join('')])\nif (rawArgs[0] === 'mcp' && retiredMcpAliases.has(rawArgs[1] ?? '')) {\n console.error(`error: unknown command '${rawArgs[1]}'`)\n process.exit(1)\n}\n\nfunction runInstaller(flag: '--claude' | '--claude-desktop' | '--codex' | '--hermes'): void {\n try {\n execFileSync(process.execPath, [installerPath, flag], { stdio: 'inherit' })\n } catch (err) {\n console.error('Installation failed:', (err as Error).message)\n process.exit(1)\n }\n}\n\nasync function withGraphMcpClient<T>(\n name: string,\n fn: (\n client: import('@modelcontextprotocol/sdk/client/index.js').Client,\n config: Awaited<ReturnType<typeof import('./config/index.js').loadConfig>>\n ) => Promise<T>\n): Promise<T> {\n const { loadConfig } = await import('./config/index.js')\n const config = await loadConfig()\n const { createConfiguredGraphMcpFetch, resolveGraphMcpEndpoint } = await import('./mcp/client.js')\n // A dead or wrong endpoint (e.g. a stale `debug` config pointing at a stopped\n // local server) otherwise surfaces as a bare \"fetch failed\"; toGraphMcpEndpointError\n // names the endpoint and the cause, and passes real backend errors through.\n const { toGraphMcpEndpointError } = await import('./mcp/transport-error.js')\n const endpoint = resolveGraphMcpEndpoint(config)\n const paymentFetch = await createConfiguredGraphMcpFetch(config)\n const { Client } = await import('@modelcontextprotocol/sdk/client/index.js')\n const { StreamableHTTPClientTransport } =\n await import('@modelcontextprotocol/sdk/client/streamableHttp.js')\n const client = new Client({ name, version: PACKAGE_VERSION })\n try {\n await client.connect(\n new StreamableHTTPClientTransport(new URL(endpoint), {\n fetch: paymentFetch,\n })\n )\n } catch (err) {\n throw toGraphMcpEndpointError(err, endpoint)\n }\n // Every CLI command builds its own client, separate from the MCP proxy's\n // one, so unattended scheduled CLI runs also write to the action log.\n const { installActionLogging } = await import('./mcp/action-log.js')\n installActionLogging(client)\n try {\n return await fn(client, config)\n } catch (err) {\n throw toGraphMcpEndpointError(err, endpoint)\n } finally {\n await client.close()\n }\n}\n\nasync function printNetworkCapabilities(opts: { json?: boolean }): Promise<void> {\n const { loadConfig } = await import('./config/index.js')\n const { fetchNetworkCapabilities, formatNetworkCapabilities } =\n await import('./mcp/capabilities.js')\n const document = await fetchNetworkCapabilities(await loadConfig())\n if (opts.json) {\n console.log(JSON.stringify(document, null, 2))\n } else {\n console.log(formatNetworkCapabilities(document))\n }\n}\n\nasync function printNetworkOverview(opts: { json?: boolean }): Promise<void> {\n const { loadConfig } = await import('./config/index.js')\n const { fetchNetworkCapabilities, formatNetworkOverview } = await import('./mcp/capabilities.js')\n const document = await fetchNetworkCapabilities(await loadConfig())\n if (opts.json) {\n console.log(JSON.stringify(document, null, 2))\n } else {\n console.log(formatNetworkOverview(document))\n }\n}\n\nasync function printNetworkCapability(name: string, opts: { json?: boolean }): Promise<void> {\n const { loadConfig } = await import('./config/index.js')\n const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } =\n await import('./mcp/capabilities.js')\n const document = await fetchNetworkCapabilities(await loadConfig())\n const network = findNetworkCapability(document, name)\n if (!network) {\n const available = document.networks.map((candidate) => candidate.network).join(', ')\n const suffix = available ? ` Available networks: ${available}.` : ''\n throw new Error(\n `Network \"${name}\" is not supported.${suffix} Run \\`cia networks\\` to list supported networks.`\n )\n }\n if (opts.json) {\n console.log(JSON.stringify(network, null, 2))\n } else {\n console.log(formatNetworkCapability(network))\n }\n}\n\n/**\n * The live graph schema of one network (meta_schema). A fresh cache answers with\n * no request; a build opens one session and reads through it.\n */\nasync function printNetworkSchema(\n name: string,\n opts: { json?: boolean; refresh?: boolean }\n): Promise<void> {\n const { loadConfig } = await import('./config/index.js')\n const { resolveGraphMcpEndpoint } = await import('./mcp/client.js')\n const { formatGraphSchemaText, getGraphSchema } = await import('./mcp/graph-schema.js')\n const config = await loadConfig()\n const schema = await getGraphSchema({\n network: name,\n refresh: opts.refresh === true,\n endpoint: resolveGraphMcpEndpoint(config),\n withClient: (fn) => withGraphMcpClient('chain-insights-cli-schema', (client) => fn(client)),\n })\n console.log(opts.json ? JSON.stringify(schema, null, 2) : formatGraphSchemaText(schema))\n}\n\nfunction addAmlAddressRiskCommand(parent: Command, networksCommand: string): void {\n parent.addCommand(\n createCliCommand('aml-address-risk')\n .description(\n 'CIA workflow: screen an address for AML risk, exchange behavior, and optional comparison with another address'\n )\n .requiredOption('--address <address>', 'Full blockchain address to screen')\n .requiredOption(\n '--network <network>',\n `Network to query. Run \\`${networksCommand}\\` for supported networks.`\n )\n .option(\n '--compare-address <address>',\n 'Optional second address to compare against the screened address'\n )\n .option('--json', 'Print machine-readable JSON output')\n .option(\n '--version <version>',\n 'AML tool contract version. Omit to use the latest version (currently v1)'\n )\n .addOption(\n new Option('--tool-version <version>', 'Internal alias for the AML tool version').hideHelp()\n )\n .action(\n async (opts: {\n address: string\n network: string\n compareAddress?: string\n json?: boolean\n version?: string\n toolVersion?: string\n }) => {\n try {\n const { resolveAmlAddressRiskVersion } = await import('./investigation/public-tools.js')\n const requestedVersion = opts.toolVersion ?? opts.version\n resolveAmlAddressRiskVersion(requestedVersion)\n await withGraphMcpClient('chain-insights-cli-aml-address-risk', async (client) => {\n const { runAmlAddressRisk } = await import('./investigation/public-tools.js')\n const result = await runAmlAddressRisk(\n client,\n {\n address: opts.address,\n network: opts.network,\n compareAddress: opts.compareAddress,\n },\n requestedVersion\n )\n console.log(\n opts.json ? JSON.stringify(result.structuredContent, null, 2) : result.summaryText\n )\n })\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n }\n )\n )\n}\n\nprogram\n .command('networks')\n .description('Show supported network status and dataset overview')\n .option('--json', 'Print raw capability JSON')\n .action(async (opts: { json?: boolean }) => {\n try {\n await printNetworkOverview(opts)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n\nprogram\n .command('network')\n .description('Show details for one supported graph network')\n .argument('<name>', 'Network identifier or display name (for example: robinhood)')\n .option('--json', 'Print raw capability JSON for this network (with --schema: the schema JSON)')\n .option(\n '--schema',\n 'Show the live graph schema: labels, link types, fields and indexes (cached for 24 hours)'\n )\n .option('--refresh', 'With --schema: rebuild the schema now instead of reading the cache')\n .action(async (name: string, opts: { json?: boolean; schema?: boolean; refresh?: boolean }) => {\n try {\n if (opts.refresh && !opts.schema) {\n throw new Error('--refresh needs --schema: run `cia network <name> --schema --refresh`.')\n }\n if (opts.schema) {\n await printNetworkSchema(name, opts)\n } else {\n await printNetworkCapability(name, opts)\n }\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n\nprogram\n .command('workflows')\n .description('List CIA workflow tools')\n .option('--json', 'Print the workflow catalog as JSON')\n .action((opts: { json?: boolean }) => {\n if (opts.json) {\n console.log(JSON.stringify(CIA_WORKFLOWS, null, 2))\n return\n }\n console.log(formatCiaWorkflows(CIA_WORKFLOWS))\n })\n\nconst workflowCommand = program.command('workflow').description('Run a high-level CIA workflow')\n\naddAmlAddressRiskCommand(workflowCommand, 'cia networks')\n\nprogram\n .command('status')\n .description('Show toolkit status and configuration')\n .action(async () => {\n const { loadConfig } = await import('./config/index.js')\n const config = await loadConfig()\n const graphMcpStatus =\n config.graphMcpMode === 'debug' && config.graphMcpAuthToken?.trim()\n ? 'bearer access mode'\n : `${config.graphMcpMode} mode`\n console.log('Config: ', config.dataDir)\n console.log('Chain Insights Graph:', graphMcpStatus)\n console.log('Graph endpoint:', config.graphMcpEndpoint)\n })\n\nprogram\n .command('update')\n .description('Check npmjs for a newer Chain Insights release and update this CLI')\n .option('--check', 'Only check for a newer release')\n .option('--dry-run', 'Print the update command without running it')\n .action(async (opts: { check?: boolean; dryRun?: boolean }) => {\n try {\n const { checkForUpdate, runPackageUpdate } = await import('./update.js')\n const result = await checkForUpdate()\n if (result.error) {\n throw new Error(`Could not check npmjs for updates: ${result.error}`)\n }\n if (!result.updateAvailable || !result.latestVersion) {\n console.log(`Chain Insights is up to date (${result.currentVersion}).`)\n return\n }\n\n console.log(\n `Chain Insights ${result.latestVersion} is available (current ${result.currentVersion}).`\n )\n if (opts.check) {\n console.log(`Run: ${result.updateCommand}`)\n return\n }\n if (opts.dryRun) {\n console.log(`Would run: ${result.updateCommand}`)\n return\n }\n\n console.log(`Running: ${result.updateCommand}`)\n runPackageUpdate(result.packageName)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n\nprogram\n .command('debug')\n .description('Configure Chain Insights Graph debug mode')\n .addCommand(\n createCliCommand('on')\n .description('Enable Chain Insights Graph debug mode without x402 payments')\n .requiredOption('--token <token>', 'Debug bearer token')\n .option('--endpoint <url>', 'Chain Insights Graph endpoint')\n .action(async (opts: { token: string; endpoint?: string }) => {\n try {\n const { saveConfig } = await import('./config/index.js')\n await saveConfig({\n graphMcpMode: 'debug',\n graphMcpAuthToken: opts.token,\n ...(opts.endpoint ? { graphMcpEndpoint: opts.endpoint } : {}),\n })\n console.log('Chain Insights Graph debug mode enabled')\n if (opts.endpoint) console.log(`Graph endpoint: ${opts.endpoint}`)\n console.log('Payments: disabled for Chain Insights Graph calls')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('off')\n .description('Disable Chain Insights Graph debug mode and use paid x402 calls')\n .action(async () => {\n try {\n const { saveConfig } = await import('./config/index.js')\n await saveConfig({ graphMcpMode: 'paid', graphMcpAuthToken: '' })\n console.log('Chain Insights Graph debug mode disabled')\n console.log('Payments: enabled for Chain Insights Graph calls')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('status')\n .description('Show Chain Insights Graph payment/debug mode')\n .action(async () => {\n try {\n const { loadConfig } = await import('./config/index.js')\n const config = await loadConfig()\n console.log(`Chain Insights Graph mode: ${config.graphMcpMode}`)\n console.log(`Graph endpoint: ${config.graphMcpEndpoint}`)\n console.log(\n `Debug token: ${config.graphMcpAuthToken?.trim() ? 'configured' : 'not configured'}`\n )\n console.log(`Payments: ${config.graphMcpMode === 'debug' ? 'disabled' : 'enabled'}`)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nprogram\n .command('access-key')\n .description('Configure Chain Insights Graph test access key mode')\n .addCommand(\n createCliCommand('set')\n .description('Use a Chain Insights Graph test access key without x402 payments')\n .argument('<key>', 'Test access key')\n .option('--endpoint <url>', 'Chain Insights Graph endpoint')\n .action(async (key: string, opts: { endpoint?: string }) => {\n try {\n const normalizedKey = key.trim()\n if (!normalizedKey) throw new Error('Test access key is required')\n const { saveConfig } = await import('./config/index.js')\n await saveConfig({\n graphMcpMode: 'debug',\n graphMcpAuthToken: normalizedKey,\n ...(opts.endpoint ? { graphMcpEndpoint: opts.endpoint } : {}),\n })\n console.log('Chain Insights Graph test access key configured')\n if (opts.endpoint) console.log(`Graph endpoint: ${opts.endpoint}`)\n console.log('Payments: disabled when the server accepts this key')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('clear')\n .description('Remove the Chain Insights Graph test access key and use paid x402 calls')\n .action(async () => {\n try {\n const { saveConfig } = await import('./config/index.js')\n await saveConfig({ graphMcpMode: 'paid', graphMcpAuthToken: '' })\n console.log('Chain Insights Graph test access key cleared')\n console.log('Payments: enabled for Chain Insights Graph calls')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('status')\n .description('Show Chain Insights Graph test access key status')\n .action(async () => {\n try {\n const { loadConfig } = await import('./config/index.js')\n const config = await loadConfig()\n console.log(`Graph endpoint: ${config.graphMcpEndpoint}`)\n console.log(\n `Access key: ${config.graphMcpAuthToken?.trim() ? 'configured' : 'not configured'}`\n )\n console.log(\n `Payments: ${config.graphMcpAuthToken?.trim() ? 'disabled when accepted by server' : 'enabled'}`\n )\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nprogram\n .command('setup')\n .description('Configure external MCP clients')\n .addCommand(\n createCliCommand('claude-code')\n .alias('claude')\n .description('Install Claude Code skills and register the MCP proxy')\n .action(() => {\n runInstaller('--claude')\n })\n )\n .addCommand(\n createCliCommand('claude-desktop')\n .description('Register the MCP proxy in Claude Desktop, which draws the money-flow views')\n .action(() => {\n runInstaller('--claude-desktop')\n })\n )\n .addCommand(\n createCliCommand('codex')\n .description('Install Codex skills and register the MCP proxy')\n .action(() => {\n runInstaller('--codex')\n })\n )\n .addCommand(\n createCliCommand('chatgpt')\n .description('Set up the ChatGPT desktop app: its Codex chats run Chain Insights')\n .action(() => {\n runInstaller('--codex')\n // The ChatGPT chat itself runs in the cloud and cannot reach a server on\n // this computer. Only the app's Codex chats can.\n console.log(\n '\\n In the ChatGPT app, ask in a Codex chat (Codex in the sidebar), not in a ChatGPT chat.\\n'\n )\n })\n )\n .addCommand(\n createCliCommand('hermes')\n .description('Install Hermes skills and register the MCP proxy')\n .action(() => {\n runInstaller('--hermes')\n })\n )\n\nprogram\n .command('config')\n .description('Read or write configuration values')\n .addCommand(\n createCliCommand('get')\n .description('Read one Chain Insights configuration value')\n .argument('<key>', 'Config key to read')\n .action(async (key: string) => {\n const { loadConfig } = await import('./config/index.js')\n const { CONFIG_KEYS } = await import('./config/schema.js')\n if (!CONFIG_KEYS.includes(key as (typeof CONFIG_KEYS)[number])) {\n console.error(`Unknown config key: ${key}`)\n process.exit(1)\n }\n const config = await loadConfig()\n const value = (config as Record<string, unknown>)[key]\n console.log(value ?? '')\n })\n )\n .addCommand(\n createCliCommand('reset')\n .description(\n 'Put every setting back to its default (production endpoint, paid mode, no test key); the wallet stays'\n )\n .action(async () => {\n try {\n const { resetConfig, loadConfig } = await import('./config/index.js')\n const { backupPath } = await resetConfig()\n const config = await loadConfig()\n if (backupPath) console.log(`Previous settings saved to ${backupPath}`)\n console.log('Settings reset to defaults.')\n console.log(`Graph endpoint: ${config.graphMcpEndpoint}`)\n console.log(`Mode: ${config.graphMcpMode}`)\n console.log('Test access: off')\n console.log('Wallet: unchanged (~/.chain-insights/wallet.json)')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('set')\n .description('Write one Chain Insights configuration value')\n .argument('<key>', 'Config key to write')\n .argument('<value>', 'Value to set')\n .action(async (key: string, value: string) => {\n // D-01: walletPrivateKey is intercepted before saveConfig — the raw private key\n // must NEVER be written to config.json.\n if (key === 'walletPrivateKey') {\n try {\n const { setWalletPrivateKey } = await import('./wallet/index.js')\n const address = await setWalletPrivateKey(value)\n console.log('Wallet private key encrypted and stored in ~/.chain-insights/wallet.json')\n console.log(`Wallet address: ${address}`)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n return // MUST return — walletPrivateKey must never reach saveConfig or config.json\n }\n const { loadConfig, saveConfig } = await import('./config/index.js')\n const { CONFIG_KEYS, DEFAULT_CONFIG } = await import('./config/schema.js')\n const current = await loadConfig()\n if (!CONFIG_KEYS.includes(key as (typeof CONFIG_KEYS)[number])) {\n console.error(`Unknown config key: ${key}`)\n process.exit(1)\n }\n const existing = (current as Record<string, unknown>)[key]\n const defaultValue = (DEFAULT_CONFIG as Record<string, unknown>)[key]\n const coerced =\n typeof existing === 'number' || typeof defaultValue === 'number' ? Number(value) : value\n await saveConfig({ [key]: coerced } as Parameters<typeof saveConfig>[0])\n const displayed = key.toLowerCase().includes('token') ? '[redacted]' : coerced\n console.log(`Set ${key} = ${displayed}`)\n })\n )\n\nprogram\n .command('wallet')\n .description('Manage the local Base USDC payment wallet')\n .addCommand(\n createCliCommand('create')\n .description('Generate a new local Base payment wallet')\n .action(async () => {\n try {\n const { isWalletConfigured, setWalletPrivateKey, walletPath } =\n await import('./wallet/index.js')\n const { createInterface } = await import('node:readline/promises')\n const { formatWalletBackupWarning, generateWalletPrivateKey, isWalletBackupConfirmed } =\n await import('./wallet/create.js')\n\n if (await isWalletConfigured()) {\n throw new Error(\n 'A payment wallet already exists. Run `cia wallet address` to view it or use `cia wallet import <private-key> --force` to replace it.'\n )\n }\n\n const privateKey = generateWalletPrivateKey()\n const color = process.stderr.isTTY === true && process.env['NO_COLOR'] === undefined\n process.stderr.write(`${formatWalletBackupWarning(privateKey, { color })}\\n`)\n const prompt = createInterface({ input: process.stdin, output: process.stderr })\n let answer: string\n try {\n answer = await prompt.question('> ')\n } finally {\n prompt.close()\n }\n process.stderr.write('\\n')\n if (!isWalletBackupConfirmed(answer)) {\n throw new Error('Wallet creation cancelled. The wallet was not saved.')\n }\n\n const address = await setWalletPrivateKey(privateKey)\n console.log(`Wallet created: ${address}`)\n console.log(`Encrypted local copy: ${walletPath()}`)\n console.log('Next: cia wallet ready')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('import')\n .description('Import a Base payment wallet')\n .argument('<private-key>', '0x-prefixed EVM private key')\n .option(\n '--force',\n 'Replace an existing wallet (the previous key is backed up next to wallet.json)'\n )\n .action(async (privateKey: string, opts: { force?: boolean }) => {\n try {\n const { setWalletPrivateKey, isWalletConfigured } = await import('./wallet/index.js')\n const replacing = opts.force === true && (await isWalletConfigured())\n const address = await setWalletPrivateKey(privateKey, { force: opts.force })\n if (replacing) {\n console.log('Previous wallet key backed up next to ~/.chain-insights/wallet.json')\n }\n console.log(`Wallet imported: ${address}`)\n console.log(\n 'Keep your original private key backed up securely; it cannot be recovered from the encrypted local copy.'\n )\n console.log('Encrypted local copy: ~/.chain-insights/wallet.json')\n console.log('Next: cia wallet ready')\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('address')\n .description('Print the local payment wallet address')\n .action(async () => {\n try {\n const { getWalletAccount } = await import('./wallet/tools.js')\n const account = await getWalletAccount()\n console.log(account.address)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('balance')\n .description('Show the local payment wallet Base USDC balance')\n .action(async () => {\n try {\n const { getWalletBalanceText } = await import('./wallet/tools.js')\n console.log(await getWalletBalanceText())\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('ready')\n .description('Check and prepare the wallet for paid Chain Insights Graph calls')\n .option('--check-only', 'Only check readiness; do not submit the one-time payment setup')\n .addOption(new Option('--no-approve', 'Deprecated alias for --check-only').hideHelp())\n .option('--payment-usdc <amount>', 'USDC setup cap to prepare for paid calls', '1')\n .addOption(\n new Option('--approval-usdc <amount>', 'Deprecated alias for --payment-usdc').hideHelp()\n )\n .option('--json', 'Print machine-readable readiness metadata')\n .action(\n async (opts: {\n checkOnly?: boolean\n approve?: boolean\n paymentUsdc?: string\n approvalUsdc?: string\n json?: boolean\n }) => {\n try {\n const { formatWalletReadiness, parsePaymentApprovalUnits, prepareWalletForPaidCalls } =\n await import('./wallet/tools.js')\n const minimumApprovalUnits = parsePaymentApprovalUnits(\n opts.paymentUsdc ?? opts.approvalUsdc ?? '1'\n )\n const result = await prepareWalletForPaidCalls({\n minimumApprovalUnits,\n approve: opts.checkOnly ? false : opts.approve !== false,\n })\n\n if (opts.json) {\n console.log(\n JSON.stringify(\n result,\n (_key, value) => (typeof value === 'bigint' ? value.toString() : value),\n 2\n )\n )\n return\n }\n\n console.log(formatWalletReadiness(result.readiness, result.approval))\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n }\n )\n )\n .addCommand(\n createCliCommand('topup')\n .description('Open a local browser page to top up the payment wallet')\n .option('--no-open', 'Print the top-up URL without opening a browser')\n .option('--json', 'Print machine-readable top-up metadata')\n .action(async (opts: { open?: boolean; json?: boolean }) => {\n try {\n const { buildTopupInfo, getWalletAccount } = await import('./wallet/tools.js')\n const { startTopupServer } = await import('./wallet/topup-server.js')\n const account = await getWalletAccount()\n const url = await startTopupServer(account)\n const info = buildTopupInfo(account.address, url)\n\n if (opts.json) {\n console.log(JSON.stringify(info, null, 2))\n } else {\n console.log(`Top-up URL: ${url}`)\n console.log(`Wallet: ${account.address}`)\n console.log('Network: Base')\n console.log('Token: USDC')\n console.log('Press Ctrl+C to stop the top-up server.')\n }\n\n if (opts.open !== false) {\n const open = (await import('open')).default\n await open(url)\n }\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nconst mcpCommand = program\n .command('mcp')\n .description('Low-level access to the Chain Insights MCP endpoint')\n .allowExcessArguments(false)\n .addCommand(\n createCliCommand('networks')\n .description('List the detailed Chain Insights capability matrix and tool support')\n .option('--json', 'Print raw capability JSON')\n .action(async (opts: { json?: boolean }) => {\n try {\n await printNetworkCapabilities(opts)\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n .addCommand(\n createCliCommand('tools')\n .description('List the remote GraphRAG MCP tools (cached for 24 hours)')\n .option('--refresh', 'Force refresh schema cache')\n .action(async (opts: { refresh?: boolean }) => {\n try {\n const { loadSchema, saveSchema } = await import('./mcp/schema-cache.js')\n const { formatToolsTable } = await import('./mcp/format.js')\n const { visibleRemoteTools } = await import('./mcp/tool-visibility.js')\n const { loadConfig } = await import('./config/index.js')\n const { createConfiguredGraphMcpFetch, resolveGraphMcpEndpoint } =\n await import('./mcp/client.js')\n const config = await loadConfig()\n const graphMcpEndpoint = resolveGraphMcpEndpoint(config)\n let tools = opts.refresh ? null : await loadSchema(graphMcpEndpoint)\n if (!tools) {\n const paymentFetch = await createConfiguredGraphMcpFetch(config)\n const { Client } = await import('@modelcontextprotocol/sdk/client/index.js')\n const { StreamableHTTPClientTransport } =\n await import('@modelcontextprotocol/sdk/client/streamableHttp.js')\n const client = new Client({ name: 'chain-insights-cli', version: PACKAGE_VERSION })\n await client.connect(\n new StreamableHTTPClientTransport(new URL(graphMcpEndpoint), { fetch: paymentFetch })\n )\n try {\n const result = await client.listTools()\n tools = result.tools as Array<{ name: string; description?: string }>\n await saveSchema(tools, graphMcpEndpoint)\n } finally {\n await client.close()\n }\n }\n console.log(formatToolsTable(visibleRemoteTools(tools)))\n } catch (err) {\n console.error((err as Error).message)\n process.exit(1)\n }\n })\n )\n\nmcpCommand.addCommand(\n createCliCommand('call')\n .description('Call a low-level MCP tool directly (advanced)')\n .option('--json', 'Print machine-readable JSON output')\n .argument('<tool>', 'Tool name to call')\n .argument('[args...]', 'Key=value arguments (e.g. address=0x1234... network=robinhood)')\n .action(async (tool: string, rawArgs: string[], opts: { json?: boolean }) => {\n try {\n const { parseMcpCallArgs } = await import('./mcp/call-args.js')\n const { assertPublicMcpToolName, validatePublicMcpToolArguments } =\n await import('./mcp/tool-visibility.js')\n const args = parseMcpCallArgs(rawArgs)\n assertPublicMcpToolName(tool)\n validatePublicMcpToolArguments(tool, args)\n\n if (tool === 'wallet_balance') {\n const { getWalletBalanceText } = await import('./wallet/tools.js')\n console.log(await getWalletBalanceText())\n return\n }\n\n if (tool === 'meta_network_capabilities') {\n await printNetworkCapabilities({ json: opts.json })\n return\n }\n\n if (tool === 'meta_schema') {\n await printNetworkSchema(String(args['network'] ?? ''), {\n json: opts.json,\n refresh: String(args['refresh'] ?? '').toLowerCase() === 'true',\n })\n return\n }\n\n if (tool === 'graph_expand') {\n throw new Error(\n 'graph_expand is used only by the Chain Insights view in Claude. Run `cia mcp call graph_query` with your own query instead.'\n )\n }\n\n if (tool === 'meta_help') {\n console.log(\n 'Graph tools: graph_query and graph_query_batch. Metadata and payment tools: meta_* and wallet_balance.'\n )\n return\n }\n\n await withGraphMcpClient('chain-insights-cli-call', async (client, config) => {\n if (tool === 'meta_usage_status') {\n try {\n const result = await client.callTool({ name: 'usage_status', arguments: {} })\n printMcpTextContent(\n result as { content?: Array<{ type: string; text?: string }>; isError?: boolean },\n { tool, json: opts.json }\n )\n } catch (err) {\n const {\n isMissingUsageStatusToolError,\n primitiveBackendUsageStatus,\n usageStatusText,\n } = await import('./mcp/usage-status.js')\n if (!isMissingUsageStatusToolError(err)) throw err\n const { resolveGraphMcpEndpoint } = await import('./mcp/client.js')\n console.log(\n usageStatusText(primitiveBackendUsageStatus(resolveGraphMcpEndpoint(config)))\n )\n }\n return\n }\n if (tool === 'meta_subscription_status') {\n try {\n const { getWalletAccount } = await import('./wallet/tools.js')\n const account = await getWalletAccount()\n const result = await client.callTool({\n name: 'subscription_status',\n arguments: { wallet: account.address },\n })\n printMcpTextContent(\n result as { content?: Array<{ type: string; text?: string }>; isError?: boolean },\n { tool, json: opts.json }\n )\n } catch (err) {\n const {\n isMissingSubscriptionStatusToolError,\n unavailableSubscriptionStatus,\n subscriptionStatusText,\n } = await import('./mcp/subscription-status.js')\n if (!isMissingSubscriptionStatusToolError(err)) throw err\n const { resolveGraphMcpEndpoint } = await import('./mcp/client.js')\n console.log(\n subscriptionStatusText(\n unavailableSubscriptionStatus(\n resolveGraphMcpEndpoint(config),\n `subscription_status failed: ${(err as Error).message}`\n )\n )\n )\n }\n return\n }\n // graph_query and graph_query_batch can run past the SDK's 60 s default\n // while the server is still answering. Other tools keep that default.\n const { graphToolRequestOptions } = await import('./mcp/request-timeout.js')\n const requestOptions = graphToolRequestOptions(tool)\n const result = requestOptions\n ? await client.callTool({ name: tool, arguments: args }, undefined, requestOptions)\n : await client.callTool({ name: tool, arguments: args })\n printMcpTextContent(\n result as { content?: Array<{ type: string; text?: string }>; isError?: boolean },\n { tool, json: opts.json }\n )\n })\n } catch (err) {\n const { formatMcpCallError } = await import('./mcp/tool-visibility.js')\n console.error(formatMcpCallError(tool, err))\n process.exit(1)\n }\n })\n)\n\n// parseAsync (not parse) so a rejected async action surfaces as a clean\n// one-line error and a non-zero exit, instead of an unhandled-rejection stack\n// trace. Commands with their own try/catch still exit(1) before this fires.\nprogram.parseAsync(normalizeAmlToolVersionArgv(process.argv)).catch((err) => {\n console.error((err as Error).message)\n process.exit(1)\n})\n"],"mappings":";;;;;;AAQA,MA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,MAAM,OAAO,SAAS;IAAE,MAAM;IAAM,WAAW;GAAK,CAAC;GACzD,oBACE,QACA;IAAE;IAAM,MAAM,KAAK;GAAK,CAC1B;EACF,CAAC;CACH,SAAS,KAAK;EACZ,MAAM,EAAE,uBAAuB,MAAM,OAAO,iCAA2B,CAAA,MAAA,MAAA,EAAA,CAAA;EACvE,QAAQ,MAAM,mBAAmB,MAAM,GAAG,CAAC;EAC3C,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC,CACL;AAKA,QAAQ,WAAW,4BAA4B,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,QAAQ;CAC3E,QAAQ,MAAO,IAAc,OAAO;CACpC,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
package/dist/mcp-proxy.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const require_print_result = require("./print-result-BEA_PyNz.cjs");
|
|
|
4
4
|
const require_client = require("./client-Ypw9BNbn.cjs");
|
|
5
5
|
const require_tool_visibility = require("./tool-visibility-CDe-ft0L.cjs");
|
|
6
6
|
const require_usage_status = require("./usage-status-BdwwgYsu.cjs");
|
|
7
|
-
const require_subscription_status = require("./subscription-status-
|
|
7
|
+
const require_subscription_status = require("./subscription-status-ru99UCPZ.cjs");
|
|
8
8
|
const require_capabilities = require("./capabilities-BGkL9yAr.cjs");
|
|
9
9
|
const require_graph_schema = require("./graph-schema-_u1aB_f1.cjs");
|
|
10
10
|
const require_action_log = require("./action-log-HniMMF7f.cjs");
|
package/dist/mcp-proxy.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { a as PACKAGE_VERSION } from "./print-result-k9kXVR2c.mjs";
|
|
|
2
2
|
import { t as PaymentRequiredError } from "./client-gsLi528K.mjs";
|
|
3
3
|
import { i as isAppOnlyTool, n as PUBLIC_MCP_TOOL_ALLOWED_ARGS, r as PUBLIC_MCP_TOOL_REQUIRED_ARGS, t as HIDDEN_REMOTE_TOOL_NAMES } from "./tool-visibility-P9wETx-d.mjs";
|
|
4
4
|
import { t as primitiveBackendUsageStatus } from "./usage-status-CXOnrq-s.mjs";
|
|
5
|
-
import { n as unavailableSubscriptionStatus } from "./subscription-status-
|
|
5
|
+
import { n as unavailableSubscriptionStatus } from "./subscription-status-DA9DCFrC.mjs";
|
|
6
6
|
import { r as mirrorGraphNetworkCapabilities } from "./capabilities-Cur8x6c7.mjs";
|
|
7
7
|
import { a as handleMetaSchema, c as GRAPH_EXPAND_TITLE, l as GRAPH_EXPAND_TOOL, n as META_SCHEMA_DESCRIPTION, o as FLOWS_MAX_OFFSET, r as META_SCHEMA_TITLE, s as GRAPH_EXPAND_DESCRIPTION, t as GraphSchemaError, u as handleGraphExpand } from "./graph-schema-CwsQBYrP.mjs";
|
|
8
8
|
import { r as appendActionLog, t as actionLogSignalsFromResult } from "./action-log-D49Par9P.mjs";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
//#region src/mcp/subscription-status.ts
|
|
3
|
+
var subscription_status_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
isMissingSubscriptionStatusToolError: () => isMissingSubscriptionStatusToolError,
|
|
5
|
+
subscriptionStatusText: () => subscriptionStatusText,
|
|
6
|
+
unavailableSubscriptionStatus: () => unavailableSubscriptionStatus
|
|
7
|
+
});
|
|
8
|
+
function unavailableSubscriptionStatus(endpoint, reason) {
|
|
9
|
+
return {
|
|
10
|
+
schema: "chain-insights.result.v1",
|
|
11
|
+
tool: "meta_subscription_status",
|
|
12
|
+
facts: {
|
|
13
|
+
subscription: {
|
|
14
|
+
subscription_status_tool: "unavailable",
|
|
15
|
+
reason
|
|
16
|
+
},
|
|
17
|
+
backend: { endpoint }
|
|
18
|
+
},
|
|
19
|
+
hint: "This backend does not expose the Chain Insights subscription_status tool; subscription windows, daily allowances, and tiers are not tracked here."
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function subscriptionStatusText(result) {
|
|
23
|
+
return JSON.stringify(result, null, 2);
|
|
24
|
+
}
|
|
25
|
+
function isMissingSubscriptionStatusToolError(err) {
|
|
26
|
+
const message = String(err.message ?? err).toLowerCase();
|
|
27
|
+
return message.includes("unknown tool") || message.includes("tool not found") || message.includes("method not found") || message.includes("subscription_status");
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { unavailableSubscriptionStatus as n, subscription_status_exports as t };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=subscription-status-DA9DCFrC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-status-DA9DCFrC.mjs","names":[],"sources":["../src/mcp/subscription-status.ts"],"sourcesContent":["export type SubscriptionStatusFacts = {\n wallet?: string\n window_end: string\n allowance_usd: number\n consumed_usd: number\n tier: string | number\n}\n\nexport type UnavailableSubscriptionStatusResult = {\n schema: 'chain-insights.result.v1'\n tool: 'meta_subscription_status'\n facts: {\n subscription: {\n subscription_status_tool: 'unavailable'\n reason: string\n }\n backend: {\n endpoint: string\n }\n }\n hint: string\n}\n\nexport function unavailableSubscriptionStatus(\n endpoint: string,\n reason: string\n): UnavailableSubscriptionStatusResult {\n return {\n schema: 'chain-insights.result.v1',\n tool: 'meta_subscription_status',\n facts: {\n subscription: {\n subscription_status_tool: 'unavailable',\n reason,\n },\n backend: {\n endpoint,\n },\n },\n hint: 'This backend does not expose the Chain Insights subscription_status tool; subscription windows, daily allowances, and tiers are not tracked here.',\n }\n}\n\nexport function subscriptionStatusText(result: UnavailableSubscriptionStatusResult): string {\n return JSON.stringify(result, null, 2)\n}\n\nexport function isMissingSubscriptionStatusToolError(err: unknown): boolean {\n const message = String((err as Error).message ?? err).toLowerCase()\n return (\n message.includes('unknown tool') ||\n message.includes('tool not found') ||\n message.includes('method not found') ||\n message.includes('subscription_status')\n )\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Extracts `{ window_end, allowance_usd, consumed_usd, tier }` from a server\n * `subscription_status` tool result. Accepts the flat server document, the\n * proxy document with facts nested under `facts.subscription`, or a JSON text\n * content block. Returns null when the facts are absent or malformed so\n * callers can degrade to the unavailable shape instead of throwing.\n */\nexport function parseSubscriptionStatusToolResult(result: unknown): SubscriptionStatusFacts | null {\n if (!isRecord(result) || result.isError === true) return null\n\n let payload: unknown = isRecord(result.structuredContent) ? result.structuredContent : undefined\n if (payload === undefined && Array.isArray(result.content)) {\n const textBlock = result.content.find(\n (block) => isRecord(block) && block.type === 'text' && typeof block.text === 'string'\n ) as { text: string } | undefined\n if (!textBlock) return null\n try {\n payload = JSON.parse(textBlock.text) as unknown\n } catch {\n return null\n }\n }\n if (!isRecord(payload)) return null\n\n const facts = isRecord(payload.facts) ? payload.facts : undefined\n const subscription = isRecord(facts?.subscription) ? facts.subscription : undefined\n const source = subscription ?? payload\n\n const windowEnd = source['window_end']\n if (typeof windowEnd !== 'string' || Number.isNaN(Date.parse(windowEnd))) return null\n const allowanceUsd = source['allowance_usd']\n const consumedUsd = source['consumed_usd']\n if (typeof allowanceUsd !== 'number' || typeof consumedUsd !== 'number') return null\n const tier = source['tier']\n if (typeof tier !== 'string' && typeof tier !== 'number') return null\n const wallet = source['wallet']\n\n return {\n ...(typeof wallet === 'string' ? { wallet } : {}),\n window_end: windowEnd,\n allowance_usd: allowanceUsd,\n consumed_usd: consumedUsd,\n tier,\n }\n}\n"],"mappings":";;;;;;;AAuBA,SAAgB,8BACd,UACA,QACqC;CACrC,OAAO;EACL,QAAQ;EACR,MAAM;EACN,OAAO;GACL,cAAc;IACZ,0BAA0B;IAC1B;GACF;GACA,SAAS,EACP,SACF;EACF;EACA,MAAM;CACR;AACF;AAEA,SAAgB,uBAAuB,QAAqD;CAC1F,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC;AACvC;AAEA,SAAgB,qCAAqC,KAAuB;CAC1E,MAAM,UAAU,OAAQ,IAAc,WAAW,GAAG,CAAC,CAAC,YAAY;CAClE,OACE,QAAQ,SAAS,cAAc,KAC/B,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,kBAAkB,KACnC,QAAQ,SAAS,qBAAqB;AAE1C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/mcp/subscription-status.ts
|
|
2
|
+
var subscription_status_exports = /* @__PURE__ */ require("./rolldown-runtime-C0BPl7ul.cjs").__exportAll({
|
|
3
|
+
isMissingSubscriptionStatusToolError: () => isMissingSubscriptionStatusToolError,
|
|
4
|
+
subscriptionStatusText: () => subscriptionStatusText,
|
|
5
|
+
unavailableSubscriptionStatus: () => unavailableSubscriptionStatus
|
|
6
|
+
});
|
|
7
|
+
function unavailableSubscriptionStatus(endpoint, reason) {
|
|
8
|
+
return {
|
|
9
|
+
schema: "chain-insights.result.v1",
|
|
10
|
+
tool: "meta_subscription_status",
|
|
11
|
+
facts: {
|
|
12
|
+
subscription: {
|
|
13
|
+
subscription_status_tool: "unavailable",
|
|
14
|
+
reason
|
|
15
|
+
},
|
|
16
|
+
backend: { endpoint }
|
|
17
|
+
},
|
|
18
|
+
hint: "This backend does not expose the Chain Insights subscription_status tool; subscription windows, daily allowances, and tiers are not tracked here."
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function subscriptionStatusText(result) {
|
|
22
|
+
return JSON.stringify(result, null, 2);
|
|
23
|
+
}
|
|
24
|
+
function isMissingSubscriptionStatusToolError(err) {
|
|
25
|
+
const message = String(err.message ?? err).toLowerCase();
|
|
26
|
+
return message.includes("unknown tool") || message.includes("tool not found") || message.includes("method not found") || message.includes("subscription_status");
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
Object.defineProperty(exports, "subscription_status_exports", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function() {
|
|
32
|
+
return subscription_status_exports;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "unavailableSubscriptionStatus", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function() {
|
|
38
|
+
return unavailableSubscriptionStatus;
|
|
39
|
+
}
|
|
40
|
+
});
|
package/docs/graph-tools.md
CHANGED
|
@@ -341,7 +341,7 @@ and `:Sanctioned`. Each role also has a flag on the node.
|
|
|
341
341
|
day to read only the internal rows.
|
|
342
342
|
- Use `meta_usage_status` through Chain Insights before public hosted reads
|
|
343
343
|
when you need the caller's remaining free-demo allowance.
|
|
344
|
-
- Hosted endpoints expose a free
|
|
344
|
+
- Hosted endpoints expose a free tier for graph_query and graph_query_batch:
|
|
345
345
|
5,000 units a day per address (an IP address block), 30 requests a minute,
|
|
346
346
|
reset at midnight UTC. A unit is one returned row, node, edge or list
|
|
347
347
|
element. Schema reads (`meta_schema`) cost nothing on every door.
|
|
@@ -350,14 +350,14 @@ and `:Sanctioned`. Each role also has a flag on the node.
|
|
|
350
350
|
There is no daily limit and no rate limit for paying agents.
|
|
351
351
|
- A subscription in $CIA (not yet live) gives 100,000 units a day at 60
|
|
352
352
|
requests a minute.
|
|
353
|
-
- Prepared wallet users receive the daily free
|
|
353
|
+
- Prepared wallet users receive the daily free tier first; after it is used,
|
|
354
354
|
x402 payment continues automatically from the configured wallet.
|
|
355
355
|
- Use explicit LIMIT and pagination in your query when you want bounded result
|
|
356
356
|
sets.
|
|
357
357
|
- Chain Insights Graph does not append `LIMIT`; Chain Insights recipes own their
|
|
358
358
|
own limits and pagination.
|
|
359
359
|
- Use bounded `graph_query` calls for public no-wallet free-demo usage.
|
|
360
|
-
`graph_query_batch` is also included in the free
|
|
360
|
+
`graph_query_batch` is also included in the free tier; use it for related
|
|
361
361
|
reads that should share one call.
|
|
362
362
|
- `per_query_timeout_seconds` is optional and capped at `60` by default (`30` for
|
|
363
363
|
`USE facts`). It can lower a limit. It cannot raise one.
|
package/docs/mcp-proxy.md
CHANGED
|
@@ -208,15 +208,15 @@ cia mcp call graph_query \
|
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
Hosted Chain Insights Graph can allow anonymous `graph_query` and
|
|
211
|
-
`graph_query_batch` calls before wallet setup. The free
|
|
211
|
+
`graph_query_batch` calls before wallet setup. The free tier is 5,000 units a
|
|
212
212
|
day per address (an IP address block), at 30 requests a minute, reset at
|
|
213
213
|
midnight UTC. A unit is one returned row, node, edge or list element.
|
|
214
214
|
Schema reads (`meta_schema`) cost nothing on every door.
|
|
215
215
|
`meta_usage_status` returns only the current caller's allowance status.
|
|
216
|
-
Wallet users receive the same free
|
|
216
|
+
Wallet users receive the same free tier first; after it is exhausted, x402
|
|
217
217
|
payment continues automatically when `wallet ready` reports ready.
|
|
218
218
|
|
|
219
|
-
The free
|
|
219
|
+
The free tier includes `graph_query_batch`. Pay as you go on x402 (and the ACP
|
|
220
220
|
offering) costs one cent per 100 units, rounded up to the next cent, with one
|
|
221
221
|
cent minimum per call; a batch is one call. It has no daily limit and no rate
|
|
222
222
|
limit for paying agents. A subscription in $CIA (not yet live) gives 100,000
|
package/package.json
CHANGED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
//#region src/mcp/subscription-status.ts
|
|
3
|
-
var subscription_status_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
-
DEFAULT_SUBSCRIPTION_MONTH_USD: () => 120,
|
|
5
|
-
depositExtensionDays: () => depositExtensionDays,
|
|
6
|
-
formatDepositGuardLine: () => formatDepositGuardLine,
|
|
7
|
-
formatDepositIrreversibilityWarning: () => formatDepositIrreversibilityWarning,
|
|
8
|
-
formatSubscriptionPassHint: () => formatSubscriptionPassHint,
|
|
9
|
-
isDepositConfirmed: () => isDepositConfirmed,
|
|
10
|
-
isMissingSubscriptionStatusToolError: () => isMissingSubscriptionStatusToolError,
|
|
11
|
-
parseSubscriptionStatusToolResult: () => parseSubscriptionStatusToolResult,
|
|
12
|
-
resolveSubscriptionMonthUsd: () => resolveSubscriptionMonthUsd,
|
|
13
|
-
subscriptionPassPriceUsd: () => subscriptionPassPriceUsd,
|
|
14
|
-
subscriptionStatusText: () => subscriptionStatusText,
|
|
15
|
-
unavailableSubscriptionStatus: () => unavailableSubscriptionStatus
|
|
16
|
-
});
|
|
17
|
-
const DAY_MS = 864e5;
|
|
18
|
-
const MONTH_PASS_DAYS = 30;
|
|
19
|
-
function unavailableSubscriptionStatus(endpoint, reason) {
|
|
20
|
-
return {
|
|
21
|
-
schema: "chain-insights.result.v1",
|
|
22
|
-
tool: "meta_subscription_status",
|
|
23
|
-
facts: {
|
|
24
|
-
subscription: {
|
|
25
|
-
subscription_status_tool: "unavailable",
|
|
26
|
-
reason
|
|
27
|
-
},
|
|
28
|
-
backend: { endpoint }
|
|
29
|
-
},
|
|
30
|
-
hint: "This backend does not expose the Chain Insights subscription_status tool; subscription windows, daily allowances, and tiers are not tracked here."
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function subscriptionStatusText(result) {
|
|
34
|
-
return JSON.stringify(result, null, 2);
|
|
35
|
-
}
|
|
36
|
-
function isMissingSubscriptionStatusToolError(err) {
|
|
37
|
-
const message = String(err.message ?? err).toLowerCase();
|
|
38
|
-
return message.includes("unknown tool") || message.includes("tool not found") || message.includes("method not found") || message.includes("subscription_status");
|
|
39
|
-
}
|
|
40
|
-
function isRecord(value) {
|
|
41
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Extracts `{ window_end, allowance_usd, consumed_usd, tier }` from a server
|
|
45
|
-
* `subscription_status` tool result. Accepts the flat server document, the
|
|
46
|
-
* proxy document with facts nested under `facts.subscription`, or a JSON text
|
|
47
|
-
* content block. Returns null when the facts are absent or malformed so
|
|
48
|
-
* callers can degrade to the unavailable shape instead of throwing.
|
|
49
|
-
*/
|
|
50
|
-
function parseSubscriptionStatusToolResult(result) {
|
|
51
|
-
if (!isRecord(result) || result.isError === true) return null;
|
|
52
|
-
let payload = isRecord(result.structuredContent) ? result.structuredContent : void 0;
|
|
53
|
-
if (payload === void 0 && Array.isArray(result.content)) {
|
|
54
|
-
const textBlock = result.content.find((block) => isRecord(block) && block.type === "text" && typeof block.text === "string");
|
|
55
|
-
if (!textBlock) return null;
|
|
56
|
-
try {
|
|
57
|
-
payload = JSON.parse(textBlock.text);
|
|
58
|
-
} catch {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (!isRecord(payload)) return null;
|
|
63
|
-
const facts = isRecord(payload.facts) ? payload.facts : void 0;
|
|
64
|
-
const source = (isRecord(facts?.subscription) ? facts.subscription : void 0) ?? payload;
|
|
65
|
-
const windowEnd = source["window_end"];
|
|
66
|
-
if (typeof windowEnd !== "string" || Number.isNaN(Date.parse(windowEnd))) return null;
|
|
67
|
-
const allowanceUsd = source["allowance_usd"];
|
|
68
|
-
const consumedUsd = source["consumed_usd"];
|
|
69
|
-
if (typeof allowanceUsd !== "number" || typeof consumedUsd !== "number") return null;
|
|
70
|
-
const tier = source["tier"];
|
|
71
|
-
if (typeof tier !== "string" && typeof tier !== "number") return null;
|
|
72
|
-
const wallet = source["wallet"];
|
|
73
|
-
return {
|
|
74
|
-
...typeof wallet === "string" ? { wallet } : {},
|
|
75
|
-
window_end: windowEnd,
|
|
76
|
-
allowance_usd: allowanceUsd,
|
|
77
|
-
consumed_usd: consumedUsd,
|
|
78
|
-
tier
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Resolves the list month price used for deposit guidance. Mirrors the
|
|
83
|
-
* operator-owned SUBSCRIPTION_MONTH_USD launch value ($120 default); a
|
|
84
|
-
* non-positive or non-numeric override fails loudly rather than printing
|
|
85
|
-
* wrong guidance.
|
|
86
|
-
*/
|
|
87
|
-
function resolveSubscriptionMonthUsd(env = process.env) {
|
|
88
|
-
const raw = env["SUBSCRIPTION_MONTH_USD"]?.trim();
|
|
89
|
-
if (!raw) return 120;
|
|
90
|
-
const parsed = Number(raw);
|
|
91
|
-
if (!Number.isFinite(parsed) || parsed <= 0) throw new Error(`SUBSCRIPTION_MONTH_USD must be a positive number; got "${raw}"`);
|
|
92
|
-
return parsed;
|
|
93
|
-
}
|
|
94
|
-
function subscriptionPassPriceUsd(pass, monthUsd) {
|
|
95
|
-
return pass === "day" ? monthUsd / MONTH_PASS_DAYS : monthUsd;
|
|
96
|
-
}
|
|
97
|
-
function formatUsd(value) {
|
|
98
|
-
return `$${value.toFixed(2)}`;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Deposit amount guidance for `cia buy day|month`. The $CIA amount at quote
|
|
102
|
-
* time is computed by the indexer TWAP, so the CLI shows the USD-equivalent
|
|
103
|
-
* and instructs sending approximately that value in $CIA.
|
|
104
|
-
*/
|
|
105
|
-
function formatSubscriptionPassHint(pass, monthUsd) {
|
|
106
|
-
const priceUsd = subscriptionPassPriceUsd(pass, monthUsd);
|
|
107
|
-
return [
|
|
108
|
-
pass === "day" ? `Day pass: ${formatUsd(priceUsd)} (SUBSCRIPTION_MONTH_USD / 30)` : `Month pass: ${formatUsd(priceUsd)} (list price)`,
|
|
109
|
-
"The exact $CIA amount is computed by the indexer TWAP at quote time.",
|
|
110
|
-
`Send approximately ${formatUsd(priceUsd)} worth of $CIA to the subscription sink.`,
|
|
111
|
-
"The receipt quote freezes the USD value and the daily allowance at deposit time."
|
|
112
|
-
].join("\n");
|
|
113
|
-
}
|
|
114
|
-
function depositExtensionDays(pass) {
|
|
115
|
-
return pass === "day" ? 1 : MONTH_PASS_DAYS;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Pre-sign guard line from the server-authoritative window end: stacking
|
|
119
|
-
* queues the new pass after the current window end (or now when expired).
|
|
120
|
-
* Spec example: "23 days active; this deposit extends to 53".
|
|
121
|
-
*/
|
|
122
|
-
function formatDepositGuardLine(facts, pass, now = /* @__PURE__ */ new Date()) {
|
|
123
|
-
const windowEndMs = Date.parse(facts.window_end);
|
|
124
|
-
const nowMs = now.getTime();
|
|
125
|
-
const activeDays = Math.max(0, Math.ceil((windowEndMs - nowMs) / DAY_MS));
|
|
126
|
-
const extendedEndMs = Math.max(nowMs, windowEndMs) + depositExtensionDays(pass) * DAY_MS;
|
|
127
|
-
return `${activeDays} days active; this deposit extends to ${Math.ceil((extendedEndMs - nowMs) / DAY_MS)}`;
|
|
128
|
-
}
|
|
129
|
-
function isDepositConfirmed(answer) {
|
|
130
|
-
return answer === "DEPOSIT";
|
|
131
|
-
}
|
|
132
|
-
function formatDepositIrreversibilityWarning(reason) {
|
|
133
|
-
return [
|
|
134
|
-
`Subscription status is unavailable: ${reason}`,
|
|
135
|
-
"The no-admin subscription sink cannot refund deposits.",
|
|
136
|
-
"Double-check the deposit amount before you send funds."
|
|
137
|
-
].join("\n");
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
export { unavailableSubscriptionStatus as n, subscription_status_exports as t };
|
|
141
|
-
|
|
142
|
-
//# sourceMappingURL=subscription-status-CJ-DaMW9.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-status-CJ-DaMW9.mjs","names":[],"sources":["../src/mcp/subscription-status.ts"],"sourcesContent":["export type SubscriptionStatusFacts = {\n wallet?: string\n window_end: string\n allowance_usd: number\n consumed_usd: number\n tier: string | number\n}\n\nexport type UnavailableSubscriptionStatusResult = {\n schema: 'chain-insights.result.v1'\n tool: 'meta_subscription_status'\n facts: {\n subscription: {\n subscription_status_tool: 'unavailable'\n reason: string\n }\n backend: {\n endpoint: string\n }\n }\n hint: string\n}\n\n// Launch list price from the subscription spec (§8, operator-owned env on the\n// server). The CLI mirrors it only for deposit guidance; the server freezes\n// the authoritative value into every grant.\nexport const DEFAULT_SUBSCRIPTION_MONTH_USD = 120\nexport type SubscriptionPass = 'day' | 'month'\n\nconst DAY_MS = 24 * 60 * 60 * 1000\n// Receipt windows follow duration.go: quote / month_usd x 720 hours. A\n// full-price month pass is 720 hours; the day pass is one thirtieth of it.\nconst MONTH_PASS_DAYS = 30\n\nexport function unavailableSubscriptionStatus(\n endpoint: string,\n reason: string\n): UnavailableSubscriptionStatusResult {\n return {\n schema: 'chain-insights.result.v1',\n tool: 'meta_subscription_status',\n facts: {\n subscription: {\n subscription_status_tool: 'unavailable',\n reason,\n },\n backend: {\n endpoint,\n },\n },\n hint: 'This backend does not expose the Chain Insights subscription_status tool; subscription windows, daily allowances, and tiers are not tracked here.',\n }\n}\n\nexport function subscriptionStatusText(result: UnavailableSubscriptionStatusResult): string {\n return JSON.stringify(result, null, 2)\n}\n\nexport function isMissingSubscriptionStatusToolError(err: unknown): boolean {\n const message = String((err as Error).message ?? err).toLowerCase()\n return (\n message.includes('unknown tool') ||\n message.includes('tool not found') ||\n message.includes('method not found') ||\n message.includes('subscription_status')\n )\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\n/**\n * Extracts `{ window_end, allowance_usd, consumed_usd, tier }` from a server\n * `subscription_status` tool result. Accepts the flat server document, the\n * proxy document with facts nested under `facts.subscription`, or a JSON text\n * content block. Returns null when the facts are absent or malformed so\n * callers can degrade to the unavailable shape instead of throwing.\n */\nexport function parseSubscriptionStatusToolResult(result: unknown): SubscriptionStatusFacts | null {\n if (!isRecord(result) || result.isError === true) return null\n\n let payload: unknown = isRecord(result.structuredContent) ? result.structuredContent : undefined\n if (payload === undefined && Array.isArray(result.content)) {\n const textBlock = result.content.find(\n (block) => isRecord(block) && block.type === 'text' && typeof block.text === 'string'\n ) as { text: string } | undefined\n if (!textBlock) return null\n try {\n payload = JSON.parse(textBlock.text) as unknown\n } catch {\n return null\n }\n }\n if (!isRecord(payload)) return null\n\n const facts = isRecord(payload.facts) ? payload.facts : undefined\n const subscription = isRecord(facts?.subscription) ? facts.subscription : undefined\n const source = subscription ?? payload\n\n const windowEnd = source['window_end']\n if (typeof windowEnd !== 'string' || Number.isNaN(Date.parse(windowEnd))) return null\n const allowanceUsd = source['allowance_usd']\n const consumedUsd = source['consumed_usd']\n if (typeof allowanceUsd !== 'number' || typeof consumedUsd !== 'number') return null\n const tier = source['tier']\n if (typeof tier !== 'string' && typeof tier !== 'number') return null\n const wallet = source['wallet']\n\n return {\n ...(typeof wallet === 'string' ? { wallet } : {}),\n window_end: windowEnd,\n allowance_usd: allowanceUsd,\n consumed_usd: consumedUsd,\n tier,\n }\n}\n\n/**\n * Resolves the list month price used for deposit guidance. Mirrors the\n * operator-owned SUBSCRIPTION_MONTH_USD launch value ($120 default); a\n * non-positive or non-numeric override fails loudly rather than printing\n * wrong guidance.\n */\nexport function resolveSubscriptionMonthUsd(env: NodeJS.ProcessEnv = process.env): number {\n const raw = env['SUBSCRIPTION_MONTH_USD']?.trim()\n if (!raw) return DEFAULT_SUBSCRIPTION_MONTH_USD\n const parsed = Number(raw)\n if (!Number.isFinite(parsed) || parsed <= 0) {\n throw new Error(`SUBSCRIPTION_MONTH_USD must be a positive number; got \"${raw}\"`)\n }\n return parsed\n}\n\nexport function subscriptionPassPriceUsd(pass: SubscriptionPass, monthUsd: number): number {\n return pass === 'day' ? monthUsd / MONTH_PASS_DAYS : monthUsd\n}\n\nfunction formatUsd(value: number): string {\n return `$${value.toFixed(2)}`\n}\n\n/**\n * Deposit amount guidance for `cia buy day|month`. The $CIA amount at quote\n * time is computed by the indexer TWAP, so the CLI shows the USD-equivalent\n * and instructs sending approximately that value in $CIA.\n */\nexport function formatSubscriptionPassHint(pass: SubscriptionPass, monthUsd: number): string {\n const priceUsd = subscriptionPassPriceUsd(pass, monthUsd)\n const priceLine =\n pass === 'day'\n ? `Day pass: ${formatUsd(priceUsd)} (SUBSCRIPTION_MONTH_USD / 30)`\n : `Month pass: ${formatUsd(priceUsd)} (list price)`\n return [\n priceLine,\n 'The exact $CIA amount is computed by the indexer TWAP at quote time.',\n `Send approximately ${formatUsd(priceUsd)} worth of $CIA to the subscription sink.`,\n 'The receipt quote freezes the USD value and the daily allowance at deposit time.',\n ].join('\\n')\n}\n\nexport function depositExtensionDays(pass: SubscriptionPass): number {\n return pass === 'day' ? 1 : MONTH_PASS_DAYS\n}\n\n/**\n * Pre-sign guard line from the server-authoritative window end: stacking\n * queues the new pass after the current window end (or now when expired).\n * Spec example: \"23 days active; this deposit extends to 53\".\n */\nexport function formatDepositGuardLine(\n facts: Pick<SubscriptionStatusFacts, 'window_end'>,\n pass: SubscriptionPass,\n now: Date = new Date()\n): string {\n const windowEndMs = Date.parse(facts.window_end)\n const nowMs = now.getTime()\n const activeDays = Math.max(0, Math.ceil((windowEndMs - nowMs) / DAY_MS))\n const extendedEndMs = Math.max(nowMs, windowEndMs) + depositExtensionDays(pass) * DAY_MS\n const extendedDays = Math.ceil((extendedEndMs - nowMs) / DAY_MS)\n return `${activeDays} days active; this deposit extends to ${extendedDays}`\n}\n\nexport function isDepositConfirmed(answer: string): boolean {\n return answer === 'DEPOSIT'\n}\n\nexport function formatDepositIrreversibilityWarning(reason: string): string {\n return [\n `Subscription status is unavailable: ${reason}`,\n 'The no-admin subscription sink cannot refund deposits.',\n 'Double-check the deposit amount before you send funds.',\n ].join('\\n')\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAM,SAAS;AAGf,MAAM,kBAAkB;AAExB,SAAgB,8BACd,UACA,QACqC;CACrC,OAAO;EACL,QAAQ;EACR,MAAM;EACN,OAAO;GACL,cAAc;IACZ,0BAA0B;IAC1B;GACF;GACA,SAAS,EACP,SACF;EACF;EACA,MAAM;CACR;AACF;AAEA,SAAgB,uBAAuB,QAAqD;CAC1F,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC;AACvC;AAEA,SAAgB,qCAAqC,KAAuB;CAC1E,MAAM,UAAU,OAAQ,IAAc,WAAW,GAAG,CAAC,CAAC,YAAY;CAClE,OACE,QAAQ,SAAS,cAAc,KAC/B,QAAQ,SAAS,gBAAgB,KACjC,QAAQ,SAAS,kBAAkB,KACnC,QAAQ,SAAS,qBAAqB;AAE1C;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,CAAC,CAAC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s").__exportAll({
|
|
3
|
-
DEFAULT_SUBSCRIPTION_MONTH_USD: () => 120,
|
|
4
|
-
depositExtensionDays: () => depositExtensionDays,
|
|
5
|
-
formatDepositGuardLine: () => formatDepositGuardLine,
|
|
6
|
-
formatDepositIrreversibilityWarning: () => formatDepositIrreversibilityWarning,
|
|
7
|
-
formatSubscriptionPassHint: () => formatSubscriptionPassHint,
|
|
8
|
-
isDepositConfirmed: () => isDepositConfirmed,
|
|
9
|
-
isMissingSubscriptionStatusToolError: () => isMissingSubscriptionStatusToolError,
|
|
10
|
-
parseSubscriptionStatusToolResult: () => parseSubscriptionStatusToolResult,
|
|
11
|
-
resolveSubscriptionMonthUsd: () => resolveSubscriptionMonthUsd,
|
|
12
|
-
subscriptionPassPriceUsd: () => subscriptionPassPriceUsd,
|
|
13
|
-
subscriptionStatusText: () => subscriptionStatusText,
|
|
14
|
-
unavailableSubscriptionStatus: () => unavailableSubscriptionStatus
|
|
15
|
-
});
|
|
16
|
-
const DAY_MS = 864e5;
|
|
17
|
-
const MONTH_PASS_DAYS = 30;
|
|
18
|
-
function unavailableSubscriptionStatus(endpoint, reason) {
|
|
19
|
-
return {
|
|
20
|
-
schema: "chain-insights.result.v1",
|
|
21
|
-
tool: "meta_subscription_status",
|
|
22
|
-
facts: {
|
|
23
|
-
subscription: {
|
|
24
|
-
subscription_status_tool: "unavailable",
|
|
25
|
-
reason
|
|
26
|
-
},
|
|
27
|
-
backend: { endpoint }
|
|
28
|
-
},
|
|
29
|
-
hint: "This backend does not expose the Chain Insights subscription_status tool; subscription windows, daily allowances, and tiers are not tracked here."
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function subscriptionStatusText(result) {
|
|
33
|
-
return JSON.stringify(result, null, 2);
|
|
34
|
-
}
|
|
35
|
-
function isMissingSubscriptionStatusToolError(err) {
|
|
36
|
-
const message = String(err.message ?? err).toLowerCase();
|
|
37
|
-
return message.includes("unknown tool") || message.includes("tool not found") || message.includes("method not found") || message.includes("subscription_status");
|
|
38
|
-
}
|
|
39
|
-
function isRecord(value) {
|
|
40
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Extracts `{ window_end, allowance_usd, consumed_usd, tier }` from a server
|
|
44
|
-
* `subscription_status` tool result. Accepts the flat server document, the
|
|
45
|
-
* proxy document with facts nested under `facts.subscription`, or a JSON text
|
|
46
|
-
* content block. Returns null when the facts are absent or malformed so
|
|
47
|
-
* callers can degrade to the unavailable shape instead of throwing.
|
|
48
|
-
*/
|
|
49
|
-
function parseSubscriptionStatusToolResult(result) {
|
|
50
|
-
if (!isRecord(result) || result.isError === true) return null;
|
|
51
|
-
let payload = isRecord(result.structuredContent) ? result.structuredContent : void 0;
|
|
52
|
-
if (payload === void 0 && Array.isArray(result.content)) {
|
|
53
|
-
const textBlock = result.content.find((block) => isRecord(block) && block.type === "text" && typeof block.text === "string");
|
|
54
|
-
if (!textBlock) return null;
|
|
55
|
-
try {
|
|
56
|
-
payload = JSON.parse(textBlock.text);
|
|
57
|
-
} catch {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (!isRecord(payload)) return null;
|
|
62
|
-
const facts = isRecord(payload.facts) ? payload.facts : void 0;
|
|
63
|
-
const source = (isRecord(facts?.subscription) ? facts.subscription : void 0) ?? payload;
|
|
64
|
-
const windowEnd = source["window_end"];
|
|
65
|
-
if (typeof windowEnd !== "string" || Number.isNaN(Date.parse(windowEnd))) return null;
|
|
66
|
-
const allowanceUsd = source["allowance_usd"];
|
|
67
|
-
const consumedUsd = source["consumed_usd"];
|
|
68
|
-
if (typeof allowanceUsd !== "number" || typeof consumedUsd !== "number") return null;
|
|
69
|
-
const tier = source["tier"];
|
|
70
|
-
if (typeof tier !== "string" && typeof tier !== "number") return null;
|
|
71
|
-
const wallet = source["wallet"];
|
|
72
|
-
return {
|
|
73
|
-
...typeof wallet === "string" ? { wallet } : {},
|
|
74
|
-
window_end: windowEnd,
|
|
75
|
-
allowance_usd: allowanceUsd,
|
|
76
|
-
consumed_usd: consumedUsd,
|
|
77
|
-
tier
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Resolves the list month price used for deposit guidance. Mirrors the
|
|
82
|
-
* operator-owned SUBSCRIPTION_MONTH_USD launch value ($120 default); a
|
|
83
|
-
* non-positive or non-numeric override fails loudly rather than printing
|
|
84
|
-
* wrong guidance.
|
|
85
|
-
*/
|
|
86
|
-
function resolveSubscriptionMonthUsd(env = process.env) {
|
|
87
|
-
const raw = env["SUBSCRIPTION_MONTH_USD"]?.trim();
|
|
88
|
-
if (!raw) return 120;
|
|
89
|
-
const parsed = Number(raw);
|
|
90
|
-
if (!Number.isFinite(parsed) || parsed <= 0) throw new Error(`SUBSCRIPTION_MONTH_USD must be a positive number; got "${raw}"`);
|
|
91
|
-
return parsed;
|
|
92
|
-
}
|
|
93
|
-
function subscriptionPassPriceUsd(pass, monthUsd) {
|
|
94
|
-
return pass === "day" ? monthUsd / MONTH_PASS_DAYS : monthUsd;
|
|
95
|
-
}
|
|
96
|
-
function formatUsd(value) {
|
|
97
|
-
return `$${value.toFixed(2)}`;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Deposit amount guidance for `cia buy day|month`. The $CIA amount at quote
|
|
101
|
-
* time is computed by the indexer TWAP, so the CLI shows the USD-equivalent
|
|
102
|
-
* and instructs sending approximately that value in $CIA.
|
|
103
|
-
*/
|
|
104
|
-
function formatSubscriptionPassHint(pass, monthUsd) {
|
|
105
|
-
const priceUsd = subscriptionPassPriceUsd(pass, monthUsd);
|
|
106
|
-
return [
|
|
107
|
-
pass === "day" ? `Day pass: ${formatUsd(priceUsd)} (SUBSCRIPTION_MONTH_USD / 30)` : `Month pass: ${formatUsd(priceUsd)} (list price)`,
|
|
108
|
-
"The exact $CIA amount is computed by the indexer TWAP at quote time.",
|
|
109
|
-
`Send approximately ${formatUsd(priceUsd)} worth of $CIA to the subscription sink.`,
|
|
110
|
-
"The receipt quote freezes the USD value and the daily allowance at deposit time."
|
|
111
|
-
].join("\n");
|
|
112
|
-
}
|
|
113
|
-
function depositExtensionDays(pass) {
|
|
114
|
-
return pass === "day" ? 1 : MONTH_PASS_DAYS;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Pre-sign guard line from the server-authoritative window end: stacking
|
|
118
|
-
* queues the new pass after the current window end (or now when expired).
|
|
119
|
-
* Spec example: "23 days active; this deposit extends to 53".
|
|
120
|
-
*/
|
|
121
|
-
function formatDepositGuardLine(facts, pass, now = /* @__PURE__ */ new Date()) {
|
|
122
|
-
const windowEndMs = Date.parse(facts.window_end);
|
|
123
|
-
const nowMs = now.getTime();
|
|
124
|
-
const activeDays = Math.max(0, Math.ceil((windowEndMs - nowMs) / DAY_MS));
|
|
125
|
-
const extendedEndMs = Math.max(nowMs, windowEndMs) + depositExtensionDays(pass) * DAY_MS;
|
|
126
|
-
return `${activeDays} days active; this deposit extends to ${Math.ceil((extendedEndMs - nowMs) / DAY_MS)}`;
|
|
127
|
-
}
|
|
128
|
-
function isDepositConfirmed(answer) {
|
|
129
|
-
return answer === "DEPOSIT";
|
|
130
|
-
}
|
|
131
|
-
function formatDepositIrreversibilityWarning(reason) {
|
|
132
|
-
return [
|
|
133
|
-
`Subscription status is unavailable: ${reason}`,
|
|
134
|
-
"The no-admin subscription sink cannot refund deposits.",
|
|
135
|
-
"Double-check the deposit amount before you send funds."
|
|
136
|
-
].join("\n");
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
Object.defineProperty(exports, "subscription_status_exports", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
get: function() {
|
|
142
|
-
return subscription_status_exports;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
Object.defineProperty(exports, "unavailableSubscriptionStatus", {
|
|
146
|
-
enumerable: true,
|
|
147
|
-
get: function() {
|
|
148
|
-
return unavailableSubscriptionStatus;
|
|
149
|
-
}
|
|
150
|
-
});
|