chain-insights 0.81.0 → 0.81.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-BRNHcabF.mjs → capabilities-BniH7lxt.mjs} +48 -3
- package/dist/capabilities-BniH7lxt.mjs.map +1 -0
- package/dist/{capabilities-DalimVY2.cjs → capabilities-DgNUpRa-.cjs} +58 -1
- package/dist/cli.cjs +9 -9
- package/dist/cli.mjs +9 -9
- package/dist/{dex-tool-B6AymECb.cjs → dex-tool-C6eLeZI2.cjs} +135 -6
- package/dist/{dex-tool-CjUZY19i.mjs → dex-tool-DW_hT1Z1.mjs} +136 -7
- package/dist/dex-tool-DW_hT1Z1.mjs.map +1 -0
- package/dist/{exchange-deposit-check-B7Uq666g.cjs → exchange-deposit-check-5e5UwqTn.cjs} +126 -22
- package/dist/{exchange-deposit-check-COXIC2Sp.mjs → exchange-deposit-check-DPU8W3vK.mjs} +127 -23
- package/dist/exchange-deposit-check-DPU8W3vK.mjs.map +1 -0
- package/dist/{graph-schema-Bjw8f155.mjs → graph-schema-0eYvShs7.mjs} +7 -2
- package/dist/{graph-schema-Bjw8f155.mjs.map → graph-schema-0eYvShs7.mjs.map} +1 -1
- package/dist/{graph-schema-BmYvS-WE.cjs → graph-schema-DNvmR6iP.cjs} +6 -1
- package/dist/layer-routing-CM99KYhc.mjs +122 -0
- package/dist/layer-routing-CM99KYhc.mjs.map +1 -0
- package/dist/layer-routing-D9KbTKUj.cjs +155 -0
- package/dist/mcp-proxy.cjs +13 -87
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +11 -85
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/{public-tools-CU1nukHW.mjs → public-tools-COhurrDw.mjs} +7 -5
- package/dist/public-tools-COhurrDw.mjs.map +1 -0
- package/dist/{public-tools-yvRiFSry.cjs → public-tools-DFvirePH.cjs} +6 -4
- package/docs/contributing.md +4 -1
- package/docs/evals.md +133 -0
- package/docs/graph-query-compatibility.md +15 -2
- package/docs/graph-tools.md +16 -3
- package/docs/mcp-proxy.md +21 -3
- package/package.json +4 -2
- package/registry/robinhood.md +7 -0
- package/skills/chain-insights-aml-exchange/SKILL.md +33 -0
- package/skills/chain-insights-cypher/SKILL.md +20 -7
- package/skills/chain-insights-dex/SKILL.md +29 -22
- package/skills/chain-insights-dex/reference.md +29 -0
- package/skills/chain-insights-dex-gauge/SKILL.md +20 -0
- package/skills/chain-insights-dex-launchpad/SKILL.md +8 -0
- package/skills/chain-insights-dex-vault/SKILL.md +12 -0
- package/skills/chain-insights-virtuals/SKILL.md +8 -2
- package/skills/chain-insights-virtuals/reference.md +14 -0
- package/dist/capabilities-BRNHcabF.mjs.map +0 -1
- package/dist/dex-tool-CjUZY19i.mjs.map +0 -1
- package/dist/exchange-deposit-check-COXIC2Sp.mjs.map +0 -1
- package/dist/public-tools-CU1nukHW.mjs.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
|
|
2
2
|
import { a as resolveGraphMcpEndpoint, n as applyMcpAuthHeaders } from "./client-BaHAIidE.mjs";
|
|
3
|
+
import { o as swapLinkShape } from "./layer-routing-CM99KYhc.mjs";
|
|
3
4
|
// src/mcp/capabilities.ts
|
|
4
5
|
var capabilities_exports = /* @__PURE__ */ __exportAll({
|
|
5
6
|
fetchNetworkCapabilities: () => fetchNetworkCapabilities,
|
|
@@ -45,12 +46,16 @@ function advertisedGraphFamily(entry) {
|
|
|
45
46
|
if (!isNumberOrNull(behind)) return null;
|
|
46
47
|
if (entry.fresh !== void 0 && typeof entry.fresh !== "boolean") return null;
|
|
47
48
|
if (!Array.isArray(entry.layers) || !entry.layers.every((layer) => typeof layer === "string")) return null;
|
|
49
|
+
const linkTypes = Array.isArray(entry.link_types) && entry.link_types.every((type) => typeof type === "string") ? [...entry.link_types] : void 0;
|
|
50
|
+
const linkLevels = isRecord(entry.link_levels) ? Object.fromEntries(Object.entries(entry.link_levels).filter((pair) => typeof pair[1] === "number")) : void 0;
|
|
48
51
|
return {
|
|
49
52
|
name: entry.name,
|
|
50
53
|
complete_through_block: entry.complete_through_block,
|
|
51
54
|
blocks_behind_head: behind,
|
|
52
55
|
...typeof entry.fresh === "boolean" ? { fresh: entry.fresh } : {},
|
|
53
|
-
layers: [...entry.layers]
|
|
56
|
+
layers: [...entry.layers],
|
|
57
|
+
...linkTypes ? { link_types: linkTypes } : {},
|
|
58
|
+
...linkLevels ? { link_levels: linkLevels } : {}
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
/** The families list, whole or not at all: one entry with a bad shape drops it. */
|
|
@@ -375,6 +380,46 @@ function formatNetworkCapability(network) {
|
|
|
375
380
|
...formatProgressTables(tables, head !== void 0)
|
|
376
381
|
].join("\n");
|
|
377
382
|
}
|
|
378
|
-
|
|
383
|
+
/**
|
|
384
|
+
* The shape of a lane's swap links, read from its `network_capabilities` reply:
|
|
385
|
+
* `levels` when its money family lists ROUTED_TO, else `route`. A call that
|
|
386
|
+
* fails, or a reply that lists no such network, gives no shape (undefined): the
|
|
387
|
+
* caller uses `route` for that one call and asks again on the next.
|
|
388
|
+
*/
|
|
389
|
+
async function readSwapLinkShape(client, network) {
|
|
390
|
+
try {
|
|
391
|
+
const answer = await client.callTool({
|
|
392
|
+
name: "network_capabilities",
|
|
393
|
+
arguments: {}
|
|
394
|
+
});
|
|
395
|
+
const structured = isRecord(answer) ? answer.structuredContent : void 0;
|
|
396
|
+
const facts = isRecord(structured) ? structured.facts : void 0;
|
|
397
|
+
const capabilities = isRecord(facts) ? facts.capabilities : void 0;
|
|
398
|
+
const capability = findNetworkCapability(mirrorGraphNetworkCapabilities({ networks: isRecord(capabilities) && Array.isArray(capabilities.networks) ? capabilities.networks : [] }), network);
|
|
399
|
+
if (!capability) return void 0;
|
|
400
|
+
return swapLinkShape(capability.graph_progress?.families);
|
|
401
|
+
} catch {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* A lane's shape, kept `ttlMs` per network once a read gives one. A read that
|
|
407
|
+
* gives none is never kept: that call answers `route`, the next reads again.
|
|
408
|
+
*/
|
|
409
|
+
function keptSwapLinkShape(read, ttlMs, now = Date.now) {
|
|
410
|
+
const kept = /* @__PURE__ */ new Map();
|
|
411
|
+
return async (network) => {
|
|
412
|
+
const entry = kept.get(network);
|
|
413
|
+
if (entry && now() - entry.at < ttlMs) return entry.shape;
|
|
414
|
+
const shape = await read(network);
|
|
415
|
+
if (shape === void 0) return "route";
|
|
416
|
+
kept.set(network, {
|
|
417
|
+
shape,
|
|
418
|
+
at: now()
|
|
419
|
+
});
|
|
420
|
+
return shape;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
export { readSwapLinkShape as a, mirrorGraphNetworkCapabilities as i, findNetworkCapability as n, keptSwapLinkShape as r, capabilities_exports as t };
|
|
379
424
|
|
|
380
|
-
//# sourceMappingURL=capabilities-
|
|
425
|
+
//# sourceMappingURL=capabilities-BniH7lxt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities-BniH7lxt.mjs","names":[],"sources":["../src/mcp/capabilities.ts"],"sourcesContent":["import type { InvestigatorConfig } from '../config/schema.js'\nimport { applyMcpAuthHeaders, resolveGraphMcpEndpoint } from './client.js'\nimport { swapLinkShape, type SwapLinkShape } from './layer-routing.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 /** The link types the family serves, when the server lists them. */\n link_types?: string[]\n /** The level of each levelled link type of the family, when the server reports it. */\n link_levels?: Record<string, number>\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 const linkTypes =\n Array.isArray(entry.link_types) && entry.link_types.every((type) => typeof type === 'string')\n ? [...(entry.link_types as string[])]\n : undefined\n const linkLevels = isRecord(entry.link_levels)\n ? Object.fromEntries(\n Object.entries(entry.link_levels).filter(\n (pair): pair is [string, number] => typeof pair[1] === 'number'\n )\n )\n : undefined\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 ...(linkTypes ? { link_types: linkTypes } : {}),\n ...(linkLevels ? { link_levels: linkLevels } : {}),\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: `smart_accounts` prints as \"smart accounts\". */\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\n/**\n * The shape of a lane's swap links, read from its `network_capabilities` reply:\n * `levels` when its money family lists ROUTED_TO, else `route`. A call that\n * fails, or a reply that lists no such network, gives no shape (undefined): the\n * caller uses `route` for that one call and asks again on the next.\n */\nexport async function readSwapLinkShape(\n client: { callTool: (request: { name: string; arguments: Record<string, unknown> }) => Promise<unknown> },\n network: string\n): Promise<SwapLinkShape | undefined> {\n try {\n const answer = await client.callTool({ name: 'network_capabilities', arguments: {} })\n const structured = isRecord(answer) ? answer.structuredContent : undefined\n const facts = isRecord(structured) ? structured.facts : undefined\n const capabilities = isRecord(facts) ? facts.capabilities : undefined\n const networks =\n isRecord(capabilities) && Array.isArray(capabilities.networks) ? capabilities.networks : []\n const capability = findNetworkCapability(mirrorGraphNetworkCapabilities({ networks }), network)\n if (!capability) return undefined\n return swapLinkShape(capability.graph_progress?.families)\n } catch {\n return undefined\n }\n}\n\n/**\n * A lane's shape, kept `ttlMs` per network once a read gives one. A read that\n * gives none is never kept: that call answers `route`, the next reads again.\n */\nexport function keptSwapLinkShape(\n read: (network: string) => Promise<SwapLinkShape | undefined>,\n ttlMs: number,\n now: () => number = Date.now\n): (network: string) => Promise<SwapLinkShape> {\n const kept = new Map<string, { shape: SwapLinkShape; at: number }>()\n return async (network) => {\n const entry = kept.get(network)\n if (entry && now() - entry.at < ttlMs) return entry.shape\n const shape = await read(network)\n if (shape === undefined) return 'route'\n kept.set(network, { shape, at: now() })\n return shape\n }\n}\n"],"mappings":";;;;;;;;;;;AAqJA,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;C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wB,WAAW,CAAC;EAAE,CAAC;EACpF,MAAM,aAAa,SAAS,MAAM,IAAI,OAAO,oBAAoB,KAAA;EACjE,MAAM,QAAQ,SAAS,UAAU,IAAI,WAAW,QAAQ,KAAA;EACxD,MAAM,eAAe,SAAS,KAAK,IAAI,MAAM,eAAe,KAAA;EAG5D,MAAM,aAAa,sBAAsB,+BAA+B,EAAE,UADxE,SAAS,YAAY,KAAK,MAAM,QAAQ,aAAa,QAAQ,IAAI,aAAa,WAAW,CAAC,EACT,CAAC,GAAG,OAAO;EAC9F,IAAI,CAAC,YAAY,OAAO,KAAA;EACxB,OAAO,cAAc,WAAW,gBAAgB,QAAQ;CAC1D,QAAQ;EACN;CACF;AACF;;;;;AAMA,SAAgB,kBACd,MACA,OACA,MAAoB,KAAK,KACoB;CAC7C,MAAM,uBAAO,IAAI,IAAkD;CACnE,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,KAAK,IAAI,OAAO;EAC9B,IAAI,SAAS,IAAI,IAAI,MAAM,KAAK,OAAO,OAAO,MAAM;EACpD,MAAM,QAAQ,MAAM,KAAK,OAAO;EAChC,IAAI,UAAU,KAAA,GAAW,OAAO;EAChC,KAAK,IAAI,SAAS;GAAE;GAAO,IAAI,IAAI;EAAE,CAAC;EACtC,OAAO;CACT;AACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
2
|
const require_client = require("./client-Ddk4X9Ko.cjs");
|
|
3
|
+
const require_layer_routing = require("./layer-routing-D9KbTKUj.cjs");
|
|
3
4
|
// src/mcp/capabilities.ts
|
|
4
5
|
var capabilities_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
5
6
|
fetchNetworkCapabilities: () => fetchNetworkCapabilities,
|
|
@@ -45,12 +46,16 @@ function advertisedGraphFamily(entry) {
|
|
|
45
46
|
if (!isNumberOrNull(behind)) return null;
|
|
46
47
|
if (entry.fresh !== void 0 && typeof entry.fresh !== "boolean") return null;
|
|
47
48
|
if (!Array.isArray(entry.layers) || !entry.layers.every((layer) => typeof layer === "string")) return null;
|
|
49
|
+
const linkTypes = Array.isArray(entry.link_types) && entry.link_types.every((type) => typeof type === "string") ? [...entry.link_types] : void 0;
|
|
50
|
+
const linkLevels = isRecord(entry.link_levels) ? Object.fromEntries(Object.entries(entry.link_levels).filter((pair) => typeof pair[1] === "number")) : void 0;
|
|
48
51
|
return {
|
|
49
52
|
name: entry.name,
|
|
50
53
|
complete_through_block: entry.complete_through_block,
|
|
51
54
|
blocks_behind_head: behind,
|
|
52
55
|
...typeof entry.fresh === "boolean" ? { fresh: entry.fresh } : {},
|
|
53
|
-
layers: [...entry.layers]
|
|
56
|
+
layers: [...entry.layers],
|
|
57
|
+
...linkTypes ? { link_types: linkTypes } : {},
|
|
58
|
+
...linkLevels ? { link_levels: linkLevels } : {}
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
/** The families list, whole or not at all: one entry with a bad shape drops it. */
|
|
@@ -375,6 +380,46 @@ function formatNetworkCapability(network) {
|
|
|
375
380
|
...formatProgressTables(tables, head !== void 0)
|
|
376
381
|
].join("\n");
|
|
377
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* The shape of a lane's swap links, read from its `network_capabilities` reply:
|
|
385
|
+
* `levels` when its money family lists ROUTED_TO, else `route`. A call that
|
|
386
|
+
* fails, or a reply that lists no such network, gives no shape (undefined): the
|
|
387
|
+
* caller uses `route` for that one call and asks again on the next.
|
|
388
|
+
*/
|
|
389
|
+
async function readSwapLinkShape(client, network) {
|
|
390
|
+
try {
|
|
391
|
+
const answer = await client.callTool({
|
|
392
|
+
name: "network_capabilities",
|
|
393
|
+
arguments: {}
|
|
394
|
+
});
|
|
395
|
+
const structured = isRecord(answer) ? answer.structuredContent : void 0;
|
|
396
|
+
const facts = isRecord(structured) ? structured.facts : void 0;
|
|
397
|
+
const capabilities = isRecord(facts) ? facts.capabilities : void 0;
|
|
398
|
+
const capability = findNetworkCapability(mirrorGraphNetworkCapabilities({ networks: isRecord(capabilities) && Array.isArray(capabilities.networks) ? capabilities.networks : [] }), network);
|
|
399
|
+
if (!capability) return void 0;
|
|
400
|
+
return require_layer_routing.swapLinkShape(capability.graph_progress?.families);
|
|
401
|
+
} catch {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* A lane's shape, kept `ttlMs` per network once a read gives one. A read that
|
|
407
|
+
* gives none is never kept: that call answers `route`, the next reads again.
|
|
408
|
+
*/
|
|
409
|
+
function keptSwapLinkShape(read, ttlMs, now = Date.now) {
|
|
410
|
+
const kept = /* @__PURE__ */ new Map();
|
|
411
|
+
return async (network) => {
|
|
412
|
+
const entry = kept.get(network);
|
|
413
|
+
if (entry && now() - entry.at < ttlMs) return entry.shape;
|
|
414
|
+
const shape = await read(network);
|
|
415
|
+
if (shape === void 0) return "route";
|
|
416
|
+
kept.set(network, {
|
|
417
|
+
shape,
|
|
418
|
+
at: now()
|
|
419
|
+
});
|
|
420
|
+
return shape;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
378
423
|
Object.defineProperty(exports, "capabilities_exports", {
|
|
379
424
|
enumerable: true,
|
|
380
425
|
get: function() {
|
|
@@ -387,9 +432,21 @@ Object.defineProperty(exports, "findNetworkCapability", {
|
|
|
387
432
|
return findNetworkCapability;
|
|
388
433
|
}
|
|
389
434
|
});
|
|
435
|
+
Object.defineProperty(exports, "keptSwapLinkShape", {
|
|
436
|
+
enumerable: true,
|
|
437
|
+
get: function() {
|
|
438
|
+
return keptSwapLinkShape;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
390
441
|
Object.defineProperty(exports, "mirrorGraphNetworkCapabilities", {
|
|
391
442
|
enumerable: true,
|
|
392
443
|
get: function() {
|
|
393
444
|
return mirrorGraphNetworkCapabilities;
|
|
394
445
|
}
|
|
395
446
|
});
|
|
447
|
+
Object.defineProperty(exports, "readSwapLinkShape", {
|
|
448
|
+
enumerable: true,
|
|
449
|
+
get: function() {
|
|
450
|
+
return readSwapLinkShape;
|
|
451
|
+
}
|
|
452
|
+
});
|
package/dist/cli.cjs
CHANGED
|
@@ -241,21 +241,21 @@ async function withGraphMcpClient(name, fn) {
|
|
|
241
241
|
}
|
|
242
242
|
async function printNetworkCapabilities(opts) {
|
|
243
243
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BdE8LcF-.cjs")).then((n) => n.config_exports);
|
|
244
|
-
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await Promise.resolve().then(() => require("./capabilities-
|
|
244
|
+
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await Promise.resolve().then(() => require("./capabilities-DgNUpRa-.cjs")).then((n) => n.capabilities_exports);
|
|
245
245
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
246
246
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
247
247
|
else console.log(formatNetworkCapabilities(document));
|
|
248
248
|
}
|
|
249
249
|
async function printNetworkOverview(opts) {
|
|
250
250
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BdE8LcF-.cjs")).then((n) => n.config_exports);
|
|
251
|
-
const { fetchNetworkCapabilities, formatNetworkOverview } = await Promise.resolve().then(() => require("./capabilities-
|
|
251
|
+
const { fetchNetworkCapabilities, formatNetworkOverview } = await Promise.resolve().then(() => require("./capabilities-DgNUpRa-.cjs")).then((n) => n.capabilities_exports);
|
|
252
252
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
253
253
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
254
254
|
else console.log(formatNetworkOverview(document));
|
|
255
255
|
}
|
|
256
256
|
async function printNetworkCapability(name, opts) {
|
|
257
257
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BdE8LcF-.cjs")).then((n) => n.config_exports);
|
|
258
|
-
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await Promise.resolve().then(() => require("./capabilities-
|
|
258
|
+
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await Promise.resolve().then(() => require("./capabilities-DgNUpRa-.cjs")).then((n) => n.capabilities_exports);
|
|
259
259
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
260
260
|
const network = findNetworkCapability(document, name);
|
|
261
261
|
if (!network) {
|
|
@@ -273,7 +273,7 @@ async function printNetworkCapability(name, opts) {
|
|
|
273
273
|
async function printNetworkSchema(name, opts) {
|
|
274
274
|
const { loadConfig } = await Promise.resolve().then(() => require("./config-BdE8LcF-.cjs")).then((n) => n.config_exports);
|
|
275
275
|
const { resolveGraphMcpEndpoint } = await Promise.resolve().then(() => require("./client-Ddk4X9Ko.cjs")).then((n) => n.client_exports);
|
|
276
|
-
const { formatGraphSchemaText, getGraphSchema } = await Promise.resolve().then(() => require("./graph-schema-
|
|
276
|
+
const { formatGraphSchemaText, getGraphSchema } = await Promise.resolve().then(() => require("./graph-schema-DNvmR6iP.cjs")).then((n) => n.graph_schema_exports);
|
|
277
277
|
const config = await loadConfig();
|
|
278
278
|
const schema = await getGraphSchema({
|
|
279
279
|
network: name,
|
|
@@ -286,11 +286,11 @@ async function printNetworkSchema(name, opts) {
|
|
|
286
286
|
function addAmlAddressRiskCommand(parent, networksCommand) {
|
|
287
287
|
parent.addCommand(createCliCommand("aml-address-risk").description("CIA workflow: screen an address for AML risk, exchange behavior, and optional comparison with another address").requiredOption("--address <address>", "Full blockchain address to screen").requiredOption("--network <network>", `Network to query. Run \`${networksCommand}\` for supported networks.`).option("--compare-address <address>", "Optional second address to compare against the screened address").option("--json", "Print machine-readable JSON output").option("--version <version>", "AML tool contract version. Omit to use the latest version (currently v1)").addOption(new commander.Option("--tool-version <version>", "Internal alias for the AML tool version").hideHelp()).action(async (opts) => {
|
|
288
288
|
try {
|
|
289
|
-
const { resolveAmlAddressRiskVersion } = await Promise.resolve().then(() => require("./public-tools-
|
|
289
|
+
const { resolveAmlAddressRiskVersion } = await Promise.resolve().then(() => require("./public-tools-DFvirePH.cjs"));
|
|
290
290
|
const requestedVersion = opts.toolVersion ?? opts.version;
|
|
291
291
|
resolveAmlAddressRiskVersion(requestedVersion);
|
|
292
292
|
await withGraphMcpClient("chain-insights-cli-aml-address-risk", async (client) => {
|
|
293
|
-
const { runAmlAddressRisk } = await Promise.resolve().then(() => require("./public-tools-
|
|
293
|
+
const { runAmlAddressRisk } = await Promise.resolve().then(() => require("./public-tools-DFvirePH.cjs"));
|
|
294
294
|
const result = await runAmlAddressRisk(client, {
|
|
295
295
|
address: opts.address,
|
|
296
296
|
network: opts.network,
|
|
@@ -647,7 +647,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
console.log(formatToolsTable(visibleRemoteTools(tools)));
|
|
650
|
-
const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./dex-tool-
|
|
650
|
+
const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./dex-tool-C6eLeZI2.cjs")).then((n) => n.dex_tool_exports);
|
|
651
651
|
const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await Promise.resolve().then(() => require("./token-lookup-D-5GBEwF.cjs")).then((n) => n.token_lookup_exports);
|
|
652
652
|
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await Promise.resolve().then(() => require("./deployer-screen-BomgSBcq.cjs")).then((n) => n.deployer_screen_exports);
|
|
653
653
|
console.log("");
|
|
@@ -693,7 +693,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
693
693
|
return;
|
|
694
694
|
}
|
|
695
695
|
if (tool === "meta_dex_lookup") {
|
|
696
|
-
const { handleMetaDexLookup } = await Promise.resolve().then(() => require("./dex-tool-
|
|
696
|
+
const { handleMetaDexLookup } = await Promise.resolve().then(() => require("./dex-tool-C6eLeZI2.cjs")).then((n) => n.dex_tool_exports);
|
|
697
697
|
const { loadRegistry } = await Promise.resolve().then(() => require("./dex-registry-BhGJUG9_.cjs")).then((n) => n.dex_registry_exports);
|
|
698
698
|
const { metaDexLookupArgs } = await Promise.resolve().then(() => require("./call-args-DXEmPeE-.cjs"));
|
|
699
699
|
const result = await withGraphMcpClient("chain-insights-cli-dex-lookup", (client) => handleMetaDexLookup(metaDexLookupArgs(args), {
|
|
@@ -755,7 +755,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
755
755
|
return;
|
|
756
756
|
}
|
|
757
757
|
if (tool === "aml_exchange_deposit_check") {
|
|
758
|
-
const { handleAmlExchangeDepositCheck } = await Promise.resolve().then(() => require("./exchange-deposit-check-
|
|
758
|
+
const { handleAmlExchangeDepositCheck } = await Promise.resolve().then(() => require("./exchange-deposit-check-5e5UwqTn.cjs")).then((n) => n.exchange_deposit_check_exports);
|
|
759
759
|
const { loadExchangeRegistry } = await Promise.resolve().then(() => require("./exchange-registry-CT0rRW__.cjs")).then((n) => n.exchange_registry_exports);
|
|
760
760
|
const result = await withGraphMcpClient("chain-insights-cli-exchange-deposit-check", (client) => handleAmlExchangeDepositCheck({
|
|
761
761
|
network: args["network"],
|
package/dist/cli.mjs
CHANGED
|
@@ -239,21 +239,21 @@ async function withGraphMcpClient(name, fn) {
|
|
|
239
239
|
}
|
|
240
240
|
async function printNetworkCapabilities(opts) {
|
|
241
241
|
const { loadConfig } = await import("./config-BkLIqOYq.mjs").then((n) => n.t);
|
|
242
|
-
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await import("./capabilities-
|
|
242
|
+
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await import("./capabilities-BniH7lxt.mjs").then((n) => n.t);
|
|
243
243
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
244
244
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
245
245
|
else console.log(formatNetworkCapabilities(document));
|
|
246
246
|
}
|
|
247
247
|
async function printNetworkOverview(opts) {
|
|
248
248
|
const { loadConfig } = await import("./config-BkLIqOYq.mjs").then((n) => n.t);
|
|
249
|
-
const { fetchNetworkCapabilities, formatNetworkOverview } = await import("./capabilities-
|
|
249
|
+
const { fetchNetworkCapabilities, formatNetworkOverview } = await import("./capabilities-BniH7lxt.mjs").then((n) => n.t);
|
|
250
250
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
251
251
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
252
252
|
else console.log(formatNetworkOverview(document));
|
|
253
253
|
}
|
|
254
254
|
async function printNetworkCapability(name, opts) {
|
|
255
255
|
const { loadConfig } = await import("./config-BkLIqOYq.mjs").then((n) => n.t);
|
|
256
|
-
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await import("./capabilities-
|
|
256
|
+
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await import("./capabilities-BniH7lxt.mjs").then((n) => n.t);
|
|
257
257
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
258
258
|
const network = findNetworkCapability(document, name);
|
|
259
259
|
if (!network) {
|
|
@@ -271,7 +271,7 @@ async function printNetworkCapability(name, opts) {
|
|
|
271
271
|
async function printNetworkSchema(name, opts) {
|
|
272
272
|
const { loadConfig } = await import("./config-BkLIqOYq.mjs").then((n) => n.t);
|
|
273
273
|
const { resolveGraphMcpEndpoint } = await import("./client-BaHAIidE.mjs").then((n) => n.r);
|
|
274
|
-
const { formatGraphSchemaText, getGraphSchema } = await import("./graph-schema-
|
|
274
|
+
const { formatGraphSchemaText, getGraphSchema } = await import("./graph-schema-0eYvShs7.mjs").then((n) => n.a);
|
|
275
275
|
const config = await loadConfig();
|
|
276
276
|
const schema = await getGraphSchema({
|
|
277
277
|
network: name,
|
|
@@ -284,11 +284,11 @@ async function printNetworkSchema(name, opts) {
|
|
|
284
284
|
function addAmlAddressRiskCommand(parent, networksCommand) {
|
|
285
285
|
parent.addCommand(createCliCommand("aml-address-risk").description("CIA workflow: screen an address for AML risk, exchange behavior, and optional comparison with another address").requiredOption("--address <address>", "Full blockchain address to screen").requiredOption("--network <network>", `Network to query. Run \`${networksCommand}\` for supported networks.`).option("--compare-address <address>", "Optional second address to compare against the screened address").option("--json", "Print machine-readable JSON output").option("--version <version>", "AML tool contract version. Omit to use the latest version (currently v1)").addOption(new Option("--tool-version <version>", "Internal alias for the AML tool version").hideHelp()).action(async (opts) => {
|
|
286
286
|
try {
|
|
287
|
-
const { resolveAmlAddressRiskVersion } = await import("./public-tools-
|
|
287
|
+
const { resolveAmlAddressRiskVersion } = await import("./public-tools-COhurrDw.mjs");
|
|
288
288
|
const requestedVersion = opts.toolVersion ?? opts.version;
|
|
289
289
|
resolveAmlAddressRiskVersion(requestedVersion);
|
|
290
290
|
await withGraphMcpClient("chain-insights-cli-aml-address-risk", async (client) => {
|
|
291
|
-
const { runAmlAddressRisk } = await import("./public-tools-
|
|
291
|
+
const { runAmlAddressRisk } = await import("./public-tools-COhurrDw.mjs");
|
|
292
292
|
const result = await runAmlAddressRisk(client, {
|
|
293
293
|
address: opts.address,
|
|
294
294
|
network: opts.network,
|
|
@@ -645,7 +645,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
console.log(formatToolsTable(visibleRemoteTools(tools)));
|
|
648
|
-
const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await import("./dex-tool-
|
|
648
|
+
const { META_DEX_LOOKUP_DESCRIPTION, META_DEX_LOOKUP_TITLE, META_DEX_LOOKUP_TOOL } = await import("./dex-tool-DW_hT1Z1.mjs").then((n) => n.a);
|
|
649
649
|
const { META_TOKEN_LOOKUP_DESCRIPTION, META_TOKEN_LOOKUP_TITLE, META_TOKEN_LOOKUP_TOOL } = await import("./token-lookup-QpIv77P2.mjs").then((n) => n.l);
|
|
650
650
|
const { AML_DEPLOYER_SCREEN_DESCRIPTION, AML_DEPLOYER_SCREEN_TITLE, AML_DEPLOYER_SCREEN_TOOL } = await import("./deployer-screen-ByQBZEsg.mjs").then((n) => n.a);
|
|
651
651
|
console.log("");
|
|
@@ -691,7 +691,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
691
691
|
return;
|
|
692
692
|
}
|
|
693
693
|
if (tool === "meta_dex_lookup") {
|
|
694
|
-
const { handleMetaDexLookup } = await import("./dex-tool-
|
|
694
|
+
const { handleMetaDexLookup } = await import("./dex-tool-DW_hT1Z1.mjs").then((n) => n.a);
|
|
695
695
|
const { loadRegistry } = await import("./dex-registry-BY67f4Ul.mjs").then((n) => n.s);
|
|
696
696
|
const { metaDexLookupArgs } = await import("./call-args-CBqbYfOE.mjs");
|
|
697
697
|
const result = await withGraphMcpClient("chain-insights-cli-dex-lookup", (client) => handleMetaDexLookup(metaDexLookupArgs(args), {
|
|
@@ -753,7 +753,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
753
753
|
return;
|
|
754
754
|
}
|
|
755
755
|
if (tool === "aml_exchange_deposit_check") {
|
|
756
|
-
const { handleAmlExchangeDepositCheck } = await import("./exchange-deposit-check-
|
|
756
|
+
const { handleAmlExchangeDepositCheck } = await import("./exchange-deposit-check-DPU8W3vK.mjs").then((n) => n.a);
|
|
757
757
|
const { loadExchangeRegistry } = await import("./exchange-registry-CoLgHw6d.mjs").then((n) => n.r);
|
|
758
758
|
const result = await withGraphMcpClient("chain-insights-cli-exchange-deposit-check", (client) => handleAmlExchangeDepositCheck({
|
|
759
759
|
network: args["network"],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
2
|
const require_answer_hint = require("./answer-hint-BlYEBq_Y.cjs");
|
|
3
|
+
const require_layer_routing = require("./layer-routing-D9KbTKUj.cjs");
|
|
3
4
|
const require_dex_registry = require("./dex-registry-BhGJUG9_.cjs");
|
|
4
5
|
// src/mcp/dex-recipes.ts
|
|
5
6
|
/** The trail-type skill of each trail, for hosts that load skills. */
|
|
@@ -37,6 +38,18 @@ function swapRowsQuery(recipient) {
|
|
|
37
38
|
function routerPayoutQuery(router) {
|
|
38
39
|
return `USE facts MATCH (r:Address {address: "${router}"})-[t:TRANSFER]->(b:Address) WHERE t.block_date = "${DAY}" AND t.tx_id = "${TX}" RETURN r.address AS from_address, b.address AS to_address, t.amount_usd AS amount_usd, t.asset_symbol AS asset_symbol, t.kind AS kind, t.tx_id AS tx_id LIMIT 10`;
|
|
39
40
|
}
|
|
41
|
+
/** The traders at one pool or pool manager on SWAPPED, by sold volume (levels). */
|
|
42
|
+
function tradersAtPoolQuery(pool) {
|
|
43
|
+
return `USE topology MATCH (s:Address)-[sw:SWAPPED]->(p:Address {address: "${pool}"}) WHERE NOT s:Pool RETURN s.address AS from_address, p.address AS to_address, labels(s) AS from_node_labels, sw.sold_asset AS sold_asset, sw.bought_asset AS bought_asset, sw.sold_usd AS sold_usd, sw.bought_usd AS bought_usd, sw.swap_count AS swap_count, sw.first_seen_height AS first_seen_height, sw.last_seen_height AS last_seen_height ORDER BY sw.sold_usd DESC LIMIT 25`;
|
|
44
|
+
}
|
|
45
|
+
/** One trader's routes on ROUTED_TO: who got what it bought (levels). */
|
|
46
|
+
function traderRoutesQuery() {
|
|
47
|
+
return `USE topology MATCH (s:Address {address: "${SELLER}"})-[r:ROUTED_TO]->(b:Address) RETURN s.address AS from_address, b.address AS to_address, labels(b) AS to_node_labels, r.tx_count AS tx_count, r.swap_count AS swap_count, r.amount_usd_sum AS amount_usd_sum, r.bought_usd_sum AS bought_usd_sum, r.unpriced_count AS unpriced_count, r.first_seen_timestamp AS first_seen_timestamp, r.last_seen_timestamp AS last_seen_timestamp ORDER BY r.amount_usd_sum DESC LIMIT 25`;
|
|
48
|
+
}
|
|
49
|
+
/** One trader's swaps on SWAPPED: the pools and the assets (levels). */
|
|
50
|
+
function traderPoolSwapsQuery() {
|
|
51
|
+
return `USE topology MATCH (s:Address {address: "${SELLER}"})-[sw:SWAPPED]->(p:Address) RETURN s.address AS from_address, p.address AS to_address, labels(p) AS to_node_labels, sw.sold_asset AS sold_asset, sw.bought_asset AS bought_asset, sw.sold_usd AS sold_usd, sw.bought_usd AS bought_usd, sw.swap_count AS swap_count, sw.last_seen_height AS last_seen_height ORDER BY sw.swap_count DESC LIMIT 25`;
|
|
52
|
+
}
|
|
40
53
|
const dayStep = {
|
|
41
54
|
step: "The day of a swap link",
|
|
42
55
|
why: "A SWAPPED link carries heights, not times: read the block of its last_seen_height for the day the facts reads need.",
|
|
@@ -59,7 +72,106 @@ function poolsStep(entry) {
|
|
|
59
72
|
};
|
|
60
73
|
}
|
|
61
74
|
/** The first reads of the exchange's trail type, with its addresses filled in. */
|
|
62
|
-
function recipeFor(entry, topPool) {
|
|
75
|
+
function recipeFor(entry, topPool, shape = "route") {
|
|
76
|
+
return shape === "levels" ? levelsRecipeFor(entry, topPool) : routeRecipeFor(entry, topPool);
|
|
77
|
+
}
|
|
78
|
+
const routesStep = {
|
|
79
|
+
step: "Who got what a trader bought",
|
|
80
|
+
why: "Fill a trader from the first step. Each ROUTED_TO link is the swaps of one payer and one receiver, in USD: a link to the trader itself means it bought for itself, any other receiver is the buyer. No router and no pool is a receiver.",
|
|
81
|
+
query: traderRoutesQuery()
|
|
82
|
+
};
|
|
83
|
+
const poolSwapsStep = {
|
|
84
|
+
step: "A trader's pools and assets",
|
|
85
|
+
why: "Fill the trader: each SWAPPED link is one pool and one asset pair, with what the pool got (sold) and what it gave (bought).",
|
|
86
|
+
query: traderPoolSwapsQuery()
|
|
87
|
+
};
|
|
88
|
+
/** The reads of a lane with the levels: SWAPPED to a pool, ROUTED_TO for the route. */
|
|
89
|
+
function levelsRecipeFor(entry, topPool) {
|
|
90
|
+
const pool = startPool(entry, topPool);
|
|
91
|
+
const steps = [];
|
|
92
|
+
const poolTraders = (at) => ({
|
|
93
|
+
step: "Traders at the busiest pool",
|
|
94
|
+
why: `The traders of ${at} on SWAPPED, by sold volume. A trader that is a contract is often an aggregator or a bot: say "a contract". A sender that only adds liquidity is on ADDED_LIQUIDITY, not here.`,
|
|
95
|
+
query: tradersAtPoolQuery(at)
|
|
96
|
+
});
|
|
97
|
+
switch (entry.trail_type) {
|
|
98
|
+
case "gauge": {
|
|
99
|
+
const router = entry.routers[0];
|
|
100
|
+
if (pool) steps.push(poolTraders(pool));
|
|
101
|
+
else {
|
|
102
|
+
const pools = poolsStep(entry);
|
|
103
|
+
if (pools) steps.push(pools);
|
|
104
|
+
}
|
|
105
|
+
steps.push(routesStep);
|
|
106
|
+
if (router) {
|
|
107
|
+
steps.push(dayStep);
|
|
108
|
+
steps.push({
|
|
109
|
+
step: "A trader's swaps through the router on one day",
|
|
110
|
+
why: `Fill the trader and the day: each row gives the tx_id of one swap that named the router ${router}; the router is never the buyer.`,
|
|
111
|
+
query: swapRowsQuery(router)
|
|
112
|
+
});
|
|
113
|
+
steps.push({
|
|
114
|
+
step: "Who the router paid in that transaction",
|
|
115
|
+
why: "Fill the day and the tx_id: the receiver of the bought asset is the buyer. A pool or a pool manager there is the next leg, not the buyer.",
|
|
116
|
+
query: routerPayoutQuery(router)
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "vault": {
|
|
122
|
+
const manager = entry.factories[0];
|
|
123
|
+
steps.push({
|
|
124
|
+
step: "Traders at the pool manager",
|
|
125
|
+
why: `${entry.display} keeps every pool in one manager, ${manager}. Each SWAPPED link into it is one trader and one asset pair: the pair names the pool.`,
|
|
126
|
+
query: tradersAtPoolQuery(manager)
|
|
127
|
+
});
|
|
128
|
+
steps.push(routesStep);
|
|
129
|
+
steps.push(dayStep);
|
|
130
|
+
steps.push({
|
|
131
|
+
step: "The facts SWAP row past the manager",
|
|
132
|
+
why: "Fill the trader and the day: the recipient column names who the manager paid.",
|
|
133
|
+
query: swapRowsQuery(manager)
|
|
134
|
+
});
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "launchpad": {
|
|
138
|
+
const factory = entry.factories[0];
|
|
139
|
+
steps.push({
|
|
140
|
+
step: "Launches of the launchpad, newest first",
|
|
141
|
+
why: `The contracts ${factory} created, with the creator of each.`,
|
|
142
|
+
query: `USE topology MATCH (f:Address {address: "${factory}"})-[d:DEPLOYED_CONTRACT]->(t:Address) RETURN f.address AS from_address, t.address AS to_address, labels(t) AS to_node_labels, t.labels AS to_labels, d.tx_origin AS creator, d.tx_id AS tx_id, d.block_height AS block_height, d.block_timestamp AS created_timestamp ORDER BY d.block_height DESC LIMIT 25`
|
|
143
|
+
});
|
|
144
|
+
steps.push({
|
|
145
|
+
step: "Traders on the curve of one launched token",
|
|
146
|
+
why: "Fill a launched token from the first step. A curve is a pool: its traders are its SWAPPED links. A launch whose curve is another contract has its traders on that contract.",
|
|
147
|
+
query: tradersAtPoolQuery(TOKEN)
|
|
148
|
+
});
|
|
149
|
+
steps.push({
|
|
150
|
+
step: "The first pool of one launched token",
|
|
151
|
+
why: "The oldest ADDED_LIQUIDITY into a :Pool is the graduation. None means it has not graduated in the graph yet.",
|
|
152
|
+
query: `USE topology MATCH (t:Address {address: "${TOKEN}"})-[l:ADDED_LIQUIDITY]->(p:Pool) RETURN t.address AS from_address, p.address AS to_address, p.labels AS to_labels, l.asset AS asset, l.usd AS usd, l.first_seen_height AS first_seen_height ORDER BY l.first_seen_height ASC LIMIT 5`
|
|
153
|
+
});
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case "plain":
|
|
157
|
+
if (pool) steps.push(poolTraders(pool));
|
|
158
|
+
else {
|
|
159
|
+
const pools = poolsStep(entry);
|
|
160
|
+
if (pools) steps.push(pools);
|
|
161
|
+
}
|
|
162
|
+
steps.push(routesStep);
|
|
163
|
+
steps.push(poolSwapsStep);
|
|
164
|
+
steps.push(dayStep);
|
|
165
|
+
steps.push({
|
|
166
|
+
step: "The swaps of a trader and a receiver on one day",
|
|
167
|
+
why: "Fill the trader, the receiver and the day.",
|
|
168
|
+
query: swapRowsQuery("<recipient address>")
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return steps;
|
|
172
|
+
}
|
|
173
|
+
/** The reads of a lane with the graph of before: SWAPPED holds the route. */
|
|
174
|
+
function routeRecipeFor(entry, topPool) {
|
|
63
175
|
const pool = startPool(entry, topPool);
|
|
64
176
|
const steps = [];
|
|
65
177
|
switch (entry.trail_type) {
|
|
@@ -170,7 +282,13 @@ function recipeFor(entry, topPool) {
|
|
|
170
282
|
*
|
|
171
283
|
* The description below is the contract with every host, Claude Desktop chat
|
|
172
284
|
* included, which reads no skill: it carries the rule the exchange skills open
|
|
173
|
-
* with. tests/host-parity.test.ts holds it to the skills'
|
|
285
|
+
* with, and the level rule. tests/host-parity.test.ts holds it to the skills'
|
|
286
|
+
* trigger words and to the level rule.
|
|
287
|
+
*
|
|
288
|
+
* The first reads follow the lane's graph shape (`linkShape`, read from
|
|
289
|
+
* meta_network_capabilities): on a lane whose money family lists ROUTED_TO the
|
|
290
|
+
* reads name SWAPPED from a trader to the pool and ROUTED_TO for the route; on
|
|
291
|
+
* any other lane they are the reads of chain-insights 0.81.0, byte for byte.
|
|
174
292
|
*/
|
|
175
293
|
var dex_tool_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
176
294
|
META_DEX_LOOKUP_DESCRIPTION: () => META_DEX_LOOKUP_DESCRIPTION,
|
|
@@ -181,7 +299,7 @@ var dex_tool_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
181
299
|
const META_DEX_LOOKUP_TOOL = "meta_dex_lookup";
|
|
182
300
|
const META_DEX_LOOKUP_SCHEMA = "chain-insights.meta-dex-lookup.v1";
|
|
183
301
|
const META_DEX_LOOKUP_TITLE = "Exchange by name or address";
|
|
184
|
-
const META_DEX_LOOKUP_DESCRIPTION =
|
|
302
|
+
const META_DEX_LOOKUP_DESCRIPTION = `Call this first when a question names a decentralized exchange, a launchpad or a vault (Aero, Aerodrome, Velodrome, up., Raphael, Topaz, Uniswap, PancakeSwap, Balancer, Curve, Penguin, Virtuals, ...) and gives no address. It turns the name into the exchange's factories, routers or pool manager, its biggest pools, and the first reads to send, with every address in full. A misspelling within two letters is taken and named in took_for. When matched is null the name is not covered: say so, list covered, and send no graph query for the name. Never ask the user for a pool, factory or router address. When the user gives a contract address instead of a name, send it as address (0x plus 40 hex, any case, with no name): the answer is the exchange whose factory, router or manager it is, and took_for names the role it holds. When matched is null no exchange row holds the address: send no read for it. A centralized exchange (Binance, OKX, Bitget) goes to meta_exchange_lookup instead. Give a name or an address, not both. ${require_layer_routing.LEVEL_RULE} The first reads follow the lane: where it serves ROUTED_TO, the traders of a pool are its SWAPPED links and the route of a trader is ROUTED_TO.`;
|
|
185
303
|
const META_DEX_LOOKUP_ANNOTATIONS = {
|
|
186
304
|
readOnlyHint: true,
|
|
187
305
|
idempotentHint: true,
|
|
@@ -308,17 +426,21 @@ function readMatch(entry, members, read) {
|
|
|
308
426
|
};
|
|
309
427
|
}
|
|
310
428
|
const ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/;
|
|
429
|
+
/** The hint's last rule on a lane with the levels; the graph of before keeps its 0.81.0 text. */
|
|
430
|
+
const LEVELS_HINT = `${require_layer_routing.LEVEL_RULE} Read families before a whole-chain SWAPPED search: it is sent when behind_dex is at most 100000, and a ROUTED_TO search when behind_money is. Never ask the user for an address.`;
|
|
431
|
+
const ROUTE_HINT = "Read families before a SWAPPED search: it is sent when behind_dex is at most 100000. Never ask the user for an address.";
|
|
311
432
|
function hintFor(result, name, address = null) {
|
|
433
|
+
const closing = result.swap_links === "levels" ? LEVELS_HINT : ROUTE_HINT;
|
|
312
434
|
if (address !== null && !result.matched) return `${require_answer_hint.ANSWER_HINT} No exchange row holds ${address}: it is not a registered exchange contract. Send no exchange read for it; read the graph for what the address did.`;
|
|
313
435
|
if (address !== null && result.matched) {
|
|
314
436
|
const { matched } = result;
|
|
315
|
-
return `${require_answer_hint.ANSWER_HINT} Say in one line: "${address} is a ${result.took_for} row of ${matched.display}." Ask nothing. Exchange ${matched.display}, trail ${matched.trail_type}: send the first reads of recipe, anchored on the addresses above, and load ${matched.skill} when this host has skills.
|
|
437
|
+
return `${require_answer_hint.ANSWER_HINT} Say in one line: "${address} is a ${result.took_for} row of ${matched.display}." Ask nothing. Exchange ${matched.display}, trail ${matched.trail_type}: send the first reads of recipe, anchored on the addresses above, and load ${matched.skill} when this host has skills. ` + closing;
|
|
316
438
|
}
|
|
317
439
|
if (name === null) return `${require_answer_hint.ANSWER_HINT} These are the exchanges the registry covers. Call meta_dex_lookup with a name for its addresses and first reads.`;
|
|
318
440
|
if (result.matched) {
|
|
319
441
|
const { matched } = result;
|
|
320
442
|
const took = result.took_for ? `Say in one line: "I took ${matched.display} for ${result.took_for}." Ask nothing. ` : "";
|
|
321
|
-
return `${require_answer_hint.ANSWER_HINT} ${took}Exchange ${matched.display}, trail ${matched.trail_type}: send the first reads of recipe, anchored on the addresses above, and load ${matched.skill} when this host has skills.
|
|
443
|
+
return `${require_answer_hint.ANSWER_HINT} ${took}Exchange ${matched.display}, trail ${matched.trail_type}: send the first reads of recipe, anchored on the addresses above, and load ${matched.skill} when this host has skills. ` + closing;
|
|
322
444
|
}
|
|
323
445
|
if (result.candidates.length > 0) {
|
|
324
446
|
const names = result.candidates.map((candidate) => `${candidate.display} (${candidate.dex})`).join(", ");
|
|
@@ -432,6 +554,12 @@ async function handleMetaDexLookup(args, deps) {
|
|
|
432
554
|
} catch (err) {
|
|
433
555
|
notes.push(`The graph reads failed: ${deps.describeFailure(err)}`);
|
|
434
556
|
}
|
|
557
|
+
let shape = "route";
|
|
558
|
+
if (!unavailable && deps.linkShape) try {
|
|
559
|
+
shape = await deps.linkShape(network);
|
|
560
|
+
} catch {
|
|
561
|
+
shape = "route";
|
|
562
|
+
}
|
|
435
563
|
const read = readMatch(entry, members, members.size > 0);
|
|
436
564
|
notes.push(...read.notes);
|
|
437
565
|
const contractsOf = (role) => [...read.contracts.values()].filter((contract) => contract.role === role);
|
|
@@ -445,7 +573,7 @@ async function handleMetaDexLookup(args, deps) {
|
|
|
445
573
|
routers: contractsOf("router"),
|
|
446
574
|
manager: contractsOf("manager")[0] ?? null,
|
|
447
575
|
pools: read.pools,
|
|
448
|
-
recipe: recipeFor(entry, topPool)
|
|
576
|
+
recipe: recipeFor(entry, topPool, shape)
|
|
449
577
|
};
|
|
450
578
|
const result = {
|
|
451
579
|
...base,
|
|
@@ -454,6 +582,7 @@ async function handleMetaDexLookup(args, deps) {
|
|
|
454
582
|
candidates: [],
|
|
455
583
|
covered: match.covered,
|
|
456
584
|
families: read.families,
|
|
585
|
+
...shape === "levels" ? { swap_links: "levels" } : {},
|
|
457
586
|
...notes.length > 0 ? { notes } : {}
|
|
458
587
|
};
|
|
459
588
|
return textResult({
|