chain-insights 0.75.0 → 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 +1 -0
- 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-ib_ICiyV.mjs → dex-tool-BoAYqhZO.mjs} +8 -62
- package/dist/dex-tool-BoAYqhZO.mjs.map +1 -0
- package/dist/{dex-tool-85_76Q8i.cjs → dex-tool-DsM-pSku.cjs} +12 -72
- 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-DNJXDaTn.cjs → graph-schema-C8Pi6r7c.cjs} +8 -25
- package/dist/{graph-schema-Bxqwukqu.mjs → graph-schema-D4LAefGf.mjs} +9 -26
- package/dist/{graph-schema-Bxqwukqu.mjs.map → graph-schema-D4LAefGf.mjs.map} +1 -1
- 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 +65 -39
- 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 +63 -38
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/{print-result-if-AbNLY.cjs → print-result-BYppJlUi.cjs} +19 -19
- package/dist/{print-result-BtEAn2Wl.mjs → print-result-IFARsMnL.mjs} +9 -21
- package/dist/print-result-IFARsMnL.mjs.map +1 -0
- package/dist/{public-tools-COG3pCpD.cjs → public-tools-Cfc1OPNS.cjs} +8 -13
- package/dist/{public-tools-DIJs4SHz.mjs → public-tools-DXlZcanX.mjs} +8 -13
- package/dist/{public-tools-DIJs4SHz.mjs.map → public-tools-DXlZcanX.mjs.map} +1 -1
- 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-DTAYvE9E.cjs → tool-visibility-DIpgPULN.cjs} +5 -10
- package/dist/{tool-visibility-zcmwMSbn.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-C7OQjmC7.mjs → transport-error-68G35VPH.mjs} +3 -4
- package/dist/{transport-error-C7OQjmC7.mjs.map → transport-error-68G35VPH.mjs.map} +1 -1
- package/dist/{transport-error-qDWQn8hb.cjs → transport-error-DXy1iTpS.cjs} +2 -3
- package/dist/{update-DqBhBXFs.mjs → update-BH8F4cQ2.mjs} +3 -4
- package/dist/{update-DqBhBXFs.mjs.map → update-BH8F4cQ2.mjs.map} +1 -1
- package/dist/{update-NowrCmjR.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/mcp-proxy.md +34 -0
- package/docs/stability.md +3 -2
- package/package.json +1 -1
- package/skills/chain-insights-cypher/SKILL.md +3 -0
- package/dist/dex-tool-ib_ICiyV.mjs.map +0 -1
- package/dist/print-result-BtEAn2Wl.mjs.map +0 -1
- package/dist/robinhood-CCTMagwM.mjs.map +0 -1
- package/dist/tool-visibility-zcmwMSbn.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote-
|
|
1
|
+
{"version":3,"file":"quote-41CbMc37.mjs","names":[],"sources":["../src/subscription/quote.ts"],"sourcesContent":["import { parseUnits } from 'viem'\nimport { CIA_TOKEN_ADDRESS } from '../wallet/robinhood.js'\n\n// The subscription is priced at 120 USD a month of 30 days, so one day costs\n// 120 / 30 = 4 USD, paid in $CIA at the CoinGecko price. A subscriber's\n// daily query allowance is the month price times 2.5, over 30 days:\n// 120 x 2.5 / 30 = 10 USD a day. The server grants quote_usd / 4 days for a\n// payment, so the days asked here are the days granted, give or take the\n// price move between this quote and the server's own.\nexport const SUBSCRIPTION_MONTH_USD = 120\nexport const SUBSCRIPTION_MONTH_DAYS = 30\nexport const SUBSCRIPTION_ALLOWANCE_MULTIPLIER = 2.5\nexport const SUBSCRIPTION_DAY_USD = SUBSCRIPTION_MONTH_USD / SUBSCRIPTION_MONTH_DAYS\nexport const DAILY_ALLOWANCE_USD =\n (SUBSCRIPTION_MONTH_USD * SUBSCRIPTION_ALLOWANCE_MULTIPLIER) / SUBSCRIPTION_MONTH_DAYS\n/**\n * The most days a wallet may hold at once. A buy may pay for at most this\n * many days minus the days left, rounded down: a wallet holding 90 days buys\n * nothing until a day has passed. The guard is the CLI's only; the sink takes\n * any deposit made by hand.\n */\nexport const MAX_DAYS_HELD = 90\n\n// The price comes from CoinGecko only. Never from an exchange pool: operator\n// ruling. A price older than this is refused, the same limit the server keeps.\nexport const COINGECKO_PLATFORM = 'robinhood'\nexport const MAX_PRICE_AGE_SECONDS = 10 * 60\nconst COINGECKO_API = 'https://api.coingecko.com/api/v3'\n\nexport interface CiaPrice {\n /** USD per $CIA, as a plain decimal string. */\n usd: string\n /** When CoinGecko last updated the price. */\n updatedAt: Date\n}\n\nexport interface Quote {\n days: number\n usd: number\n price: CiaPrice\n /** The $CIA to pay, in token units (18 decimals), rounded up. */\n amount: bigint\n}\n\n/** A JSON number as a plain decimal string: 3.2e-7 becomes 0.00000032. */\nfunction plainDecimal(value: number): string {\n const text = String(value)\n if (!/e/i.test(text)) return text\n return value.toFixed(18).replace(/0+$/, '').replace(/\\.$/, '')\n}\n\nexport function assertDays(days: number): void {\n if (!Number.isInteger(days) || days < 1 || days > MAX_DAYS_HELD) {\n throw new Error(`Days must be a whole number from 1 to ${MAX_DAYS_HELD}.`)\n }\n}\n\n/**\n * The $CIA amount for `days` at `priceUsd` USD per $CIA: days x 4 USD over the\n * price, in token units, rounded up so the payment never falls short.\n */\nexport function quoteAmount(days: number, priceUsd: string): bigint {\n assertDays(days)\n const price = parseUnits(priceUsd, 18)\n if (price <= 0n) throw new Error('The $CIA price must be above zero.')\n const usd = parseUnits(String(days * SUBSCRIPTION_DAY_USD), 18)\n const scaled = usd * 10n ** 18n\n return (scaled + price - 1n) / price\n}\n\nexport function quoteForDays(days: number, price: CiaPrice): Quote {\n return { days, usd: days * SUBSCRIPTION_DAY_USD, price, amount: quoteAmount(days, price.usd) }\n}\n\ntype FetchLike = (input: string, init?: { headers?: Record<string, string> }) => Promise<{\n ok: boolean\n status: number\n json(): Promise<unknown>\n}>\n\n/**\n * The $CIA price in USD from CoinGecko. Sends CHAIN_INSIGHTS_COINGECKO_API_KEY\n * as the demo key header when it is set. Refuses a missing, zero or stale price.\n */\nexport async function fetchCiaUsdPrice(\n fetchImpl: FetchLike = fetch as unknown as FetchLike,\n env: NodeJS.ProcessEnv = process.env,\n now: Date = new Date()\n): Promise<CiaPrice> {\n const contract = CIA_TOKEN_ADDRESS.toLowerCase()\n const url =\n `${COINGECKO_API}/simple/token_price/${COINGECKO_PLATFORM}` +\n `?contract_addresses=${contract}&vs_currencies=usd&include_last_updated_at=true`\n const apiKey = env['CHAIN_INSIGHTS_COINGECKO_API_KEY']?.trim()\n const headers: Record<string, string> = { accept: 'application/json' }\n if (apiKey) headers['x-cg-demo-api-key'] = apiKey\n const response = await fetchImpl(url, { headers })\n if (!response.ok) {\n throw new Error(`CoinGecko did not answer the $CIA price (HTTP ${response.status}). Try again in a minute.`)\n }\n const body = (await response.json()) as Record<string, { usd?: unknown; last_updated_at?: unknown } | undefined>\n const entry = body?.[contract]\n const usd = entry?.usd\n if (typeof usd !== 'number' || !Number.isFinite(usd) || usd <= 0) {\n throw new Error('CoinGecko has no $CIA price right now. Try again later.')\n }\n const updated = entry?.last_updated_at\n if (typeof updated !== 'number' || !Number.isFinite(updated)) {\n throw new Error('CoinGecko sent the $CIA price without its time. Try again later.')\n }\n const ageSeconds = now.getTime() / 1000 - updated\n if (ageSeconds > MAX_PRICE_AGE_SECONDS) {\n throw new Error(\n `The $CIA price on CoinGecko is ${Math.round(ageSeconds / 60)} minutes old, over the ${MAX_PRICE_AGE_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UAAU,KAAK,EAAE,QAAQ,CAAC;CACjD,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,iDAAiD,SAAS,OAAO,0BAA0B;CAG7G,MAAM,SAAQ,MADM,SAAS,KAAK,EAAA,GACb;CACrB,MAAM,MAAM,OAAO;CACnB,IAAI,OAAO,QAAQ,YAAY,CAAC,OAAO,SAAS,GAAG,KAAK,OAAO,GAC7D,MAAM,IAAI,MAAM,yDAAyD;CAE3E,MAAM,UAAU,OAAO;CACvB,IAAI,OAAO,YAAY,YAAY,CAAC,OAAO,SAAS,OAAO,GACzD,MAAM,IAAI,MAAM,kEAAkE;CAEpF,MAAM,aAAa,IAAI,QAAQ,IAAI,MAAO;CAC1C,IAAI,aAAa,uBACf,MAAM,IAAI,MACR,kCAAkC,KAAK,MAAM,aAAa,EAAE,EAAE,yBAAyB,wBAAwB,GAAG,gCACpH;CAEF,OAAO;EAAE,KAAK,aAAa,GAAG;EAAG,2BAAW,IAAI,KAAK,UAAU,GAAI;CAAE;AACvE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_robinhood = require("./robinhood-
|
|
1
|
+
const require_robinhood = require("./robinhood-DumTxvlA.cjs");
|
|
2
2
|
let viem = require("viem");
|
|
3
3
|
const SUBSCRIPTION_DAY_USD = 4;
|
|
4
4
|
/**
|
|
@@ -62,7 +62,6 @@ async function fetchCiaUsdPrice(fetchImpl = fetch, env = process.env, now = /* @
|
|
|
62
62
|
updatedAt: /* @__PURE__ */ new Date(updated * 1e3)
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
//#endregion
|
|
66
65
|
exports.MAX_DAYS_HELD = MAX_DAYS_HELD;
|
|
67
66
|
exports.SUBSCRIPTION_DAY_USD = SUBSCRIPTION_DAY_USD;
|
|
68
67
|
exports.assertDays = assertDays;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/mcp/request-timeout.ts
|
|
2
2
|
const GRAPH_TOOL_REQUEST_TIMEOUT_MS = 3e5;
|
|
3
3
|
function graphToolRequestOptions(tool) {
|
|
4
4
|
if (tool === "graph_query" || tool === "graph_query_batch") return {
|
|
@@ -6,6 +6,5 @@ function graphToolRequestOptions(tool) {
|
|
|
6
6
|
maxTotalTimeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
exports.GRAPH_TOOL_REQUEST_TIMEOUT_MS = GRAPH_TOOL_REQUEST_TIMEOUT_MS;
|
|
11
10
|
exports.graphToolRequestOptions = graphToolRequestOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/mcp/request-timeout.ts
|
|
2
2
|
const GRAPH_TOOL_REQUEST_TIMEOUT_MS = 3e5;
|
|
3
3
|
function graphToolRequestOptions(tool) {
|
|
4
4
|
if (tool === "graph_query" || tool === "graph_query_batch") return {
|
|
@@ -6,7 +6,6 @@ function graphToolRequestOptions(tool) {
|
|
|
6
6
|
maxTotalTimeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { GRAPH_TOOL_REQUEST_TIMEOUT_MS, graphToolRequestOptions };
|
|
11
10
|
|
|
12
|
-
//# sourceMappingURL=request-timeout-
|
|
11
|
+
//# sourceMappingURL=request-timeout-K3ljP0pa.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-timeout-
|
|
1
|
+
{"version":3,"file":"request-timeout-K3ljP0pa.mjs","names":[],"sources":["../src/mcp/request-timeout.ts"],"sourcesContent":["import type { Client } from '@modelcontextprotocol/sdk/client/index.js'\n\n// Above the graph server's 100 s batch budget and the 125 s edge limit.\n// The SDK default is 60 s and fails a batch the server is still answering.\nexport const GRAPH_TOOL_REQUEST_TIMEOUT_MS = 5 * 60 * 1000\n\nexport function graphToolRequestOptions(tool: string): Parameters<Client['callTool']>[2] {\n if (tool === 'graph_query' || tool === 'graph_query_batch') {\n return {\n timeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS,\n maxTotalTimeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS,\n }\n }\n return undefined\n}\n"],"mappings":";AAIA,MAAa,gCAAgC;AAE7C,SAAgB,wBAAwB,MAAiD;CACvF,IAAI,SAAS,iBAAiB,SAAS,qBACrC,OAAO;EACL,SAAS;EACT,iBAAiB;CACnB;AAGJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { privateKeyToAccount } from "viem/accounts";
|
|
2
2
|
import { createPublicClient, createWalletClient, decodeEventLog, defineChain, formatEther, formatUnits, http } from "viem";
|
|
3
3
|
import { robinhood } from "viem/chains";
|
|
4
|
-
|
|
4
|
+
// src/wallet/robinhood.ts
|
|
5
5
|
const ROBINHOOD_CHAIN_ID = 4663;
|
|
6
6
|
const ROBINHOOD_NETWORK = "eip155:4663";
|
|
7
7
|
const ROBINHOOD_NETWORK_DISPLAY = "Robinhood Chain";
|
|
@@ -220,7 +220,6 @@ async function depositCiaForSubscription(privateKey, amount, env = process.env)
|
|
|
220
220
|
received
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
|
-
//#endregion
|
|
224
223
|
export { ROBINHOOD_NETWORK_DISPLAY as a, explorerTxUrl as c, getRobinhoodEthBalance as d, readCiaAllowance as f, robinhoodRpcUrls as h, ROBINHOOD_NETWORK as i, formatCia as l, readRobinhoodEthBalance as m, CIA_TOKEN_ADDRESS as n, approveCiaForSubscription as o, readCiaBalance as p, ROBINHOOD_CHAIN_ID as r, depositCiaForSubscription as s, CIA_SYMBOL as t, getCiaBalance as u };
|
|
225
224
|
|
|
226
|
-
//# sourceMappingURL=robinhood-
|
|
225
|
+
//# sourceMappingURL=robinhood-0NZsA6ZW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robinhood-0NZsA6ZW.mjs","names":[],"sources":["../src/wallet/robinhood.ts"],"sourcesContent":["import {\n createPublicClient,\n createWalletClient,\n decodeEventLog,\n defineChain,\n formatEther,\n formatUnits,\n http,\n type Address,\n type Chain,\n type Hex,\n} from 'viem'\nimport { robinhood } from 'viem/chains'\nimport { privateKeyToAccount } from 'viem/accounts'\n\n// Robinhood Chain: the network of the $CIA token and of the subscription\n// payment. Also the second EVM network accepted for x402 Permit2 payments\n// beside Base (src/mcp/client.ts).\nexport const ROBINHOOD_CHAIN_ID = 4663\nexport const ROBINHOOD_NETWORK = 'eip155:4663'\nexport const ROBINHOOD_NETWORK_DISPLAY = 'Robinhood Chain'\nexport const ROBINHOOD_RPC_URL = 'https://rpc.mainnet.chain.robinhood.com'\nexport const PUBLIC_ROBINHOOD_RPC_URLS = [ROBINHOOD_RPC_URL, 'https://rpc.ordofi.network'] as const\nexport const ROBINHOOD_EXPLORER_URL = 'https://robin.etherscan.io'\n\n// $CIA, the Chain Insights token on Robinhood Chain.\nexport const CIA_TOKEN_ADDRESS = '0x766bd6598182586beda76414dc5f8deb1530a213' as const\nexport const CIA_DECIMALS = 18\nexport const CIA_SYMBOL = '$CIA'\n\n// The subscription sink. Module-private on purpose: only the buy below sends\n// to it, and no text a user reads names it. $CIA sent to it by hand is not\n// credited to a subscription.\nconst SUBSCRIPTION_SINK = '0x67a8c068cc762e371706ea6c399178171f92810d' as const\n\n// viem's chain entry links Blockscout; Chain Insights links Etherscan.\nexport const robinhoodChain: Chain = defineChain({\n ...robinhood,\n blockExplorers: {\n default: { name: 'Robinhood Chain Etherscan', url: ROBINHOOD_EXPLORER_URL },\n },\n})\n\nconst ERC20_ABI = [\n {\n type: 'function',\n name: 'balanceOf',\n stateMutability: 'view',\n inputs: [{ name: 'account', type: 'address' }],\n outputs: [{ name: '', type: 'uint256' }],\n },\n {\n type: 'function',\n name: 'allowance',\n stateMutability: 'view',\n inputs: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n ],\n outputs: [{ name: '', type: 'uint256' }],\n },\n {\n type: 'function',\n name: 'approve',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [{ name: '', type: 'bool' }],\n },\n] as const\n\nconst SINK_ABI = [\n {\n type: 'function',\n name: 'deposit',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'token', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n outputs: [],\n },\n {\n type: 'event',\n name: 'Received',\n inputs: [\n { name: 'from', type: 'address', indexed: true },\n { name: 'token', type: 'address', indexed: true },\n { name: 'amount', type: 'uint256', indexed: false },\n ],\n },\n] as const\n\n/**\n * The Robinhood Chain RPC list: ROBINHOOD_RPC_URL from the environment first,\n * then the public endpoints, without duplicates.\n */\nexport function robinhoodRpcUrls(env: NodeJS.ProcessEnv = process.env): string[] {\n const override = env['ROBINHOOD_RPC_URL']?.trim()\n const urls = [...(override ? [override] : []), ...PUBLIC_ROBINHOOD_RPC_URLS]\n return [...new Set(urls)]\n}\n\nexport function explorerTxUrl(hash: string): string {\n return `${ROBINHOOD_EXPLORER_URL}/tx/${hash}`\n}\n\nexport function explorerAddressUrl(address: string): string {\n return `${ROBINHOOD_EXPLORER_URL}/address/${address}`\n}\n\n/** A $CIA amount in token units (18 decimals) as a decimal string. */\nexport function formatCia(amount: bigint): string {\n return formatUnits(amount, CIA_DECIMALS)\n}\n\nfunction publicClient(url: string) {\n return createPublicClient({ chain: robinhoodChain, transport: http(url) })\n}\n\n/** Walks the RPC list; null when every endpoint fails. */\nasync function readFirst<T>(env: NodeJS.ProcessEnv, read: (url: string) => Promise<T>): Promise<T | null> {\n for (const url of robinhoodRpcUrls(env)) {\n try {\n return await read(url)\n } catch {\n // Try the next Robinhood Chain RPC endpoint.\n }\n }\n return null\n}\n\nexport function readCiaBalance(address: string, env: NodeJS.ProcessEnv = process.env): Promise<bigint | null> {\n return readFirst(env, (url) =>\n publicClient(url).readContract({\n address: CIA_TOKEN_ADDRESS,\n abi: ERC20_ABI,\n functionName: 'balanceOf',\n args: [address as Address],\n })\n )\n}\n\nexport function readRobinhoodEthBalance(address: string, env: NodeJS.ProcessEnv = process.env): Promise<bigint | null> {\n return readFirst(env, (url) => publicClient(url).getBalance({ address: address as Address }))\n}\n\n/** The $CIA the subscription sink may take from `owner`. */\nexport function readCiaAllowance(owner: string, env: NodeJS.ProcessEnv = process.env): Promise<bigint | null> {\n return readFirst(env, (url) =>\n publicClient(url).readContract({\n address: CIA_TOKEN_ADDRESS,\n abi: ERC20_ABI,\n functionName: 'allowance',\n args: [owner as Address, SUBSCRIPTION_SINK],\n })\n )\n}\n\n/** The $CIA balance as a decimal string, or 'unknown' when every RPC fails. */\nexport async function getCiaBalance(address: string, env: NodeJS.ProcessEnv = process.env): Promise<string> {\n const value = await readCiaBalance(address, env)\n return value === null ? 'unknown' : formatCia(value)\n}\n\n/** The ETH balance on Robinhood Chain, or 'unknown' when every RPC fails. */\nexport async function getRobinhoodEthBalance(address: string, env: NodeJS.ProcessEnv = process.env): Promise<string> {\n const value = await readRobinhoodEthBalance(address, env)\n return value === null ? 'unknown' : formatEther(value)\n}\n\n/** The allowance of the subscription sink, or 'unknown' when every RPC fails. */\nexport async function getCiaAllowance(owner: string, env: NodeJS.ProcessEnv = process.env): Promise<string> {\n const value = await readCiaAllowance(owner, env)\n return value === null ? 'unknown' : formatCia(value)\n}\n\nexport interface SentTransaction {\n txHash: Hex\n status: 'success' | 'reverted'\n}\n\nexport interface DepositTransaction extends SentTransaction {\n /** The sink's Received log of this deposit, or null when it has none. */\n received: { from: string; token: string; amount: bigint } | null\n}\n\n/**\n * A transaction is sent once, through the first RPC of the list, and never\n * resent through another: a send that failed half-way may still land.\n */\nfunction writeClients(privateKey: Hex, env: NodeJS.ProcessEnv) {\n const url = robinhoodRpcUrls(env)[0]\n const account = privateKeyToAccount(privateKey)\n return {\n account,\n publicClient: publicClient(url),\n walletClient: createWalletClient({ account, chain: robinhoodChain, transport: http(url) }),\n }\n}\n\n/** Approves exactly `amount` $CIA to the subscription sink, never more. */\nexport async function approveCiaForSubscription(\n privateKey: Hex,\n amount: bigint,\n env: NodeJS.ProcessEnv = process.env\n): Promise<SentTransaction> {\n const { publicClient: reader, walletClient } = writeClients(privateKey, env)\n const txHash = await walletClient.writeContract({\n address: CIA_TOKEN_ADDRESS,\n abi: ERC20_ABI,\n functionName: 'approve',\n args: [SUBSCRIPTION_SINK, amount],\n })\n const receipt = await reader.waitForTransactionReceipt({ hash: txHash })\n return { txHash, status: receipt.status }\n}\n\n/** Deposits `amount` $CIA into the subscription sink and reads its Received log. */\nexport async function depositCiaForSubscription(\n privateKey: Hex,\n amount: bigint,\n env: NodeJS.ProcessEnv = process.env\n): Promise<DepositTransaction> {\n const { publicClient: reader, walletClient } = writeClients(privateKey, env)\n const txHash = await walletClient.writeContract({\n address: SUBSCRIPTION_SINK,\n abi: SINK_ABI,\n functionName: 'deposit',\n args: [CIA_TOKEN_ADDRESS, amount],\n })\n const receipt = await reader.waitForTransactionReceipt({ hash: txHash })\n let received: DepositTransaction['received'] = null\n for (const log of receipt.logs) {\n if (log.address.toLowerCase() !== SUBSCRIPTION_SINK) continue\n try {\n const event = decodeEventLog({ abi: SINK_ABI, data: log.data, topics: log.topics })\n if (event.eventName === 'Received') {\n received = { from: event.args.from, token: event.args.token, amount: event.args.amount }\n }\n } catch {\n // Not the Received event.\n }\n }\n return { txHash, status: receipt.status, received }\n}\n"],"mappings":";;;;AAkBA,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,4BAA4B;AAEzC,MAAa,4BAA4B,CAAC,2CAAmB,4BAA4B;AACzF,MAAa,yBAAyB;AAGtC,MAAa,oBAAoB;AACjC,MAAa,eAAe;AAC5B,MAAa,aAAa;AAK1B,MAAM,oBAAoB;AAG1B,MAAa,iBAAwB,YAAY;CAC/C,GAAG;CACH,gBAAgB,EACd,SAAS;EAAE,MAAM;EAA6B,KAAK;CAAuB,EAC5E;AACF,CAAC;AAED,MAAM,YAAY;CAChB;EACE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viem_chains = require("viem/chains");
|
|
4
|
-
|
|
4
|
+
// src/wallet/robinhood.ts
|
|
5
5
|
const ROBINHOOD_CHAIN_ID = 4663;
|
|
6
6
|
const ROBINHOOD_NETWORK = "eip155:4663";
|
|
7
7
|
const ROBINHOOD_NETWORK_DISPLAY = "Robinhood Chain";
|
|
@@ -220,7 +220,6 @@ async function depositCiaForSubscription(privateKey, amount, env = process.env)
|
|
|
220
220
|
received
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
|
-
//#endregion
|
|
224
223
|
Object.defineProperty(exports, "CIA_SYMBOL", {
|
|
225
224
|
enumerable: true,
|
|
226
225
|
get: function() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __exportAll = (all, no_symbols) => {
|
|
5
5
|
let target = {};
|
|
@@ -10,5 +10,4 @@ var __exportAll = (all, no_symbols) => {
|
|
|
10
10
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
11
|
return target;
|
|
12
12
|
};
|
|
13
|
-
//#endregion
|
|
14
13
|
export { __exportAll as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -28,7 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
value: mod,
|
|
29
29
|
enumerable: true
|
|
30
30
|
}) : target, mod));
|
|
31
|
-
//#endregion
|
|
32
31
|
Object.defineProperty(exports, "__exportAll", {
|
|
33
32
|
enumerable: true,
|
|
34
33
|
get: function() {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// src/subscription/rules.ts
|
|
2
2
|
const SUBSCRIPTION_RULES = "Two funding doors for the one local wallet: wallet_topup is USDC on Base, for pay-per-call queries; subscription_topup is $CIA and a little ETH on Robinhood Chain, for the subscription. Buying subscription days is `cia subscription buy --days N`, run by the user in a terminal, and it needs the user's own yes. An agent never buys: no tool can buy or pay. Never send $CIA by hand to any other address: it is not credited.";
|
|
3
3
|
const META_SUBSCRIPTION_STATUS_DESCRIPTION = "Return the subscription of the caller's wallet, proven by the wallet's own signature: active or not, the window start and end, the days left, the daily allowance of 10 USD with what is used and left today, the tier, and payments seen on chain and not credited yet. Takes no arguments: send {}. " + SUBSCRIPTION_RULES;
|
|
4
4
|
const SUBSCRIPTION_TOPUP_TOOL = "subscription_topup";
|
|
5
5
|
const SUBSCRIPTION_TOPUP_DESCRIPTION = "Show the local Chain Insights wallet address and its QR code for funding with $CIA and ETH (for gas) on Robinhood Chain, with its $CIA and ETH balances. Read-only: it signs nothing and sends nothing. Takes no arguments: send {}. " + SUBSCRIPTION_RULES;
|
|
6
6
|
const WALLET_TOPUP_DESCRIPTION = "Show the local Chain Insights payment wallet address and its QR code for funding with USDC on Base Mainnet. Read-only: it makes no payment and signs nothing. " + SUBSCRIPTION_RULES;
|
|
7
|
-
//#endregion
|
|
8
7
|
export { WALLET_TOPUP_DESCRIPTION as i, SUBSCRIPTION_TOPUP_DESCRIPTION as n, SUBSCRIPTION_TOPUP_TOOL as r, META_SUBSCRIPTION_STATUS_DESCRIPTION as t };
|
|
9
8
|
|
|
10
|
-
//# sourceMappingURL=rules-
|
|
9
|
+
//# sourceMappingURL=rules-B3w9pCeQ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules-
|
|
1
|
+
{"version":3,"file":"rules-B3w9pCeQ.mjs","names":[],"sources":["../src/subscription/rules.ts"],"sourcesContent":["// The subscription rules, in the one text every host reads: the tool\n// description. Claude Desktop chat loads no skill, so the rules ride on each\n// subscription tool; the chain-insights-cypher skill repeats them.\n\nexport const SUBSCRIPTION_RULES =\n 'Two funding doors for the one local wallet: wallet_topup is USDC on Base, for pay-per-call queries; subscription_topup is $CIA and a little ETH on Robinhood Chain, for the subscription. ' +\n 'Buying subscription days is `cia subscription buy --days N`, run by the user in a terminal, and it needs the user\\'s own yes. An agent never buys: no tool can buy or pay. ' +\n 'Never send $CIA by hand to any other address: it is not credited.'\n\nexport const META_SUBSCRIPTION_STATUS_DESCRIPTION =\n \"Return the subscription of the caller's wallet, proven by the wallet's own signature: active or not, the window start and end, the days left, the daily allowance of 10 USD with what is used and left today, the tier, and payments seen on chain and not credited yet. Takes no arguments: send {}. \" +\n SUBSCRIPTION_RULES\n\nexport const SUBSCRIPTION_TOPUP_TOOL = 'subscription_topup'\n\nexport const SUBSCRIPTION_TOPUP_DESCRIPTION =\n 'Show the local Chain Insights wallet address and its QR code for funding with $CIA and ETH (for gas) on Robinhood Chain, with its $CIA and ETH balances. Read-only: it signs nothing and sends nothing. Takes no arguments: send {}. ' +\n SUBSCRIPTION_RULES\n\nexport const WALLET_TOPUP_DESCRIPTION =\n 'Show the local Chain Insights payment wallet address and its QR code for funding with USDC on Base Mainnet. Read-only: it makes no payment and signs nothing. ' +\n SUBSCRIPTION_RULES\n"],"mappings":";AAIA,MAAa,qBACX;AAIF,MAAa,uCACX,2SACA;AAEF,MAAa,0BAA0B;AAEvC,MAAa,iCACX,0OACA;AAEF,MAAa,2BACX,mKACA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// src/subscription/rules.ts
|
|
2
2
|
const SUBSCRIPTION_RULES = "Two funding doors for the one local wallet: wallet_topup is USDC on Base, for pay-per-call queries; subscription_topup is $CIA and a little ETH on Robinhood Chain, for the subscription. Buying subscription days is `cia subscription buy --days N`, run by the user in a terminal, and it needs the user's own yes. An agent never buys: no tool can buy or pay. Never send $CIA by hand to any other address: it is not credited.";
|
|
3
3
|
const META_SUBSCRIPTION_STATUS_DESCRIPTION = "Return the subscription of the caller's wallet, proven by the wallet's own signature: active or not, the window start and end, the days left, the daily allowance of 10 USD with what is used and left today, the tier, and payments seen on chain and not credited yet. Takes no arguments: send {}. " + SUBSCRIPTION_RULES;
|
|
4
4
|
const SUBSCRIPTION_TOPUP_TOOL = "subscription_topup";
|
|
5
5
|
const SUBSCRIPTION_TOPUP_DESCRIPTION = "Show the local Chain Insights wallet address and its QR code for funding with $CIA and ETH (for gas) on Robinhood Chain, with its $CIA and ETH balances. Read-only: it signs nothing and sends nothing. Takes no arguments: send {}. " + SUBSCRIPTION_RULES;
|
|
6
6
|
const WALLET_TOPUP_DESCRIPTION = "Show the local Chain Insights payment wallet address and its QR code for funding with USDC on Base Mainnet. Read-only: it makes no payment and signs nothing. " + SUBSCRIPTION_RULES;
|
|
7
|
-
//#endregion
|
|
8
7
|
Object.defineProperty(exports, "META_SUBSCRIPTION_STATUS_DESCRIPTION", {
|
|
9
8
|
enumerable: true,
|
|
10
9
|
get: function() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
import { isIP } from "node:net";
|
|
6
|
-
|
|
6
|
+
// src/config/mcp-endpoint.ts
|
|
7
7
|
const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
|
|
8
8
|
"localhost",
|
|
9
9
|
"127.0.0.1",
|
|
@@ -39,8 +39,7 @@ function validateMcpEndpoint(value, key) {
|
|
|
39
39
|
if (parsed.protocol === "http:" && !isLoopbackHost(parsed.hostname) && !isKubernetesServiceHost(parsed.hostname)) throw new Error(`${key} must use https:// for remote hosts. http:// is allowed only for localhost, loopback addresses, or Kubernetes *.svc.cluster.local service DNS.`);
|
|
40
40
|
return trimmed;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
//#region src/config/limits.ts
|
|
42
|
+
// src/config/limits.ts
|
|
44
43
|
const LIMIT_SPECS = { viz_max_nodes: {
|
|
45
44
|
builtin: 100,
|
|
46
45
|
min: 1,
|
|
@@ -62,15 +61,10 @@ function limitCeiling(key, network) {
|
|
|
62
61
|
if (networkCeiling === void 0 || !Number.isFinite(networkCeiling)) return builtinCeiling;
|
|
63
62
|
return Math.min(builtinCeiling, Math.trunc(networkCeiling));
|
|
64
63
|
}
|
|
65
|
-
|
|
66
|
-
//#region src/config/schema.ts
|
|
64
|
+
// src/config/schema.ts
|
|
67
65
|
var schema_exports = /* @__PURE__ */ __exportAll({
|
|
68
66
|
CONFIG_KEYS: () => CONFIG_KEYS,
|
|
69
|
-
|
|
70
|
-
DEFAULT_CONFIG: () => DEFAULT_CONFIG,
|
|
71
|
-
LimitsSchema: () => LimitsSchema,
|
|
72
|
-
NetworkLimitsSchema: () => NetworkLimitsSchema,
|
|
73
|
-
parseInvestigatorConfig: () => parseInvestigatorConfig
|
|
67
|
+
DEFAULT_CONFIG: () => DEFAULT_CONFIG
|
|
74
68
|
});
|
|
75
69
|
function limitBagSchema(network) {
|
|
76
70
|
return z.record(z.string(), z.number()).superRefine((bag, ctx) => {
|
|
@@ -148,7 +142,6 @@ const CONFIG_KEYS = [
|
|
|
148
142
|
"dataDir",
|
|
149
143
|
"version"
|
|
150
144
|
];
|
|
151
|
-
//#endregion
|
|
152
145
|
export { graphMcpEndpointEnvOverride as i, parseInvestigatorConfig as n, schema_exports as r, DEFAULT_CONFIG as t };
|
|
153
146
|
|
|
154
|
-
//# sourceMappingURL=schema-
|
|
147
|
+
//# sourceMappingURL=schema-CKnQsdw9.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-KjZqCHbu.mjs","names":[],"sources":["../src/config/mcp-endpoint.ts","../src/config/limits.ts","../src/config/schema.ts"],"sourcesContent":["import { isIP } from 'node:net'\n\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]'])\n\nexport const LOCAL_GRAPH_MCP_ENDPOINT = 'http://127.0.0.1:8012/mcp'\nexport const DEFAULT_GRAPH_MCP_ENDPOINT = 'https://mcp.chain-insights.ai/'\n\nfunction isLoopbackHost(hostname: string): boolean {\n const normalized = hostname.toLowerCase().replace(/^\\[(.*)\\]$/, '$1')\n if (LOOPBACK_HOSTS.has(normalized)) return true\n if (isIP(normalized) !== 4) return false\n return normalized.split('.')[0] === '127'\n}\n\nfunction isKubernetesServiceHost(hostname: string): boolean {\n return hostname.toLowerCase().endsWith('.svc.cluster.local')\n}\n\nexport function graphMcpEndpointEnvOverride(): string | undefined {\n const envEndpoint =\n process.env.CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT?.trim() || process.env.GRAPH_MCP_ENDPOINT?.trim()\n return envEndpoint ? validateMcpEndpoint(envEndpoint, 'graphMcpEndpoint') : undefined\n}\n\nexport function validateMcpEndpoint(value: string, key: string): string {\n const trimmed = value.trim()\n if (!trimmed) {\n throw new Error(`${key} must be a non-empty absolute URL.`)\n }\n\n let parsed: URL\n try {\n parsed = new URL(trimmed)\n } catch {\n throw new Error(\n `${key} must be an absolute URL (example: https://mcp.example.com/mcp or http://127.0.0.1:8012/mcp).`\n )\n }\n\n if (parsed.username || parsed.password) {\n throw new Error(`${key} must not include URL credentials.`)\n }\n if (parsed.search || parsed.hash) {\n throw new Error(`${key} must not include query parameters or URL fragments.`)\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new Error(`${key} must use either https:// or http://.`)\n }\n if (\n parsed.protocol === 'http:' &&\n !isLoopbackHost(parsed.hostname) &&\n !isKubernetesServiceHost(parsed.hostname)\n ) {\n throw new Error(\n `${key} must use https:// for remote hosts. http:// is allowed only for localhost, loopback addresses, or Kubernetes *.svc.cluster.local service DNS.`\n )\n }\n\n return trimmed\n}\n","// Tunable search bounds for investigation and detection tools.\n//\n// Every hardcoded search cap in this repo used to be a bare `const` compiled\n// into one call site. That is wrong for two reasons at once: a value that is\n// right for a small chain is far too high for a busy one, and a value that is\n// right for a routine sweep is far too low for an analyst working a single\n// live case. A real high-fan-in deposit made the cost of that concrete — at\n// the old 500-row reverse-deposit cap the victim origin was NOT reachable at\n// four hops, and at 5000 rows the same four-hop trace closed the full\n// deposit -> victim chain in six seconds. The cap, not the depth, was the\n// binding constraint.\n//\n// This module generalizes the per-network default-table pattern (a\n// `resolve*Config(network, params)` function) into ONE registry the whole\n// codebase shares, so a knob is declared once with its default, its floor, and\n// its hard ceiling.\n//\n// ── Precedence (highest wins) ──────────────────────────────────────────────\n// 1. per-call — an argument on the MCP tool / CLI flag\n// 2. config file — `networkLimits[network][key]` in ~/.chain-insights/config.json\n// 3. config file — `limits[key]` (all networks)\n// 4. per-network — NETWORK_LIMIT_DEFAULTS[network].defaults[key]\n// 5. built-in — LIMIT_SPECS[key].builtin\n//\n// ── Ceilings ───────────────────────────────────────────────────────────────\n// An unbounded limit is a denial-of-service against the graph and against the\n// caller's metered spend, so every knob carries a hard ceiling. The ceiling is\n// NOT itself reachable from the per-call layer: a per-network entry may LOWER\n// a ceiling for a chain that cannot afford the work, but nothing outside this\n// file can RAISE the absolute maximum. Raising it is a code change, on\n// purpose.\n//\n// ── Rejection, not silent clamping ─────────────────────────────────────────\n// An over-ceiling request throws LimitRangeError naming the knob and its\n// ceiling. Silently clamping would hand an analyst a result that reads as\n// exhaustive when it is not — the same class of failure as the arbitrary row\n// truncation this registry exists to fix.\n\nexport interface LimitSpec {\n /** Value used when no layer overrides it. Chosen to preserve historical behaviour exactly. */\n builtin: number\n /** Lowest accepted value. */\n min: number\n /** Absolute maximum. Only a code change to this file may raise it. */\n ceiling: number\n /** What the knob bounds, for docs and error messages. */\n description: string\n}\n\n// Row/frontier ceilings are generous because their cost is close to linear\n// in the value; the exponential hop caps (corridor/attribution and the\n// aml_trace_* tools) were removed with the retired detection realm.\nexport const LIMIT_SPECS = {\n // Unused. Kept so old config files that still set it load without error.\n viz_max_nodes: {\n builtin: 100,\n min: 1,\n ceiling: 2_000,\n description: 'Unused; kept so old config files that set it still load.',\n },\n} as const satisfies Record<string, LimitSpec>\n\nexport type LimitKey = keyof typeof LIMIT_SPECS\nexport const LIMIT_KEYS = Object.keys(LIMIT_SPECS) as LimitKey[]\n\nexport function isLimitKey(key: string): key is LimitKey {\n return Object.prototype.hasOwnProperty.call(LIMIT_SPECS, key)\n}\n\nexport interface NetworkLimitOverride {\n /** Per-network default values. Must sit inside the built-in [min, ceiling]. */\n defaults?: Partial<Record<LimitKey, number>>\n /**\n * Per-network ceilings. May only LOWER the built-in ceiling; a higher value\n * is ignored so no chain can widen the absolute maximum from data.\n */\n ceilings?: Partial<Record<LimitKey, number>>\n}\n\n// Per-network defaults. Empty today: every chain currently starts on the\n// built-in values, which is exactly what keeps this change behaviour-neutral.\n// A chain that needs different economics adds an entry here (or an operator\n// sets `networkLimits` in the config file) without touching a call site.\nexport const NETWORK_LIMIT_DEFAULTS: Record<string, NetworkLimitOverride> = {}\n\n/** Config-file layer, as parsed from ~/.chain-insights/config.json. */\nexport interface LimitConfig {\n limits?: Partial<Record<LimitKey, number>>\n networkLimits?: Record<string, Partial<Record<LimitKey, number>>>\n}\n\nexport class LimitRangeError extends Error {\n readonly code = 'LIMIT_OUT_OF_RANGE'\n constructor(\n readonly key: LimitKey,\n readonly requested: number,\n readonly min: number,\n readonly ceiling: number,\n readonly source: string\n ) {\n super(\n `${key} must be an integer between ${min} and ${ceiling} (got ${requested} from ${source}). ` +\n `${LIMIT_SPECS[key].description} The ceiling is a hard bound and cannot be raised per call.`\n )\n this.name = 'LimitRangeError'\n }\n}\n\n/**\n * The maximum this network will accept. A per-network entry may lower it;\n * nothing may raise it above the built-in ceiling.\n */\nexport function limitCeiling(key: LimitKey, network?: string): number {\n const builtinCeiling = LIMIT_SPECS[key].ceiling\n const networkCeiling = network ? NETWORK_LIMIT_DEFAULTS[network]?.ceilings?.[key] : undefined\n if (networkCeiling === undefined || !Number.isFinite(networkCeiling)) return builtinCeiling\n return Math.min(builtinCeiling, Math.trunc(networkCeiling))\n}\n\nexport interface ResolveLimitContext {\n network?: string\n config?: LimitConfig\n}\n\n/**\n * The value used when the caller passes nothing: config file, then per-network\n * default, then built-in. Always inside [min, ceiling] for the network.\n */\nexport function limitDefault(key: LimitKey, ctx: ResolveLimitContext = {}): number {\n const spec = LIMIT_SPECS[key]\n const ceiling = limitCeiling(key, ctx.network)\n const candidates = [\n ctx.network ? ctx.config?.networkLimits?.[ctx.network]?.[key] : undefined,\n ctx.config?.limits?.[key],\n ctx.network ? NETWORK_LIMIT_DEFAULTS[ctx.network]?.defaults?.[key] : undefined,\n ]\n for (const candidate of candidates) {\n if (candidate === undefined || !Number.isFinite(candidate)) continue\n const value = Math.trunc(candidate)\n if (value < spec.min || value > ceiling) {\n throw new LimitRangeError(key, value, spec.min, ceiling, 'configuration')\n }\n return value\n }\n // The built-in is clamped rather than rejected: a per-network entry that\n // lowers a ceiling below the built-in default is a deliberate tightening of\n // that chain, not an operator error to fail on.\n return Math.min(spec.builtin, ceiling)\n}\n\n/** What a knob resolved to, and what the caller asked for. Emitted so a bounded search is visible without reading warnings. */\nexport interface LimitResolution {\n key: LimitKey\n /** What the caller passed, if anything. */\n requested?: number\n /** What the run actually used. */\n used: number\n /** The value that would have been used with no per-call override. */\n fallback: number\n /** The hard maximum for this network. */\n ceiling: number\n}\n\n/**\n * Resolve one knob. `requested` is the per-call layer; undefined/null/NaN\n * means \"no override\" and falls through to limitDefault.\n *\n * Throws LimitRangeError for a non-integer, below-min, or above-ceiling\n * request. Rejecting is deliberate: see the header note on silent clamping.\n */\nexport function resolveLimitDetail(\n key: LimitKey,\n requested: number | undefined | null,\n ctx: ResolveLimitContext = {}\n): LimitResolution {\n const spec = LIMIT_SPECS[key]\n const ceiling = limitCeiling(key, ctx.network)\n const fallback = limitDefault(key, ctx)\n if (requested === undefined || requested === null) {\n return { key, used: fallback, fallback, ceiling }\n }\n if (!Number.isFinite(requested) || !Number.isInteger(requested)) {\n throw new LimitRangeError(key, Number(requested), spec.min, ceiling, 'the call')\n }\n if (requested < spec.min || requested > ceiling) {\n throw new LimitRangeError(key, requested, spec.min, ceiling, 'the call')\n }\n return { key, requested, used: requested, fallback, ceiling }\n}\n\n/** resolveLimitDetail, when only the number is wanted. */\nexport function resolveLimit(\n key: LimitKey,\n requested: number | undefined | null,\n ctx: ResolveLimitContext = {}\n): number {\n return resolveLimitDetail(key, requested, ctx).used\n}\n\n/**\n * Renders resolved knobs for a tool response, so the effective depth/breadth\n * of a search is visible in the structured output without reading warnings.\n * `requested` is present only when the caller actually passed a value, which\n * makes \"I asked for 4 and got 4\" and \"I asked for nothing and got 3\"\n * distinguishable at a glance.\n */\nexport function limitsReport(resolutions: LimitResolution[]): Record<\n string,\n {\n requested?: number\n used: number\n default: number\n ceiling: number\n }\n> {\n return Object.fromEntries(\n resolutions.map((resolution) => [\n resolution.key,\n {\n ...(resolution.requested !== undefined ? { requested: resolution.requested } : {}),\n used: resolution.used,\n default: resolution.fallback,\n ceiling: resolution.ceiling,\n },\n ])\n )\n}\n\n/**\n * Integer-safe rendering for a value that is interpolated into a query.\n *\n * Cypher cannot parameterize a LIMIT, so the number is inlined — but ONLY\n * after resolveLimit has proven it is an integer inside a bounded range, and\n * this function re-proves it at the interpolation site. A recent CodeQL high\n * came from hand-interpolating an unvalidated value into query text; this is\n * the one sanctioned path.\n */\nexport function limitLiteral(value: number): string {\n if (!Number.isInteger(value) || value < 0) {\n throw new Error(`limit literal must be a non-negative integer (got ${String(value)})`)\n }\n return String(value)\n}\n","import * as z from 'zod'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { DEFAULT_GRAPH_MCP_ENDPOINT, validateMcpEndpoint } from './mcp-endpoint.js'\nimport { LIMIT_SPECS, isLimitKey, limitCeiling, type LimitKey } from './limits.js'\n\n// Config-file layer for the tunable search bounds (see config/limits.ts).\n// `limits` applies to every network; `networkLimits.<network>` is more\n// specific and wins over it. Both are validated here so a bad value fails at\n// config load rather than mid-investigation, and an unknown key is rejected\n// outright — a silently ignored knob is indistinguishable from one that had\n// no effect.\nfunction limitBagSchema(network?: string) {\n return z.record(z.string(), z.number()).superRefine((bag, ctx) => {\n for (const [key, value] of Object.entries(bag)) {\n const where = network ? `networkLimits.${network}.${key}` : `limits.${key}`\n if (!isLimitKey(key)) {\n ctx.addIssue({ code: z.ZodIssueCode.custom, message: `${where}: unknown limit key` })\n continue\n }\n const spec = LIMIT_SPECS[key as LimitKey]\n const ceiling = limitCeiling(key as LimitKey, network)\n if (!Number.isInteger(value) || value < spec.min || value > ceiling) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `${where}: must be an integer between ${spec.min} and ${ceiling} (got ${value})`,\n })\n }\n }\n })\n}\n\nexport const LimitsSchema = limitBagSchema()\n\nexport const NetworkLimitsSchema = z\n .record(z.string(), z.record(z.string(), z.number()))\n .superRefine((byNetwork, ctx) => {\n for (const [network, bag] of Object.entries(byNetwork)) {\n const parsed = limitBagSchema(network).safeParse(bag)\n if (parsed.success) continue\n for (const issue of parsed.error.issues) {\n ctx.addIssue({ code: z.ZodIssueCode.custom, message: issue.message })\n }\n }\n })\n\nfunction endpointSchema(key: 'graphMcpEndpoint') {\n return z.string().transform((value, ctx) => {\n try {\n return validateMcpEndpoint(value, key)\n } catch (err) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: (err as Error).message,\n })\n return z.NEVER\n }\n })\n}\n\nexport const ConfigSchema = z.object({\n graphMcpEndpoint: endpointSchema('graphMcpEndpoint').default(DEFAULT_GRAPH_MCP_ENDPOINT),\n graphMcpAuthToken: z.string().optional(),\n graphMcpMode: z.enum(['paid', 'debug']).default('paid'),\n walletAddress: z.string().optional(),\n serverPort: z.number().int().min(1024).max(65535).default(4321),\n dataDir: z.string().default(path.join(os.homedir(), '.chain-insights')),\n version: z.string().default('1'),\n limits: LimitsSchema.optional(),\n networkLimits: NetworkLimitsSchema.optional(),\n // Paths only. Never store or log certificate or key bytes.\n truthIngressCertPath: z.string().min(1).optional(),\n truthIngressKeyPath: z.string().min(1).optional(),\n truthIngressCaPath: z.string().min(1).optional(),\n})\n\nexport type InvestigatorConfig = z.infer<typeof ConfigSchema>\n\nfunction formatConfigValidationError(error: z.ZodError): string {\n return error.issues.map((issue) => issue.message).join('\\n')\n}\n\nexport function parseInvestigatorConfig(input: unknown): InvestigatorConfig {\n const parsed = ConfigSchema.safeParse(input)\n if (parsed.success) return parsed.data\n throw new Error(formatConfigValidationError(parsed.error))\n}\n\nexport const DEFAULT_CONFIG: InvestigatorConfig = parseInvestigatorConfig({})\n\nexport const CONFIG_KEYS = [\n 'graphMcpEndpoint',\n 'graphMcpAuthToken',\n 'graphMcpMode',\n 'walletAddress',\n 'serverPort',\n 'dataDir',\n 'version',\n // `limits` / `networkLimits` are nested objects, not scalar `cia config set`\n // targets, so they are deliberately absent from CONFIG_KEYS. Edit them in\n // ~/.chain-insights/config.json; they are validated on load.\n] as const\n\nexport type ConfigKey = (typeof CONFIG_KEYS)[number]\n"],"mappings":";;;;;;AAEA,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAa;CAAa;CAAO;AAAO,CAAC;AAGzE,MAAa,6BAA6B;AAE1C,SAAS,eAAe,UAA2B;CACjD,MAAM,aAAa,SAAS,YAAY,CAAC,CAAC,QAAQ,cAAc,IAAI;CACpE,IAAI,eAAe,IAAI,UAAU,GAAG,OAAO;CAC3C,IAAI,KAAK,UAAU,MAAM,GAAG,OAAO;CACnC,OAAO,WAAW,MAAM,GAAG,CAAC,CAAC,OAAO;AACtC;AAEA,SAAS,wBAAwB,UAA2B;CAC1D,OAAO,SAAS,YAAY,CAAC,CAAC,SAAS,oBAAoB;AAC7D;AAEA,SAAgB,8BAAkD;CAChE,MAAM,cACJ,QAAQ,IAAI,mCAAmC,KAAK,KAAK,QAAQ,IAAI,oBAAoB,KAAK;CAChG,OAAO,cAAc,oBAAoB,aAAa,kBAAkB,IAAI,KAAA;AAC9E;AAEA,SAAgB,oBAAoB,OAAe,KAAqB;CACtE,MAAM,UAAU,MAAM,K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AAkB,CAAC,CAAC,QAAQ,0BAA0B;CACvF,mBAAmB,EAAE,OAAO,CAAC,CAAC,SAAS;CACvC,cAAc,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC,CAAC,CAAC,QAAQ,MAAM;CACtD,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS;CACnC,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,IAAI;CAC9D,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,KAAK,KAAK,GAAG,QAAQ,GAAG,iBAAiB,CAAC;CACtE,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,GAAG;CAC/B,QAAQ,aAAa,SAAS;CAC9B,eAAe,oBAAoB,SAAS;CAE5C,sBAAsB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CACjD,qBAAqB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CAChD,oBAAoB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;AACjD,CAAC;AAID,SAAS,4BAA4B,OAA2B;CAC9D,OAAO,MAAM,OAAO,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC,KAAK,IAAI;AAC7D;AAEA,SAAgB,wBAAwB,OAAoC;CAC1E,MAAM,SAAS,aAAa,UAAU,KAAK;CAC3C,IAAI,OAAO,SAAS,OAAO,OAAO;CAClC,MAAM,IAAI,MAAM,4BAA4B,OAAO,KAAK,CAAC;AAC3D;AAEA,MAAa,iBAAqC,wBAAwB,CAAC,CAAC;AAE5E,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;AAIF"}
|
|
1
|
+
{"version":3,"file":"schema-CKnQsdw9.mjs","names":[],"sources":["../src/config/mcp-endpoint.ts","../src/config/limits.ts","../src/config/schema.ts"],"sourcesContent":["import { isIP } from 'node:net'\n\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]'])\n\nexport const LOCAL_GRAPH_MCP_ENDPOINT = 'http://127.0.0.1:8012/mcp'\nexport const DEFAULT_GRAPH_MCP_ENDPOINT = 'https://mcp.chain-insights.ai/'\n\nfunction isLoopbackHost(hostname: string): boolean {\n const normalized = hostname.toLowerCase().replace(/^\\[(.*)\\]$/, '$1')\n if (LOOPBACK_HOSTS.has(normalized)) return true\n if (isIP(normalized) !== 4) return false\n return normalized.split('.')[0] === '127'\n}\n\nfunction isKubernetesServiceHost(hostname: string): boolean {\n return hostname.toLowerCase().endsWith('.svc.cluster.local')\n}\n\nexport function graphMcpEndpointEnvOverride(): string | undefined {\n const envEndpoint =\n process.env.CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT?.trim() || process.env.GRAPH_MCP_ENDPOINT?.trim()\n return envEndpoint ? validateMcpEndpoint(envEndpoint, 'graphMcpEndpoint') : undefined\n}\n\nexport function validateMcpEndpoint(value: string, key: string): string {\n const trimmed = value.trim()\n if (!trimmed) {\n throw new Error(`${key} must be a non-empty absolute URL.`)\n }\n\n let parsed: URL\n try {\n parsed = new URL(trimmed)\n } catch {\n throw new Error(\n `${key} must be an absolute URL (example: https://mcp.example.com/mcp or http://127.0.0.1:8012/mcp).`\n )\n }\n\n if (parsed.username || parsed.password) {\n throw new Error(`${key} must not include URL credentials.`)\n }\n if (parsed.search || parsed.hash) {\n throw new Error(`${key} must not include query parameters or URL fragments.`)\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new Error(`${key} must use either https:// or http://.`)\n }\n if (\n parsed.protocol === 'http:' &&\n !isLoopbackHost(parsed.hostname) &&\n !isKubernetesServiceHost(parsed.hostname)\n ) {\n throw new Error(\n `${key} must use https:// for remote hosts. http:// is allowed only for localhost, loopback addresses, or Kubernetes *.svc.cluster.local service DNS.`\n )\n }\n\n return trimmed\n}\n","// Tunable search bounds for investigation and detection tools.\n//\n// Every hardcoded search cap in this repo used to be a bare `const` compiled\n// into one call site. That is wrong for two reasons at once: a value that is\n// right for a small chain is far too high for a busy one, and a value that is\n// right for a routine sweep is far too low for an analyst working a single\n// live case. A real high-fan-in deposit made the cost of that concrete — at\n// the old 500-row reverse-deposit cap the victim origin was NOT reachable at\n// four hops, and at 5000 rows the same four-hop trace closed the full\n// deposit -> victim chain in six seconds. The cap, not the depth, was the\n// binding constraint.\n//\n// This module generalizes the per-network default-table pattern (a\n// `resolve*Config(network, params)` function) into ONE registry the whole\n// codebase shares, so a knob is declared once with its default, its floor, and\n// its hard ceiling.\n//\n// ── Precedence (highest wins) ──────────────────────────────────────────────\n// 1. per-call — an argument on the MCP tool / CLI flag\n// 2. config file — `networkLimits[network][key]` in ~/.chain-insights/config.json\n// 3. config file — `limits[key]` (all networks)\n// 4. per-network — NETWORK_LIMIT_DEFAULTS[network].defaults[key]\n// 5. built-in — LIMIT_SPECS[key].builtin\n//\n// ── Ceilings ───────────────────────────────────────────────────────────────\n// An unbounded limit is a denial-of-service against the graph and against the\n// caller's metered spend, so every knob carries a hard ceiling. The ceiling is\n// NOT itself reachable from the per-call layer: a per-network entry may LOWER\n// a ceiling for a chain that cannot afford the work, but nothing outside this\n// file can RAISE the absolute maximum. Raising it is a code change, on\n// purpose.\n//\n// ── Rejection, not silent clamping ─────────────────────────────────────────\n// An over-ceiling request throws LimitRangeError naming the knob and its\n// ceiling. Silently clamping would hand an analyst a result that reads as\n// exhaustive when it is not — the same class of failure as the arbitrary row\n// truncation this registry exists to fix.\n\nexport interface LimitSpec {\n /** Value used when no layer overrides it. Chosen to preserve historical behaviour exactly. */\n builtin: number\n /** Lowest accepted value. */\n min: number\n /** Absolute maximum. Only a code change to this file may raise it. */\n ceiling: number\n /** What the knob bounds, for docs and error messages. */\n description: string\n}\n\n// Row/frontier ceilings are generous because their cost is close to linear\n// in the value; the exponential hop caps (corridor/attribution and the\n// aml_trace_* tools) were removed with the retired detection realm.\nexport const LIMIT_SPECS = {\n // Unused. Kept so old config files that still set it load without error.\n viz_max_nodes: {\n builtin: 100,\n min: 1,\n ceiling: 2_000,\n description: 'Unused; kept so old config files that set it still load.',\n },\n} as const satisfies Record<string, LimitSpec>\n\nexport type LimitKey = keyof typeof LIMIT_SPECS\nexport const LIMIT_KEYS = Object.keys(LIMIT_SPECS) as LimitKey[]\n\nexport function isLimitKey(key: string): key is LimitKey {\n return Object.prototype.hasOwnProperty.call(LIMIT_SPECS, key)\n}\n\nexport interface NetworkLimitOverride {\n /** Per-network default values. Must sit inside the built-in [min, ceiling]. */\n defaults?: Partial<Record<LimitKey, number>>\n /**\n * Per-network ceilings. May only LOWER the built-in ceiling; a higher value\n * is ignored so no chain can widen the absolute maximum from data.\n */\n ceilings?: Partial<Record<LimitKey, number>>\n}\n\n// Per-network defaults. Empty today: every chain currently starts on the\n// built-in values, which is exactly what keeps this change behaviour-neutral.\n// A chain that needs different economics adds an entry here (or an operator\n// sets `networkLimits` in the config file) without touching a call site.\nexport const NETWORK_LIMIT_DEFAULTS: Record<string, NetworkLimitOverride> = {}\n\n/** Config-file layer, as parsed from ~/.chain-insights/config.json. */\nexport interface LimitConfig {\n limits?: Partial<Record<LimitKey, number>>\n networkLimits?: Record<string, Partial<Record<LimitKey, number>>>\n}\n\nexport class LimitRangeError extends Error {\n readonly code = 'LIMIT_OUT_OF_RANGE'\n constructor(\n readonly key: LimitKey,\n readonly requested: number,\n readonly min: number,\n readonly ceiling: number,\n readonly source: string\n ) {\n super(\n `${key} must be an integer between ${min} and ${ceiling} (got ${requested} from ${source}). ` +\n `${LIMIT_SPECS[key].description} The ceiling is a hard bound and cannot be raised per call.`\n )\n this.name = 'LimitRangeError'\n }\n}\n\n/**\n * The maximum this network will accept. A per-network entry may lower it;\n * nothing may raise it above the built-in ceiling.\n */\nexport function limitCeiling(key: LimitKey, network?: string): number {\n const builtinCeiling = LIMIT_SPECS[key].ceiling\n const networkCeiling = network ? NETWORK_LIMIT_DEFAULTS[network]?.ceilings?.[key] : undefined\n if (networkCeiling === undefined || !Number.isFinite(networkCeiling)) return builtinCeiling\n return Math.min(builtinCeiling, Math.trunc(networkCeiling))\n}\n\nexport interface ResolveLimitContext {\n network?: string\n config?: LimitConfig\n}\n\n/**\n * The value used when the caller passes nothing: config file, then per-network\n * default, then built-in. Always inside [min, ceiling] for the network.\n */\nexport function limitDefault(key: LimitKey, ctx: ResolveLimitContext = {}): number {\n const spec = LIMIT_SPECS[key]\n const ceiling = limitCeiling(key, ctx.network)\n const candidates = [\n ctx.network ? ctx.config?.networkLimits?.[ctx.network]?.[key] : undefined,\n ctx.config?.limits?.[key],\n ctx.network ? NETWORK_LIMIT_DEFAULTS[ctx.network]?.defaults?.[key] : undefined,\n ]\n for (const candidate of candidates) {\n if (candidate === undefined || !Number.isFinite(candidate)) continue\n const value = Math.trunc(candidate)\n if (value < spec.min || value > ceiling) {\n throw new LimitRangeError(key, value, spec.min, ceiling, 'configuration')\n }\n return value\n }\n // The built-in is clamped rather than rejected: a per-network entry that\n // lowers a ceiling below the built-in default is a deliberate tightening of\n // that chain, not an operator error to fail on.\n return Math.min(spec.builtin, ceiling)\n}\n\n/** What a knob resolved to, and what the caller asked for. Emitted so a bounded search is visible without reading warnings. */\nexport interface LimitResolution {\n key: LimitKey\n /** What the caller passed, if anything. */\n requested?: number\n /** What the run actually used. */\n used: number\n /** The value that would have been used with no per-call override. */\n fallback: number\n /** The hard maximum for this network. */\n ceiling: number\n}\n\n/**\n * Resolve one knob. `requested` is the per-call layer; undefined/null/NaN\n * means \"no override\" and falls through to limitDefault.\n *\n * Throws LimitRangeError for a non-integer, below-min, or above-ceiling\n * request. Rejecting is deliberate: see the header note on silent clamping.\n */\nexport function resolveLimitDetail(\n key: LimitKey,\n requested: number | undefined | null,\n ctx: ResolveLimitContext = {}\n): LimitResolution {\n const spec = LIMIT_SPECS[key]\n const ceiling = limitCeiling(key, ctx.network)\n const fallback = limitDefault(key, ctx)\n if (requested === undefined || requested === null) {\n return { key, used: fallback, fallback, ceiling }\n }\n if (!Number.isFinite(requested) || !Number.isInteger(requested)) {\n throw new LimitRangeError(key, Number(requested), spec.min, ceiling, 'the call')\n }\n if (requested < spec.min || requested > ceiling) {\n throw new LimitRangeError(key, requested, spec.min, ceiling, 'the call')\n }\n return { key, requested, used: requested, fallback, ceiling }\n}\n\n/** resolveLimitDetail, when only the number is wanted. */\nexport function resolveLimit(\n key: LimitKey,\n requested: number | undefined | null,\n ctx: ResolveLimitContext = {}\n): number {\n return resolveLimitDetail(key, requested, ctx).used\n}\n\n/**\n * Renders resolved knobs for a tool response, so the effective depth/breadth\n * of a search is visible in the structured output without reading warnings.\n * `requested` is present only when the caller actually passed a value, which\n * makes \"I asked for 4 and got 4\" and \"I asked for nothing and got 3\"\n * distinguishable at a glance.\n */\nexport function limitsReport(resolutions: LimitResolution[]): Record<\n string,\n {\n requested?: number\n used: number\n default: number\n ceiling: number\n }\n> {\n return Object.fromEntries(\n resolutions.map((resolution) => [\n resolution.key,\n {\n ...(resolution.requested !== undefined ? { requested: resolution.requested } : {}),\n used: resolution.used,\n default: resolution.fallback,\n ceiling: resolution.ceiling,\n },\n ])\n )\n}\n\n/**\n * Integer-safe rendering for a value that is interpolated into a query.\n *\n * Cypher cannot parameterize a LIMIT, so the number is inlined — but ONLY\n * after resolveLimit has proven it is an integer inside a bounded range, and\n * this function re-proves it at the interpolation site. A recent CodeQL high\n * came from hand-interpolating an unvalidated value into query text; this is\n * the one sanctioned path.\n */\nexport function limitLiteral(value: number): string {\n if (!Number.isInteger(value) || value < 0) {\n throw new Error(`limit literal must be a non-negative integer (got ${String(value)})`)\n }\n return String(value)\n}\n","import * as z from 'zod'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { DEFAULT_GRAPH_MCP_ENDPOINT, validateMcpEndpoint } from './mcp-endpoint.js'\nimport { LIMIT_SPECS, isLimitKey, limitCeiling, type LimitKey } from './limits.js'\n\n// Config-file layer for the tunable search bounds (see config/limits.ts).\n// `limits` applies to every network; `networkLimits.<network>` is more\n// specific and wins over it. Both are validated here so a bad value fails at\n// config load rather than mid-investigation, and an unknown key is rejected\n// outright — a silently ignored knob is indistinguishable from one that had\n// no effect.\nfunction limitBagSchema(network?: string) {\n return z.record(z.string(), z.number()).superRefine((bag, ctx) => {\n for (const [key, value] of Object.entries(bag)) {\n const where = network ? `networkLimits.${network}.${key}` : `limits.${key}`\n if (!isLimitKey(key)) {\n ctx.addIssue({ code: z.ZodIssueCode.custom, message: `${where}: unknown limit key` })\n continue\n }\n const spec = LIMIT_SPECS[key as LimitKey]\n const ceiling = limitCeiling(key as LimitKey, network)\n if (!Number.isInteger(value) || value < spec.min || value > ceiling) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `${where}: must be an integer between ${spec.min} and ${ceiling} (got ${value})`,\n })\n }\n }\n })\n}\n\nexport const LimitsSchema = limitBagSchema()\n\nexport const NetworkLimitsSchema = z\n .record(z.string(), z.record(z.string(), z.number()))\n .superRefine((byNetwork, ctx) => {\n for (const [network, bag] of Object.entries(byNetwork)) {\n const parsed = limitBagSchema(network).safeParse(bag)\n if (parsed.success) continue\n for (const issue of parsed.error.issues) {\n ctx.addIssue({ code: z.ZodIssueCode.custom, message: issue.message })\n }\n }\n })\n\nfunction endpointSchema(key: 'graphMcpEndpoint') {\n return z.string().transform((value, ctx) => {\n try {\n return validateMcpEndpoint(value, key)\n } catch (err) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: (err as Error).message,\n })\n return z.NEVER\n }\n })\n}\n\nexport const ConfigSchema = z.object({\n graphMcpEndpoint: endpointSchema('graphMcpEndpoint').default(DEFAULT_GRAPH_MCP_ENDPOINT),\n graphMcpAuthToken: z.string().optional(),\n graphMcpMode: z.enum(['paid', 'debug']).default('paid'),\n walletAddress: z.string().optional(),\n serverPort: z.number().int().min(1024).max(65535).default(4321),\n dataDir: z.string().default(path.join(os.homedir(), '.chain-insights')),\n version: z.string().default('1'),\n limits: LimitsSchema.optional(),\n networkLimits: NetworkLimitsSchema.optional(),\n // Paths only. Never store or log certificate or key bytes.\n truthIngressCertPath: z.string().min(1).optional(),\n truthIngressKeyPath: z.string().min(1).optional(),\n truthIngressCaPath: z.string().min(1).optional(),\n})\n\nexport type InvestigatorConfig = z.infer<typeof ConfigSchema>\n\nfunction formatConfigValidationError(error: z.ZodError): string {\n return error.issues.map((issue) => issue.message).join('\\n')\n}\n\nexport function parseInvestigatorConfig(input: unknown): InvestigatorConfig {\n const parsed = ConfigSchema.safeParse(input)\n if (parsed.success) return parsed.data\n throw new Error(formatConfigValidationError(parsed.error))\n}\n\nexport const DEFAULT_CONFIG: InvestigatorConfig = parseInvestigatorConfig({})\n\nexport const CONFIG_KEYS = [\n 'graphMcpEndpoint',\n 'graphMcpAuthToken',\n 'graphMcpMode',\n 'walletAddress',\n 'serverPort',\n 'dataDir',\n 'version',\n // `limits` / `networkLimits` are nested objects, not scalar `cia config set`\n // targets, so they are deliberately absent from CONFIG_KEYS. Edit them in\n // ~/.chain-insights/config.json; they are validated on load.\n] as const\n\nexport type ConfigKey = (typeof CONFIG_KEYS)[number]\n"],"mappings":";;;;;;AAEA,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAa;CAAa;CAAO;AAAO,CAAC;AAGzE,MAAa,6BAA6B;AAE1C,SAAS,eAAe,UAA2B;CACjD,MAAM,aAAa,SAAS,YAAY,CAAC,CAAC,QAAQ,cAAc,IAAI;CACpE,IAAI,eAAe,IAAI,UAAU,GAAG,OAAO;CAC3C,IAAI,KAAK,UAAU,MAAM,GAAG,OAAO;CACnC,OAAO,WAAW,MAAM,GAAG,CAAC,CAAC,OAAO;AACtC;AAEA,SAAS,wBAAwB,UAA2B;CAC1D,OAAO,SAAS,YAAY,CAAC,CAAC,SAAS,oBAAoB;AAC7D;AAEA,SAAgB,8BAAkD;CAChE,MAAM,cACJ,QAAQ,IAAI,mCAAmC,KAAK,KAAK,QAAQ,IAAI,oBAAoB,KAAK;CAChG,OAAO,cAAc,oBAAoB,aAAa,kBAAkB,IAAI,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|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
2
|
let node_path = require("node:path");
|
|
3
3
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
4
4
|
let node_os = require("node:os");
|
|
@@ -6,7 +6,7 @@ node_os = require_rolldown_runtime.__toESM(node_os, 1);
|
|
|
6
6
|
let zod = require("zod");
|
|
7
7
|
zod = require_rolldown_runtime.__toESM(zod, 1);
|
|
8
8
|
let node_net = require("node:net");
|
|
9
|
-
|
|
9
|
+
// src/config/mcp-endpoint.ts
|
|
10
10
|
const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
|
|
11
11
|
"localhost",
|
|
12
12
|
"127.0.0.1",
|
|
@@ -42,8 +42,7 @@ function validateMcpEndpoint(value, key) {
|
|
|
42
42
|
if (parsed.protocol === "http:" && !isLoopbackHost(parsed.hostname) && !isKubernetesServiceHost(parsed.hostname)) throw new Error(`${key} must use https:// for remote hosts. http:// is allowed only for localhost, loopback addresses, or Kubernetes *.svc.cluster.local service DNS.`);
|
|
43
43
|
return trimmed;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
//#region src/config/limits.ts
|
|
45
|
+
// src/config/limits.ts
|
|
47
46
|
const LIMIT_SPECS = { viz_max_nodes: {
|
|
48
47
|
builtin: 100,
|
|
49
48
|
min: 1,
|
|
@@ -65,15 +64,10 @@ function limitCeiling(key, network) {
|
|
|
65
64
|
if (networkCeiling === void 0 || !Number.isFinite(networkCeiling)) return builtinCeiling;
|
|
66
65
|
return Math.min(builtinCeiling, Math.trunc(networkCeiling));
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
//#region src/config/schema.ts
|
|
67
|
+
// src/config/schema.ts
|
|
70
68
|
var schema_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
71
69
|
CONFIG_KEYS: () => CONFIG_KEYS,
|
|
72
|
-
|
|
73
|
-
DEFAULT_CONFIG: () => DEFAULT_CONFIG,
|
|
74
|
-
LimitsSchema: () => LimitsSchema,
|
|
75
|
-
NetworkLimitsSchema: () => NetworkLimitsSchema,
|
|
76
|
-
parseInvestigatorConfig: () => parseInvestigatorConfig
|
|
70
|
+
DEFAULT_CONFIG: () => DEFAULT_CONFIG
|
|
77
71
|
});
|
|
78
72
|
function limitBagSchema(network) {
|
|
79
73
|
return zod.record(zod.string(), zod.number()).superRefine((bag, ctx) => {
|
|
@@ -151,7 +145,6 @@ const CONFIG_KEYS = [
|
|
|
151
145
|
"dataDir",
|
|
152
146
|
"version"
|
|
153
147
|
];
|
|
154
|
-
//#endregion
|
|
155
148
|
Object.defineProperty(exports, "DEFAULT_CONFIG", {
|
|
156
149
|
enumerable: true,
|
|
157
150
|
get: function() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as chainInsightsHome, t as CACHE_TTL_MS } from "./cache-location-
|
|
1
|
+
import { n as chainInsightsHome, t as CACHE_TTL_MS } from "./cache-location-DxTTqBwk.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
-
|
|
4
|
+
// src/mcp/schema-cache.ts
|
|
5
5
|
function schemaPath() {
|
|
6
6
|
return path.join(chainInsightsHome(), "mcp-schema.json");
|
|
7
7
|
}
|
|
@@ -27,7 +27,6 @@ async function saveSchema(tools, endpoint) {
|
|
|
27
27
|
};
|
|
28
28
|
await writeFile(p, JSON.stringify(cache, null, 2) + "\n", { mode: 384 });
|
|
29
29
|
}
|
|
30
|
-
//#endregion
|
|
31
30
|
export { loadSchema, saveSchema };
|
|
32
31
|
|
|
33
|
-
//# sourceMappingURL=schema-cache-
|
|
32
|
+
//# sourceMappingURL=schema-cache-BfKHodDY.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-cache-
|
|
1
|
+
{"version":3,"file":"schema-cache-BfKHodDY.mjs","names":[],"sources":["../src/mcp/schema-cache.ts"],"sourcesContent":["import { readFile, writeFile, mkdir } from 'node:fs/promises'\nimport path from 'node:path'\nimport { CACHE_TTL_MS, chainInsightsHome } from './cache-location.js'\n\nexport interface McpTool {\n name: string\n title?: string\n description?: string\n inputSchema?: Record<string, unknown>\n outputSchema?: Record<string, unknown>\n annotations?: Record<string, unknown>\n _meta?: Record<string, unknown>\n}\n\ninterface SchemaCache {\n tools: McpTool[]\n cachedAt: number\n endpoint?: string\n}\n\n// Derived at call time so tests can override HOME via process.env['HOME']\nfunction schemaPath(): string {\n return path.join(chainInsightsHome(), 'mcp-schema.json')\n}\n\nexport async function loadSchema(endpoint?: string): Promise<McpTool[] | null> {\n try {\n const raw = await readFile(schemaPath(), 'utf8')\n const cache = JSON.parse(raw) as SchemaCache // JSON parse errors propagate\n if (Date.now() - cache.cachedAt > CACHE_TTL_MS) return null // TTL expired\n if (endpoint && cache.endpoint !== endpoint) return null\n return cache.tools\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return null\n throw err // re-throw JSON parse or other errors\n }\n}\n\nexport async function saveSchema(tools: McpTool[], endpoint?: string): Promise<void> {\n const p = schemaPath()\n await mkdir(path.dirname(p), { recursive: true })\n const cache: SchemaCache = { tools, cachedAt: Date.now(), ...(endpoint ? { endpoint } : {}) }\n await writeFile(p, JSON.stringify(cache, null, 2) + '\\n', { mode: 0o600 })\n}\n"],"mappings":";;;;AAqBA,SAAS,aAAqB;CAC5B,OAAO,KAAK,KAAK,kBAAkB,GAAG,iBAAiB;AACzD;AAEA,eAAsB,WAAW,UAA8C;CAC7E,IAAI;EACF,MAAM,MAAM,MAAM,SAAS,WAAW,GAAG,MAAM;EAC/C,MAAM,QAAQ,KAAK,MAAM,GAAG;EAC5B,IAAI,KAAK,IAAI,IAAI,MAAM,WAAW,cAAc,OAAO;EACvD,IAAI,YAAY,MAAM,aAAa,UAAU,OAAO;EACpD,OAAO,MAAM;CACf,SAAS,KAAK;EACZ,IAAK,IAA8B,SAAS,UAAU,OAAO;EAC7D,MAAM;CACR;AACF;AAEA,eAAsB,WAAW,OAAkB,UAAkC;CACnF,MAAM,IAAI,WAAW;CACrB,MAAM,MAAM,KAAK,QAAQ,CAAC,GAAG,EAAE,WAAW,KAAK,CAAC;CAChD,MAAM,QAAqB;EAAE;EAAO,UAAU,KAAK,IAAI;EAAG,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CAAG;CAC5F,MAAM,UAAU,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,IAAI,MAAM,EAAE,MAAM,IAAM,CAAC;AAC3E"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
2
|
-
const require_cache_location = require("./cache-location-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
|
+
const require_cache_location = require("./cache-location-C09AE55j.cjs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
5
5
|
let node_fs_promises = require("node:fs/promises");
|
|
6
|
-
|
|
6
|
+
// src/mcp/schema-cache.ts
|
|
7
7
|
function schemaPath() {
|
|
8
8
|
return node_path.default.join(require_cache_location.chainInsightsHome(), "mcp-schema.json");
|
|
9
9
|
}
|
|
@@ -29,6 +29,5 @@ async function saveSchema(tools, endpoint) {
|
|
|
29
29
|
};
|
|
30
30
|
await (0, node_fs_promises.writeFile)(p, JSON.stringify(cache, null, 2) + "\n", { mode: 384 });
|
|
31
31
|
}
|
|
32
|
-
//#endregion
|
|
33
32
|
exports.loadSchema = loadSchema;
|
|
34
33
|
exports.saveSchema = saveSchema;
|
|
@@ -2,7 +2,7 @@ import { fileURLToPath } from "node:url";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { cpSync, existsSync, lstatSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
|
-
|
|
5
|
+
// src/skill-refresh.ts
|
|
6
6
|
/**
|
|
7
7
|
* Keeps the skill copies that `cia setup` installed at the version of the
|
|
8
8
|
* package that runs. npm runs no setup step on `npm i -g chain-insights@X`, so
|
|
@@ -208,7 +208,6 @@ function refreshInstalledSkills(version, options = {}) {
|
|
|
208
208
|
}
|
|
209
209
|
return result;
|
|
210
210
|
}
|
|
211
|
-
//#endregion
|
|
212
211
|
export { readPackagedSkillRules, refreshInstalledSkills };
|
|
213
212
|
|
|
214
|
-
//# sourceMappingURL=skill-refresh-
|
|
213
|
+
//# sourceMappingURL=skill-refresh-BchIsODN.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-refresh-xYWZ_hua.mjs","names":[],"sources":["../src/skill-refresh.ts"],"sourcesContent":["import {\n type Dirent,\n cpSync,\n existsSync,\n lstatSync,\n readFileSync,\n readdirSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs'\nimport { homedir } from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Keeps the skill copies that `cia setup` installed at the version of the\n * package that runs. npm runs no setup step on `npm i -g chain-insights@X`, so\n * without this an upgrade brings new server rules while every host keeps\n * reading the skill of the release it was set up with.\n *\n * Rules, in order:\n * - Only a place setup already installed is refreshed.\n * - A protocol skill new in this release is added only to a place where setup\n * installed the core skill as a copy, not stamped by a newer release. Nothing\n * is installed anywhere else.\n * - A symlinked skill belongs to its owner (a checkout) and is never touched.\n * - A copy stamped by a newer release is left alone: two installs of\n * different versions (a global install and a bundled extension) must not\n * take turns downgrading each other.\n */\n\n/** The core skill: the graph query dialect and the answer rules. Always shipped. */\nexport const CORE_SKILL_NAME = 'chain-insights-cypher'\n\n/** A shipped skill's directory name. */\nexport const PUBLIC_SKILL_PATTERN = /^chain-insights-[a-z0-9-]+$/\n\n/**\n * The shipped skills, read from a skills/ directory: the core skill, then every\n * protocol skill (a directory named chain-insights-* that holds a SKILL.md),\n * sorted. bin/install.cjs and scripts/sync-plugin-skills.mjs apply the same\n * rule; the installer also leaves out its retired names.\n */\nexport function publicSkillNames(sourceDir: string = packagedSkillsDir()): string[] {\n let entries: Dirent[]\n try {\n entries = readdirSync(sourceDir, { withFileTypes: true })\n } catch {\n return [CORE_SKILL_NAME]\n }\n const protocol = entries\n .filter((entry) => entry.isDirectory() && PUBLIC_SKILL_PATTERN.test(entry.name))\n .map((entry) => entry.name)\n .filter((name) => name !== CORE_SKILL_NAME)\n .filter((name) => existsSync(path.join(sourceDir, name, 'SKILL.md')))\n .sort()\n return [CORE_SKILL_NAME, ...protocol]\n}\n\n/** Written inside each installed skill by setup and by the refresh. */\nexport const SKILL_VERSION_FILE = '.chain-insights-version'\n\nexport interface SkillRefreshResult {\n /** Skill directories replaced with the packaged copy. */\n refreshed: string[]\n /** Protocol skill directories added beside a core skill that setup installed. */\n installed: string[]\n /** Skill directories left alone, with the reason. */\n skipped: { dir: string; reason: 'symlink' | 'newer' | 'current' }[]\n /** Skill directories that could not be replaced, with the error text. */\n failed: { dir: string; error: string }[]\n}\n\n/** The places `cia setup` installs skills: Claude Code, Codex, Hermes. */\nexport function skillTargetDirs(home: string = homedir()): string[] {\n return [\n path.join(home, '.claude', 'skills'),\n path.join(home, '.codex', 'skills'),\n path.join(home, '.hermes', 'skills', 'chain-insights'),\n ]\n}\n\n/** The skills/ directory shipped in the package, next to dist/ and src/. */\nexport function packagedSkillsDir(): string {\n return fileURLToPath(new URL('../skills', import.meta.url))\n}\n\n/**\n * The rules of the packaged skill, for hosts that cannot load a local skill:\n * SKILL.md without its front matter, which only says when to load it.\n */\nexport function readPackagedSkillRules(sourceDir: string = packagedSkillsDir()): string {\n const text = readFileSync(path.join(sourceDir, CORE_SKILL_NAME, 'SKILL.md'), 'utf8')\n const frontMatter = /^---\\n[\\s\\S]*?\\n---\\n+/\n return text.replace(frontMatter, '').trimEnd() + '\\n'\n}\n\n/** Compares two x.y.z versions; a pre-release suffix is ignored. */\nexport function compareVersions(a: string, b: string): number {\n const parts = (v: string) =>\n v\n .split('-')[0]!\n .split('.')\n .map((n) => Number.parseInt(n, 10) || 0)\n const left = parts(a)\n const right = parts(b)\n for (let i = 0; i < Math.max(left.length, right.length); i++) {\n const diff = (left[i] ?? 0) - (right[i] ?? 0)\n if (diff !== 0) return diff\n }\n return 0\n}\n\nfunction readStamp(skillDir: string): string | undefined {\n try {\n return readFileSync(path.join(skillDir, SKILL_VERSION_FILE), 'utf8').trim() || undefined\n } catch {\n return undefined\n }\n}\n\n/** Swaps the packaged copy in through hidden siblings, so a reader never sees half a skill. */\nfunction replaceSkill(source: string, dest: string, version: string): void {\n const parent = path.dirname(dest)\n const name = path.basename(dest)\n const staged = path.join(parent, `.${name}.refresh-${process.pid}`)\n const retired = path.join(parent, `.${name}.old-${process.pid}`)\n rmSync(staged, { recursive: true, force: true })\n try {\n cpSync(source, staged, { recursive: true })\n writeFileSync(path.join(staged, SKILL_VERSION_FILE), `${version}\\n`, 'utf8')\n renameSync(dest, retired)\n try {\n renameSync(staged, dest)\n } catch (error) {\n renameSync(retired, dest)\n throw error\n }\n rmSync(retired, { recursive: true, force: true })\n } finally {\n rmSync(staged, { recursive: true, force: true })\n }\n}\n\n/** Copies a skill in through a hidden sibling, so a reader never sees half a skill. */\nfunction addSkill(source: string, dest: string, version: string): void {\n const staged = path.join(path.dirname(dest), `.${path.basename(dest)}.refresh-${process.pid}`)\n rmSync(staged, { recursive: true, force: true })\n try {\n cpSync(source, staged, { recursive: true })\n writeFileSync(path.join(staged, SKILL_VERSION_FILE), `${version}\\n`, 'utf8')\n renameSync(staged, dest)\n } finally {\n rmSync(staged, { recursive: true, force: true })\n }\n}\n\n/** Setup installed the core skill here as a copy, and no newer release owns it. */\nfunction coreSetUpIn(target: string, version: string): boolean {\n const core = path.join(target, CORE_SKILL_NAME)\n try {\n const stat = lstatSync(core)\n if (stat.isSymbolicLink() || !stat.isDirectory()) return false\n } catch {\n return false\n }\n const stamp = readStamp(core)\n return stamp === undefined || compareVersions(stamp, version) <= 0\n}\n\nexport function refreshInstalledSkills(\n version: string,\n options: { home?: string; sourceDir?: string } = {}\n): SkillRefreshResult {\n const sourceDir = options.sourceDir ?? packagedSkillsDir()\n const result: SkillRefreshResult = { refreshed: [], installed: [], skipped: [], failed: [] }\n const names = publicSkillNames(sourceDir)\n for (const target of skillTargetDirs(options.home)) {\n const setUpHere = coreSetUpIn(target, version)\n for (const name of names) {\n const source = path.join(sourceDir, name)\n const dest = path.join(target, name)\n if (!existsSync(source)) continue\n let stat\n try {\n stat = lstatSync(dest)\n } catch {\n // Not installed here. A protocol skill joins a core skill setup installed.\n if (name !== CORE_SKILL_NAME && setUpHere) {\n try {\n addSkill(source, dest, version)\n result.installed.push(dest)\n } catch (error) {\n result.failed.push({\n dir: dest,\n error: error instanceof Error ? error.message : String(error),\n })\n }\n }\n continue\n }\n if (stat.isSymbolicLink()) {\n result.skipped.push({ dir: dest, reason: 'symlink' })\n continue\n }\n if (!stat.isDirectory()) continue\n const stamp = readStamp(dest)\n if (stamp !== undefined) {\n const order = compareVersions(stamp, version)\n if (order > 0) {\n result.skipped.push({ dir: dest, reason: 'newer' })\n continue\n }\n if (order === 0) {\n result.skipped.push({ dir: dest, reason: 'current' })\n continue\n }\n }\n try {\n replaceSkill(source, dest, version)\n result.refreshed.push(dest)\n } catch (error) {\n result.failed.push({\n dir: dest,\n error: error instanceof Error ? error.message : String(error),\n })\n }\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,kBAAkB;;AAG/B,MAAa,uBAAuB;;;;;;;AAQpC,SAAgB,iBAAiB,YAAoB,kBAAkB,GAAa;CAClF,IAAI;CACJ,IAAI;EACF,UAAU,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC;CAC1D,QAAQ;EACN,OAAO,CAAC,eAAe;CACzB;CACA,MAAM,WAAW,QACd,QAAQ,UAAU,MAAM,YAAY,KAAK,qBAAqB,KAAK,MAAM,IAAI,CAAC,CAAC,CAC/E,KAAK,UAAU,MAAM,I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KAAK;MAAE,KAAK;MAAM,QAAQ;KAAQ,CAAC;KAClD;IACF;IACA,IAAI,UAAU,GAAG;KACf,OAAO,QAAQ,KAAK;MAAE,KAAK;MAAM,QAAQ;KAAU,CAAC;KACpD;IACF;GACF;GACA,IAAI;IACF,aAAa,QAAQ,MAAM,OAAO;IAClC,OAAO,UAAU,KAAK,IAAI;GAC5B,SAAS,OAAO;IACd,OAAO,OAAO,KAAK;KACjB,KAAK;KACL,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAC9D,CAAC;GACH;EACF;CACF;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"skill-refresh-BchIsODN.mjs","names":[],"sources":["../src/skill-refresh.ts"],"sourcesContent":["import {\n type Dirent,\n cpSync,\n existsSync,\n lstatSync,\n readFileSync,\n readdirSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs'\nimport { homedir } from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Keeps the skill copies that `cia setup` installed at the version of the\n * package that runs. npm runs no setup step on `npm i -g chain-insights@X`, so\n * without this an upgrade brings new server rules while every host keeps\n * reading the skill of the release it was set up with.\n *\n * Rules, in order:\n * - Only a place setup already installed is refreshed.\n * - A protocol skill new in this release is added only to a place where setup\n * installed the core skill as a copy, not stamped by a newer release. Nothing\n * is installed anywhere else.\n * - A symlinked skill belongs to its owner (a checkout) and is never touched.\n * - A copy stamped by a newer release is left alone: two installs of\n * different versions (a global install and a bundled extension) must not\n * take turns downgrading each other.\n */\n\n/** The core skill: the graph query dialect and the answer rules. Always shipped. */\nexport const CORE_SKILL_NAME = 'chain-insights-cypher'\n\n/** A shipped skill's directory name. */\nexport const PUBLIC_SKILL_PATTERN = /^chain-insights-[a-z0-9-]+$/\n\n/**\n * The shipped skills, read from a skills/ directory: the core skill, then every\n * protocol skill (a directory named chain-insights-* that holds a SKILL.md),\n * sorted. bin/install.cjs and scripts/sync-plugin-skills.mjs apply the same\n * rule; the installer also leaves out its retired names.\n */\nexport function publicSkillNames(sourceDir: string = packagedSkillsDir()): string[] {\n let entries: Dirent[]\n try {\n entries = readdirSync(sourceDir, { withFileTypes: true })\n } catch {\n return [CORE_SKILL_NAME]\n }\n const protocol = entries\n .filter((entry) => entry.isDirectory() && PUBLIC_SKILL_PATTERN.test(entry.name))\n .map((entry) => entry.name)\n .filter((name) => name !== CORE_SKILL_NAME)\n .filter((name) => existsSync(path.join(sourceDir, name, 'SKILL.md')))\n .sort()\n return [CORE_SKILL_NAME, ...protocol]\n}\n\n/** Written inside each installed skill by setup and by the refresh. */\nexport const SKILL_VERSION_FILE = '.chain-insights-version'\n\nexport interface SkillRefreshResult {\n /** Skill directories replaced with the packaged copy. */\n refreshed: string[]\n /** Protocol skill directories added beside a core skill that setup installed. */\n installed: string[]\n /** Skill directories left alone, with the reason. */\n skipped: { dir: string; reason: 'symlink' | 'newer' | 'current' }[]\n /** Skill directories that could not be replaced, with the error text. */\n failed: { dir: string; error: string }[]\n}\n\n/** The places `cia setup` installs skills: Claude Code, Codex, Hermes. */\nexport function skillTargetDirs(home: string = homedir()): string[] {\n return [\n path.join(home, '.claude', 'skills'),\n path.join(home, '.codex', 'skills'),\n path.join(home, '.hermes', 'skills', 'chain-insights'),\n ]\n}\n\n/** The skills/ directory shipped in the package, next to dist/ and src/. */\nexport function packagedSkillsDir(): string {\n return fileURLToPath(new URL('../skills', import.meta.url))\n}\n\n/**\n * The rules of the packaged skill, for hosts that cannot load a local skill:\n * SKILL.md without its front matter, which only says when to load it.\n */\nexport function readPackagedSkillRules(sourceDir: string = packagedSkillsDir()): string {\n const text = readFileSync(path.join(sourceDir, CORE_SKILL_NAME, 'SKILL.md'), 'utf8')\n const frontMatter = /^---\\n[\\s\\S]*?\\n---\\n+/\n return text.replace(frontMatter, '').trimEnd() + '\\n'\n}\n\n/** Compares two x.y.z versions; a pre-release suffix is ignored. */\nexport function compareVersions(a: string, b: string): number {\n const parts = (v: string) =>\n v\n .split('-')[0]!\n .split('.')\n .map((n) => Number.parseInt(n, 10) || 0)\n const left = parts(a)\n const right = parts(b)\n for (let i = 0; i < Math.max(left.length, right.length); i++) {\n const diff = (left[i] ?? 0) - (right[i] ?? 0)\n if (diff !== 0) return diff\n }\n return 0\n}\n\nfunction readStamp(skillDir: string): string | undefined {\n try {\n return readFileSync(path.join(skillDir, SKILL_VERSION_FILE), 'utf8').trim() || undefined\n } catch {\n return undefined\n }\n}\n\n/** Swaps the packaged copy in through hidden siblings, so a reader never sees half a skill. */\nfunction replaceSkill(source: string, dest: string, version: string): void {\n const parent = path.dirname(dest)\n const name = path.basename(dest)\n const staged = path.join(parent, `.${name}.refresh-${process.pid}`)\n const retired = path.join(parent, `.${name}.old-${process.pid}`)\n rmSync(staged, { recursive: true, force: true })\n try {\n cpSync(source, staged, { recursive: true })\n writeFileSync(path.join(staged, SKILL_VERSION_FILE), `${version}\\n`, 'utf8')\n renameSync(dest, retired)\n try {\n renameSync(staged, dest)\n } catch (error) {\n renameSync(retired, dest)\n throw error\n }\n rmSync(retired, { recursive: true, force: true })\n } finally {\n rmSync(staged, { recursive: true, force: true })\n }\n}\n\n/** Copies a skill in through a hidden sibling, so a reader never sees half a skill. */\nfunction addSkill(source: string, dest: string, version: string): void {\n const staged = path.join(path.dirname(dest), `.${path.basename(dest)}.refresh-${process.pid}`)\n rmSync(staged, { recursive: true, force: true })\n try {\n cpSync(source, staged, { recursive: true })\n writeFileSync(path.join(staged, SKILL_VERSION_FILE), `${version}\\n`, 'utf8')\n renameSync(staged, dest)\n } finally {\n rmSync(staged, { recursive: true, force: true })\n }\n}\n\n/** Setup installed the core skill here as a copy, and no newer release owns it. */\nfunction coreSetUpIn(target: string, version: string): boolean {\n const core = path.join(target, CORE_SKILL_NAME)\n try {\n const stat = lstatSync(core)\n if (stat.isSymbolicLink() || !stat.isDirectory()) return false\n } catch {\n return false\n }\n const stamp = readStamp(core)\n return stamp === undefined || compareVersions(stamp, version) <= 0\n}\n\nexport function refreshInstalledSkills(\n version: string,\n options: { home?: string; sourceDir?: string } = {}\n): SkillRefreshResult {\n const sourceDir = options.sourceDir ?? packagedSkillsDir()\n const result: SkillRefreshResult = { refreshed: [], installed: [], skipped: [], failed: [] }\n const names = publicSkillNames(sourceDir)\n for (const target of skillTargetDirs(options.home)) {\n const setUpHere = coreSetUpIn(target, version)\n for (const name of names) {\n const source = path.join(sourceDir, name)\n const dest = path.join(target, name)\n if (!existsSync(source)) continue\n let stat\n try {\n stat = lstatSync(dest)\n } catch {\n // Not installed here. A protocol skill joins a core skill setup installed.\n if (name !== CORE_SKILL_NAME && setUpHere) {\n try {\n addSkill(source, dest, version)\n result.installed.push(dest)\n } catch (error) {\n result.failed.push({\n dir: dest,\n error: error instanceof Error ? error.message : String(error),\n })\n }\n }\n continue\n }\n if (stat.isSymbolicLink()) {\n result.skipped.push({ dir: dest, reason: 'symlink' })\n continue\n }\n if (!stat.isDirectory()) continue\n const stamp = readStamp(dest)\n if (stamp !== undefined) {\n const order = compareVersions(stamp, version)\n if (order > 0) {\n result.skipped.push({ dir: dest, reason: 'newer' })\n continue\n }\n if (order === 0) {\n result.skipped.push({ dir: dest, reason: 'current' })\n continue\n }\n }\n try {\n replaceSkill(source, dest, version)\n result.refreshed.push(dest)\n } catch (error) {\n result.failed.push({\n dir: dest,\n error: error instanceof Error ? error.message : String(error),\n })\n }\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,kBAAkB;;AAG/B,MAAa,uBAAuB;;;;;;;AAQpC,SAAgB,iBAAiB,YAAoB,kBAAkB,GAAa;CAClF,IAAI;CACJ,IAAI;EACF,UAAU,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC;CAC1D,QAAQ;EACN,OAAO,CAAC,eAAe;CACzB;CACA,MAAM,WAAW,QACd,QAAQ,UAAU,MAAM,YAAY,KAAK,qBAAqB,KAAK,MAAM,IAAI,CAAC,CAAC,CAC/E,KAAK,UAAU,MAAM,IA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AAK;MAAE,KAAK;MAAM,QAAQ;KAAQ,CAAC;KAClD;IACF;IACA,IAAI,UAAU,GAAG;KACf,OAAO,QAAQ,KAAK;MAAE,KAAK;MAAM,QAAQ;KAAU,CAAC;KACpD;IACF;GACF;GACA,IAAI;IACF,aAAa,QAAQ,MAAM,OAAO;IAClC,OAAO,UAAU,KAAK,IAAI;GAC5B,SAAS,OAAO;IACd,OAAO,OAAO,KAAK;KACjB,KAAK;KACL,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAC9D,CAAC;GACH;EACF;CACF;CACA,OAAO;AACT"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
2
|
let node_url = require("node:url");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
5
5
|
let node_fs = require("node:fs");
|
|
6
6
|
let node_os = require("node:os");
|
|
7
|
-
|
|
7
|
+
// src/skill-refresh.ts
|
|
8
8
|
/**
|
|
9
9
|
* Keeps the skill copies that `cia setup` installed at the version of the
|
|
10
10
|
* package that runs. npm runs no setup step on `npm i -g chain-insights@X`, so
|
|
@@ -210,6 +210,5 @@ function refreshInstalledSkills(version, options = {}) {
|
|
|
210
210
|
}
|
|
211
211
|
return result;
|
|
212
212
|
}
|
|
213
|
-
//#endregion
|
|
214
213
|
exports.readPackagedSkillRules = readPackagedSkillRules;
|
|
215
214
|
exports.refreshInstalledSkills = refreshInstalledSkills;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
2
|
+
// src/mcp/subscription-status.ts
|
|
3
3
|
var subscription_status_exports = /* @__PURE__ */ __exportAll({
|
|
4
4
|
formatSubscriptionStatus: () => formatSubscriptionStatus,
|
|
5
5
|
isMissingSubscriptionStatusToolError: () => isMissingSubscriptionStatusToolError,
|
|
@@ -142,7 +142,6 @@ function formatSubscriptionStatus(facts) {
|
|
|
142
142
|
if (!facts.active && facts.pending_payments.length === 0) lines.push("Buy days with `cia subscription buy --days N`.");
|
|
143
143
|
return lines.join("\n");
|
|
144
144
|
}
|
|
145
|
-
//#endregion
|
|
146
145
|
export { unavailableSubscriptionStatus as i, subscriptionStatusNeedsWallet as n, subscription_status_exports as r, subscriptionStatusArguments as t };
|
|
147
146
|
|
|
148
|
-
//# sourceMappingURL=subscription-status-
|
|
147
|
+
//# sourceMappingURL=subscription-status-5WfPhSep.mjs.map
|