chain-insights 0.74.1 → 0.76.0
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 +3 -2
- package/dist/{action-log-D49Par9P.mjs → action-log-Byv9Ln_6.mjs} +4 -10
- package/dist/{action-log-D49Par9P.mjs.map → action-log-Byv9Ln_6.mjs.map} +1 -1
- package/dist/{action-log-HniMMF7f.cjs → action-log-WMW6xFMx.cjs} +3 -9
- package/dist/{active-Dkf8AB1R.mjs → active-D2aabYRF.mjs} +3 -4
- package/dist/{active-Dkf8AB1R.mjs.map → active-D2aabYRF.mjs.map} +1 -1
- package/dist/{active-Bc13hJIm.cjs → active-q3yViZhc.cjs} +2 -3
- package/dist/answer-hint-BlYEBq_Y.cjs +57 -0
- package/dist/answer-hint-vOE1O6Lf.mjs +48 -0
- package/dist/answer-hint-vOE1O6Lf.mjs.map +1 -0
- package/dist/{buy-_mpdRieG.mjs → buy-B2luUbWF.mjs} +5 -6
- package/dist/{buy-_mpdRieG.mjs.map → buy-B2luUbWF.mjs.map} +1 -1
- package/dist/{buy-97M6dtEu.cjs → buy-DEoGITbT.cjs} +4 -5
- package/dist/{cache-location-CBVzUIxq.cjs → cache-location-C09AE55j.cjs} +2 -3
- package/dist/{cache-location-BO2XkfgI.mjs → cache-location-DxTTqBwk.mjs} +2 -3
- package/dist/{cache-location-BO2XkfgI.mjs.map → cache-location-DxTTqBwk.mjs.map} +1 -1
- package/dist/{call-args-B0oMK1-J.mjs → call-args-CBqbYfOE.mjs} +15 -4
- package/dist/{call-args-B0oMK1-J.mjs.map → call-args-CBqbYfOE.mjs.map} +1 -1
- package/dist/{call-args-C8Gp5gco.cjs → call-args-DXEmPeE-.cjs} +14 -2
- package/dist/{capabilities-DxojbX4D.mjs → capabilities-BRNHcabF.mjs} +5 -11
- package/dist/{capabilities-DxojbX4D.mjs.map → capabilities-BRNHcabF.mjs.map} +1 -1
- package/dist/{capabilities-Ds3320iS.cjs → capabilities-DalimVY2.cjs} +4 -10
- package/dist/{claude-desktop-Jmm4PlBZ.cjs → claude-desktop-3OksQZVE.cjs} +2 -3
- package/dist/{claude-desktop-6jwX0Lux.mjs → claude-desktop-C1SDYAP2.mjs} +2 -3
- package/dist/{claude-desktop-6jwX0Lux.mjs.map → claude-desktop-C1SDYAP2.mjs.map} +1 -1
- package/dist/cli.cjs +95 -76
- package/dist/cli.mjs +94 -75
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-7qOfAdpH.mjs → client-BaHAIidE.mjs} +10 -21
- package/dist/{client-7qOfAdpH.mjs.map → client-BaHAIidE.mjs.map} +1 -1
- package/dist/{client-C9uwHnBS.cjs → client-Ddk4X9Ko.cjs} +9 -20
- package/dist/{config-BxtMoo9c.cjs → config-BdE8LcF-.cjs} +3 -5
- package/dist/{config-9MabJh5R.mjs → config-BkLIqOYq.mjs} +4 -6
- package/dist/{config-9MabJh5R.mjs.map → config-BkLIqOYq.mjs.map} +1 -1
- package/dist/{create-CpfZq2fx.mjs → create-CluDZkuF.mjs} +3 -4
- package/dist/{create-CpfZq2fx.mjs.map → create-CluDZkuF.mjs.map} +1 -1
- package/dist/{create-DdggkF04.cjs → create-DvBumvHn.cjs} +2 -3
- package/dist/{dex-registry-Chs79Ukc.cjs → dex-registry-CZQB2YhU.cjs} +4 -26
- package/dist/{dex-registry-rziydXYq.mjs → dex-registry-D6Xxi_vr.mjs} +5 -27
- package/dist/{dex-registry-rziydXYq.mjs.map → dex-registry-D6Xxi_vr.mjs.map} +1 -1
- package/dist/{dex-tool-DsaAIa-a.mjs → dex-tool-BoAYqhZO.mjs} +13 -67
- package/dist/dex-tool-BoAYqhZO.mjs.map +1 -0
- package/dist/{dex-tool-DLWnff1n.cjs → dex-tool-DsM-pSku.cjs} +17 -77
- package/dist/{format-CSesEBvS.mjs → format-CsnW5M4D.mjs} +2 -3
- package/dist/{format-CSesEBvS.mjs.map → format-CsnW5M4D.mjs.map} +1 -1
- package/dist/{format-DfhRQq4L.cjs → format-DUzmoeaE.cjs} +1 -2
- package/dist/{graph-schema-BGbJumCY.cjs → graph-schema-C8Pi6r7c.cjs} +12 -29
- package/dist/{graph-schema-ClqjzgrM.mjs → graph-schema-D4LAefGf.mjs} +13 -30
- package/dist/graph-schema-D4LAefGf.mjs.map +1 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +0 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/{known-keys-B87ZqOgE.mjs → known-keys-BbuzCZOW.mjs} +4 -7
- package/dist/{known-keys-B87ZqOgE.mjs.map → known-keys-BbuzCZOW.mjs.map} +1 -1
- package/dist/{known-keys-PKZF5GYd.cjs → known-keys-Cy8lKDOA.cjs} +3 -6
- package/dist/mcp-proxy.cjs +83 -57
- package/dist/mcp-proxy.d.cts +2 -2
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts +2 -2
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +81 -56
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/{print-result-Cyqrlx8P.cjs → print-result-BYppJlUi.cjs} +20 -20
- package/dist/{print-result-C3YazZBw.mjs → print-result-IFARsMnL.mjs} +10 -22
- package/dist/print-result-IFARsMnL.mjs.map +1 -0
- package/dist/{public-tools-Bl_l_rKK.cjs → public-tools-Cfc1OPNS.cjs} +16 -21
- package/dist/{public-tools-CQjGt7_q.mjs → public-tools-DXlZcanX.mjs} +16 -21
- package/dist/public-tools-DXlZcanX.mjs.map +1 -0
- package/dist/{quote-DfTut0cx.mjs → quote-41CbMc37.mjs} +2 -3
- package/dist/{quote-DfTut0cx.mjs.map → quote-41CbMc37.mjs.map} +1 -1
- package/dist/{quote-B9sYNOiv.cjs → quote-pFKcSvMv.cjs} +1 -2
- package/dist/{request-timeout-CYmQF8N7.cjs → request-timeout-DxwNijQD.cjs} +1 -2
- package/dist/{request-timeout-lBBe0mGf.mjs → request-timeout-K3ljP0pa.mjs} +2 -3
- package/dist/{request-timeout-lBBe0mGf.mjs.map → request-timeout-K3ljP0pa.mjs.map} +1 -1
- package/dist/{robinhood-CCTMagwM.mjs → robinhood-0NZsA6ZW.mjs} +2 -3
- package/dist/robinhood-0NZsA6ZW.mjs.map +1 -0
- package/dist/{robinhood-ChiT69sc.cjs → robinhood-DumTxvlA.cjs} +1 -2
- package/dist/{rolldown-runtime-8H4AJuhK.mjs → rolldown-runtime-BJohB4LM.mjs} +1 -2
- package/dist/{rolldown-runtime-C0BPl7ul.cjs → rolldown-runtime-BW-eSwOZ.cjs} +1 -2
- package/dist/{rules-BWdbOtHi.mjs → rules-B3w9pCeQ.mjs} +2 -3
- package/dist/{rules-BWdbOtHi.mjs.map → rules-B3w9pCeQ.mjs.map} +1 -1
- package/dist/{rules-BD-cNHMX.cjs → rules-BKwfmNsJ.cjs} +1 -2
- package/dist/{schema-KjZqCHbu.mjs → schema-CKnQsdw9.mjs} +6 -13
- package/dist/{schema-KjZqCHbu.mjs.map → schema-CKnQsdw9.mjs.map} +1 -1
- package/dist/{schema-tX0U0-VI.cjs → schema-CSESfCvA.cjs} +5 -12
- package/dist/{schema-cache-DRObKUvS.mjs → schema-cache-BfKHodDY.mjs} +3 -4
- package/dist/{schema-cache-DRObKUvS.mjs.map → schema-cache-BfKHodDY.mjs.map} +1 -1
- package/dist/{schema-cache-C7v9ml6S.cjs → schema-cache-NLgJmh4X.cjs} +3 -4
- package/dist/{skill-refresh-xYWZ_hua.mjs → skill-refresh-BchIsODN.mjs} +2 -3
- package/dist/{skill-refresh-xYWZ_hua.mjs.map → skill-refresh-BchIsODN.mjs.map} +1 -1
- package/dist/{skill-refresh-Be2D5FrX.cjs → skill-refresh-DaCTxhhy.cjs} +2 -3
- package/dist/{subscription-status-DIuH84fM.mjs → subscription-status-5WfPhSep.mjs} +3 -4
- package/dist/{subscription-status-DIuH84fM.mjs.map → subscription-status-5WfPhSep.mjs.map} +1 -1
- package/dist/{subscription-status-9tMfD90J.cjs → subscription-status-w4zI2KCK.cjs} +2 -3
- package/dist/token-lookup-BJ00JO9A.cjs +342 -0
- package/dist/token-lookup-XnyisLQW.mjs +303 -0
- package/dist/token-lookup-XnyisLQW.mjs.map +1 -0
- package/dist/{tool-visibility-BNwvcuVx.cjs → tool-visibility-DIpgPULN.cjs} +5 -10
- package/dist/{tool-visibility-B6983rxo.mjs → tool-visibility-Dy3psowS.mjs} +6 -11
- package/dist/tool-visibility-Dy3psowS.mjs.map +1 -0
- package/dist/{tools-D9ep9E7Q.mjs → tools-6pZo4h_p.mjs} +6 -21
- package/dist/{tools-D9ep9E7Q.mjs.map → tools-6pZo4h_p.mjs.map} +1 -1
- package/dist/{tools-Cmnq7yip.cjs → tools-DZLizem9.cjs} +5 -20
- package/dist/{topup-B6gZbTmv.mjs → topup--7JTo4UQ.mjs} +6 -7
- package/dist/{topup-B6gZbTmv.mjs.map → topup--7JTo4UQ.mjs.map} +1 -1
- package/dist/{topup-DVTCU2le.cjs → topup-BgI9OcUd.cjs} +5 -6
- package/dist/{topup-server-ShuYSyBY.cjs → topup-server-D9Uk1Th3.cjs} +7 -24
- package/dist/{topup-server-KQDviFXG.mjs → topup-server-DR0HaUcR.mjs} +8 -25
- package/dist/{topup-server-KQDviFXG.mjs.map → topup-server-DR0HaUcR.mjs.map} +1 -1
- package/dist/{topup-server-BcT7DIpd.mjs → topup-server-DlwzFEF1.mjs} +5 -12
- package/dist/{topup-server-BcT7DIpd.mjs.map → topup-server-DlwzFEF1.mjs.map} +1 -1
- package/dist/{topup-server-f4Gx0vji.cjs → topup-server-H1M_7PJK.cjs} +4 -11
- package/dist/{transport-error-D4hmpkqL.mjs → transport-error-68G35VPH.mjs} +3 -4
- package/dist/{transport-error-D4hmpkqL.mjs.map → transport-error-68G35VPH.mjs.map} +1 -1
- package/dist/{transport-error-CgISST8l.cjs → transport-error-DXy1iTpS.cjs} +2 -3
- package/dist/{update-CZDHSi_u.mjs → update-BH8F4cQ2.mjs} +3 -4
- package/dist/{update-CZDHSi_u.mjs.map → update-BH8F4cQ2.mjs.map} +1 -1
- package/dist/{update-DGyRlm3J.cjs → update-DUDdQSEU.cjs} +2 -3
- package/dist/{usage-status-Frot6fPG.mjs → usage-status-BUZgRl4r.mjs} +3 -5
- package/dist/{usage-status-Frot6fPG.mjs.map → usage-status-BUZgRl4r.mjs.map} +1 -1
- package/dist/{usage-status-DonwoLR3.cjs → usage-status-DnV3I3gX.cjs} +2 -4
- package/dist/{wallet-QTo5YCFR.mjs → wallet-B1M0HdQh.mjs} +4 -8
- package/dist/{wallet-QTo5YCFR.mjs.map → wallet-B1M0HdQh.mjs.map} +1 -1
- package/dist/{wallet-CgIAfdxL.cjs → wallet-BubGd_sG.cjs} +3 -7
- package/docs/graph-query-compatibility.md +13 -13
- package/docs/graph-tools.md +22 -22
- package/docs/mcp-proxy.md +35 -1
- package/docs/stability.md +3 -2
- package/package.json +1 -1
- package/skills/chain-insights-cypher/SKILL.md +30 -27
- package/skills/chain-insights-dex/SKILL.md +2 -2
- package/skills/chain-insights-dex/reference.md +1 -1
- package/skills/chain-insights-dex-gauge/SKILL.md +4 -4
- package/skills/chain-insights-dex-launchpad/SKILL.md +2 -2
- package/skills/chain-insights-virtuals/reference.md +5 -5
- package/dist/dex-tool-DsaAIa-a.mjs.map +0 -1
- package/dist/graph-schema-ClqjzgrM.mjs.map +0 -1
- package/dist/print-result-C3YazZBw.mjs.map +0 -1
- package/dist/public-tools-CQjGt7_q.mjs.map +0 -1
- package/dist/robinhood-CCTMagwM.mjs.map +0 -1
- package/dist/tool-visibility-B6983rxo.mjs.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
|
-
|
|
3
|
+
// src/version.ts
|
|
4
4
|
const PACKAGE_INFO = JSON.parse((0, node_fs.readFileSync)(new URL("../package.json", require("url").pathToFileURL(__filename).href), "utf8"));
|
|
5
5
|
const PACKAGE_VERSION = PACKAGE_INFO.version;
|
|
6
|
-
|
|
7
|
-
//#region src/mcp/balance-text.ts
|
|
6
|
+
// src/mcp/balance-text.ts
|
|
8
7
|
/**
|
|
9
8
|
* An ETH text twin beside every native balance column of a chain answer.
|
|
10
9
|
*
|
|
@@ -49,8 +48,7 @@ function addBalanceText(row) {
|
|
|
49
48
|
function stripEthProperties(query) {
|
|
50
49
|
return query.replace(/\.((?:[A-Za-z_][A-Za-z0-9_]*_)?balance)_eth\b/g, ".$1");
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
//#region src/mcp/label-case.ts
|
|
51
|
+
// src/mcp/label-case.ts
|
|
54
52
|
const CANONICAL = new Map([
|
|
55
53
|
"Account",
|
|
56
54
|
"Address",
|
|
@@ -83,7 +81,7 @@ const CANONICAL = new Map([
|
|
|
83
81
|
"BRIDGED",
|
|
84
82
|
"BUNDLED",
|
|
85
83
|
"DEPLOYED_CONTRACT",
|
|
86
|
-
"
|
|
84
|
+
"FLOWED_TO",
|
|
87
85
|
"LINKED",
|
|
88
86
|
"OPERATED_BY",
|
|
89
87
|
"REMOVED_LIQUIDITY",
|
|
@@ -126,8 +124,7 @@ function fixSegment(segment) {
|
|
|
126
124
|
function fixLabelCase(query) {
|
|
127
125
|
return query.split(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`)/).map((part, index) => index % 2 === 1 ? part : fixSegment(part)).join("");
|
|
128
126
|
}
|
|
129
|
-
|
|
130
|
-
//#region src/mcp/timestamp-text.ts
|
|
127
|
+
// src/mcp/timestamp-text.ts
|
|
131
128
|
/**
|
|
132
129
|
* A UTC text twin beside every timestamp column of a graph answer.
|
|
133
130
|
*
|
|
@@ -137,14 +134,7 @@ function fixLabelCase(query) {
|
|
|
137
134
|
* for 23:55:43 UTC). Hosts without a shell (Claude Desktop) have no other
|
|
138
135
|
* way to convert, so the proxy writes `<column>_utc` next to each one.
|
|
139
136
|
*/
|
|
140
|
-
var timestamp_text_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
141
|
-
addTimestampText: () => addTimestampText,
|
|
142
|
-
stripUtcProperties: () => stripUtcProperties,
|
|
143
|
-
utcText: () => utcText,
|
|
144
|
-
withTimestampText: () => withTimestampText,
|
|
145
|
-
withTimestampTextResult: () => withTimestampTextResult,
|
|
146
|
-
withoutUtcProperties: () => withoutUtcProperties
|
|
147
|
-
});
|
|
137
|
+
var timestamp_text_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({ withoutUtcProperties: () => withoutUtcProperties });
|
|
148
138
|
const TIMESTAMP_KEY = /(_timestamp|_time|_at|_seen|_active)$/;
|
|
149
139
|
const MIN_MS = 0xe8d4a51000;
|
|
150
140
|
const MAX_MS = 4e12;
|
|
@@ -251,8 +241,7 @@ function withTimestampTextResult(result) {
|
|
|
251
241
|
}] : content
|
|
252
242
|
};
|
|
253
243
|
}
|
|
254
|
-
|
|
255
|
-
//#region src/mcp/print-result.ts
|
|
244
|
+
// src/mcp/print-result.ts
|
|
256
245
|
const ERROR_DETAIL_FIELDS = [
|
|
257
246
|
"code",
|
|
258
247
|
"rule",
|
|
@@ -423,7 +412,6 @@ function printMcpTextContent(result, options = {}) {
|
|
|
423
412
|
if (result.isError) throw new McpToolError(texts.join("\n").trim() || "MCP tool returned an error", errorDetailOf(result.structuredContent));
|
|
424
413
|
for (const text of texts) console.log(formatMcpTextContent(text, options.tool, options));
|
|
425
414
|
}
|
|
426
|
-
//#endregion
|
|
427
415
|
Object.defineProperty(exports, "McpToolError", {
|
|
428
416
|
enumerable: true,
|
|
429
417
|
get: function() {
|
|
@@ -448,6 +436,12 @@ Object.defineProperty(exports, "formatMcpToolError", {
|
|
|
448
436
|
return formatMcpToolError;
|
|
449
437
|
}
|
|
450
438
|
});
|
|
439
|
+
Object.defineProperty(exports, "isEpochMs", {
|
|
440
|
+
enumerable: true,
|
|
441
|
+
get: function() {
|
|
442
|
+
return isEpochMs;
|
|
443
|
+
}
|
|
444
|
+
});
|
|
451
445
|
Object.defineProperty(exports, "printMcpTextContent", {
|
|
452
446
|
enumerable: true,
|
|
453
447
|
get: function() {
|
|
@@ -460,6 +454,12 @@ Object.defineProperty(exports, "timestamp_text_exports", {
|
|
|
460
454
|
return timestamp_text_exports;
|
|
461
455
|
}
|
|
462
456
|
});
|
|
457
|
+
Object.defineProperty(exports, "utcText", {
|
|
458
|
+
enumerable: true,
|
|
459
|
+
get: function() {
|
|
460
|
+
return utcText;
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
463
|
Object.defineProperty(exports, "withTimestampTextResult", {
|
|
464
464
|
enumerable: true,
|
|
465
465
|
get: function() {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
|
|
3
|
+
// src/version.ts
|
|
4
4
|
const PACKAGE_INFO = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
5
5
|
const PACKAGE_VERSION = PACKAGE_INFO.version;
|
|
6
|
-
|
|
7
|
-
//#region src/mcp/balance-text.ts
|
|
6
|
+
// src/mcp/balance-text.ts
|
|
8
7
|
/**
|
|
9
8
|
* An ETH text twin beside every native balance column of a chain answer.
|
|
10
9
|
*
|
|
@@ -49,8 +48,7 @@ function addBalanceText(row) {
|
|
|
49
48
|
function stripEthProperties(query) {
|
|
50
49
|
return query.replace(/\.((?:[A-Za-z_][A-Za-z0-9_]*_)?balance)_eth\b/g, ".$1");
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
//#region src/mcp/label-case.ts
|
|
51
|
+
// src/mcp/label-case.ts
|
|
54
52
|
const CANONICAL = new Map([
|
|
55
53
|
"Account",
|
|
56
54
|
"Address",
|
|
@@ -83,7 +81,7 @@ const CANONICAL = new Map([
|
|
|
83
81
|
"BRIDGED",
|
|
84
82
|
"BUNDLED",
|
|
85
83
|
"DEPLOYED_CONTRACT",
|
|
86
|
-
"
|
|
84
|
+
"FLOWED_TO",
|
|
87
85
|
"LINKED",
|
|
88
86
|
"OPERATED_BY",
|
|
89
87
|
"REMOVED_LIQUIDITY",
|
|
@@ -126,8 +124,7 @@ function fixSegment(segment) {
|
|
|
126
124
|
function fixLabelCase(query) {
|
|
127
125
|
return query.split(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`)/).map((part, index) => index % 2 === 1 ? part : fixSegment(part)).join("");
|
|
128
126
|
}
|
|
129
|
-
|
|
130
|
-
//#region src/mcp/timestamp-text.ts
|
|
127
|
+
// src/mcp/timestamp-text.ts
|
|
131
128
|
/**
|
|
132
129
|
* A UTC text twin beside every timestamp column of a graph answer.
|
|
133
130
|
*
|
|
@@ -137,14 +134,7 @@ function fixLabelCase(query) {
|
|
|
137
134
|
* for 23:55:43 UTC). Hosts without a shell (Claude Desktop) have no other
|
|
138
135
|
* way to convert, so the proxy writes `<column>_utc` next to each one.
|
|
139
136
|
*/
|
|
140
|
-
var timestamp_text_exports = /* @__PURE__ */ __exportAll({
|
|
141
|
-
addTimestampText: () => addTimestampText,
|
|
142
|
-
stripUtcProperties: () => stripUtcProperties,
|
|
143
|
-
utcText: () => utcText,
|
|
144
|
-
withTimestampText: () => withTimestampText,
|
|
145
|
-
withTimestampTextResult: () => withTimestampTextResult,
|
|
146
|
-
withoutUtcProperties: () => withoutUtcProperties
|
|
147
|
-
});
|
|
137
|
+
var timestamp_text_exports = /* @__PURE__ */ __exportAll({ withoutUtcProperties: () => withoutUtcProperties });
|
|
148
138
|
const TIMESTAMP_KEY = /(_timestamp|_time|_at|_seen|_active)$/;
|
|
149
139
|
const MIN_MS = 0xe8d4a51000;
|
|
150
140
|
const MAX_MS = 4e12;
|
|
@@ -251,8 +241,7 @@ function withTimestampTextResult(result) {
|
|
|
251
241
|
}] : content
|
|
252
242
|
};
|
|
253
243
|
}
|
|
254
|
-
|
|
255
|
-
//#region src/mcp/print-result.ts
|
|
244
|
+
// src/mcp/print-result.ts
|
|
256
245
|
const ERROR_DETAIL_FIELDS = [
|
|
257
246
|
"code",
|
|
258
247
|
"rule",
|
|
@@ -423,7 +412,6 @@ function printMcpTextContent(result, options = {}) {
|
|
|
423
412
|
if (result.isError) throw new McpToolError(texts.join("\n").trim() || "MCP tool returned an error", errorDetailOf(result.structuredContent));
|
|
424
413
|
for (const text of texts) console.log(formatMcpTextContent(text, options.tool, options));
|
|
425
414
|
}
|
|
426
|
-
|
|
427
|
-
export { withTimestampTextResult as a, PACKAGE_VERSION as c, timestamp_text_exports as i, formatMcpToolError as n, withoutUtcProperties as o, printMcpTextContent as r, PACKAGE_INFO as s, McpToolError as t };
|
|
415
|
+
export { timestamp_text_exports as a, withoutUtcProperties as c, isEpochMs as i, PACKAGE_INFO as l, formatMcpToolError as n, utcText as o, printMcpTextContent as r, withTimestampTextResult as s, McpToolError as t, PACKAGE_VERSION as u };
|
|
428
416
|
|
|
429
|
-
//# sourceMappingURL=print-result-
|
|
417
|
+
//# sourceMappingURL=print-result-IFARsMnL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-result-IFARsMnL.mjs","names":["isRecord"],"sources":["../src/version.ts","../src/mcp/balance-text.ts","../src/mcp/label-case.ts","../src/mcp/timestamp-text.ts","../src/mcp/print-result.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\n\nexport const PACKAGE_INFO = JSON.parse(\n readFileSync(new URL('../package.json', import.meta.url), 'utf8')\n) as { name: string; version: string }\n\nexport const PACKAGE_VERSION = PACKAGE_INFO.version\n","/**\n * An ETH text twin beside every native balance column of a chain answer.\n *\n * `USE chain` serves `balance` as wei in decimal text, exact and 16 to 22\n * digits long. A host without a shell (Claude Desktop, 2026-10-21) printed\n * `10003752747799400` to the user as the balance. A model that divides by\n * 10^18 by head misplaces the point, so the proxy writes `<column>_eth`\n * next to each one, the same way `<column>_utc` sits beside a timestamp.\n */\n\nconst BALANCE_KEY = /(^|_)balance$/\nconst WEI_TEXT = /^[0-9]{1,78}$/\nconst WEI_PER_ETH = 10n ** 18n\n\n/** `0.0100037527477994` for `10003752747799400` wei: exact, no exponent, no trailing zeros. */\nexport function ethText(wei: string): string {\n const value = BigInt(wei)\n const whole = value / WEI_PER_ETH\n const frac = (value % WEI_PER_ETH).toString().padStart(18, '0').replace(/0+$/, '')\n return frac === '' ? whole.toString() : `${whole}.${frac}`\n}\n\nfunction isWeiText(value: unknown): value is string {\n return typeof value === 'string' && WEI_TEXT.test(value)\n}\n\n/**\n * One row with a `<key>_eth` string after every wei balance column that has\n * no twin yet. A column the model itself named `*_eth` (an alias such as\n * `a.balance_eth AS held_eth`, see stripEthProperties) arrives as wei and is\n * rendered as ETH text in place: the model gets the column it asked for.\n */\nexport function addBalanceText(row: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(row)) {\n out[key] = key.endsWith('_eth') && isWeiText(value) ? ethText(value) : value\n if (BALANCE_KEY.test(key) && isWeiText(value) && !(`${key}_eth` in row)) out[`${key}_eth`] = ethText(value)\n }\n return out\n}\n\n/**\n * The `_eth` twin is added by the proxy; it is no chain property. A query\n * that names `a.balance_eth` is rewritten to `a.balance`, so the row comes\n * back and the twin is written beside it. An alias after AS stays as written.\n */\nexport function stripEthProperties(query: string): string {\n return query.replace(/\\.((?:[A-Za-z_][A-Za-z0-9_]*_)?balance)_eth\\b/g, '.$1')\n}\n","/**\n * A node label or link type written in the wrong case is spelled the graph's way.\n *\n * Labels and link types are case sensitive. `(a:address {address: \"0x…\"})`\n * matches nothing and the read answers zero rows with no error, so the model\n * tells the user the address has no activity. Claude Desktop did exactly that\n * for the basket router on 2026-10-21 (skill loop, basket round 8): its links\n * were there under `:Address`.\n *\n * Only a name that is a known label or link type, in another case, after the\n * `:` (or `|`) of a node or link pattern is rewritten. Text inside quotes and a\n * map value such as `{address: address}` stay as written.\n */\n\nconst NAMES = [\n // topology node labels\n 'Account', 'Address', 'Bridge', 'Bundler', 'Chain', 'Contract', 'EntryPoint', 'Exchange', 'IssuerFrozen', 'Launchpad',\n 'Mixer', 'NFT', 'OnMoneyTrail', 'Paymaster', 'Poisoned', 'Pool', 'Protocol', 'Sanctioned', 'Scam', 'SmartAccount',\n 'Targeted', 'Token', 'Victim',\n // chain lookups\n 'Transaction', 'Block', 'Head',\n // topology link types\n 'ADDED_LIQUIDITY', 'APPROVED', 'BRIDGED', 'BUNDLED', 'DEPLOYED_CONTRACT', 'FLOWED_TO', 'LINKED', 'OPERATED_BY',\n 'REMOVED_LIQUIDITY', 'SIGNED_AUTHORIZATION', 'SIGNED_FOR', 'SPONSORED', 'SWAPPED', 'TRANSFERRED',\n // facts link types\n 'TRANSFER', 'BRIDGE_CROSSING', 'SWAP', 'LIQUIDITY_ADD', 'LIQUIDITY_REMOVE',\n]\n\nconst CANONICAL = new Map(NAMES.map((name) => [name.toLowerCase(), name]))\nconst IDENT = /[A-Za-z0-9_]/\n\nfunction prevNonSpace(text: string, from: number): number {\n let i = from\n while (i >= 0 && /\\s/.test(text[i])) i--\n return i\n}\n\n/** True when the `:` or `|` at `at` opens a label or link type, not a map value. */\nfunction opensLabel(text: string, at: number): boolean {\n let i = prevNonSpace(text, at - 1)\n if (i < 0) return false\n // `[:TRANSFER|swap]`: a `|` counts only after a link type of its own.\n if (text[at] !== '|' && (text[i] === '(' || text[i] === '[')) return true\n if (!IDENT.test(text[i])) return false\n while (i >= 0 && IDENT.test(text[i])) i--\n const before = prevNonSpace(text, i)\n // `(a:Address:contract)`: the name before this `:` is itself a label.\n if (before >= 0 && (text[before] === ':' || text[before] === '|')) return opensLabel(text, before)\n return text[at] === ':' && before >= 0 && (text[before] === '(' || text[before] === '[')\n}\n\nfunction fixSegment(segment: string): string {\n return segment.replace(/([:|])(\\s*)([A-Za-z_][A-Za-z0-9_]*)/g, (whole, mark: string, space: string, name: string, at: number) => {\n const canonical = CANONICAL.get(name.toLowerCase())\n if (!canonical || canonical === name || !opensLabel(segment, at)) return whole\n return `${mark}${space}${canonical}`\n })\n}\n\n/** The query with every known label and link type in the graph's case; quoted text is untouched. */\nexport function fixLabelCase(query: string): string {\n return query\n .split(/(\"(?:[^\"\\\\]|\\\\.)*\"|'(?:[^'\\\\]|\\\\.)*'|`[^`]*`)/)\n .map((part, index) => (index % 2 === 1 ? part : fixSegment(part)))\n .join('')\n}\n","/**\n * A UTC text twin beside every timestamp column of a graph answer.\n *\n * The graph serves integer milliseconds. A model that converts them by head\n * gets the time of day wrong about one time in three (loop 3, 2026-10-10:\n * four of twelve answers about one block named 00:15, 09:35, 06:35 or 09:15\n * for 23:55:43 UTC). Hosts without a shell (Claude Desktop) have no other\n * way to convert, so the proxy writes `<column>_utc` next to each one.\n */\n\nimport { addBalanceText, stripEthProperties } from './balance-text.js'\nimport { fixLabelCase } from './label-case.js'\n\nconst TIMESTAMP_KEY = /(_timestamp|_time|_at|_seen|_active)$/\nconst MIN_MS = 1_000_000_000_000 // 2001-09-09\nconst MAX_MS = 4_000_000_000_000 // 2096-10-02\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** `2026-08-05 23:55:43 UTC` for epoch milliseconds. */\nexport function utcText(ms: number): string {\n return `${new Date(ms).toISOString().slice(0, 19).replace('T', ' ')} UTC`\n}\n\nexport function isEpochMs(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value >= MIN_MS && value <= MAX_MS\n}\n\n/**\n * One row with a `<key>_utc` string after every epoch-millisecond timestamp\n * column. A column the model itself named `*_utc` (its query asked for the\n * twin as a property, see stripUtcProperties) arrives as milliseconds and is\n * rendered as UTC text in place: the model gets the column it asked for.\n */\nexport function addTimestampText(row: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(row)) {\n out[key] = key.endsWith('_utc') && isEpochMs(value) ? utcText(value) : value\n if (TIMESTAMP_KEY.test(key) && isEpochMs(value) && !(`${key}_utc` in row)) out[`${key}_utc`] = utcText(value)\n }\n return out\n}\n\n/**\n * The `_utc` twin is added to a reply by the proxy; it is no graph property.\n * Thirteen of 48 loop-5 rounds wrote `f.first_seen_timestamp_utc` into a\n * query anyway: topology answers null, a SWAP read is refused. The property\n * reference is rewritten to its millisecond column, `x.<column>_utc` to\n * `x.<column>`; an alias after AS is not a property and stays as written, so\n * `f.first_seen_timestamp_utc AS first_seen_utc` yields a `first_seen_utc`\n * column that addTimestampText renders as text. A label or link type in the\n * wrong case is spelled the graph's way (label-case.ts).\n */\nexport function stripUtcProperties(query: string): string {\n return fixLabelCase(stripEthProperties(query.replace(/\\.([A-Za-z_][A-Za-z0-9_]*?)_utc\\b/g, '.$1')))\n}\n\n/** graph_query and graph_query_batch arguments with stripUtcProperties applied to every query. */\nexport function withoutUtcProperties(toolName: string, args: Record<string, unknown>): Record<string, unknown> {\n if (toolName === 'graph_query' && typeof args.query === 'string') return { ...args, query: stripUtcProperties(args.query) }\n if (toolName === 'graph_query_batch' && Array.isArray(args.queries)) {\n return {\n ...args,\n queries: args.queries.map((entry) =>\n isRecord(entry) && typeof entry.query === 'string' ? { ...entry, query: stripUtcProperties(entry.query) } : entry\n ),\n }\n }\n return args\n}\n\nfunction mapResults(holder: unknown): unknown {\n if (!isRecord(holder) || !Array.isArray(holder.results)) return holder\n return {\n ...holder,\n results: holder.results.map((row) => (isRecord(row) ? addBalanceText(addTimestampText(row)) : row)),\n }\n}\n\n/**\n * The structured content of graph_query (facts.query.results) or\n * graph_query_batch (facts.queries[].results) with the UTC twins and the\n * ETH twins (balance-text.ts) added.\n * Anything else comes back as it was.\n */\nexport function withTimestampText(structuredContent: unknown): unknown {\n if (!isRecord(structuredContent) || !isRecord(structuredContent.facts)) return structuredContent\n const facts = structuredContent.facts\n if (!isRecord(facts.query) && !Array.isArray(facts.queries)) return structuredContent\n const next: Record<string, unknown> = { ...facts }\n if (isRecord(facts.query)) next.query = mapResults(facts.query)\n if (Array.isArray(facts.queries)) next.queries = facts.queries.map(mapResults)\n return { ...structuredContent, facts: next }\n}\n\ntype TextBlock = { type: string; text?: string }\n\n/**\n * A tool result whose structured content and single JSON text block both carry\n * the UTC twins. A text block that is not the JSON of the structured content\n * is left alone.\n */\nexport function withTimestampTextResult<T extends { content?: TextBlock[]; structuredContent?: unknown }>(result: T): T {\n const structured = withTimestampText(result.structuredContent)\n if (structured === result.structuredContent) return result\n const content = result.content ?? []\n const only = content.length === 1 && content[0]?.type === 'text' ? content[0] : null\n let parsed: unknown = undefined\n try {\n parsed = only?.text ? JSON.parse(only.text) : undefined\n } catch {\n parsed = undefined\n }\n const textIsStructured =\n parsed !== undefined && JSON.stringify(parsed) === JSON.stringify(result.structuredContent)\n return {\n ...result,\n structuredContent: structured,\n content: textIsStructured ? [{ ...only, text: JSON.stringify(structured) }] : content,\n }\n}\n","import { withTimestampTextResult } from './timestamp-text.js'\n\nexport interface McpTextResult {\n content?: Array<{ type: string; text?: string }>\n structuredContent?: unknown\n isError?: boolean\n}\n\n/**\n * The refusal envelope of the graph server, as the reply carries it in\n * `structuredContent.error_detail`. `class` is one of `refused`, `killed`,\n * `capacity` or `failed`, and it decides the caller's next move.\n */\nexport interface McpErrorDetail {\n code?: string\n rule?: string\n class?: string\n fix?: string\n example?: string\n}\n\nconst ERROR_DETAIL_FIELDS = ['code', 'rule', 'class', 'fix', 'example'] as const\n\n/**\n * A tool reply flagged `isError`: the server answered, and its answer is an\n * error. It is never a failure of the connection, so no caller may report it\n * as an unreachable endpoint. `message` is the server's own text and\n * `errorDetail` is the envelope of the reply, absent when the reply has none.\n */\nexport class McpToolError extends Error {\n readonly errorDetail?: McpErrorDetail\n\n constructor(message: string, errorDetail?: McpErrorDetail) {\n super(message)\n this.name = 'McpToolError'\n if (errorDetail) this.errorDetail = errorDetail\n }\n}\n\nexport interface McpPrintOptions {\n tool?: string\n json?: boolean\n}\n\n// What a switched-off or lagging chain layer means for the caller, in the line\n// under the server's text. The endpoint answered, so the endpoint is up, and\n// the other two layers do not depend on the chain node.\nconst CHAIN_UNAVAILABLE_MEANING =\n 'the chain layer is off or behind. The endpoint is up. USE topology and USE facts still work.'\n\n/**\n * How `cia mcp call` shows an McpToolError: the server's own text, then one\n * line built from its error_detail, `code <code> · class <class> · <fix>`. A\n * reply with no error_detail is the server text alone. For `chain_unavailable`\n * the line also says what the code means for the caller.\n */\nexport function formatMcpToolError(err: McpToolError): string {\n const detail = err.errorDetail\n if (!detail) return err.message\n const parts: string[] = []\n if (detail.code) parts.push(`code ${detail.code}`)\n if (detail.class) parts.push(`class ${detail.class}`)\n if (detail.fix) parts.push(detail.fix)\n if (detail.code === 'chain_unavailable') parts.push(CHAIN_UNAVAILABLE_MEANING)\n if (parts.length === 0) return err.message\n return `${err.message}\\n ${parts.join(' · ')}`\n}\n\ntype JsonRecord = Record<string, unknown>\n\nfunction isRecord(value: unknown): value is JsonRecord {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\n/** The text fields of `structuredContent.error_detail`, or undefined when it has none. */\nfunction errorDetailOf(structuredContent: unknown): McpErrorDetail | undefined {\n if (!isRecord(structuredContent) || !isRecord(structuredContent.error_detail)) return undefined\n const detail: McpErrorDetail = {}\n for (const field of ERROR_DETAIL_FIELDS) {\n const value = structuredContent.error_detail[field]\n if (typeof value === 'string') detail[field] = value\n }\n return Object.keys(detail).length > 0 ? detail : undefined\n}\n\nfunction displayValue(value: unknown): string {\n if (value === null || value === undefined) return ''\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\n try {\n return JSON.stringify(value)\n } catch {\n return String(value)\n }\n}\n\nfunction formatTable(rows: Array<JsonRecord>): string[] {\n if (rows.length === 0) return []\n const columns = [...new Set(rows.flatMap((row) => Object.keys(row)))]\n const values = rows.map((row) => columns.map((column) => displayValue(row[column])))\n const widths = columns.map((column, index) =>\n Math.max(column.length, ...values.map((row) => row[index]?.length ?? 0))\n )\n const line = (row: string[]): string =>\n row\n .map((value, index) => (index === row.length - 1 ? value : value.padEnd(widths[index] ?? 0)))\n .join(' | ')\n return [line(columns), widths.map((width) => '-'.repeat(width)).join('-+-'), ...values.map(line)]\n}\n\nfunction formatGraphResult(value: JsonRecord, fallbackTool?: string): string | null {\n const facts = isRecord(value.facts) ? value.facts : undefined\n const query = facts && isRecord(facts.query) ? facts.query : undefined\n const queries = facts && Array.isArray(facts.queries) ? facts.queries : undefined\n if (!query && !queries) return null\n\n const lines = [`Tool: ${displayValue(value.tool) || fallbackTool || 'MCP result'}`]\n const subject = isRecord(value.subject)\n ? value.subject\n : facts && isRecord(facts.subject)\n ? facts.subject\n : undefined\n if (subject?.network !== undefined) lines.push(`Network: ${displayValue(subject.network)}`)\n\n if (query) {\n const results = Array.isArray(query.results) ? query.results.filter(isRecord) : []\n if (query.count !== undefined) lines.push(`Rows: ${displayValue(query.count)}`)\n else lines.push(`Rows: ${results.length}`)\n if (query.billable_units !== undefined) {\n lines.push(`Billed units: ${displayValue(query.billable_units)}`)\n }\n if (query.elapsed_ms !== undefined) lines.push(`Elapsed: ${displayValue(query.elapsed_ms)} ms`)\n if (query.truncated !== undefined) lines.push(`Truncated: ${displayValue(query.truncated)}`)\n if (query.error !== undefined) lines.push(`Error: ${displayValue(query.error)}`)\n if (results.length > 0) lines.push('', 'Results:', ...formatTable(results))\n else lines.push('', 'Results: none')\n }\n\n if (queries) {\n lines.push(`Queries: ${queries.length}`)\n for (const entry of queries) {\n if (!isRecord(entry)) continue\n const id = displayValue(entry.id) || 'query'\n const results = Array.isArray(entry.results) ? entry.results.filter(isRecord) : []\n lines.push('', `[${id}]`)\n if (entry.error !== undefined) lines.push(`Error: ${displayValue(entry.error)}`)\n lines.push(`Rows: ${displayValue(entry.count ?? results.length)}`)\n if (results.length > 0) lines.push(...formatTable(results))\n else lines.push('Results: none')\n }\n }\n\n return lines.join('\\n')\n}\n\n/**\n * Formats one MCP text block for terminal output. JSON is indented when the\n * caller requests `--json`; graph query envelopes are rendered as a compact\n * result summary and table by default.\n */\nexport function formatMcpTextContent(\n text: string,\n tool?: string,\n options: Pick<McpPrintOptions, 'json'> = {}\n): string {\n let parsed: unknown\n try {\n parsed = JSON.parse(text) as unknown\n } catch {\n return text\n }\n\n if (options.json) {\n try {\n return JSON.stringify(parsed, null, 2)\n } catch {\n return text\n }\n }\n\n if (isRecord(parsed)) {\n return formatGraphResult(parsed, tool) ?? JSON.stringify(parsed, null, 2)\n }\n return displayValue(parsed)\n}\n\n/**\n * Prints the text blocks of an MCP tool result to stdout. When the result is\n * flagged `isError`, throws an McpToolError with the tool's error text instead\n * — MCP `callTool` returns tool errors as ordinary results (it does not\n * reject), so callers must surface them as failures (non-zero exit) rather than\n * printing to stdout and exiting 0. The error keeps the `error_detail` of the\n * reply, so a caller can tell a refused query from a dead endpoint.\n */\n/** The tools whose rows carry the `_utc` and `_eth` twins, the same two the proxy adds (src/mcp/proxy.ts). */\nfunction isGraphReadTool(tool?: string): boolean {\n return tool === 'graph_query' || tool === 'graph_query_batch'\n}\n\n/**\n * A graph reply with the twins the proxy writes for a host: `<column>_utc`\n * beside every timestamp and `<column>_eth` beside every wei balance. The\n * shell path printed the server row as it arrived (chain-insights #509), so a\n * person reading `cia mcp call` got the raw milliseconds and the raw wei.\n * The text block the server sends is the JSON of its structured content, so\n * both are rewritten together; a result with no structured content is read\n * from its text block first.\n */\nexport function withGraphTwins(result: McpTextResult, tool?: string): McpTextResult {\n if (!isGraphReadTool(tool) || result.isError) return result\n const only = (result.content ?? []).length === 1 && result.content?.[0]?.type === 'text' ? result.content[0] : null\n let structured = result.structuredContent\n if (structured === undefined && only?.text) {\n try {\n structured = JSON.parse(only.text) as unknown\n } catch {\n return result\n }\n }\n const twinned = withTimestampTextResult({ ...result, structuredContent: structured })\n return twinned.structuredContent === structured && result.structuredContent !== undefined ? result : twinned\n}\n\nexport function printMcpTextContent(result: McpTextResult, options: McpPrintOptions = {}): void {\n result = withGraphTwins(result, options.tool)\n const texts = (result.content ?? [])\n .filter((item) => item.type === 'text')\n .map((item) => item.text ?? '')\n\n if (result.isError) {\n throw new McpToolError(\n texts.join('\\n').trim() || 'MCP tool returned an error',\n errorDetailOf(result.structuredContent)\n )\n }\n\n for (const text of texts) console.log(formatMcpTextContent(text, options.tool, options))\n}\n"],"mappings":";;;AAEA,MAAa,eAAe,KAAK,MAC/B,aAAa,IAAI,IAAI,mBAAmB,YAAY,GAAG,GAAG,MAAM,CAClE;AAEA,MAAa,kBAAkB,aAAa;;;;;;;;;;;ACI5C,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,cAAc,OAAO;;AAG3B,SAAgB,QAAQ,KAAqB;CAC3C,MAAM,QAAQ,OAAO,GAAG;CACxB,MAAM,QAAQ,QAAQ;CACtB,MAAM,QAAQ,QAAQ,YAAA,CAAa,SAAS,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,QAAQ,OAAO,EAAE;CACjF,OAAO,SAAS,KAAK,MAAM,SAAS,IAAI,GAAG,MAAM,GAAG;AACtD;AAEA,SAAS,UAAU,OAAiC;CAClD,OAAO,OAAO,UAAU,YAAY,SAAS,KAAK,KAAK;AACzD;;;;;;;AAQA,SAAgB,eAAe,KAAuD;CACpF,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAAG;EAC9C,IAAI,OAAO,IAAI,SAAS,MAAM,KAAK,UAAU,KAAK,IAAI,QAAQ,KAAK,IAAI;EACvE,IAAI,YAAY,KAAK,GAAG,KAAK,UAAU,KAAK,KAAK,EAAE,GAAG,IAAI,SAAS,MAAM,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;CAC5G;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,mBAAmB,OAAuB;CACxD,OAAO,MAAM,QAAQ,kDAAkD,KA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AO;CACT;CAEF,MAAM,UAAU,wBAAwB;EAAE,GAAG;EAAQ,mBAAmB;CAAW,CAAC;CACpF,OAAO,QAAQ,sBAAsB,cAAc,OAAO,sBAAsB,KAAA,IAAY,SAAS;AACvG;AAEA,SAAgB,oBAAoB,QAAuB,UAA2B,CAAC,GAAS;CAC9F,SAAS,eAAe,QAAQ,QAAQ,IAAI;CAC5C,MAAM,SAAS,OAAO,WAAW,CAAC,EAAA,CAC/B,QAAQ,SAAS,KAAK,SAAS,MAAM,CAAC,CACtC,KAAK,SAAS,KAAK,QAAQ,EAAE;CAEhC,IAAI,OAAO,SACT,MAAM,IAAI,aACR,MAAM,KAAK,IAAI,CAAC,CAAC,KAAK,KAAK,8BAC3B,cAAc,OAAO,iBAAiB,CACxC;CAGF,KAAK,MAAM,QAAQ,OAAO,QAAQ,IAAI,qBAAqB,MAAM,QAAQ,MAAM,OAAO,CAAC;AACzF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
2
|
-
const require_active = require("./active-
|
|
3
|
-
const require_request_timeout = require("./request-timeout-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
|
+
const require_active = require("./active-q3yViZhc.cjs");
|
|
3
|
+
const require_request_timeout = require("./request-timeout-DxwNijQD.cjs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
6
6
|
let node_fs_promises = require("node:fs/promises");
|
|
7
|
-
|
|
7
|
+
// src/investigation/graph-normalizer.ts
|
|
8
8
|
const GRAPH_TYPE_LABELS = /* @__PURE__ */ new Set([
|
|
9
9
|
"Address",
|
|
10
10
|
"Exchange",
|
|
@@ -15,7 +15,7 @@ const GRAPH_TYPE_LABELS = /* @__PURE__ */ new Set([
|
|
|
15
15
|
"IPAddress"
|
|
16
16
|
]);
|
|
17
17
|
const FLOW_EDGE_TYPES = /* @__PURE__ */ new Set([
|
|
18
|
-
"
|
|
18
|
+
"flowed_to",
|
|
19
19
|
"transfer",
|
|
20
20
|
"transfer_to",
|
|
21
21
|
"transfers_to"
|
|
@@ -96,7 +96,7 @@ function normalizeNode(node) {
|
|
|
96
96
|
}
|
|
97
97
|
function normalizeEdgeType(edge) {
|
|
98
98
|
const edgeType = lowerSnake(typeof edge["edge_type"] === "string" && edge["edge_type"].trim() ? edge["edge_type"] : typeof edge["type"] === "string" && edge["type"].trim() ? edge["type"] : typeof edge["relationship_type"] === "string" && edge["relationship_type"].trim() ? edge["relationship_type"] : "related_to");
|
|
99
|
-
return FLOW_EDGE_TYPES.has(edgeType) ? "
|
|
99
|
+
return FLOW_EDGE_TYPES.has(edgeType) ? "flowed_to" : edgeType;
|
|
100
100
|
}
|
|
101
101
|
function normalizeEdge(edge) {
|
|
102
102
|
if (!isRecord$1(edge)) return {};
|
|
@@ -127,8 +127,7 @@ function normalizeGraphPayload(payload) {
|
|
|
127
127
|
edge_anchors: Array.isArray(payload["edge_anchors"]) ? payload["edge_anchors"] : []
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
//#region src/investigation/risk-level.ts
|
|
130
|
+
// src/investigation/risk-level.ts
|
|
132
131
|
/**
|
|
133
132
|
* Risk-level normalization shared by the AML tools and graph payload builders.
|
|
134
133
|
*
|
|
@@ -167,8 +166,7 @@ function riskSeverityRank(value) {
|
|
|
167
166
|
if (!normalized || normalized === UNSCORED_RISK_LEVEL) return -1;
|
|
168
167
|
return RISK_SEVERITIES.indexOf(normalized);
|
|
169
168
|
}
|
|
170
|
-
|
|
171
|
-
//#region src/workspace/output-root.ts
|
|
169
|
+
// src/workspace/output-root.ts
|
|
172
170
|
const NO_WORKSPACE_ERROR = "No Chain Insights workspace found. Run: cia init .";
|
|
173
171
|
function requireWorkspaceRoot(startDir = process.cwd()) {
|
|
174
172
|
const workspace = require_active.findActiveWorkspace(startDir);
|
|
@@ -192,8 +190,7 @@ function workspaceOutputPaths(workspaceRoot = requireWorkspaceRoot()) {
|
|
|
192
190
|
logsRoot: node_path.default.join(root, ".chain-insights", "runtime", "logs")
|
|
193
191
|
};
|
|
194
192
|
}
|
|
195
|
-
|
|
196
|
-
//#region src/lib/usage-accumulator.ts
|
|
193
|
+
// src/lib/usage-accumulator.ts
|
|
197
194
|
function createUsageAccumulator() {
|
|
198
195
|
return {
|
|
199
196
|
billable_units: 0,
|
|
@@ -285,8 +282,7 @@ function wrapClientForUsageTracking(client, totals) {
|
|
|
285
282
|
return typeof value === "function" ? value.bind(target) : value;
|
|
286
283
|
} });
|
|
287
284
|
}
|
|
288
|
-
|
|
289
|
-
//#region src/investigation/public-tools.ts
|
|
285
|
+
// src/investigation/public-tools.ts
|
|
290
286
|
const AML_ADDRESS_RISK_SUPPORTED_VERSIONS = ["v1"];
|
|
291
287
|
const LATEST_AML_ADDRESS_RISK_VERSION = "v1";
|
|
292
288
|
function resolveAmlAddressRiskVersion(requested) {
|
|
@@ -453,7 +449,7 @@ function exchangeOutflowQueryAtDepth(address, depth) {
|
|
|
453
449
|
];
|
|
454
450
|
const edgeVariables = Array.from({ length: depth }, (_, index) => `r${index + 1}`);
|
|
455
451
|
const relationshipChain = edgeVariables.map((edgeVariable, index) => {
|
|
456
|
-
return `-[${edgeVariable}:
|
|
452
|
+
return `-[${edgeVariable}:FLOWED_TO]->(${index === edgeVariables.length - 1 ? "exchange" : intermediateVariables[index]}:Address)`;
|
|
457
453
|
}).join("");
|
|
458
454
|
const intermediatePredicates = intermediateVariables.map((nodeVariable) => `${nodeVariable}.is_exchange IS NULL`);
|
|
459
455
|
const poolGuards = walkGuardTerms(["a", ...intermediateVariables], depth);
|
|
@@ -482,7 +478,7 @@ function exchangeInflowQueryAtDepth(address, depth) {
|
|
|
482
478
|
];
|
|
483
479
|
const edgeVariables = Array.from({ length: depth }, (_, index) => `r${index + 1}`);
|
|
484
480
|
const relationshipChain = edgeVariables.map((edgeVariable, index) => {
|
|
485
|
-
return `-[${edgeVariable}:
|
|
481
|
+
return `-[${edgeVariable}:FLOWED_TO]->(${index === edgeVariables.length - 1 ? "a" : intermediateVariables[index]}:Address)`;
|
|
486
482
|
}).join("");
|
|
487
483
|
const intermediatePredicates = intermediateVariables.map((nodeVariable) => `${nodeVariable}.is_exchange IS NULL`);
|
|
488
484
|
const poolGuards = walkGuardTerms(["a", ...intermediateVariables], depth);
|
|
@@ -503,7 +499,7 @@ function connectionProbeQuery(address, compareAddress) {
|
|
|
503
499
|
return {
|
|
504
500
|
id: "connection_probe",
|
|
505
501
|
query: [
|
|
506
|
-
`MATCH (a:Address {address: "${escapeCypherString(address)}"})-[r:
|
|
502
|
+
`MATCH (a:Address {address: "${escapeCypherString(address)}"})-[r:FLOWED_TO]-(b:Address {address: "${escapeCypherString(compareAddress)}"})`,
|
|
507
503
|
"RETURN [a.address, b.address] AS addresses, 1 AS hops",
|
|
508
504
|
"LIMIT 5"
|
|
509
505
|
].join(" ")
|
|
@@ -527,8 +523,8 @@ function shouldIncludeRouteQueries(compareAddress) {
|
|
|
527
523
|
function connectionRouteQueries(address, compareAddress) {
|
|
528
524
|
const routeQuery = (fromAddress, toAddress) => [
|
|
529
525
|
`MATCH p = SHORTEST 1 (a:Address {address: "${escapeCypherString(fromAddress)}"} WHERE ${walkGuardTerms(["a"], 2)})`,
|
|
530
|
-
` (()-[:
|
|
531
|
-
` ()-[:
|
|
526
|
+
` (()-[:FLOWED_TO|SWAPPED]-(via:Address) WHERE ${walkGuardTerms(["via"], 2)}){0,${CONNECTION_ROUTE_DEPTH_BOUND}}`,
|
|
527
|
+
` ()-[:FLOWED_TO|SWAPPED]-(b:Address {address: "${escapeCypherString(toAddress)}"}) RETURN p LIMIT 1`
|
|
532
528
|
].join("");
|
|
533
529
|
return [{
|
|
534
530
|
id: "connection_route_outbound",
|
|
@@ -831,7 +827,7 @@ function buildRiskGraph(address, profile, rows, network) {
|
|
|
831
827
|
edges.push({
|
|
832
828
|
source: path[index],
|
|
833
829
|
target: path[index + 1],
|
|
834
|
-
edge_type: "
|
|
830
|
+
edge_type: "flowed_to",
|
|
835
831
|
usd_amount: edge["amount_usd_sum"] ?? 0,
|
|
836
832
|
amount_usd_sum: edge["amount_usd_sum"] ?? 0,
|
|
837
833
|
tx_count: edge["tx_count"] ?? 0,
|
|
@@ -1171,6 +1167,5 @@ function artifactEvidence(artifacts) {
|
|
|
1171
1167
|
function htmlEscape(value) {
|
|
1172
1168
|
return String(value ?? "").replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
1173
1169
|
}
|
|
1174
|
-
//#endregion
|
|
1175
1170
|
exports.resolveAmlAddressRiskVersion = resolveAmlAddressRiskVersion;
|
|
1176
1171
|
exports.runAmlAddressRisk = runAmlAddressRisk;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as findActiveWorkspace } from "./active-
|
|
2
|
-
import { GRAPH_TOOL_REQUEST_TIMEOUT_MS } from "./request-timeout-
|
|
1
|
+
import { n as findActiveWorkspace } from "./active-D2aabYRF.mjs";
|
|
2
|
+
import { GRAPH_TOOL_REQUEST_TIMEOUT_MS } from "./request-timeout-K3ljP0pa.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
-
|
|
5
|
+
// src/investigation/graph-normalizer.ts
|
|
6
6
|
const GRAPH_TYPE_LABELS = /* @__PURE__ */ new Set([
|
|
7
7
|
"Address",
|
|
8
8
|
"Exchange",
|
|
@@ -13,7 +13,7 @@ const GRAPH_TYPE_LABELS = /* @__PURE__ */ new Set([
|
|
|
13
13
|
"IPAddress"
|
|
14
14
|
]);
|
|
15
15
|
const FLOW_EDGE_TYPES = /* @__PURE__ */ new Set([
|
|
16
|
-
"
|
|
16
|
+
"flowed_to",
|
|
17
17
|
"transfer",
|
|
18
18
|
"transfer_to",
|
|
19
19
|
"transfers_to"
|
|
@@ -94,7 +94,7 @@ function normalizeNode(node) {
|
|
|
94
94
|
}
|
|
95
95
|
function normalizeEdgeType(edge) {
|
|
96
96
|
const edgeType = lowerSnake(typeof edge["edge_type"] === "string" && edge["edge_type"].trim() ? edge["edge_type"] : typeof edge["type"] === "string" && edge["type"].trim() ? edge["type"] : typeof edge["relationship_type"] === "string" && edge["relationship_type"].trim() ? edge["relationship_type"] : "related_to");
|
|
97
|
-
return FLOW_EDGE_TYPES.has(edgeType) ? "
|
|
97
|
+
return FLOW_EDGE_TYPES.has(edgeType) ? "flowed_to" : edgeType;
|
|
98
98
|
}
|
|
99
99
|
function normalizeEdge(edge) {
|
|
100
100
|
if (!isRecord$1(edge)) return {};
|
|
@@ -125,8 +125,7 @@ function normalizeGraphPayload(payload) {
|
|
|
125
125
|
edge_anchors: Array.isArray(payload["edge_anchors"]) ? payload["edge_anchors"] : []
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
//#region src/investigation/risk-level.ts
|
|
128
|
+
// src/investigation/risk-level.ts
|
|
130
129
|
/**
|
|
131
130
|
* Risk-level normalization shared by the AML tools and graph payload builders.
|
|
132
131
|
*
|
|
@@ -165,8 +164,7 @@ function riskSeverityRank(value) {
|
|
|
165
164
|
if (!normalized || normalized === UNSCORED_RISK_LEVEL) return -1;
|
|
166
165
|
return RISK_SEVERITIES.indexOf(normalized);
|
|
167
166
|
}
|
|
168
|
-
|
|
169
|
-
//#region src/workspace/output-root.ts
|
|
167
|
+
// src/workspace/output-root.ts
|
|
170
168
|
const NO_WORKSPACE_ERROR = "No Chain Insights workspace found. Run: cia init .";
|
|
171
169
|
function requireWorkspaceRoot(startDir = process.cwd()) {
|
|
172
170
|
const workspace = findActiveWorkspace(startDir);
|
|
@@ -190,8 +188,7 @@ function workspaceOutputPaths(workspaceRoot = requireWorkspaceRoot()) {
|
|
|
190
188
|
logsRoot: path.join(root, ".chain-insights", "runtime", "logs")
|
|
191
189
|
};
|
|
192
190
|
}
|
|
193
|
-
|
|
194
|
-
//#region src/lib/usage-accumulator.ts
|
|
191
|
+
// src/lib/usage-accumulator.ts
|
|
195
192
|
function createUsageAccumulator() {
|
|
196
193
|
return {
|
|
197
194
|
billable_units: 0,
|
|
@@ -283,8 +280,7 @@ function wrapClientForUsageTracking(client, totals) {
|
|
|
283
280
|
return typeof value === "function" ? value.bind(target) : value;
|
|
284
281
|
} });
|
|
285
282
|
}
|
|
286
|
-
|
|
287
|
-
//#region src/investigation/public-tools.ts
|
|
283
|
+
// src/investigation/public-tools.ts
|
|
288
284
|
const AML_ADDRESS_RISK_SUPPORTED_VERSIONS = ["v1"];
|
|
289
285
|
const LATEST_AML_ADDRESS_RISK_VERSION = "v1";
|
|
290
286
|
function resolveAmlAddressRiskVersion(requested) {
|
|
@@ -451,7 +447,7 @@ function exchangeOutflowQueryAtDepth(address, depth) {
|
|
|
451
447
|
];
|
|
452
448
|
const edgeVariables = Array.from({ length: depth }, (_, index) => `r${index + 1}`);
|
|
453
449
|
const relationshipChain = edgeVariables.map((edgeVariable, index) => {
|
|
454
|
-
return `-[${edgeVariable}:
|
|
450
|
+
return `-[${edgeVariable}:FLOWED_TO]->(${index === edgeVariables.length - 1 ? "exchange" : intermediateVariables[index]}:Address)`;
|
|
455
451
|
}).join("");
|
|
456
452
|
const intermediatePredicates = intermediateVariables.map((nodeVariable) => `${nodeVariable}.is_exchange IS NULL`);
|
|
457
453
|
const poolGuards = walkGuardTerms(["a", ...intermediateVariables], depth);
|
|
@@ -480,7 +476,7 @@ function exchangeInflowQueryAtDepth(address, depth) {
|
|
|
480
476
|
];
|
|
481
477
|
const edgeVariables = Array.from({ length: depth }, (_, index) => `r${index + 1}`);
|
|
482
478
|
const relationshipChain = edgeVariables.map((edgeVariable, index) => {
|
|
483
|
-
return `-[${edgeVariable}:
|
|
479
|
+
return `-[${edgeVariable}:FLOWED_TO]->(${index === edgeVariables.length - 1 ? "a" : intermediateVariables[index]}:Address)`;
|
|
484
480
|
}).join("");
|
|
485
481
|
const intermediatePredicates = intermediateVariables.map((nodeVariable) => `${nodeVariable}.is_exchange IS NULL`);
|
|
486
482
|
const poolGuards = walkGuardTerms(["a", ...intermediateVariables], depth);
|
|
@@ -501,7 +497,7 @@ function connectionProbeQuery(address, compareAddress) {
|
|
|
501
497
|
return {
|
|
502
498
|
id: "connection_probe",
|
|
503
499
|
query: [
|
|
504
|
-
`MATCH (a:Address {address: "${escapeCypherString(address)}"})-[r:
|
|
500
|
+
`MATCH (a:Address {address: "${escapeCypherString(address)}"})-[r:FLOWED_TO]-(b:Address {address: "${escapeCypherString(compareAddress)}"})`,
|
|
505
501
|
"RETURN [a.address, b.address] AS addresses, 1 AS hops",
|
|
506
502
|
"LIMIT 5"
|
|
507
503
|
].join(" ")
|
|
@@ -525,8 +521,8 @@ function shouldIncludeRouteQueries(compareAddress) {
|
|
|
525
521
|
function connectionRouteQueries(address, compareAddress) {
|
|
526
522
|
const routeQuery = (fromAddress, toAddress) => [
|
|
527
523
|
`MATCH p = SHORTEST 1 (a:Address {address: "${escapeCypherString(fromAddress)}"} WHERE ${walkGuardTerms(["a"], 2)})`,
|
|
528
|
-
` (()-[:
|
|
529
|
-
` ()-[:
|
|
524
|
+
` (()-[:FLOWED_TO|SWAPPED]-(via:Address) WHERE ${walkGuardTerms(["via"], 2)}){0,${CONNECTION_ROUTE_DEPTH_BOUND}}`,
|
|
525
|
+
` ()-[:FLOWED_TO|SWAPPED]-(b:Address {address: "${escapeCypherString(toAddress)}"}) RETURN p LIMIT 1`
|
|
530
526
|
].join("");
|
|
531
527
|
return [{
|
|
532
528
|
id: "connection_route_outbound",
|
|
@@ -829,7 +825,7 @@ function buildRiskGraph(address, profile, rows, network) {
|
|
|
829
825
|
edges.push({
|
|
830
826
|
source: path[index],
|
|
831
827
|
target: path[index + 1],
|
|
832
|
-
edge_type: "
|
|
828
|
+
edge_type: "flowed_to",
|
|
833
829
|
usd_amount: edge["amount_usd_sum"] ?? 0,
|
|
834
830
|
amount_usd_sum: edge["amount_usd_sum"] ?? 0,
|
|
835
831
|
tx_count: edge["tx_count"] ?? 0,
|
|
@@ -1169,7 +1165,6 @@ function artifactEvidence(artifacts) {
|
|
|
1169
1165
|
function htmlEscape(value) {
|
|
1170
1166
|
return String(value ?? "").replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
1171
1167
|
}
|
|
1172
|
-
//#endregion
|
|
1173
1168
|
export { resolveAmlAddressRiskVersion, runAmlAddressRisk };
|
|
1174
1169
|
|
|
1175
|
-
//# sourceMappingURL=public-tools-
|
|
1170
|
+
//# sourceMappingURL=public-tools-DXlZcanX.mjs.map
|