chain-insights 0.58.5 → 0.59.1
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/dist/{capabilities-CUjNyrsJ.mjs → capabilities-BnuroVv_.mjs} +76 -5
- package/dist/capabilities-BnuroVv_.mjs.map +1 -0
- package/dist/{capabilities-Bx5Lj4WE.cjs → capabilities-CF-KwJ6B.cjs} +75 -4
- package/dist/cli.cjs +4 -4
- package/dist/cli.mjs +4 -4
- package/dist/{graph-schema-CCr2sK20.mjs → graph-schema-DdriUxEe.mjs} +2 -2
- package/dist/{graph-schema-CCr2sK20.mjs.map → graph-schema-DdriUxEe.mjs.map} +1 -1
- package/dist/{graph-schema-D8yUdDTG.cjs → graph-schema-DrU7Zaa5.cjs} +1 -1
- package/dist/mcp-proxy.cjs +7 -4
- package/dist/mcp-proxy.mjs +7 -4
- package/dist/mcp-proxy.mjs.map +1 -1
- package/docs/graph-tools.md +16 -1
- package/package.json +1 -1
- package/skills/chain-insights-cypher/SKILL.md +3 -3
- package/dist/capabilities-CUjNyrsJ.mjs.map +0 -1
|
@@ -2,6 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
|
2
2
|
import { a as resolveGraphMcpEndpoint, n as applyMcpAuthHeaders } from "./client-gsLi528K.mjs";
|
|
3
3
|
//#region src/mcp/capabilities.ts
|
|
4
4
|
var capabilities_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
familyDisplayName: () => familyDisplayName,
|
|
5
6
|
fetchNetworkCapabilities: () => fetchNetworkCapabilities,
|
|
6
7
|
findNetworkCapability: () => findNetworkCapability,
|
|
7
8
|
formatNetworkCapabilities: () => formatNetworkCapabilities,
|
|
@@ -38,6 +39,36 @@ function advertisedLaneProgress(raw) {
|
|
|
38
39
|
}
|
|
39
40
|
return lanes;
|
|
40
41
|
}
|
|
42
|
+
function isNumberOrNull(value) {
|
|
43
|
+
return value === null || typeof value === "number";
|
|
44
|
+
}
|
|
45
|
+
/** One family entry, or null when any member has the wrong shape. */
|
|
46
|
+
function advertisedGraphFamily(entry) {
|
|
47
|
+
if (!isRecord(entry) || typeof entry.name !== "string" || entry.name.trim() === "") return null;
|
|
48
|
+
if (!isNumberOrNull(entry.complete_through_block)) return null;
|
|
49
|
+
const behind = entry.blocks_behind_head === void 0 ? null : entry.blocks_behind_head;
|
|
50
|
+
if (!isNumberOrNull(behind)) return null;
|
|
51
|
+
if (entry.fresh !== void 0 && typeof entry.fresh !== "boolean") return null;
|
|
52
|
+
if (!Array.isArray(entry.layers) || !entry.layers.every((layer) => typeof layer === "string")) return null;
|
|
53
|
+
return {
|
|
54
|
+
name: entry.name,
|
|
55
|
+
complete_through_block: entry.complete_through_block,
|
|
56
|
+
blocks_behind_head: behind,
|
|
57
|
+
...typeof entry.fresh === "boolean" ? { fresh: entry.fresh } : {},
|
|
58
|
+
layers: [...entry.layers]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** The families list, whole or not at all: one entry with a bad shape drops it. */
|
|
62
|
+
function advertisedGraphFamilies(raw) {
|
|
63
|
+
if (!Array.isArray(raw)) return void 0;
|
|
64
|
+
const families = [];
|
|
65
|
+
for (const entry of raw) {
|
|
66
|
+
const family = advertisedGraphFamily(entry);
|
|
67
|
+
if (family === null) return void 0;
|
|
68
|
+
families.push(family);
|
|
69
|
+
}
|
|
70
|
+
return families;
|
|
71
|
+
}
|
|
41
72
|
function advertisedGraphProgress(raw) {
|
|
42
73
|
if (!isRecord(raw) || typeof raw.complete_through_block !== "number") return void 0;
|
|
43
74
|
if (!Array.isArray(raw.layers)) return void 0;
|
|
@@ -49,10 +80,13 @@ function advertisedGraphProgress(raw) {
|
|
|
49
80
|
position: entry.position
|
|
50
81
|
});
|
|
51
82
|
}
|
|
52
|
-
|
|
83
|
+
const progress = {
|
|
53
84
|
complete_through_block: raw.complete_through_block,
|
|
54
85
|
layers
|
|
55
86
|
};
|
|
87
|
+
const families = advertisedGraphFamilies(raw.families);
|
|
88
|
+
if (families) progress.families = families;
|
|
89
|
+
return progress;
|
|
56
90
|
}
|
|
57
91
|
function advertisedNetwork(raw) {
|
|
58
92
|
if (!isRecord(raw) || typeof raw.network !== "string" || raw.network.trim() === "") return null;
|
|
@@ -207,6 +241,10 @@ function laneDisplayName(lane) {
|
|
|
207
241
|
function layerDisplayName(layer) {
|
|
208
242
|
return layer;
|
|
209
243
|
}
|
|
244
|
+
/** A family prints by its plain name: `chain_facts` prints as "chain facts". */
|
|
245
|
+
function familyDisplayName(family) {
|
|
246
|
+
return family.replace(/_/g, " ");
|
|
247
|
+
}
|
|
210
248
|
/** 87642448 -> "87,642,448", the same on every machine (no locale). */
|
|
211
249
|
function groupThousands(value) {
|
|
212
250
|
return (value < 0 ? "-" : "") + String(Math.trunc(Math.abs(value))).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
@@ -230,6 +268,32 @@ function notReportedRow(label) {
|
|
|
230
268
|
note: "not reported"
|
|
231
269
|
};
|
|
232
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* The family rows, in the order the server sends them. A block family's lag is
|
|
273
|
+
* the server's `blocks_behind_head`, or head minus height when the server knows
|
|
274
|
+
* no head. A family with no block (annotations) prints "fresh" or "walking" and
|
|
275
|
+
* no lag.
|
|
276
|
+
*/
|
|
277
|
+
function familyRows(families, head) {
|
|
278
|
+
return families.map((family) => {
|
|
279
|
+
const label = familyDisplayName(family.name);
|
|
280
|
+
const height = family.complete_through_block;
|
|
281
|
+
if (height === null) return {
|
|
282
|
+
label,
|
|
283
|
+
height: null,
|
|
284
|
+
note: family.fresh === void 0 ? "not started" : family.fresh ? "fresh" : "walking"
|
|
285
|
+
};
|
|
286
|
+
if (head === void 0) return {
|
|
287
|
+
label,
|
|
288
|
+
height
|
|
289
|
+
};
|
|
290
|
+
return {
|
|
291
|
+
label,
|
|
292
|
+
height,
|
|
293
|
+
behind: family.blocks_behind_head ?? Math.max(0, head - height)
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}
|
|
233
297
|
function formatProgressTables(tables, withLag) {
|
|
234
298
|
const allRows = tables.flatMap((table) => table.rows);
|
|
235
299
|
const labelWidth = Math.max(TABLE_LABEL_WIDTH, ...allRows.map((row) => row.label.length + 4), ...tables.map((table) => table.title.length + 2));
|
|
@@ -244,7 +308,7 @@ function formatProgressTables(tables, withLag) {
|
|
|
244
308
|
let line = ` ${row.label}`.padEnd(labelWidth);
|
|
245
309
|
if (row.height === null) line += row.note ?? "";
|
|
246
310
|
else {
|
|
247
|
-
line += groupThousands(row.height).
|
|
311
|
+
line += groupThousands(row.height).padStart(heightWidth);
|
|
248
312
|
if (withLag && row.behind !== void 0) line += " " + groupThousands(row.behind).padStart(lagWidth);
|
|
249
313
|
}
|
|
250
314
|
lines.push(line.trimEnd());
|
|
@@ -255,8 +319,10 @@ function formatProgressTables(tables, withLag) {
|
|
|
255
319
|
/**
|
|
256
320
|
* `cia network <name>`: how far this network is indexed. The chain node's head
|
|
257
321
|
* comes first; every row reads against it. Known lanes print by plain name,
|
|
258
|
-
* unknown lanes as sent after them,
|
|
259
|
-
*
|
|
322
|
+
* unknown lanes as sent after them, the layer families by plain name in the
|
|
323
|
+
* server's order, graph layers as sent, and evidence in its own table. Heights
|
|
324
|
+
* are right-aligned, so a shorter height lines up by its last digit.
|
|
325
|
+
* `--json` never comes through here.
|
|
260
326
|
*/
|
|
261
327
|
function formatNetworkCapability(network) {
|
|
262
328
|
const headBlock = network.freshness?.chain_head_block;
|
|
@@ -289,11 +355,16 @@ function formatNetworkCapability(network) {
|
|
|
289
355
|
label: laneDisplayName(lane.lane),
|
|
290
356
|
height: lane.height
|
|
291
357
|
}));
|
|
358
|
+
const families = network.graph_progress?.families;
|
|
292
359
|
const tables = [
|
|
293
360
|
{
|
|
294
361
|
title: "Indexing",
|
|
295
362
|
rows: indexing.length > 0 ? progressRows(indexing, head) : [notReportedRow("indexing")]
|
|
296
363
|
},
|
|
364
|
+
...families ? [{
|
|
365
|
+
title: "Families",
|
|
366
|
+
rows: familyRows(families, head)
|
|
367
|
+
}] : [],
|
|
297
368
|
{
|
|
298
369
|
title: "Graph",
|
|
299
370
|
rows: layers.length > 0 ? progressRows(layers, head) : [notReportedRow("graph")]
|
|
@@ -312,4 +383,4 @@ function formatNetworkCapability(network) {
|
|
|
312
383
|
//#endregion
|
|
313
384
|
export { findNetworkCapability as n, mirrorGraphNetworkCapabilities as r, capabilities_exports as t };
|
|
314
385
|
|
|
315
|
-
//# sourceMappingURL=capabilities-
|
|
386
|
+
//# sourceMappingURL=capabilities-BnuroVv_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities-BnuroVv_.mjs","names":[],"sources":["../src/mcp/capabilities.ts"],"sourcesContent":["import type { InvestigatorConfig } from '../config/schema.js'\nimport { applyMcpAuthHeaders, resolveGraphMcpEndpoint } from './client.js'\n\nexport interface NetworkTopologyLayer {\n enabled: boolean\n coverage?: {\n from_block?: number\n to_block?: number\n from_timestamp?: string\n to_timestamp?: string\n chain_tip_block?: number\n blocks_behind_tip?: number\n /** Lowest height among the raw-data lanes that have started. Above it an empty answer may mean \"not indexed yet\". */\n complete_through_block?: number\n }\n}\n\nexport interface NetworkLayerCapability {\n enabled: boolean\n live?: NetworkTopologyLayer\n archive?: NetworkTopologyLayer\n /** The relationships a facts layer serves, when the server lists them. */\n relationships?: string[]\n}\n\n/**\n * A block the server publishes about one layer's limits. The mirror repeats it\n * exactly as it came: the members named below are the ones known today, and\n * any other member the server adds is kept. Read a limit from the block, never\n * from a number written elsewhere.\n */\nexport type NetworkAdmissionBlock = Record<string, unknown>\n\n/** `USE chain`: the lookups, the ceilings and the slots of the chain layer. */\nexport interface ChainAdmission extends NetworkAdmissionBlock {\n enabled: boolean\n /** ok, or the reason the layer is off or behind. */\n status?: string\n rules_version?: string\n grammar?: string\n /** The labels of `USE chain`, such as Transaction, Block, Head and Address. */\n lookups?: string[]\n ceiling_seconds?: Record<string, number>\n slots?: number\n past_slots?: number\n slots_per_caller?: number\n calls_per_second_per_caller?: number\n batch_max?: number\n call_gas?: number\n head_ttl_ms?: number\n max_head_age_seconds?: number\n /** How many blocks below the tip a past `Address` read (`at_block`) must be. Read it here, never write it down. */\n at_block_min_depth?: number\n}\n\n/** `USE topology`: the shape rules, when the server publishes them. */\nexport interface TopologyAdmission extends NetworkAdmissionBlock {\n rules_version?: string\n max_hops_per_path?: number\n max_limit?: number\n slots?: number\n}\n\n/** `USE facts`: the read contract, when the server publishes it. */\nexport interface FactsAdmission extends NetworkAdmissionBlock {\n rules_version?: string\n window_days?: number\n max_rows?: number\n max_hops?: number\n}\n\nexport interface NetworkCapability {\n network: string\n display_name?: string\n status: string\n default?: boolean\n /** The layers as the server sent them. Absent when the server sent none. */\n layers?: Record<string, NetworkLayerCapability>\n tools: Record<string, string>\n /** The three layer blocks below are repeated exactly as sent, and absent when not sent. */\n chain_admission?: ChainAdmission\n topology_admission?: TopologyAdmission\n facts_admission?: FactsAdmission\n coverage?: {\n from_block?: number\n to_block?: number\n from_timestamp?: string\n to_timestamp?: string\n chain_tip_block?: number\n blocks_behind_tip?: number\n /** Lowest height among the raw-data lanes that have started. Above it an empty answer may mean \"not indexed yet\". */\n complete_through_block?: number\n }\n freshness?: {\n last_processed_at?: string\n last_successful_sync_at?: string\n max_data_age_seconds?: number\n last_processing_duration_seconds?: number\n /** The chain node's own head block, and how old that reading is. */\n chain_head_block?: number\n chain_head_age_seconds?: number\n warehouse_blocks_behind_head?: number\n graph_blocks_behind_head?: number\n }\n lane_progress?: NetworkLaneProgress[]\n graph_progress?: NetworkGraphProgress\n}\n\n/** One writer lane's committed height. null: the lane has not started. */\nexport interface NetworkLaneProgress {\n lane: string\n height: number | null\n}\n\n/**\n * How far each block layer of the topology graph reaches, and how far the\n * money family reaches (`complete_through_block`). `families` is absent on a\n * server that does not group its layers into families.\n */\nexport interface NetworkGraphProgress {\n complete_through_block: number\n layers: { layer: string; position: number }[]\n families?: NetworkGraphFamily[]\n}\n\n/**\n * One layer family as the server reports it. A block family carries the block\n * it is complete through and its lag behind the head (null on a server that\n * knows no head). `annotations` follows runs, not blocks: both numbers are null\n * and `fresh` says whether its last run is current.\n */\nexport interface NetworkGraphFamily {\n name: string\n complete_through_block: number | null\n blocks_behind_head: number | null\n fresh?: boolean\n layers: string[]\n}\n\nexport interface NetworkCapabilitiesDocument {\n schema: 'chain-insights.network-capabilities.v1'\n networks: NetworkCapability[]\n}\n\nconst AVAILABLE_TOOLS_PER_LINE = 3\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction advertisedTools(raw: unknown): Record<string, string> {\n if (!isRecord(raw)) return {}\n const tools: Record<string, string> = {}\n for (const [name, status] of Object.entries(raw)) {\n if (name.trim() !== '' && typeof status === 'string') tools[name] = status\n }\n return tools\n}\n\nfunction advertisedLaneProgress(raw: unknown): NetworkLaneProgress[] | undefined {\n if (!Array.isArray(raw)) return undefined\n const lanes: NetworkLaneProgress[] = []\n for (const entry of raw) {\n if (!isRecord(entry) || typeof entry.lane !== 'string' || entry.lane.trim() === '') continue\n if (typeof entry.height === 'number') lanes.push({ lane: entry.lane, height: entry.height })\n else if (entry.height === null) lanes.push({ lane: entry.lane, height: null })\n }\n return lanes\n}\n\nfunction isNumberOrNull(value: unknown): value is number | null {\n return value === null || typeof value === 'number'\n}\n\n/** One family entry, or null when any member has the wrong shape. */\nfunction advertisedGraphFamily(entry: unknown): NetworkGraphFamily | null {\n if (!isRecord(entry) || typeof entry.name !== 'string' || entry.name.trim() === '') return null\n if (!isNumberOrNull(entry.complete_through_block)) return null\n const behind = entry.blocks_behind_head === undefined ? null : entry.blocks_behind_head\n if (!isNumberOrNull(behind)) return null\n if (entry.fresh !== undefined && typeof entry.fresh !== 'boolean') return null\n if (!Array.isArray(entry.layers) || !entry.layers.every((layer) => typeof layer === 'string'))\n return null\n return {\n name: entry.name,\n complete_through_block: entry.complete_through_block,\n blocks_behind_head: behind,\n ...(typeof entry.fresh === 'boolean' ? { fresh: entry.fresh } : {}),\n layers: [...(entry.layers as string[])],\n }\n}\n\n/** The families list, whole or not at all: one entry with a bad shape drops it. */\nfunction advertisedGraphFamilies(raw: unknown): NetworkGraphFamily[] | undefined {\n if (!Array.isArray(raw)) return undefined\n const families: NetworkGraphFamily[] = []\n for (const entry of raw) {\n const family = advertisedGraphFamily(entry)\n if (family === null) return undefined\n families.push(family)\n }\n return families\n}\n\nfunction advertisedGraphProgress(raw: unknown): NetworkGraphProgress | undefined {\n if (!isRecord(raw) || typeof raw.complete_through_block !== 'number') return undefined\n if (!Array.isArray(raw.layers)) return undefined\n const layers: NetworkGraphProgress['layers'] = []\n for (const entry of raw.layers) {\n if (!isRecord(entry) || typeof entry.layer !== 'string' || typeof entry.position !== 'number')\n continue\n layers.push({ layer: entry.layer, position: entry.position })\n }\n const progress: NetworkGraphProgress = {\n complete_through_block: raw.complete_through_block,\n layers,\n }\n const families = advertisedGraphFamilies(raw.families)\n if (families) progress.families = families\n return progress\n}\n\nfunction advertisedNetwork(raw: unknown): NetworkCapability | null {\n if (!isRecord(raw) || typeof raw.network !== 'string' || raw.network.trim() === '') {\n return null\n }\n const network = raw.network.trim()\n const capability: NetworkCapability = {\n network,\n display_name:\n typeof raw.display_name === 'string' && raw.display_name.trim() !== ''\n ? raw.display_name\n : network,\n status: typeof raw.status === 'string' && raw.status.trim() !== '' ? raw.status : 'live',\n tools: advertisedTools(raw.tools),\n }\n // The layer blocks are the server's own words about its limits. They pass\n // through exactly as sent: nothing is added, no default is invented and no\n // member is dropped. A block the server did not send stays absent.\n if (isRecord(raw.layers)) capability.layers = raw.layers as NetworkCapability['layers']\n if (isRecord(raw.chain_admission)) {\n capability.chain_admission = raw.chain_admission as unknown as ChainAdmission\n }\n if (isRecord(raw.topology_admission)) {\n capability.topology_admission = raw.topology_admission as TopologyAdmission\n }\n if (isRecord(raw.facts_admission)) {\n capability.facts_admission = raw.facts_admission as FactsAdmission\n }\n if (raw.default === true) capability.default = true\n if (raw.default === false) capability.default = false\n if (isRecord(raw.coverage)) capability.coverage = raw.coverage as NetworkCapability['coverage']\n if (isRecord(raw.freshness))\n capability.freshness = raw.freshness as NetworkCapability['freshness']\n const laneProgress = advertisedLaneProgress(raw.lane_progress)\n if (laneProgress) capability.lane_progress = laneProgress\n const graphProgress = advertisedGraphProgress(raw.graph_progress)\n if (graphProgress) capability.graph_progress = graphProgress\n return capability\n}\n\n/** Repeat GraphRAG's network list. CIA does not add, drop, or invent names. */\nexport function mirrorGraphNetworkCapabilities(document: {\n networks: unknown[]\n}): NetworkCapabilitiesDocument {\n return {\n schema: 'chain-insights.network-capabilities.v1',\n networks: document.networks\n .map((network) => advertisedNetwork(network))\n .filter((network): network is NetworkCapability => network !== null),\n }\n}\n\nfunction publicNetworkCapabilities(\n document: NetworkCapabilitiesDocument\n): NetworkCapabilitiesDocument {\n return mirrorGraphNetworkCapabilities(document)\n}\n\nfunction metadataNetworksUrl(endpoint: string): URL {\n const url = new URL(endpoint)\n url.pathname = '/metadata/networks'\n url.search = ''\n url.hash = ''\n return url\n}\n\nexport async function fetchNetworkCapabilities(\n config: Pick<InvestigatorConfig, 'graphMcpAuthToken' | 'graphMcpMode' | 'graphMcpEndpoint'>\n): Promise<NetworkCapabilitiesDocument> {\n const endpoint = resolveGraphMcpEndpoint(config)\n const request = metadataNetworksUrl(endpoint)\n const headers = new Headers()\n const token = config.graphMcpAuthToken?.trim()\n if (token) {\n applyMcpAuthHeaders(headers, token)\n }\n let response: Response\n try {\n response = await fetch(request, { headers })\n } catch (err) {\n throw new Error(`network capabilities unavailable at ${request}: ${(err as Error).message}`)\n }\n if (!response.ok) {\n throw new Error(`network capabilities unavailable at ${request}: HTTP ${response.status}`)\n }\n const parsed = (await response.json()) as NetworkCapabilitiesDocument\n if (\n parsed.schema !== 'chain-insights.network-capabilities.v1' ||\n !Array.isArray(parsed.networks)\n ) {\n throw new Error('network capabilities response has unsupported schema')\n }\n return publicNetworkCapabilities(parsed)\n}\n\nfunction availableTools(network: NetworkCapability): string[] {\n const tools = Object.entries(network.tools ?? {})\n .filter(([, status]) => status === 'available')\n .map(([name]) => name)\n return tools.sort()\n}\n\nfunction availableToolLines(network: NetworkCapability): string[] {\n const tools = availableTools(network)\n if (tools.length === 0) return ['none']\n const lines: string[] = []\n for (let index = 0; index < tools.length; index += AVAILABLE_TOOLS_PER_LINE) {\n lines.push(tools.slice(index, index + AVAILABLE_TOOLS_PER_LINE).join(', '))\n }\n return lines\n}\n\nfunction shortDate(value?: string): string {\n if (!value) return ''\n return value.slice(0, 10)\n}\n\nfunction datasetLabel(network: NetworkCapability): string {\n const coverage = network.coverage\n if (!coverage) return 'unknown'\n const blockRange =\n coverage.from_block !== undefined && coverage.to_block !== undefined\n ? `${coverage.from_block}..${coverage.to_block}`\n : 'blocks unknown'\n const dateRange =\n coverage.from_timestamp && coverage.to_timestamp\n ? `${shortDate(coverage.from_timestamp)}..${shortDate(coverage.to_timestamp)}`\n : ''\n if (blockRange === 'blocks unknown' && dateRange === '') return 'unknown'\n if (blockRange === 'blocks unknown') return dateRange\n if (dateRange === '') return blockRange\n return `${blockRange} / ${dateRange}`\n}\n\nfunction displayName(network: NetworkCapability): string {\n return network.display_name || network.network\n}\n\nfunction statusLabel(network: NetworkCapability): string {\n return network.default ? `${network.status} (default)` : network.status\n}\n\nfunction formatTable(headers: string[], rows: string[][], minimumWidths: number[]): string {\n const widths = headers.map((header, index) =>\n Math.max(\n minimumWidths[index] ?? 0,\n header.length,\n ...rows.map((row) => row[index]?.length ?? 0)\n )\n )\n const row = (values: string[]) =>\n values.map((value, index) => value.padEnd(widths[index]!)).join(' ')\n return [row(headers), widths.map((width) => '-'.repeat(width)).join(' '), ...rows.map(row)].join(\n '\\n'\n )\n}\n\nexport function formatNetworkOverview(document: NetworkCapabilitiesDocument): string {\n if (document.networks.length === 0) return 'No supported networks advertised.'\n const rows = document.networks.map((network) => [\n displayName(network),\n statusLabel(network),\n datasetLabel(network),\n ])\n return formatTable(['Network', 'Status', 'Dataset'], rows, [14, 10, 38])\n}\n\nexport function formatNetworkCapabilities(document: NetworkCapabilitiesDocument): string {\n if (document.networks.length === 0) return 'No supported networks advertised.'\n const networkRows = document.networks.flatMap((network) => {\n const toolLines = availableToolLines(network)\n return toolLines.map((toolLine, index) => [\n index === 0 ? displayName(network) : '',\n index === 0 ? datasetLabel(network) : '',\n toolLine,\n ])\n })\n return formatTable(['Network', 'Dataset', 'Chain Insights tools'], networkRows, [14, 38, 64])\n}\n\nexport function findNetworkCapability(\n document: NetworkCapabilitiesDocument,\n name: string\n): NetworkCapability | undefined {\n const normalizedName = name.trim().toLowerCase()\n if (!normalizedName) return undefined\n return document.networks.find((network) =>\n [network.network, network.display_name].some(\n (candidate) => candidate?.trim().toLowerCase() === normalizedName\n )\n )\n}\n\n/** The writer lanes a customer sees, in screen order, by their plain names. */\nconst KNOWN_LANES: readonly (readonly [string, string])[] = [\n ['core_transfers_source_head', 'receipts'],\n ['core_transfers_internal_follow', 'traces'],\n ['core_dex_follow', 'dex'],\n ['core_bridge_follow', 'bridge'],\n ['core_smart_account_follow', 'smart accounts'],\n]\n\n/** The evidence worker's lane. It has its own table and never joins Indexing. */\nconst EVIDENCE_LANE = 'evidence_sync'\n\n/** The plain name a lane prints as. An unknown lane prints as sent. */\nexport function laneDisplayName(lane: string): string {\n if (lane === EVIDENCE_LANE) return 'evidence'\n return KNOWN_LANES.find(([name]) => name === lane)?.[1] ?? lane\n}\n\n/** A graph layer prints as sent: it is the link kind a query names. */\nexport function layerDisplayName(layer: string): string {\n return layer\n}\n\n/** A family prints by its plain name: `chain_facts` prints as \"chain facts\". */\nexport function familyDisplayName(family: string): string {\n return family.replace(/_/g, ' ')\n}\n\n/** 87642448 -> \"87,642,448\", the same on every machine (no locale). */\nexport function groupThousands(value: number): string {\n const sign = value < 0 ? '-' : ''\n const digits = String(Math.trunc(Math.abs(value)))\n return sign + digits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n}\n\n/** One row of a progress table. `behind` is absent with no head or no height. */\ninterface ProgressRow {\n label: string\n height: number | null\n /** Text printed in the height column instead of a number. */\n note?: string\n behind?: number\n}\n\nconst DETAIL_LABEL_WIDTH = 18\nconst TABLE_LABEL_WIDTH = 30\nconst HEIGHT_MIN_WIDTH = 10\nconst LAG_HEADER = 'behind head'\n\nfunction progressRows(\n entries: { label: string; height: number | null }[],\n head: number | undefined\n): ProgressRow[] {\n return entries.map(({ label, height }) => ({\n label,\n height,\n ...(height === null ? { note: 'not started' } : {}),\n ...(height !== null && head !== undefined ? { behind: Math.max(0, head - height) } : {}),\n }))\n}\n\nfunction notReportedRow(label: string): ProgressRow {\n return { label, height: null, note: 'not reported' }\n}\n\n/**\n * The family rows, in the order the server sends them. A block family's lag is\n * the server's `blocks_behind_head`, or head minus height when the server knows\n * no head. A family with no block (annotations) prints \"fresh\" or \"walking\" and\n * no lag.\n */\nfunction familyRows(families: NetworkGraphFamily[], head: number | undefined): ProgressRow[] {\n return families.map((family) => {\n const label = familyDisplayName(family.name)\n const height = family.complete_through_block\n if (height === null) {\n const note = family.fresh === undefined ? 'not started' : family.fresh ? 'fresh' : 'walking'\n return { label, height: null, note }\n }\n if (head === undefined) return { label, height }\n const behind = family.blocks_behind_head ?? Math.max(0, head - height)\n return { label, height, behind }\n })\n}\n\nfunction formatProgressTables(\n tables: { title: string; rows: ProgressRow[] }[],\n withLag: boolean\n): string[] {\n const allRows = tables.flatMap((table) => table.rows)\n const labelWidth = Math.max(\n TABLE_LABEL_WIDTH,\n ...allRows.map((row) => row.label.length + 4),\n ...tables.map((table) => table.title.length + 2)\n )\n const heightWidth = Math.max(\n HEIGHT_MIN_WIDTH,\n ...allRows.map((row) => (row.height === null ? 0 : groupThousands(row.height).length))\n )\n const lagWidth = Math.max(\n LAG_HEADER.length,\n ...allRows.map((row) => (row.behind === undefined ? 0 : groupThousands(row.behind).length))\n )\n const lines: string[] = []\n for (const table of tables) {\n if (lines.length > 0) lines.push('')\n const header = table.title.padEnd(labelWidth) + 'height'\n lines.push(withLag ? header.padEnd(labelWidth + heightWidth + 2) + LAG_HEADER : header)\n for (const row of table.rows) {\n let line = ` ${row.label}`.padEnd(labelWidth)\n if (row.height === null) {\n line += row.note ?? ''\n } else {\n line += groupThousands(row.height).padStart(heightWidth)\n if (withLag && row.behind !== undefined) {\n line += ' ' + groupThousands(row.behind).padStart(lagWidth)\n }\n }\n lines.push(line.trimEnd())\n }\n }\n return lines\n}\n\n/**\n * `cia network <name>`: how far this network is indexed. The chain node's head\n * comes first; every row reads against it. Known lanes print by plain name,\n * unknown lanes as sent after them, the layer families by plain name in the\n * server's order, graph layers as sent, and evidence in its own table. Heights\n * are right-aligned, so a shorter height lines up by its last digit.\n * `--json` never comes through here.\n */\nexport function formatNetworkCapability(network: NetworkCapability): string {\n const headBlock = network.freshness?.chain_head_block\n const head = typeof headBlock === 'number' ? headBlock : undefined\n const detail: [string, string][] = [\n ['Network', displayName(network)],\n ['Identifier', network.network],\n ['Status', statusLabel(network)],\n ]\n if (head !== undefined) {\n const age = network.freshness?.chain_head_age_seconds\n const ageText = typeof age === 'number' ? ` (${groupThousands(age)} s old)` : ''\n detail.push(['Blockchain head', `${groupThousands(head)}${ageText}`])\n }\n\n const lanes = network.lane_progress ?? []\n const known = KNOWN_LANES.flatMap(([name, label]) =>\n lanes.filter((lane) => lane.lane === name).map((lane) => ({ label, height: lane.height }))\n )\n const unknown = lanes\n .filter(\n (lane) => lane.lane !== EVIDENCE_LANE && !KNOWN_LANES.some(([name]) => name === lane.lane)\n )\n .map((lane) => ({ label: laneDisplayName(lane.lane), height: lane.height }))\n const indexing = [...known, ...unknown]\n const layers = (network.graph_progress?.layers ?? []).map((layer) => ({\n label: layerDisplayName(layer.layer),\n height: layer.position,\n }))\n const evidence = lanes\n .filter((lane) => lane.lane === EVIDENCE_LANE)\n .map((lane) => ({ label: laneDisplayName(lane.lane), height: lane.height }))\n\n const families = network.graph_progress?.families\n\n const tables = [\n {\n title: 'Indexing',\n rows: indexing.length > 0 ? progressRows(indexing, head) : [notReportedRow('indexing')],\n },\n // Absent on a server that sends no families: the table is left out, so the\n // screen of such a server stays as it was.\n ...(families ? [{ title: 'Families', rows: familyRows(families, head) }] : []),\n {\n title: 'Graph',\n rows: layers.length > 0 ? progressRows(layers, head) : [notReportedRow('graph')],\n },\n {\n title: 'Evidence',\n rows: evidence.length > 0 ? progressRows(evidence, head) : [notReportedRow('evidence')],\n },\n ]\n\n return [\n ...detail.map(([label, value]) => `${label.padEnd(DETAIL_LABEL_WIDTH)}${value}`),\n '',\n ...formatProgressTables(tables, head !== undefined),\n ].join('\\n')\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgJA,MAAM,2BAA2B;AAEjC,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,gBAAgB,KAAsC;CAC7D,IAAI,CAAC,SAAS,GAAG,GAAG,OAAO,CAAC;CAC5B,MAAM,QAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,GAAG,GAC7C,IAAI,KAAK,KAAK,MAAM,MAAM,OAAO,WAAW,UAAU,MAAM,QAAQ;CAEtE,OAAO;AACT;AAEA,SAAS,uBAAuB,KAAiD;CAC/E,IAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,OAAO,KAAA;CAChC,MAAM,QAA+B,CAAC;CACtC,KAAK,MAAM,SAAS,KAAK;EACvB,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,MAAM,SAAS,YAAY,MAAM,KAAK,KAAK,MAAM,IAAI;EACpF,IAAI,OAAO,MAAM,WAAW,UAAU,MAAM,KAAK;GAAE,MAAM,MAAM;GAAM,QAAQ,MAAM;EAAO,CAAC;OACtF,IAAI,MAAM,WAAW,MAAM,MAAM,KAAK;GAAE,MAAM,MAAM;GAAM,QAAQ;EAAK,CAAC;CAC/E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ACP,MAAM,OAAO,SAAS,IAAI,aAAa,QAAQ,IAAI,IAAI,CAAC,eAAe,OAAO,CAAC;EACjF;EACA;GACE,OAAO;GACP,MAAM,SAAS,SAAS,IAAI,aAAa,UAAU,IAAI,IAAI,CAAC,eAAe,UAAU,CAAC;EACxF;CACF;CAEA,OAAO;EACL,GAAG,OAAO,KAAK,CAAC,OAAO,WAAW,GAAG,MAAM,OAAO,kBAAkB,IAAI,OAAO;EAC/E;EACA,GAAG,qBAAqB,QAAQ,SAAS,KAAA,CAAS;CACpD,CAAC,CAAC,KAAK,IAAI;AACb"}
|
|
@@ -2,6 +2,7 @@ const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
|
2
2
|
const require_client = require("./client-Ypw9BNbn.cjs");
|
|
3
3
|
//#region src/mcp/capabilities.ts
|
|
4
4
|
var capabilities_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
5
|
+
familyDisplayName: () => familyDisplayName,
|
|
5
6
|
fetchNetworkCapabilities: () => fetchNetworkCapabilities,
|
|
6
7
|
findNetworkCapability: () => findNetworkCapability,
|
|
7
8
|
formatNetworkCapabilities: () => formatNetworkCapabilities,
|
|
@@ -38,6 +39,36 @@ function advertisedLaneProgress(raw) {
|
|
|
38
39
|
}
|
|
39
40
|
return lanes;
|
|
40
41
|
}
|
|
42
|
+
function isNumberOrNull(value) {
|
|
43
|
+
return value === null || typeof value === "number";
|
|
44
|
+
}
|
|
45
|
+
/** One family entry, or null when any member has the wrong shape. */
|
|
46
|
+
function advertisedGraphFamily(entry) {
|
|
47
|
+
if (!isRecord(entry) || typeof entry.name !== "string" || entry.name.trim() === "") return null;
|
|
48
|
+
if (!isNumberOrNull(entry.complete_through_block)) return null;
|
|
49
|
+
const behind = entry.blocks_behind_head === void 0 ? null : entry.blocks_behind_head;
|
|
50
|
+
if (!isNumberOrNull(behind)) return null;
|
|
51
|
+
if (entry.fresh !== void 0 && typeof entry.fresh !== "boolean") return null;
|
|
52
|
+
if (!Array.isArray(entry.layers) || !entry.layers.every((layer) => typeof layer === "string")) return null;
|
|
53
|
+
return {
|
|
54
|
+
name: entry.name,
|
|
55
|
+
complete_through_block: entry.complete_through_block,
|
|
56
|
+
blocks_behind_head: behind,
|
|
57
|
+
...typeof entry.fresh === "boolean" ? { fresh: entry.fresh } : {},
|
|
58
|
+
layers: [...entry.layers]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** The families list, whole or not at all: one entry with a bad shape drops it. */
|
|
62
|
+
function advertisedGraphFamilies(raw) {
|
|
63
|
+
if (!Array.isArray(raw)) return void 0;
|
|
64
|
+
const families = [];
|
|
65
|
+
for (const entry of raw) {
|
|
66
|
+
const family = advertisedGraphFamily(entry);
|
|
67
|
+
if (family === null) return void 0;
|
|
68
|
+
families.push(family);
|
|
69
|
+
}
|
|
70
|
+
return families;
|
|
71
|
+
}
|
|
41
72
|
function advertisedGraphProgress(raw) {
|
|
42
73
|
if (!isRecord(raw) || typeof raw.complete_through_block !== "number") return void 0;
|
|
43
74
|
if (!Array.isArray(raw.layers)) return void 0;
|
|
@@ -49,10 +80,13 @@ function advertisedGraphProgress(raw) {
|
|
|
49
80
|
position: entry.position
|
|
50
81
|
});
|
|
51
82
|
}
|
|
52
|
-
|
|
83
|
+
const progress = {
|
|
53
84
|
complete_through_block: raw.complete_through_block,
|
|
54
85
|
layers
|
|
55
86
|
};
|
|
87
|
+
const families = advertisedGraphFamilies(raw.families);
|
|
88
|
+
if (families) progress.families = families;
|
|
89
|
+
return progress;
|
|
56
90
|
}
|
|
57
91
|
function advertisedNetwork(raw) {
|
|
58
92
|
if (!isRecord(raw) || typeof raw.network !== "string" || raw.network.trim() === "") return null;
|
|
@@ -207,6 +241,10 @@ function laneDisplayName(lane) {
|
|
|
207
241
|
function layerDisplayName(layer) {
|
|
208
242
|
return layer;
|
|
209
243
|
}
|
|
244
|
+
/** A family prints by its plain name: `chain_facts` prints as "chain facts". */
|
|
245
|
+
function familyDisplayName(family) {
|
|
246
|
+
return family.replace(/_/g, " ");
|
|
247
|
+
}
|
|
210
248
|
/** 87642448 -> "87,642,448", the same on every machine (no locale). */
|
|
211
249
|
function groupThousands(value) {
|
|
212
250
|
return (value < 0 ? "-" : "") + String(Math.trunc(Math.abs(value))).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
@@ -230,6 +268,32 @@ function notReportedRow(label) {
|
|
|
230
268
|
note: "not reported"
|
|
231
269
|
};
|
|
232
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* The family rows, in the order the server sends them. A block family's lag is
|
|
273
|
+
* the server's `blocks_behind_head`, or head minus height when the server knows
|
|
274
|
+
* no head. A family with no block (annotations) prints "fresh" or "walking" and
|
|
275
|
+
* no lag.
|
|
276
|
+
*/
|
|
277
|
+
function familyRows(families, head) {
|
|
278
|
+
return families.map((family) => {
|
|
279
|
+
const label = familyDisplayName(family.name);
|
|
280
|
+
const height = family.complete_through_block;
|
|
281
|
+
if (height === null) return {
|
|
282
|
+
label,
|
|
283
|
+
height: null,
|
|
284
|
+
note: family.fresh === void 0 ? "not started" : family.fresh ? "fresh" : "walking"
|
|
285
|
+
};
|
|
286
|
+
if (head === void 0) return {
|
|
287
|
+
label,
|
|
288
|
+
height
|
|
289
|
+
};
|
|
290
|
+
return {
|
|
291
|
+
label,
|
|
292
|
+
height,
|
|
293
|
+
behind: family.blocks_behind_head ?? Math.max(0, head - height)
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}
|
|
233
297
|
function formatProgressTables(tables, withLag) {
|
|
234
298
|
const allRows = tables.flatMap((table) => table.rows);
|
|
235
299
|
const labelWidth = Math.max(TABLE_LABEL_WIDTH, ...allRows.map((row) => row.label.length + 4), ...tables.map((table) => table.title.length + 2));
|
|
@@ -244,7 +308,7 @@ function formatProgressTables(tables, withLag) {
|
|
|
244
308
|
let line = ` ${row.label}`.padEnd(labelWidth);
|
|
245
309
|
if (row.height === null) line += row.note ?? "";
|
|
246
310
|
else {
|
|
247
|
-
line += groupThousands(row.height).
|
|
311
|
+
line += groupThousands(row.height).padStart(heightWidth);
|
|
248
312
|
if (withLag && row.behind !== void 0) line += " " + groupThousands(row.behind).padStart(lagWidth);
|
|
249
313
|
}
|
|
250
314
|
lines.push(line.trimEnd());
|
|
@@ -255,8 +319,10 @@ function formatProgressTables(tables, withLag) {
|
|
|
255
319
|
/**
|
|
256
320
|
* `cia network <name>`: how far this network is indexed. The chain node's head
|
|
257
321
|
* comes first; every row reads against it. Known lanes print by plain name,
|
|
258
|
-
* unknown lanes as sent after them,
|
|
259
|
-
*
|
|
322
|
+
* unknown lanes as sent after them, the layer families by plain name in the
|
|
323
|
+
* server's order, graph layers as sent, and evidence in its own table. Heights
|
|
324
|
+
* are right-aligned, so a shorter height lines up by its last digit.
|
|
325
|
+
* `--json` never comes through here.
|
|
260
326
|
*/
|
|
261
327
|
function formatNetworkCapability(network) {
|
|
262
328
|
const headBlock = network.freshness?.chain_head_block;
|
|
@@ -289,11 +355,16 @@ function formatNetworkCapability(network) {
|
|
|
289
355
|
label: laneDisplayName(lane.lane),
|
|
290
356
|
height: lane.height
|
|
291
357
|
}));
|
|
358
|
+
const families = network.graph_progress?.families;
|
|
292
359
|
const tables = [
|
|
293
360
|
{
|
|
294
361
|
title: "Indexing",
|
|
295
362
|
rows: indexing.length > 0 ? progressRows(indexing, head) : [notReportedRow("indexing")]
|
|
296
363
|
},
|
|
364
|
+
...families ? [{
|
|
365
|
+
title: "Families",
|
|
366
|
+
rows: familyRows(families, head)
|
|
367
|
+
}] : [],
|
|
297
368
|
{
|
|
298
369
|
title: "Graph",
|
|
299
370
|
rows: layers.length > 0 ? progressRows(layers, head) : [notReportedRow("graph")]
|
package/dist/cli.cjs
CHANGED
|
@@ -120,21 +120,21 @@ async function withGraphMcpClient(name, fn) {
|
|
|
120
120
|
}
|
|
121
121
|
async function printNetworkCapabilities(opts) {
|
|
122
122
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
123
|
-
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await Promise.resolve().then(() => require("./capabilities-
|
|
123
|
+
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await Promise.resolve().then(() => require("./capabilities-CF-KwJ6B.cjs")).then((n) => n.capabilities_exports);
|
|
124
124
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
125
125
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
126
126
|
else console.log(formatNetworkCapabilities(document));
|
|
127
127
|
}
|
|
128
128
|
async function printNetworkOverview(opts) {
|
|
129
129
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
130
|
-
const { fetchNetworkCapabilities, formatNetworkOverview } = await Promise.resolve().then(() => require("./capabilities-
|
|
130
|
+
const { fetchNetworkCapabilities, formatNetworkOverview } = await Promise.resolve().then(() => require("./capabilities-CF-KwJ6B.cjs")).then((n) => n.capabilities_exports);
|
|
131
131
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
132
132
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
133
133
|
else console.log(formatNetworkOverview(document));
|
|
134
134
|
}
|
|
135
135
|
async function printNetworkCapability(name, opts) {
|
|
136
136
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
137
|
-
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await Promise.resolve().then(() => require("./capabilities-
|
|
137
|
+
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await Promise.resolve().then(() => require("./capabilities-CF-KwJ6B.cjs")).then((n) => n.capabilities_exports);
|
|
138
138
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
139
139
|
const network = findNetworkCapability(document, name);
|
|
140
140
|
if (!network) {
|
|
@@ -152,7 +152,7 @@ async function printNetworkCapability(name, opts) {
|
|
|
152
152
|
async function printNetworkSchema(name, opts) {
|
|
153
153
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
154
154
|
const { resolveGraphMcpEndpoint } = await Promise.resolve().then(() => require("./client-Ypw9BNbn.cjs")).then((n) => n.client_exports);
|
|
155
|
-
const { formatGraphSchemaText, getGraphSchema } = await Promise.resolve().then(() => require("./graph-schema-
|
|
155
|
+
const { formatGraphSchemaText, getGraphSchema } = await Promise.resolve().then(() => require("./graph-schema-DrU7Zaa5.cjs")).then((n) => n.graph_schema_exports);
|
|
156
156
|
const config = await loadConfig();
|
|
157
157
|
const schema = await getGraphSchema({
|
|
158
158
|
network: name,
|
package/dist/cli.mjs
CHANGED
|
@@ -118,21 +118,21 @@ async function withGraphMcpClient(name, fn) {
|
|
|
118
118
|
}
|
|
119
119
|
async function printNetworkCapabilities(opts) {
|
|
120
120
|
const { loadConfig } = await import("./config-9MabJh5R.mjs").then((n) => n.t);
|
|
121
|
-
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await import("./capabilities-
|
|
121
|
+
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await import("./capabilities-BnuroVv_.mjs").then((n) => n.t);
|
|
122
122
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
123
123
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
124
124
|
else console.log(formatNetworkCapabilities(document));
|
|
125
125
|
}
|
|
126
126
|
async function printNetworkOverview(opts) {
|
|
127
127
|
const { loadConfig } = await import("./config-9MabJh5R.mjs").then((n) => n.t);
|
|
128
|
-
const { fetchNetworkCapabilities, formatNetworkOverview } = await import("./capabilities-
|
|
128
|
+
const { fetchNetworkCapabilities, formatNetworkOverview } = await import("./capabilities-BnuroVv_.mjs").then((n) => n.t);
|
|
129
129
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
130
130
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
131
131
|
else console.log(formatNetworkOverview(document));
|
|
132
132
|
}
|
|
133
133
|
async function printNetworkCapability(name, opts) {
|
|
134
134
|
const { loadConfig } = await import("./config-9MabJh5R.mjs").then((n) => n.t);
|
|
135
|
-
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await import("./capabilities-
|
|
135
|
+
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await import("./capabilities-BnuroVv_.mjs").then((n) => n.t);
|
|
136
136
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
137
137
|
const network = findNetworkCapability(document, name);
|
|
138
138
|
if (!network) {
|
|
@@ -150,7 +150,7 @@ async function printNetworkCapability(name, opts) {
|
|
|
150
150
|
async function printNetworkSchema(name, opts) {
|
|
151
151
|
const { loadConfig } = await import("./config-9MabJh5R.mjs").then((n) => n.t);
|
|
152
152
|
const { resolveGraphMcpEndpoint } = await import("./client-gsLi528K.mjs").then((n) => n.r);
|
|
153
|
-
const { formatGraphSchemaText, getGraphSchema } = await import("./graph-schema-
|
|
153
|
+
const { formatGraphSchemaText, getGraphSchema } = await import("./graph-schema-DdriUxEe.mjs").then((n) => n.i);
|
|
154
154
|
const config = await loadConfig();
|
|
155
155
|
const schema = await getGraphSchema({
|
|
156
156
|
network: name,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
2
|
import { t as PaymentRequiredError } from "./client-gsLi528K.mjs";
|
|
3
|
-
import { n as findNetworkCapability, r as mirrorGraphNetworkCapabilities } from "./capabilities-
|
|
3
|
+
import { n as findNetworkCapability, r as mirrorGraphNetworkCapabilities } from "./capabilities-BnuroVv_.mjs";
|
|
4
4
|
import { n as chainInsightsHome, t as CACHE_TTL_MS } from "./cache-location-BO2XkfgI.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
@@ -1177,4 +1177,4 @@ async function handleMetaSchema(args, deps) {
|
|
|
1177
1177
|
//#endregion
|
|
1178
1178
|
export { handleMetaSchema as a, GRAPH_EXPAND_TITLE as c, graph_schema_exports as i, GRAPH_EXPAND_TOOL as l, META_SCHEMA_DESCRIPTION as n, FLOWS_MAX_OFFSET as o, META_SCHEMA_TITLE as r, GRAPH_EXPAND_DESCRIPTION as s, GraphSchemaError as t, handleGraphExpand as u };
|
|
1179
1179
|
|
|
1180
|
-
//# sourceMappingURL=graph-schema-
|
|
1180
|
+
//# sourceMappingURL=graph-schema-DdriUxEe.mjs.map
|