chain-insights 0.85.2 → 0.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +2 -0
  2. package/bin/install.cjs +2 -1
  3. package/dist/{active-q3yViZhc.cjs → active-COPA14FA.cjs} +2 -16
  4. package/dist/{active-D2aabYRF.mjs → active-CyC4jFka.mjs} +2 -7
  5. package/dist/{active-D2aabYRF.mjs.map → active-CyC4jFka.mjs.map} +1 -1
  6. package/dist/address-card-C-NB03XP.cjs +218 -0
  7. package/dist/address-card-LYaT5yz0.mjs +190 -0
  8. package/dist/address-card-LYaT5yz0.mjs.map +1 -0
  9. package/dist/address-risk-DPuXBsvH.cjs +806 -0
  10. package/dist/address-risk-Da6FsfGx.mjs +653 -0
  11. package/dist/address-risk-Da6FsfGx.mjs.map +1 -0
  12. package/dist/{capabilities-Mxa4oQdd.cjs → capabilities-DkNreyv7.cjs} +1 -1
  13. package/dist/{capabilities-bZOr5Ads.mjs → capabilities-w5bNR7F9.mjs} +2 -2
  14. package/dist/{capabilities-bZOr5Ads.mjs.map → capabilities-w5bNR7F9.mjs.map} +1 -1
  15. package/dist/cli.cjs +138 -46
  16. package/dist/cli.mjs +138 -46
  17. package/dist/cli.mjs.map +1 -1
  18. package/dist/{deployer-screen-B5yrXZGo.mjs → deployer-screen-Bkw_sz94.mjs} +3 -3
  19. package/dist/{deployer-screen-B5yrXZGo.mjs.map → deployer-screen-Bkw_sz94.mjs.map} +1 -1
  20. package/dist/{deployer-screen-0SOQ_HFf.cjs → deployer-screen-CFLi7OeH.cjs} +2 -2
  21. package/dist/{dex-registry-BY67f4Ul.mjs → dex-registry-Bkri0--q.mjs} +10 -2
  22. package/dist/{dex-registry-BY67f4Ul.mjs.map → dex-registry-Bkri0--q.mjs.map} +1 -1
  23. package/dist/{dex-registry-BhGJUG9_.cjs → dex-registry-CyR3GyRr.cjs} +20 -0
  24. package/dist/{dex-tool-7BK_gD6H.mjs → dex-tool-D0K_Qx4N.mjs} +4 -4
  25. package/dist/dex-tool-D0K_Qx4N.mjs.map +1 -0
  26. package/dist/{dex-tool-Be9NAuD8.cjs → dex-tool-DQ5Eg0LO.cjs} +3 -3
  27. package/dist/{exchange-deposit-check-C5MseGlZ.cjs → exchange-deposit-check-BNzkwQeW.cjs} +18 -18
  28. package/dist/{exchange-deposit-check-CXHZCHWW.mjs → exchange-deposit-check-DIALj2sm.mjs} +19 -19
  29. package/dist/exchange-deposit-check-DIALj2sm.mjs.map +1 -0
  30. package/dist/{exchange-registry-CT0rRW__.cjs → exchange-registry-CEgkeQV1.cjs} +16 -93
  31. package/dist/{exchange-registry-CoLgHw6d.mjs → exchange-registry-Dr5UtcT5.mjs} +17 -94
  32. package/dist/exchange-registry-Dr5UtcT5.mjs.map +1 -0
  33. package/dist/{exchange-tool-Dc46SJ49.mjs → exchange-tool-B7E29YoQ.mjs} +4 -4
  34. package/dist/exchange-tool-B7E29YoQ.mjs.map +1 -0
  35. package/dist/{exchange-tool-B2SMeC5f.cjs → exchange-tool-CXaUBAd2.cjs} +3 -3
  36. package/dist/{graph-schema-CcrYPpSv.cjs → graph-schema-Bn3txQCj.cjs} +115 -12
  37. package/dist/{graph-schema-CRQuKya1.mjs → graph-schema-DvABR1yl.mjs} +97 -12
  38. package/dist/graph-schema-DvABR1yl.mjs.map +1 -0
  39. package/dist/{layer-routing-YDj-ynG9.cjs → layer-routing-j48SQ8Wk.cjs} +2 -2
  40. package/dist/{layer-routing-DCJVNN6O.mjs → layer-routing-r4IbIQSr.mjs} +3 -3
  41. package/dist/layer-routing-r4IbIQSr.mjs.map +1 -0
  42. package/dist/mcp-proxy.cjs +62 -15
  43. package/dist/mcp-proxy.d.cts.map +1 -1
  44. package/dist/mcp-proxy.d.mts.map +1 -1
  45. package/dist/mcp-proxy.mjs +62 -15
  46. package/dist/mcp-proxy.mjs.map +1 -1
  47. package/dist/public-file-BISyAesm.mjs +133 -0
  48. package/dist/public-file-BISyAesm.mjs.map +1 -0
  49. package/dist/public-file-DDp2CrUl.cjs +138 -0
  50. package/dist/{request-timeout-DxwNijQD.cjs → request-timeout-BXiIt9Jy.cjs} +0 -1
  51. package/dist/{request-timeout-K3ljP0pa.mjs → request-timeout-DetG2xO4.mjs} +2 -2
  52. package/dist/{request-timeout-K3ljP0pa.mjs.map → request-timeout-DetG2xO4.mjs.map} +1 -1
  53. package/dist/{token-lookup-Cf59VdGe.mjs → token-lookup-Ck0q7crJ.mjs} +2 -2
  54. package/dist/{token-lookup-Cf59VdGe.mjs.map → token-lookup-Ck0q7crJ.mjs.map} +1 -1
  55. package/dist/{token-lookup-DqjSRIxd.cjs → token-lookup-DLe4erP9.cjs} +1 -1
  56. package/dist/token-risk-CpMfFRoY.cjs +1004 -0
  57. package/dist/token-risk-DhnJc2kJ.mjs +971 -0
  58. package/dist/token-risk-DhnJc2kJ.mjs.map +1 -0
  59. package/dist/{tool-visibility-D8Up081E.cjs → tool-visibility-BCa-tmyZ.cjs} +11 -2
  60. package/dist/{tool-visibility-DuTds7V4.mjs → tool-visibility-BstrSl4s.mjs} +12 -3
  61. package/dist/tool-visibility-BstrSl4s.mjs.map +1 -0
  62. package/docs/contributing.md +10 -8
  63. package/docs/development.md +5 -5
  64. package/docs/evals.md +16 -1
  65. package/docs/graph-query-compatibility.md +15 -2
  66. package/docs/graph-tools.md +44 -6
  67. package/docs/mcp-proxy.md +189 -8
  68. package/docs/stability.md +4 -5
  69. package/docs/testing.md +76 -0
  70. package/package.json +1 -1
  71. package/registry/README.md +20 -5
  72. package/registry/address-card.json +680 -0
  73. package/skills/chain-insights-address-risk/SKILL.md +61 -0
  74. package/skills/chain-insights-address-risk/agents/openai.yaml +4 -0
  75. package/skills/chain-insights-aml-exchange/SKILL.md +9 -7
  76. package/skills/chain-insights-cypher/SKILL.md +79 -3
  77. package/skills/chain-insights-token-risk/SKILL.md +81 -0
  78. package/skills/chain-insights-token-risk/agents/openai.yaml +4 -0
  79. package/skills/chain-insights-virtuals/reference.md +1 -1
  80. package/dist/dex-tool-7BK_gD6H.mjs.map +0 -1
  81. package/dist/exchange-deposit-check-CXHZCHWW.mjs.map +0 -1
  82. package/dist/exchange-registry-CoLgHw6d.mjs.map +0 -1
  83. package/dist/exchange-tool-Dc46SJ49.mjs.map +0 -1
  84. package/dist/graph-schema-CRQuKya1.mjs.map +0 -1
  85. package/dist/layer-routing-DCJVNN6O.mjs.map +0 -1
  86. package/dist/public-tools-CBszU2oX.cjs +0 -1334
  87. package/dist/public-tools-DVhUjSDV.mjs +0 -1333
  88. package/dist/public-tools-DVhUjSDV.mjs.map +0 -1
  89. package/dist/tool-visibility-DuTds7V4.mjs.map +0 -1
@@ -0,0 +1,133 @@
1
+ import { n as DEX_REGISTRY_TTL_MS, t as DEX_REGISTRY_FETCH_BUDGET_MS } from "./dex-registry-Bkri0--q.mjs";
2
+ import path from "node:path";
3
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
4
+ // src/mcp/public-file.ts
5
+ /**
6
+ * One public file of this repository, read at run time by the proxy.
7
+ *
8
+ * The exchange lookup (registry/exchanges/<network>.json) and the address card
9
+ * dictionary (registry/address-card.json) are read the same way:
10
+ *
11
+ * cached ~/.chain-insights/cache/<name>.json, younger than one hour
12
+ * fetched the copy on main over raw.githubusercontent.com, within 3 s,
13
+ * at most once an hour, never two fetches of one file in flight
14
+ * packaged the copy in the installed package
15
+ *
16
+ * A fetched file is used only when it passes the file's rules. A malformed
17
+ * file never replaces a good cache: the stale cache keeps answering and one
18
+ * line names the fault. A packaged copy with a higher version than the cache
19
+ * or the fetched file wins, so an upgrade is never answered from an older
20
+ * file. A file merged on main reaches every running proxy within the hour,
21
+ * with no release.
22
+ *
23
+ * The DEX registry (src/mcp/dex-registry.ts) keeps its own loader: its cache
24
+ * file has its own shape, and a network it does not cover is refused.
25
+ */
26
+ function isRecord(value) {
27
+ return !!value && typeof value === "object" && !Array.isArray(value);
28
+ }
29
+ async function readCache(spec) {
30
+ try {
31
+ const parsed = JSON.parse(await readFile(spec.cachePath, "utf8"));
32
+ if (!isRecord(parsed) || typeof parsed.checked_at_ms !== "number") return null;
33
+ if (parsed.source !== "fetched" && parsed.source !== "packaged") return null;
34
+ if (spec.fault(parsed.document) !== null) return null;
35
+ return parsed;
36
+ } catch {
37
+ return null;
38
+ }
39
+ }
40
+ async function writeCache(target, file) {
41
+ await mkdir(path.dirname(target), { recursive: true });
42
+ const scratch = `${target}.${process.pid}.tmp`;
43
+ await writeFile(scratch, JSON.stringify(file, null, 2) + "\n", { mode: 384 });
44
+ await rename(scratch, target);
45
+ }
46
+ async function fetchDocument(spec, options) {
47
+ const { url } = spec;
48
+ let response;
49
+ try {
50
+ response = await (options.fetch ?? fetch)(url, { signal: AbortSignal.timeout(options.budgetMs ?? DEX_REGISTRY_FETCH_BUDGET_MS) });
51
+ } catch (err) {
52
+ return { fault: `${url} unreachable: ${err instanceof Error ? err.message : String(err)}` };
53
+ }
54
+ if (response.status !== 200) return { fault: `${url} answered HTTP ${response.status}` };
55
+ let parsed;
56
+ try {
57
+ parsed = JSON.parse(await response.text());
58
+ } catch {
59
+ return { fault: `${url} is not JSON` };
60
+ }
61
+ const fault = spec.fault(parsed);
62
+ return fault ? { fault: `${url} is malformed: ${fault}` } : { document: parsed };
63
+ }
64
+ const inFlight = /* @__PURE__ */ new Map();
65
+ /**
66
+ * The file: the fresh cache, else the public copy, else the stale cache, else
67
+ * the packaged copy. Null when there is no copy anywhere; it never throws.
68
+ */
69
+ async function loadPublicFile(spec, options = {}) {
70
+ const now = options.now ?? Date.now;
71
+ const { packaged } = spec;
72
+ const pick = (document, source) => packaged !== null && spec.version(packaged) > spec.version(document) ? {
73
+ document: packaged,
74
+ source: "packaged"
75
+ } : {
76
+ document,
77
+ source
78
+ };
79
+ const cache = await readCache(spec);
80
+ const age = cache ? now() - cache.checked_at_ms : Infinity;
81
+ if (cache && age >= 0 && age < DEX_REGISTRY_TTL_MS) return pick(cache.document, cache.source === "fetched" ? "cached" : "packaged");
82
+ const running = inFlight.get(spec.cachePath);
83
+ if (running) return running;
84
+ const load = (async () => {
85
+ const save = async (file) => {
86
+ try {
87
+ await writeCache(spec.cachePath, file);
88
+ } catch (err) {
89
+ spec.log(`the cache ${spec.cachePath} could not be written: ${err instanceof Error ? err.message : String(err)}`);
90
+ }
91
+ };
92
+ const outcome = await fetchDocument(spec, options);
93
+ const checked = now();
94
+ if ("document" in outcome) {
95
+ await save({
96
+ document: outcome.document,
97
+ checked_at_ms: checked,
98
+ source: "fetched"
99
+ });
100
+ return pick(outcome.document, "fetched");
101
+ }
102
+ if (cache) {
103
+ spec.log(outcome.fault);
104
+ await save({
105
+ ...cache,
106
+ checked_at_ms: checked
107
+ });
108
+ return pick(cache.document, cache.source === "fetched" ? "cached" : "packaged");
109
+ }
110
+ if (packaged !== null) {
111
+ spec.log(outcome.fault);
112
+ await save({
113
+ document: packaged,
114
+ checked_at_ms: checked,
115
+ source: "packaged"
116
+ });
117
+ return {
118
+ document: packaged,
119
+ source: "packaged"
120
+ };
121
+ }
122
+ return null;
123
+ })();
124
+ inFlight.set(spec.cachePath, load);
125
+ try {
126
+ return await load;
127
+ } finally {
128
+ inFlight.delete(spec.cachePath);
129
+ }
130
+ }
131
+ export { loadPublicFile as t };
132
+
133
+ //# sourceMappingURL=public-file-BISyAesm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-file-BISyAesm.mjs","names":[],"sources":["../src/mcp/public-file.ts"],"sourcesContent":["/**\n * One public file of this repository, read at run time by the proxy.\n *\n * The exchange lookup (registry/exchanges/<network>.json) and the address card\n * dictionary (registry/address-card.json) are read the same way:\n *\n * cached ~/.chain-insights/cache/<name>.json, younger than one hour\n * fetched the copy on main over raw.githubusercontent.com, within 3 s,\n * at most once an hour, never two fetches of one file in flight\n * packaged the copy in the installed package\n *\n * A fetched file is used only when it passes the file's rules. A malformed\n * file never replaces a good cache: the stale cache keeps answering and one\n * line names the fault. A packaged copy with a higher version than the cache\n * or the fetched file wins, so an upgrade is never answered from an older\n * file. A file merged on main reaches every running proxy within the hour,\n * with no release.\n *\n * The DEX registry (src/mcp/dex-registry.ts) keeps its own loader: its cache\n * file has its own shape, and a network it does not cover is refused.\n */\n\nimport { mkdir, readFile, rename, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { DEX_REGISTRY_FETCH_BUDGET_MS, DEX_REGISTRY_TTL_MS } from './dex-registry.js'\n\nexport type PublicFileSource = 'fetched' | 'cached' | 'packaged'\n\nexport interface LoadedPublicFile<T> {\n document: T\n source: PublicFileSource\n}\n\nexport interface PublicFileSpec<T> {\n /** The URL of the copy on main, or its override. */\n url: string\n /** The cache file, under the chain-insights home. */\n cachePath: string\n /** The fault of a document, or null when it passes the rules. */\n fault: (value: unknown) => string | null\n /** The packaged copy, or null when the package carries none. */\n packaged: T | null\n /** The version of a document: the higher one wins against the packaged copy. */\n version: (document: T) => number\n /** One line per fault: a failed fetch, a malformed file, a cache that cannot be written. */\n log: (line: string) => void\n}\n\nexport interface PublicFileOptions {\n fetch?: typeof fetch\n now?: () => number\n budgetMs?: number\n}\n\ninterface CacheFile<T> {\n document: T\n checked_at_ms: number\n source: 'fetched' | 'packaged'\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nasync function readCache<T>(spec: PublicFileSpec<T>): Promise<CacheFile<T> | null> {\n try {\n const parsed = JSON.parse(await readFile(spec.cachePath, 'utf8')) as unknown\n if (!isRecord(parsed) || typeof parsed.checked_at_ms !== 'number') return null\n if (parsed.source !== 'fetched' && parsed.source !== 'packaged') return null\n if (spec.fault(parsed.document) !== null) return null\n return parsed as unknown as CacheFile<T>\n } catch {\n return null\n }\n}\n\nasync function writeCache<T>(target: string, file: CacheFile<T>): Promise<void> {\n await mkdir(path.dirname(target), { recursive: true })\n // Written beside the target and renamed, so a second proxy never reads half of it.\n const scratch = `${target}.${process.pid}.tmp`\n await writeFile(scratch, JSON.stringify(file, null, 2) + '\\n', { mode: 0o600 })\n await rename(scratch, target)\n}\n\nasync function fetchDocument<T>(\n spec: PublicFileSpec<T>,\n options: PublicFileOptions\n): Promise<{ document: T } | { fault: string }> {\n const { url } = spec\n let response: Response\n try {\n response = await (options.fetch ?? fetch)(url, {\n signal: AbortSignal.timeout(options.budgetMs ?? DEX_REGISTRY_FETCH_BUDGET_MS),\n })\n } catch (err) {\n return { fault: `${url} unreachable: ${err instanceof Error ? err.message : String(err)}` }\n }\n if (response.status !== 200) return { fault: `${url} answered HTTP ${response.status}` }\n let parsed: unknown\n try {\n parsed = JSON.parse(await response.text())\n } catch {\n return { fault: `${url} is not JSON` }\n }\n const fault = spec.fault(parsed)\n return fault ? { fault: `${url} is malformed: ${fault}` } : { document: parsed as T }\n}\n\n// Loads in flight, by cache file: two calls at once share one fetch.\nconst inFlight = new Map<string, Promise<LoadedPublicFile<unknown> | null>>()\n\n/**\n * The file: the fresh cache, else the public copy, else the stale cache, else\n * the packaged copy. Null when there is no copy anywhere; it never throws.\n */\nexport async function loadPublicFile<T>(\n spec: PublicFileSpec<T>,\n options: PublicFileOptions = {}\n): Promise<LoadedPublicFile<T> | null> {\n const now = options.now ?? Date.now\n const { packaged } = spec\n const pick = (document: T, source: PublicFileSource): LoadedPublicFile<T> =>\n packaged !== null && spec.version(packaged) > spec.version(document)\n ? { document: packaged, source: 'packaged' }\n : { document, source }\n\n const cache = await readCache(spec)\n const age = cache ? now() - cache.checked_at_ms : Infinity\n if (cache && age >= 0 && age < DEX_REGISTRY_TTL_MS) {\n return pick(cache.document, cache.source === 'fetched' ? 'cached' : 'packaged')\n }\n\n const running = inFlight.get(spec.cachePath)\n if (running) return running as Promise<LoadedPublicFile<T> | null>\n const load = (async (): Promise<LoadedPublicFile<T> | null> => {\n const save = async (file: CacheFile<T>): Promise<void> => {\n try {\n await writeCache(spec.cachePath, file)\n } catch (err) {\n spec.log(\n `the cache ${spec.cachePath} could not be written: ${err instanceof Error ? err.message : String(err)}`\n )\n }\n }\n const outcome = await fetchDocument(spec, options)\n const checked = now()\n if ('document' in outcome) {\n await save({ document: outcome.document, checked_at_ms: checked, source: 'fetched' })\n return pick(outcome.document, 'fetched')\n }\n if (cache) {\n // The stale cache keeps answering, and the next fetch waits an hour.\n spec.log(outcome.fault)\n await save({ ...cache, checked_at_ms: checked })\n return pick(cache.document, cache.source === 'fetched' ? 'cached' : 'packaged')\n }\n if (packaged !== null) {\n spec.log(outcome.fault)\n await save({ document: packaged, checked_at_ms: checked, source: 'packaged' })\n return { document: packaged, source: 'packaged' }\n }\n return null\n })()\n inFlight.set(spec.cachePath, load)\n try {\n return await load\n } finally {\n inFlight.delete(spec.cachePath)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAS,SAAS,OAAkD;CAClE,OAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACrE;AAEA,eAAe,UAAa,MAAuD;CACjF,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,MAAM,SAAS,KAAK,WAAW,MAAM,CAAC;EAChE,IAAI,CAAC,SAAS,MAAM,KAAK,OAAO,OAAO,kBAAkB,UAAU,OAAO;EAC1E,IAAI,OAAO,WAAW,aAAa,OAAO,WAAW,YAAY,OAAO;EACxE,IAAI,KAAK,MAAM,OAAO,QAAQ,MAAM,MAAM,OAAO;EACjD,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAe,WAAc,QAAgB,MAAmC;CAC9E,MAAM,MAAM,KAAK,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;CAErD,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,IAAI;CACzC,MAAM,UAAU,SAAS,KAAK,UAAU,MAAM,MAAM,CAAC,IAAI,MAAM,EAAE,MAAM,IAAM,CAAC;CAC9E,MAAM,OAAO,SAAS,MAAM;AAC9B;AAEA,eAAe,cACb,MACA,SAC8C;CAC9C,MAAM,EAAE,QAAQ;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WAAW,IAAI;GACvC,SAAS,KAAK;IACZ,KAAK,IACH,aAAa,KAAK,UAAU,yBAAyB,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,GACtG;GACF;EACF;EACA,MAAM,UAAU,MAAM,cAAc,MAAM,OAAO;EACjD,MAAM,UAAU,IAAI;EACpB,IAAI,cAAc,SAAS;GACzB,MAAM,KAAK;IAAE,UAAU,QAAQ;IAAU,eAAe;IAAS,QAAQ;GAAU,CAAC;GACpF,OAAO,KAAK,QAAQ,UAAU,SAAS;EACzC;EACA,IAAI,OAAO;GAET,KAAK,IAAI,QAAQ,KAAK;GACtB,MAAM,KAAK;IAAE,GAAG;IAAO,eAAe;GAAQ,CAAC;GAC/C,OAAO,KAAK,MAAM,UAAU,MAAM,WAAW,YAAY,WAAW,UAAU;EAChF;EACA,IAAI,aAAa,MAAM;GACrB,KAAK,IAAI,QAAQ,KAAK;GACtB,MAAM,KAAK;IAAE,UAAU;IAAU,eAAe;IAAS,QAAQ;GAAW,CAAC;GAC7E,OAAO;IAAE,UAAU;IAAU,QAAQ;GAAW;EAClD;EACA,OAAO;CACT,EAAA,CAAG;CACH,SAAS,IAAI,KAAK,WAAW,IAAI;CACjC,IAAI;EACF,OAAO,MAAM;CACf,UAAU;EACR,SAAS,OAAO,KAAK,SAAS;CAChC;AACF"}
@@ -0,0 +1,138 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
2
+ const require_dex_registry = require("./dex-registry-CyR3GyRr.cjs");
3
+ let node_path = require("node:path");
4
+ node_path = require_rolldown_runtime.__toESM(node_path, 1);
5
+ let node_fs_promises = require("node:fs/promises");
6
+ // src/mcp/public-file.ts
7
+ /**
8
+ * One public file of this repository, read at run time by the proxy.
9
+ *
10
+ * The exchange lookup (registry/exchanges/<network>.json) and the address card
11
+ * dictionary (registry/address-card.json) are read the same way:
12
+ *
13
+ * cached ~/.chain-insights/cache/<name>.json, younger than one hour
14
+ * fetched the copy on main over raw.githubusercontent.com, within 3 s,
15
+ * at most once an hour, never two fetches of one file in flight
16
+ * packaged the copy in the installed package
17
+ *
18
+ * A fetched file is used only when it passes the file's rules. A malformed
19
+ * file never replaces a good cache: the stale cache keeps answering and one
20
+ * line names the fault. A packaged copy with a higher version than the cache
21
+ * or the fetched file wins, so an upgrade is never answered from an older
22
+ * file. A file merged on main reaches every running proxy within the hour,
23
+ * with no release.
24
+ *
25
+ * The DEX registry (src/mcp/dex-registry.ts) keeps its own loader: its cache
26
+ * file has its own shape, and a network it does not cover is refused.
27
+ */
28
+ function isRecord(value) {
29
+ return !!value && typeof value === "object" && !Array.isArray(value);
30
+ }
31
+ async function readCache(spec) {
32
+ try {
33
+ const parsed = JSON.parse(await (0, node_fs_promises.readFile)(spec.cachePath, "utf8"));
34
+ if (!isRecord(parsed) || typeof parsed.checked_at_ms !== "number") return null;
35
+ if (parsed.source !== "fetched" && parsed.source !== "packaged") return null;
36
+ if (spec.fault(parsed.document) !== null) return null;
37
+ return parsed;
38
+ } catch {
39
+ return null;
40
+ }
41
+ }
42
+ async function writeCache(target, file) {
43
+ await (0, node_fs_promises.mkdir)(node_path.default.dirname(target), { recursive: true });
44
+ const scratch = `${target}.${process.pid}.tmp`;
45
+ await (0, node_fs_promises.writeFile)(scratch, JSON.stringify(file, null, 2) + "\n", { mode: 384 });
46
+ await (0, node_fs_promises.rename)(scratch, target);
47
+ }
48
+ async function fetchDocument(spec, options) {
49
+ const { url } = spec;
50
+ let response;
51
+ try {
52
+ response = await (options.fetch ?? fetch)(url, { signal: AbortSignal.timeout(options.budgetMs ?? require_dex_registry.DEX_REGISTRY_FETCH_BUDGET_MS) });
53
+ } catch (err) {
54
+ return { fault: `${url} unreachable: ${err instanceof Error ? err.message : String(err)}` };
55
+ }
56
+ if (response.status !== 200) return { fault: `${url} answered HTTP ${response.status}` };
57
+ let parsed;
58
+ try {
59
+ parsed = JSON.parse(await response.text());
60
+ } catch {
61
+ return { fault: `${url} is not JSON` };
62
+ }
63
+ const fault = spec.fault(parsed);
64
+ return fault ? { fault: `${url} is malformed: ${fault}` } : { document: parsed };
65
+ }
66
+ const inFlight = /* @__PURE__ */ new Map();
67
+ /**
68
+ * The file: the fresh cache, else the public copy, else the stale cache, else
69
+ * the packaged copy. Null when there is no copy anywhere; it never throws.
70
+ */
71
+ async function loadPublicFile(spec, options = {}) {
72
+ const now = options.now ?? Date.now;
73
+ const { packaged } = spec;
74
+ const pick = (document, source) => packaged !== null && spec.version(packaged) > spec.version(document) ? {
75
+ document: packaged,
76
+ source: "packaged"
77
+ } : {
78
+ document,
79
+ source
80
+ };
81
+ const cache = await readCache(spec);
82
+ const age = cache ? now() - cache.checked_at_ms : Infinity;
83
+ if (cache && age >= 0 && age < require_dex_registry.DEX_REGISTRY_TTL_MS) return pick(cache.document, cache.source === "fetched" ? "cached" : "packaged");
84
+ const running = inFlight.get(spec.cachePath);
85
+ if (running) return running;
86
+ const load = (async () => {
87
+ const save = async (file) => {
88
+ try {
89
+ await writeCache(spec.cachePath, file);
90
+ } catch (err) {
91
+ spec.log(`the cache ${spec.cachePath} could not be written: ${err instanceof Error ? err.message : String(err)}`);
92
+ }
93
+ };
94
+ const outcome = await fetchDocument(spec, options);
95
+ const checked = now();
96
+ if ("document" in outcome) {
97
+ await save({
98
+ document: outcome.document,
99
+ checked_at_ms: checked,
100
+ source: "fetched"
101
+ });
102
+ return pick(outcome.document, "fetched");
103
+ }
104
+ if (cache) {
105
+ spec.log(outcome.fault);
106
+ await save({
107
+ ...cache,
108
+ checked_at_ms: checked
109
+ });
110
+ return pick(cache.document, cache.source === "fetched" ? "cached" : "packaged");
111
+ }
112
+ if (packaged !== null) {
113
+ spec.log(outcome.fault);
114
+ await save({
115
+ document: packaged,
116
+ checked_at_ms: checked,
117
+ source: "packaged"
118
+ });
119
+ return {
120
+ document: packaged,
121
+ source: "packaged"
122
+ };
123
+ }
124
+ return null;
125
+ })();
126
+ inFlight.set(spec.cachePath, load);
127
+ try {
128
+ return await load;
129
+ } finally {
130
+ inFlight.delete(spec.cachePath);
131
+ }
132
+ }
133
+ Object.defineProperty(exports, "loadPublicFile", {
134
+ enumerable: true,
135
+ get: function() {
136
+ return loadPublicFile;
137
+ }
138
+ });
@@ -6,5 +6,4 @@ function graphToolRequestOptions(tool) {
6
6
  maxTotalTimeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS
7
7
  };
8
8
  }
9
- exports.GRAPH_TOOL_REQUEST_TIMEOUT_MS = GRAPH_TOOL_REQUEST_TIMEOUT_MS;
10
9
  exports.graphToolRequestOptions = graphToolRequestOptions;
@@ -6,6 +6,6 @@ function graphToolRequestOptions(tool) {
6
6
  maxTotalTimeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS
7
7
  };
8
8
  }
9
- export { GRAPH_TOOL_REQUEST_TIMEOUT_MS, graphToolRequestOptions };
9
+ export { graphToolRequestOptions };
10
10
 
11
- //# sourceMappingURL=request-timeout-K3ljP0pa.mjs.map
11
+ //# sourceMappingURL=request-timeout-DetG2xO4.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-timeout-K3ljP0pa.mjs","names":[],"sources":["../src/mcp/request-timeout.ts"],"sourcesContent":["import type { Client } from '@modelcontextprotocol/sdk/client/index.js'\n\n// Above the graph server's 100 s batch budget and the 125 s edge limit.\n// The SDK default is 60 s and fails a batch the server is still answering.\nexport const GRAPH_TOOL_REQUEST_TIMEOUT_MS = 5 * 60 * 1000\n\nexport function graphToolRequestOptions(tool: string): Parameters<Client['callTool']>[2] {\n if (tool === 'graph_query' || tool === 'graph_query_batch') {\n return {\n timeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS,\n maxTotalTimeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS,\n }\n }\n return undefined\n}\n"],"mappings":";AAIA,MAAa,gCAAgC;AAE7C,SAAgB,wBAAwB,MAAiD;CACvF,IAAI,SAAS,iBAAiB,SAAS,qBACrC,OAAO;EACL,SAAS;EACT,iBAAiB;CACnB;AAGJ"}
1
+ {"version":3,"file":"request-timeout-DetG2xO4.mjs","names":[],"sources":["../src/mcp/request-timeout.ts"],"sourcesContent":["import type { Client } from '@modelcontextprotocol/sdk/client/index.js'\n\n// Above the graph server's 100 s batch budget and the 125 s edge limit.\n// The SDK default is 60 s and fails a batch the server is still answering.\nexport const GRAPH_TOOL_REQUEST_TIMEOUT_MS = 5 * 60 * 1000\n\nexport function graphToolRequestOptions(tool: string): Parameters<Client['callTool']>[2] {\n if (tool === 'graph_query' || tool === 'graph_query_batch') {\n return {\n timeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS,\n maxTotalTimeout: GRAPH_TOOL_REQUEST_TIMEOUT_MS,\n }\n }\n return undefined\n}\n"],"mappings":";AAIA,MAAa,gCAAgC;AAE7C,SAAgB,wBAAwB,MAAiD;CACvF,IAAI,SAAS,iBAAiB,SAAS,qBACrC,OAAO;EACL,SAAS;EACT,iBAAiB;CACnB;AAGJ"}
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.mjs";
2
2
  import { t as ANSWER_HINT } from "./answer-hint-vOE1O6Lf.mjs";
3
- import { d as normalizeDexNetwork, r as DexRegistryError } from "./dex-registry-BY67f4Ul.mjs";
3
+ import { p as normalizeDexNetwork, r as DexRegistryError } from "./dex-registry-Bkri0--q.mjs";
4
4
  import { i as isEpochMs, o as utcText } from "./print-result-IFARsMnL.mjs";
5
5
  // src/mcp/token-lookup.ts
6
6
  /**
@@ -353,4 +353,4 @@ async function handleMetaTokenLookup(args, deps) {
353
353
  }
354
354
  export { SYMBOL_MAX as a, refusalOf as c, META_TOKEN_LOOKUP_TOOL as i, token_lookup_exports as l, META_TOKEN_LOOKUP_DESCRIPTION as n, handleMetaTokenLookup as o, META_TOKEN_LOOKUP_TITLE as r, membersOf as s, META_TOKEN_LOOKUP_ANNOTATIONS as t };
355
355
 
356
- //# sourceMappingURL=token-lookup-Cf59VdGe.mjs.map
356
+ //# sourceMappingURL=token-lookup-Ck0q7crJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-lookup-Cf59VdGe.mjs","names":[],"sources":["../src/mcp/token-lookup.ts"],"sourcesContent":["/**\n * meta_token_lookup: a ticker or a token name becomes its contracts.\n *\n * A local tool of the proxy. It sends one anchored facts read of the Asset\n * lookup by symbol, the same read by name when the symbol answers nothing, and\n * then the creator and the factory of each candidate from topology, one batch\n * member per candidate. Nothing is matched here: the graph server matches the\n * symbol or the name, case-insensitively and exactly, and orders the rows\n * verified first, then oldest first. The proxy keeps that order.\n *\n * The read also asks the server how many contracts match. When more match than\n * the 25 listed, a second read brings the newest: a copy of a verified token is\n * made after it, so the oldest 25 alone hide exactly the copies. A server that\n * does not count yet is read the old way, and the answer says the list is a part.\n *\n * Tickers collide on purpose: clones reuse a symbol to borrow its trust. The\n * tool never picks one. The description below is the contract with every\n * host, Claude Desktop chat included, which reads no skill.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport { isEpochMs, utcText } from './timestamp-text.js'\n\nexport const META_TOKEN_LOOKUP_TOOL = 'meta_token_lookup'\nexport const META_TOKEN_LOOKUP_SCHEMA = 'chain-insights.meta-token-lookup.v1' as const\nexport const META_TOKEN_LOOKUP_TITLE = 'Token by ticker or name'\nexport const META_TOKEN_LOOKUP_DESCRIPTION =\n 'Call this first when a question names a token by its ticker or name and gives no contract ' +\n '(TCITY, USDG, SPCX). It returns the contracts on the network that carry that symbol, ' +\n 'verified first, then oldest first, with the count of all of them and, when more than 25 match, ' +\n 'the newest ones too. Tickers collide: never treat the first row as the token. ' +\n 'When several match, name them and ask, or pick by the evidence the user gave. Zero candidates ' +\n 'means no contract carries the symbol: say so, and do not search the web.'\nexport const META_TOKEN_LOOKUP_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const META_TOKEN_LOOKUP_ARGS = ['network', 'symbol'] as const\n\n/** The candidates returned. The read asks for one more, so a full page says there are more. */\nexport const CANDIDATES_MAX = 25\nexport const ROWS_READ = CANDIDATES_MAX + 1\n/** The graph server admits at most 20 members in one graph_query_batch. */\nexport const CREATOR_BATCH_MAX = 20\nexport const SYMBOL_MAX = 64\n\nexport const ADDRESS_INPUT_HINT = 'an address is already an anchor: read it on USE topology'\n\nexport interface TokenCandidate {\n contract: string\n symbol: string | null\n name: string | null\n token_standard: string | null\n decimals: number | null\n verified: boolean\n verification_source: string | null\n first_seen_timestamp: number | null\n first_seen_timestamp_utc: string | null\n creator: string | null\n factory: string | null\n}\n\nexport interface MetaTokenLookupResult {\n schema: typeof META_TOKEN_LOOKUP_SCHEMA\n network: string\n query: string\n matched_on: 'symbol' | 'name' | null\n candidates: TokenCandidate[]\n /** More contracts carry the key than the candidates listed. */\n truncated: boolean\n /** How many contracts carry the key, counted by the server; null when the server does not count. */\n matches: number | null\n /** When more match than the candidates listed: the newest that are not among them, newest first. */\n newest: TokenCandidate[]\n /** With exactly one verified candidate: how many contracts were first seen after it. */\n first_seen_after_verified: { verified_contract: string; count: number; at_least: boolean } | null\n hint: string\n}\n\n/** One graph_query or graph_query_batch reply as the remote client returns it. */\nexport type GraphAnswer = {\n content?: unknown[]\n structuredContent?: unknown\n isError?: boolean\n}\n\nexport interface TokenToolDependencies {\n /** One graph_query through the proxy's remote client, billed as any read. */\n graphQuery: (args: { network: string; query: string }) => Promise<GraphAnswer>\n /** One graph_query_batch through the proxy's remote client, billed as any read. */\n graphQueryBatch: (args: {\n network: string\n queries: Array<{ id: string; query: string }>\n }) => Promise<GraphAnswer>\n /** The reason no read can be sent now, or undefined when the graph is reachable. */\n unavailable?: () => Promise<string | undefined> | string | undefined\n /** The text of a call that threw: payment required, transport. */\n describeFailure: (err: unknown) => string\n}\n\nexport type MetaTokenLookupToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\nconst ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/\nconst CONTRACT_FORM = /^0x[0-9a-f]{40}$/\n// A string literal of the read holds no double quote, no backslash and no\n// control character: the symbol is refused rather than escaped, so the read the\n// server receives is always the read written here.\nfunction unsafeLiteral(text: string): boolean {\n for (const char of text) {\n const code = char.codePointAt(0)!\n if (char === '\"' || char === '\\\\' || code < 0x20 || code === 0x7f) return true\n }\n return false\n}\nconst CODE_PREFIX = /^([a-z][a-z0-9_]*):\\s*/\n// Codes of a read that was stopped, not refused: the same read may answer later.\nconst TRANSIENT_CODE =\n /(timeout|memory_limit|cpu_limit|busy|_failed$|rate_limited|unavailable|too_large|node_error)/\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction errorResult(text: string): MetaTokenLookupToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: MetaTokenLookupResult): MetaTokenLookupToolResult {\n return {\n content: [{ type: 'text', text: JSON.stringify(structured, null, 2) }],\n structuredContent: structured as unknown as Record<string, unknown>,\n isError: false,\n }\n}\n\n/**\n * The facts Asset read by symbol or by name. `counted` asks the server for the\n * number of contracts that match, on every row. `newest` reads the newest 25\n * instead of verified first, then oldest first. With neither it is the read\n * every server admits.\n */\nexport function assetQuery(\n key: 'symbol' | 'name',\n value: string,\n form: 'plain' | 'counted' | 'newest' = 'plain'\n): string {\n return (\n `USE facts MATCH (t:Asset {${key}: \"${value}\"}) ` +\n 'RETURN t.asset_contract AS contract, t.asset_symbol AS symbol, t.name AS name, ' +\n 't.token_standard AS token_standard, t.decimals AS decimals, t.verified AS verified, ' +\n 't.verification_source AS verification_source, t.first_seen_timestamp AS first_seen_timestamp' +\n (form === 'counted' ? ', t.match_count AS match_count' : '') +\n (form === 'newest'\n ? ` ORDER BY t.first_seen_timestamp DESC LIMIT ${CANDIDATES_MAX}`\n : ` LIMIT ${ROWS_READ}`)\n )\n}\n\n/** The topology read of who deployed one contract: the deploying address and the transaction's sender. */\nexport function creatorQuery(contract: string): string {\n return (\n `USE topology MATCH (f:Address)-[d:DEPLOYED_CONTRACT]->(t:Address {address: \"${contract}\"}) ` +\n 'RETURN f.address AS factory, d.tx_origin AS creator LIMIT 1'\n )\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value : null\n\nconst numberOrNull = (value: unknown): number | null => {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)))\n return Number(value)\n return null\n}\n\nconst addressOrNull = (value: unknown): string | null =>\n typeof value === 'string' && ADDRESS_FORM.test(value.trim()) ? value.trim().toLowerCase() : null\n\nfunction verifiedOf(value: unknown): boolean {\n if (typeof value === 'boolean') return value\n if (typeof value === 'number') return value === 1\n if (typeof value === 'string') return ['true', '1'].includes(value.trim().toLowerCase())\n return false\n}\n\nfunction answerText(answer: GraphAnswer): string {\n return (Array.isArray(answer.content) ? answer.content : [])\n .map((block) => (isRecord(block) && typeof block.text === 'string' ? block.text : ''))\n .filter(Boolean)\n .join('\\n')\n .trim()\n}\n\nexport type Refusal = { code: string; text: string; transient: boolean }\n\n/** A graph_query answer that did not answer: its code, its text, and whether the same read may answer later. */\nexport function refusalOf(answer: GraphAnswer): Refusal {\n const text = answerText(answer)\n const detail = isRecord(answer.structuredContent)\n ? answer.structuredContent.error_detail\n : undefined\n const detailCode = isRecord(detail) && typeof detail.code === 'string' ? detail.code : ''\n const detailClass = isRecord(detail) && typeof detail.class === 'string' ? detail.class : ''\n const named = detailCode || CODE_PREFIX.exec(text)?.[1] || ''\n // A refusal that names no class is a stop only when its code says so; a\n // refusal in plain words (\"unknown label Asset\") is a server that lacks the read.\n const transient = detailClass ? detailClass !== 'refused' : TRANSIENT_CODE.test(named)\n const code = named || 'not_served'\n return { code, text: text || `${code}: the graph endpoint refused the read`, transient }\n}\n\n/** The result rows of a graph_query answer, or null when it holds none. */\nfunction rowsOf(answer: GraphAnswer): Array<Record<string, unknown>> | null {\n const facts = isRecord(answer.structuredContent) ? answer.structuredContent.facts : undefined\n const query = isRecord(facts) ? facts.query : undefined\n const results = isRecord(query) ? query.results : undefined\n return Array.isArray(results) ? results.filter(isRecord) : null\n}\n\nexport type Member = { id?: unknown; ok?: unknown; results?: unknown; error?: unknown }\n\n/** The members of a graph_query_batch answer by id. */\nexport function membersOf(answer: GraphAnswer): Map<string, Member> {\n const facts = isRecord(answer.structuredContent) ? answer.structuredContent.facts : undefined\n const queries = isRecord(facts) ? facts.queries : undefined\n const members = new Map<string, Member>()\n if (Array.isArray(queries)) {\n for (const member of queries)\n if (isRecord(member) && typeof member.id === 'string') members.set(member.id, member)\n }\n return members\n}\n\nfunction candidateOf(row: Record<string, unknown>): TokenCandidate | null {\n const contract = textOrNull(row.contract)?.trim().toLowerCase()\n if (!contract) return null\n const firstSeen = numberOrNull(row.first_seen_timestamp)\n return {\n contract,\n symbol: textOrNull(row.symbol),\n name: textOrNull(row.name),\n token_standard: textOrNull(row.token_standard),\n decimals: numberOrNull(row.decimals),\n verified: verifiedOf(row.verified),\n verification_source: textOrNull(row.verification_source),\n first_seen_timestamp: firstSeen,\n first_seen_timestamp_utc: isEpochMs(firstSeen) ? utcText(firstSeen) : null,\n creator: null,\n factory: null,\n }\n}\n\ntype Read =\n | { kind: 'rows'; rows: Array<Record<string, unknown>> }\n | { kind: 'not_served'; refusal: Refusal }\n | { kind: 'failed'; text: string }\n\nasync function readAssets(\n deps: TokenToolDependencies,\n network: string,\n key: 'symbol' | 'name',\n value: string,\n form: 'plain' | 'counted' | 'newest'\n): Promise<Read> {\n let answer: GraphAnswer\n try {\n answer = await deps.graphQuery({ network, query: assetQuery(key, value, form) })\n } catch (err) {\n return { kind: 'failed', text: deps.describeFailure(err) }\n }\n const rows = rowsOf(answer)\n if (answer.isError !== true && rows !== null) return { kind: 'rows', rows }\n const refusal = refusalOf(answer)\n if (answer.isError === true && refusal.transient) return { kind: 'failed', text: refusal.text }\n return { kind: 'not_served', refusal }\n}\n\n/**\n * The creator and the factory of each candidate, written in place. Returns why\n * some creators were not read, or null when every read answered. A read that\n * answered with no row leaves the candidate's creator empty with no note: the\n * graph holds no deployment for it.\n */\nasync function readCreators(\n deps: TokenToolDependencies,\n network: string,\n candidates: TokenCandidate[]\n): Promise<string | null> {\n const contracts = [\n ...new Set(candidates.map((c) => c.contract).filter((c) => CONTRACT_FORM.test(c))),\n ]\n const found = new Map<string, { creator: string | null; factory: string | null }>()\n const reasons: string[] = []\n let unread = candidates.length - candidates.filter((c) => CONTRACT_FORM.test(c.contract)).length\n for (let at = 0; at < contracts.length; at += CREATOR_BATCH_MAX) {\n const chunk = contracts.slice(at, at + CREATOR_BATCH_MAX)\n const queries = chunk.map((contract) => ({\n id: `creator:${contract}`,\n query: creatorQuery(contract),\n }))\n let members = new Map<string, Member>()\n try {\n const answer = await deps.graphQueryBatch({ network, queries })\n members = membersOf(answer)\n if (members.size === 0) {\n reasons.push(\n answer.isError === true ? refusalOf(answer).text : 'the batch answer held no reads'\n )\n }\n } catch (err) {\n reasons.push(deps.describeFailure(err))\n }\n for (const contract of chunk) {\n const member = members.get(`creator:${contract}`)\n if (member?.ok === true && Array.isArray(member.results)) {\n const row = member.results.find(isRecord)\n found.set(contract, {\n creator: row ? addressOrNull(row.creator) : null,\n factory: row ? addressOrNull(row.factory) : null,\n })\n continue\n }\n unread += 1\n if (member && typeof member.error === 'string' && !reasons.includes(member.error))\n reasons.push(member.error)\n }\n }\n for (const candidate of candidates) {\n const read = found.get(candidate.contract)\n if (read) Object.assign(candidate, read)\n }\n if (unread === 0) return null\n return `${unread} of ${candidates.length}${reasons.length > 0 ? `: ${reasons.join('; ')}` : ''}`\n}\n\nconst NO_WEB =\n 'Do not search the web and do not guess a contract: a web page is not a contract on this network.'\n\nfunction hintFor(\n result: Omit<MetaTokenLookupResult, 'hint'>,\n creatorsNotRead: string | null\n): string {\n const { network, query, candidates, matched_on, truncated, matches, newest } = result\n const later = result.first_seen_after_verified\n const parts: string[] = [ANSWER_HINT]\n if (candidates.length === 0) {\n parts.push(\n `No contract on ${network} carries the symbol or the name \"${query}\". Say so in one line. ${NO_WEB} ` +\n 'Ask the user for the contract if they have one.'\n )\n return parts.join(' ')\n }\n if (matched_on === 'name') {\n parts.push(`No contract carries \"${query}\" as its symbol; these carry it as their name.`)\n }\n if (candidates.length === 1) {\n parts.push(\n `One contract on ${network} carries \"${query}\": ${candidates[0]!.contract}. ` +\n 'Say it is the only one on this network, then read it by this full contract on USE topology.'\n )\n } else {\n if (!truncated) {\n parts.push(`${candidates.length} contracts on ${network} carry \"${query}\".`)\n } else if (matches === null) {\n parts.push(\n `More than ${CANDIDATES_MAX} contracts on ${network} carry \"${query}\": how many is not in this answer. ` +\n `candidates lists the ${candidates.length} oldest, the verified first. ` +\n `The list is a part: never give ${candidates.length} or ${ROWS_READ} as the count, say \"more than ${CANDIDATES_MAX}\", and never say that none exist beyond it.`\n )\n } else {\n parts.push(\n `${matches} contracts on ${network} carry \"${query}\". candidates lists ${candidates.length} of them, verified first, then oldest first` +\n `${newest.length > 0 ? `, and newest lists the ${newest.length} newest that are not among them, newest first` : ''}. ` +\n `The lists are a part: the count is ${matches}, never the number of rows.`\n )\n }\n parts.push(\n 'Tickers collide: never treat the first row as the token. Name them, each contract in full, ' +\n 'with its creator and first seen time, and ask which one the user means, or pick one by the evidence the user gave ' +\n '(a creator, a launch date, a price move) and say why.'\n )\n }\n if (later && later.count > 0) {\n parts.push(\n `${later.at_least ? 'At least ' : ''}${later.count} of them ${later.count === 1 ? 'was' : 'were'} first seen after the verified contract ${later.verified_contract}: ` +\n 'each took a symbol that a verified token already carried. That is a copy of the name. A copied name alone is not proof of a scam.'\n )\n }\n if (later && later.at_least) {\n parts.push(\n `This answer does not list every contract first seen after the verified contract ${later.verified_contract}` +\n `${matches === null ? ': it lists the oldest only' : ''}. How many were made after it is not known from this answer` +\n `${later.count === 0 ? ', and a list that shows none does not mean none exist' : ''}. ` +\n 'Never answer that none, or no contract, was created after it; say the list holds the oldest contracts and the later ones are not in it.'\n )\n }\n if (creatorsNotRead) {\n parts.push(\n `The creators were not read for ${creatorsNotRead}. creator and factory are empty there because the read failed, ` +\n 'not because the chain holds none.'\n )\n }\n parts.push('Write every contract and creator in full, 0x plus 40 hex characters.')\n return parts.join(' ')\n}\n\n/** meta_token_lookup, {network, symbol}. Every argument is checked before a read is sent. */\nexport async function handleMetaTokenLookup(\n args: unknown,\n deps: TokenToolDependencies\n): Promise<MetaTokenLookupToolResult> {\n const record = isRecord(args) ? args : {}\n let network: string\n try {\n network = normalizeDexNetwork(record.network)\n } catch (err) {\n return errorResult(\n err instanceof DexRegistryError ? err.message : `invalid_network: ${(err as Error).message}`\n )\n }\n if (typeof record.symbol !== 'string' || record.symbol.trim() === '') {\n return errorResult(\n 'invalid_symbol: symbol is required: the ticker or the name as the user wrote it, for example TCITY'\n )\n }\n const symbol = record.symbol.trim()\n if (symbol.length > SYMBOL_MAX) {\n return errorResult(`invalid_symbol: symbol holds at most ${SYMBOL_MAX} characters`)\n }\n const base = {\n schema: META_TOKEN_LOOKUP_SCHEMA,\n network,\n query: symbol,\n }\n\n if (ADDRESS_FORM.test(symbol)) {\n const address = symbol.toLowerCase()\n return textResult({\n ...base,\n matched_on: null,\n candidates: [],\n truncated: false,\n matches: null,\n newest: [],\n first_seen_after_verified: null,\n hint: `${ANSWER_HINT} ${address} is a contract address, not a ticker: ${ADDRESS_INPUT_HINT}. Send no token lookup for it.`,\n })\n }\n if (unsafeLiteral(symbol)) {\n return errorResult(\n 'invalid_symbol: a symbol holds no double quote, backslash or control character. Send the ticker or the name as plain text.'\n )\n }\n\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n return errorResult(\n `No token read was sent: ${unavailable} The lookup has no answer yet, which is not \"no contract\": try again later, or ask the user for the contract. ${NO_WEB}`\n )\n }\n\n // A server that does not count refuses the counted read; the plain read is\n // the one every server admits.\n let form: 'counted' | 'plain' = 'counted'\n let matchedOn: 'symbol' | 'name' = 'symbol'\n let read = await readAssets(deps, network, 'symbol', symbol, form)\n if (read.kind === 'not_served') {\n form = 'plain'\n read = await readAssets(deps, network, 'symbol', symbol, form)\n }\n if (read.kind === 'rows' && read.rows.length === 0) {\n matchedOn = 'name'\n read = await readAssets(deps, network, 'name', symbol, form)\n }\n if (read.kind === 'failed') {\n return errorResult(\n `The token read failed: ${read.text} This is not \"no contract\": send the same lookup again once, or ask the user for the contract. ${NO_WEB}`\n )\n }\n if (read.kind === 'not_served') {\n return textResult({\n ...base,\n matched_on: null,\n candidates: [],\n truncated: false,\n matches: null,\n newest: [],\n first_seen_after_verified: null,\n hint:\n `${ANSWER_HINT} This lookup gave no answer (${read.refusal.code}). ` +\n `That is not \"no contract carries ${symbol}\": ask the user for the token's contract, 0x plus 40 hex characters. ${NO_WEB}`,\n })\n }\n\n const total = read.rows.length\n const truncated = total > CANDIDATES_MAX\n const candidates = read.rows\n .slice(0, CANDIDATES_MAX)\n .map(candidateOf)\n .filter((candidate): candidate is TokenCandidate => candidate !== null)\n const counted = form === 'counted' ? numberOrNull(read.rows[0]?.match_count) : null\n const matches = counted !== null && counted >= total ? counted : truncated ? null : total\n\n // More match than are listed: the newest page. A failed or refused page\n // leaves the answer as the oldest list, which the hint calls a part.\n let newestPage: TokenCandidate[] | null = null\n if (truncated && form === 'counted') {\n const page = await readAssets(deps, network, matchedOn, symbol, 'newest')\n if (page.kind === 'rows') {\n newestPage = page.rows\n .map(candidateOf)\n .filter((candidate): candidate is TokenCandidate => candidate !== null)\n }\n }\n const listed = new Set(candidates.map((candidate) => candidate.contract))\n const verified = candidates.filter((candidate) => candidate.verified)\n const anchor =\n verified.length === 1 && verified[0]!.first_seen_timestamp !== null ? verified[0]! : null\n const after = (candidate: TokenCandidate): boolean =>\n anchor !== null &&\n candidate.first_seen_timestamp !== null &&\n candidate.first_seen_timestamp > anchor.first_seen_timestamp!\n let firstSeenAfterVerified: MetaTokenLookupResult['first_seen_after_verified'] = null\n if (anchor) {\n // Every later contract is known when the lists reach back to the verified\n // one: nothing was cut, or the newest page holds a row that is not later.\n const pool = !truncated ? candidates : (newestPage ?? candidates)\n const reachesBack =\n !truncated ||\n (newestPage !== null &&\n (newestPage.length < CANDIDATES_MAX || newestPage.some((row) => !after(row))))\n firstSeenAfterVerified = {\n verified_contract: anchor.contract,\n count: pool.filter(after).length,\n at_least: !reachesBack,\n }\n }\n const newest = (newestPage ?? []).filter((candidate) => !listed.has(candidate.contract))\n\n const creatorsNotRead =\n candidates.length > 0 ? await readCreators(deps, network, [...candidates, ...newest]) : null\n const result = {\n ...base,\n matched_on: candidates.length > 0 ? matchedOn : null,\n candidates,\n truncated,\n matches,\n newest,\n first_seen_after_verified: firstSeenAfterVerified,\n }\n return textResult({ ...result, hint: hintFor(result, creatorsNotRead) })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,yBAAyB;AACtC,MAAa,2BAA2B;AACxC,MAAa,0BAA0B;AACvC,MAAa,gCACX;AAMF,MAAa,gCAAgC;CAC3C,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;;AAIA,MAAa,iBAAiB;AAC9B,MAAa,YAAY;;AAEzB,MAAa,oBAAoB;AACjC,MAAa,aAAa;AAE1B,MAAa,qBAAqB;AA4DlC,MAAM,eAAe;AACrB,MAAM,gBAAgB;AAItB,SAAS,cAAc,MAAuB;CAC5C,KAAK,MAAM,QAAQ,MAAM;EACvB,MAAM,OAAO,KAAK,YAAY,CAAC;EAC/B,IAAI,SAAS,QAAO,SAAS,QAAQ,OAAO,MAAQ,SAAS,KAAM,OAAO;CAC5E;CACA,OAAO;AACT;AACA,MAAM,cAAc;AAEpB,MAAM,iBACJ;AAEF,SAAS,SAAS,OAAkD;CAClE,OAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACrE;AAEA,SAAS,YAAY,MAAyC;CAC5D,OAAO;EAAE,SAAS,CAAC;GAAE,MAAM;GAAQ;EAAK,CAAC;EAAG,SAAS;CAAK;AAC5D;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AAM,QAAQ,CAAC,MAAM,GAAG,CAAC;EAC/E,yBAAyB;GACvB,mBAAmB,OAAO;GAC1B,OAAO,KAAK,OAAO,KAAK,CAAC,CAAC;GAC1B,UAAU,CAAC;EACb;CACF;CACA,MAAM,UAAU,cAAc,CAAC,EAAA,CAAG,QAAQ,cAAc,CAAC,OAAO,IAAI,UAAU,QAAQ,CAAC;CAEvF,MAAM,kBACJ,WAAW,SAAS,IAAI,MAAM,aAAa,MAAM,SAAS,CAAC,GAAG,YAAY,GAAG,MAAM,CAAC,IAAI;CAC1F,MAAM,SAAS;EACb,GAAG;EACH,YAAY,WAAW,SAAS,IAAI,YAAY;EAChD;EACA;EACA;EACA;EACA,2BAA2B;CAC7B;CACA,OAAO,WAAW;EAAE,GAAG;EAAQ,MAAM,QAAQ,QAAQ,eAAe;CAAE,CAAC;AACzE"}
1
+ {"version":3,"file":"token-lookup-Ck0q7crJ.mjs","names":[],"sources":["../src/mcp/token-lookup.ts"],"sourcesContent":["/**\n * meta_token_lookup: a ticker or a token name becomes its contracts.\n *\n * A local tool of the proxy. It sends one anchored facts read of the Asset\n * lookup by symbol, the same read by name when the symbol answers nothing, and\n * then the creator and the factory of each candidate from topology, one batch\n * member per candidate. Nothing is matched here: the graph server matches the\n * symbol or the name, case-insensitively and exactly, and orders the rows\n * verified first, then oldest first. The proxy keeps that order.\n *\n * The read also asks the server how many contracts match. When more match than\n * the 25 listed, a second read brings the newest: a copy of a verified token is\n * made after it, so the oldest 25 alone hide exactly the copies. A server that\n * does not count yet is read the old way, and the answer says the list is a part.\n *\n * Tickers collide on purpose: clones reuse a symbol to borrow its trust. The\n * tool never picks one. The description below is the contract with every\n * host, Claude Desktop chat included, which reads no skill.\n */\n\nimport { ANSWER_HINT } from './answer-hint.js'\nimport { DexRegistryError, normalizeDexNetwork } from './dex-registry.js'\nimport { isEpochMs, utcText } from './timestamp-text.js'\n\nexport const META_TOKEN_LOOKUP_TOOL = 'meta_token_lookup'\nexport const META_TOKEN_LOOKUP_SCHEMA = 'chain-insights.meta-token-lookup.v1' as const\nexport const META_TOKEN_LOOKUP_TITLE = 'Token by ticker or name'\nexport const META_TOKEN_LOOKUP_DESCRIPTION =\n 'Call this first when a question names a token by its ticker or name and gives no contract ' +\n '(TCITY, USDG, SPCX). It returns the contracts on the network that carry that symbol, ' +\n 'verified first, then oldest first, with the count of all of them and, when more than 25 match, ' +\n 'the newest ones too. Tickers collide: never treat the first row as the token. ' +\n 'When several match, name them and ask, or pick by the evidence the user gave. Zero candidates ' +\n 'means no contract carries the symbol: say so, and do not search the web.'\nexport const META_TOKEN_LOOKUP_ANNOTATIONS = {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n} as const\nexport const META_TOKEN_LOOKUP_ARGS = ['network', 'symbol'] as const\n\n/** The candidates returned. The read asks for one more, so a full page says there are more. */\nexport const CANDIDATES_MAX = 25\nexport const ROWS_READ = CANDIDATES_MAX + 1\n/** The graph server admits at most 20 members in one graph_query_batch. */\nexport const CREATOR_BATCH_MAX = 20\nexport const SYMBOL_MAX = 64\n\nexport const ADDRESS_INPUT_HINT = 'an address is already an anchor: read it on USE topology'\n\nexport interface TokenCandidate {\n contract: string\n symbol: string | null\n name: string | null\n token_standard: string | null\n decimals: number | null\n verified: boolean\n verification_source: string | null\n first_seen_timestamp: number | null\n first_seen_timestamp_utc: string | null\n creator: string | null\n factory: string | null\n}\n\nexport interface MetaTokenLookupResult {\n schema: typeof META_TOKEN_LOOKUP_SCHEMA\n network: string\n query: string\n matched_on: 'symbol' | 'name' | null\n candidates: TokenCandidate[]\n /** More contracts carry the key than the candidates listed. */\n truncated: boolean\n /** How many contracts carry the key, counted by the server; null when the server does not count. */\n matches: number | null\n /** When more match than the candidates listed: the newest that are not among them, newest first. */\n newest: TokenCandidate[]\n /** With exactly one verified candidate: how many contracts were first seen after it. */\n first_seen_after_verified: { verified_contract: string; count: number; at_least: boolean } | null\n hint: string\n}\n\n/** One graph_query or graph_query_batch reply as the remote client returns it. */\nexport type GraphAnswer = {\n content?: unknown[]\n structuredContent?: unknown\n isError?: boolean\n}\n\nexport interface TokenToolDependencies {\n /** One graph_query through the proxy's remote client, billed as any read. */\n graphQuery: (args: { network: string; query: string }) => Promise<GraphAnswer>\n /** One graph_query_batch through the proxy's remote client, billed as any read. */\n graphQueryBatch: (args: {\n network: string\n queries: Array<{ id: string; query: string }>\n }) => Promise<GraphAnswer>\n /** The reason no read can be sent now, or undefined when the graph is reachable. */\n unavailable?: () => Promise<string | undefined> | string | undefined\n /** The text of a call that threw: payment required, transport. */\n describeFailure: (err: unknown) => string\n}\n\nexport type MetaTokenLookupToolResult = {\n content: Array<{ type: 'text'; text: string }>\n structuredContent?: Record<string, unknown>\n isError: boolean\n}\n\nconst ADDRESS_FORM = /^0x[0-9a-fA-F]{40}$/\nconst CONTRACT_FORM = /^0x[0-9a-f]{40}$/\n// A string literal of the read holds no double quote, no backslash and no\n// control character: the symbol is refused rather than escaped, so the read the\n// server receives is always the read written here.\nfunction unsafeLiteral(text: string): boolean {\n for (const char of text) {\n const code = char.codePointAt(0)!\n if (char === '\"' || char === '\\\\' || code < 0x20 || code === 0x7f) return true\n }\n return false\n}\nconst CODE_PREFIX = /^([a-z][a-z0-9_]*):\\s*/\n// Codes of a read that was stopped, not refused: the same read may answer later.\nconst TRANSIENT_CODE =\n /(timeout|memory_limit|cpu_limit|busy|_failed$|rate_limited|unavailable|too_large|node_error)/\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction errorResult(text: string): MetaTokenLookupToolResult {\n return { content: [{ type: 'text', text }], isError: true }\n}\n\nfunction textResult(structured: MetaTokenLookupResult): MetaTokenLookupToolResult {\n return {\n content: [{ type: 'text', text: JSON.stringify(structured, null, 2) }],\n structuredContent: structured as unknown as Record<string, unknown>,\n isError: false,\n }\n}\n\n/**\n * The facts Asset read by symbol or by name. `counted` asks the server for the\n * number of contracts that match, on every row. `newest` reads the newest 25\n * instead of verified first, then oldest first. With neither it is the read\n * every server admits.\n */\nexport function assetQuery(\n key: 'symbol' | 'name',\n value: string,\n form: 'plain' | 'counted' | 'newest' = 'plain'\n): string {\n return (\n `USE facts MATCH (t:Asset {${key}: \"${value}\"}) ` +\n 'RETURN t.asset_contract AS contract, t.asset_symbol AS symbol, t.name AS name, ' +\n 't.token_standard AS token_standard, t.decimals AS decimals, t.verified AS verified, ' +\n 't.verification_source AS verification_source, t.first_seen_timestamp AS first_seen_timestamp' +\n (form === 'counted' ? ', t.match_count AS match_count' : '') +\n (form === 'newest'\n ? ` ORDER BY t.first_seen_timestamp DESC LIMIT ${CANDIDATES_MAX}`\n : ` LIMIT ${ROWS_READ}`)\n )\n}\n\n/** The topology read of who deployed one contract: the deploying address and the transaction's sender. */\nexport function creatorQuery(contract: string): string {\n return (\n `USE topology MATCH (f:Address)-[d:DEPLOYED_CONTRACT]->(t:Address {address: \"${contract}\"}) ` +\n 'RETURN f.address AS factory, d.tx_origin AS creator LIMIT 1'\n )\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() !== '' ? value : null\n\nconst numberOrNull = (value: unknown): number | null => {\n if (typeof value === 'number' && Number.isFinite(value)) return value\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value)))\n return Number(value)\n return null\n}\n\nconst addressOrNull = (value: unknown): string | null =>\n typeof value === 'string' && ADDRESS_FORM.test(value.trim()) ? value.trim().toLowerCase() : null\n\nfunction verifiedOf(value: unknown): boolean {\n if (typeof value === 'boolean') return value\n if (typeof value === 'number') return value === 1\n if (typeof value === 'string') return ['true', '1'].includes(value.trim().toLowerCase())\n return false\n}\n\nfunction answerText(answer: GraphAnswer): string {\n return (Array.isArray(answer.content) ? answer.content : [])\n .map((block) => (isRecord(block) && typeof block.text === 'string' ? block.text : ''))\n .filter(Boolean)\n .join('\\n')\n .trim()\n}\n\nexport type Refusal = { code: string; text: string; transient: boolean }\n\n/** A graph_query answer that did not answer: its code, its text, and whether the same read may answer later. */\nexport function refusalOf(answer: GraphAnswer): Refusal {\n const text = answerText(answer)\n const detail = isRecord(answer.structuredContent)\n ? answer.structuredContent.error_detail\n : undefined\n const detailCode = isRecord(detail) && typeof detail.code === 'string' ? detail.code : ''\n const detailClass = isRecord(detail) && typeof detail.class === 'string' ? detail.class : ''\n const named = detailCode || CODE_PREFIX.exec(text)?.[1] || ''\n // A refusal that names no class is a stop only when its code says so; a\n // refusal in plain words (\"unknown label Asset\") is a server that lacks the read.\n const transient = detailClass ? detailClass !== 'refused' : TRANSIENT_CODE.test(named)\n const code = named || 'not_served'\n return { code, text: text || `${code}: the graph endpoint refused the read`, transient }\n}\n\n/** The result rows of a graph_query answer, or null when it holds none. */\nfunction rowsOf(answer: GraphAnswer): Array<Record<string, unknown>> | null {\n const facts = isRecord(answer.structuredContent) ? answer.structuredContent.facts : undefined\n const query = isRecord(facts) ? facts.query : undefined\n const results = isRecord(query) ? query.results : undefined\n return Array.isArray(results) ? results.filter(isRecord) : null\n}\n\nexport type Member = { id?: unknown; ok?: unknown; results?: unknown; error?: unknown }\n\n/** The members of a graph_query_batch answer by id. */\nexport function membersOf(answer: GraphAnswer): Map<string, Member> {\n const facts = isRecord(answer.structuredContent) ? answer.structuredContent.facts : undefined\n const queries = isRecord(facts) ? facts.queries : undefined\n const members = new Map<string, Member>()\n if (Array.isArray(queries)) {\n for (const member of queries)\n if (isRecord(member) && typeof member.id === 'string') members.set(member.id, member)\n }\n return members\n}\n\nfunction candidateOf(row: Record<string, unknown>): TokenCandidate | null {\n const contract = textOrNull(row.contract)?.trim().toLowerCase()\n if (!contract) return null\n const firstSeen = numberOrNull(row.first_seen_timestamp)\n return {\n contract,\n symbol: textOrNull(row.symbol),\n name: textOrNull(row.name),\n token_standard: textOrNull(row.token_standard),\n decimals: numberOrNull(row.decimals),\n verified: verifiedOf(row.verified),\n verification_source: textOrNull(row.verification_source),\n first_seen_timestamp: firstSeen,\n first_seen_timestamp_utc: isEpochMs(firstSeen) ? utcText(firstSeen) : null,\n creator: null,\n factory: null,\n }\n}\n\ntype Read =\n | { kind: 'rows'; rows: Array<Record<string, unknown>> }\n | { kind: 'not_served'; refusal: Refusal }\n | { kind: 'failed'; text: string }\n\nasync function readAssets(\n deps: TokenToolDependencies,\n network: string,\n key: 'symbol' | 'name',\n value: string,\n form: 'plain' | 'counted' | 'newest'\n): Promise<Read> {\n let answer: GraphAnswer\n try {\n answer = await deps.graphQuery({ network, query: assetQuery(key, value, form) })\n } catch (err) {\n return { kind: 'failed', text: deps.describeFailure(err) }\n }\n const rows = rowsOf(answer)\n if (answer.isError !== true && rows !== null) return { kind: 'rows', rows }\n const refusal = refusalOf(answer)\n if (answer.isError === true && refusal.transient) return { kind: 'failed', text: refusal.text }\n return { kind: 'not_served', refusal }\n}\n\n/**\n * The creator and the factory of each candidate, written in place. Returns why\n * some creators were not read, or null when every read answered. A read that\n * answered with no row leaves the candidate's creator empty with no note: the\n * graph holds no deployment for it.\n */\nasync function readCreators(\n deps: TokenToolDependencies,\n network: string,\n candidates: TokenCandidate[]\n): Promise<string | null> {\n const contracts = [\n ...new Set(candidates.map((c) => c.contract).filter((c) => CONTRACT_FORM.test(c))),\n ]\n const found = new Map<string, { creator: string | null; factory: string | null }>()\n const reasons: string[] = []\n let unread = candidates.length - candidates.filter((c) => CONTRACT_FORM.test(c.contract)).length\n for (let at = 0; at < contracts.length; at += CREATOR_BATCH_MAX) {\n const chunk = contracts.slice(at, at + CREATOR_BATCH_MAX)\n const queries = chunk.map((contract) => ({\n id: `creator:${contract}`,\n query: creatorQuery(contract),\n }))\n let members = new Map<string, Member>()\n try {\n const answer = await deps.graphQueryBatch({ network, queries })\n members = membersOf(answer)\n if (members.size === 0) {\n reasons.push(\n answer.isError === true ? refusalOf(answer).text : 'the batch answer held no reads'\n )\n }\n } catch (err) {\n reasons.push(deps.describeFailure(err))\n }\n for (const contract of chunk) {\n const member = members.get(`creator:${contract}`)\n if (member?.ok === true && Array.isArray(member.results)) {\n const row = member.results.find(isRecord)\n found.set(contract, {\n creator: row ? addressOrNull(row.creator) : null,\n factory: row ? addressOrNull(row.factory) : null,\n })\n continue\n }\n unread += 1\n if (member && typeof member.error === 'string' && !reasons.includes(member.error))\n reasons.push(member.error)\n }\n }\n for (const candidate of candidates) {\n const read = found.get(candidate.contract)\n if (read) Object.assign(candidate, read)\n }\n if (unread === 0) return null\n return `${unread} of ${candidates.length}${reasons.length > 0 ? `: ${reasons.join('; ')}` : ''}`\n}\n\nconst NO_WEB =\n 'Do not search the web and do not guess a contract: a web page is not a contract on this network.'\n\nfunction hintFor(\n result: Omit<MetaTokenLookupResult, 'hint'>,\n creatorsNotRead: string | null\n): string {\n const { network, query, candidates, matched_on, truncated, matches, newest } = result\n const later = result.first_seen_after_verified\n const parts: string[] = [ANSWER_HINT]\n if (candidates.length === 0) {\n parts.push(\n `No contract on ${network} carries the symbol or the name \"${query}\". Say so in one line. ${NO_WEB} ` +\n 'Ask the user for the contract if they have one.'\n )\n return parts.join(' ')\n }\n if (matched_on === 'name') {\n parts.push(`No contract carries \"${query}\" as its symbol; these carry it as their name.`)\n }\n if (candidates.length === 1) {\n parts.push(\n `One contract on ${network} carries \"${query}\": ${candidates[0]!.contract}. ` +\n 'Say it is the only one on this network, then read it by this full contract on USE topology.'\n )\n } else {\n if (!truncated) {\n parts.push(`${candidates.length} contracts on ${network} carry \"${query}\".`)\n } else if (matches === null) {\n parts.push(\n `More than ${CANDIDATES_MAX} contracts on ${network} carry \"${query}\": how many is not in this answer. ` +\n `candidates lists the ${candidates.length} oldest, the verified first. ` +\n `The list is a part: never give ${candidates.length} or ${ROWS_READ} as the count, say \"more than ${CANDIDATES_MAX}\", and never say that none exist beyond it.`\n )\n } else {\n parts.push(\n `${matches} contracts on ${network} carry \"${query}\". candidates lists ${candidates.length} of them, verified first, then oldest first` +\n `${newest.length > 0 ? `, and newest lists the ${newest.length} newest that are not among them, newest first` : ''}. ` +\n `The lists are a part: the count is ${matches}, never the number of rows.`\n )\n }\n parts.push(\n 'Tickers collide: never treat the first row as the token. Name them, each contract in full, ' +\n 'with its creator and first seen time, and ask which one the user means, or pick one by the evidence the user gave ' +\n '(a creator, a launch date, a price move) and say why.'\n )\n }\n if (later && later.count > 0) {\n parts.push(\n `${later.at_least ? 'At least ' : ''}${later.count} of them ${later.count === 1 ? 'was' : 'were'} first seen after the verified contract ${later.verified_contract}: ` +\n 'each took a symbol that a verified token already carried. That is a copy of the name. A copied name alone is not proof of a scam.'\n )\n }\n if (later && later.at_least) {\n parts.push(\n `This answer does not list every contract first seen after the verified contract ${later.verified_contract}` +\n `${matches === null ? ': it lists the oldest only' : ''}. How many were made after it is not known from this answer` +\n `${later.count === 0 ? ', and a list that shows none does not mean none exist' : ''}. ` +\n 'Never answer that none, or no contract, was created after it; say the list holds the oldest contracts and the later ones are not in it.'\n )\n }\n if (creatorsNotRead) {\n parts.push(\n `The creators were not read for ${creatorsNotRead}. creator and factory are empty there because the read failed, ` +\n 'not because the chain holds none.'\n )\n }\n parts.push('Write every contract and creator in full, 0x plus 40 hex characters.')\n return parts.join(' ')\n}\n\n/** meta_token_lookup, {network, symbol}. Every argument is checked before a read is sent. */\nexport async function handleMetaTokenLookup(\n args: unknown,\n deps: TokenToolDependencies\n): Promise<MetaTokenLookupToolResult> {\n const record = isRecord(args) ? args : {}\n let network: string\n try {\n network = normalizeDexNetwork(record.network)\n } catch (err) {\n return errorResult(\n err instanceof DexRegistryError ? err.message : `invalid_network: ${(err as Error).message}`\n )\n }\n if (typeof record.symbol !== 'string' || record.symbol.trim() === '') {\n return errorResult(\n 'invalid_symbol: symbol is required: the ticker or the name as the user wrote it, for example TCITY'\n )\n }\n const symbol = record.symbol.trim()\n if (symbol.length > SYMBOL_MAX) {\n return errorResult(`invalid_symbol: symbol holds at most ${SYMBOL_MAX} characters`)\n }\n const base = {\n schema: META_TOKEN_LOOKUP_SCHEMA,\n network,\n query: symbol,\n }\n\n if (ADDRESS_FORM.test(symbol)) {\n const address = symbol.toLowerCase()\n return textResult({\n ...base,\n matched_on: null,\n candidates: [],\n truncated: false,\n matches: null,\n newest: [],\n first_seen_after_verified: null,\n hint: `${ANSWER_HINT} ${address} is a contract address, not a ticker: ${ADDRESS_INPUT_HINT}. Send no token lookup for it.`,\n })\n }\n if (unsafeLiteral(symbol)) {\n return errorResult(\n 'invalid_symbol: a symbol holds no double quote, backslash or control character. Send the ticker or the name as plain text.'\n )\n }\n\n const unavailable = await deps.unavailable?.()\n if (unavailable) {\n return errorResult(\n `No token read was sent: ${unavailable} The lookup has no answer yet, which is not \"no contract\": try again later, or ask the user for the contract. ${NO_WEB}`\n )\n }\n\n // A server that does not count refuses the counted read; the plain read is\n // the one every server admits.\n let form: 'counted' | 'plain' = 'counted'\n let matchedOn: 'symbol' | 'name' = 'symbol'\n let read = await readAssets(deps, network, 'symbol', symbol, form)\n if (read.kind === 'not_served') {\n form = 'plain'\n read = await readAssets(deps, network, 'symbol', symbol, form)\n }\n if (read.kind === 'rows' && read.rows.length === 0) {\n matchedOn = 'name'\n read = await readAssets(deps, network, 'name', symbol, form)\n }\n if (read.kind === 'failed') {\n return errorResult(\n `The token read failed: ${read.text} This is not \"no contract\": send the same lookup again once, or ask the user for the contract. ${NO_WEB}`\n )\n }\n if (read.kind === 'not_served') {\n return textResult({\n ...base,\n matched_on: null,\n candidates: [],\n truncated: false,\n matches: null,\n newest: [],\n first_seen_after_verified: null,\n hint:\n `${ANSWER_HINT} This lookup gave no answer (${read.refusal.code}). ` +\n `That is not \"no contract carries ${symbol}\": ask the user for the token's contract, 0x plus 40 hex characters. ${NO_WEB}`,\n })\n }\n\n const total = read.rows.length\n const truncated = total > CANDIDATES_MAX\n const candidates = read.rows\n .slice(0, CANDIDATES_MAX)\n .map(candidateOf)\n .filter((candidate): candidate is TokenCandidate => candidate !== null)\n const counted = form === 'counted' ? numberOrNull(read.rows[0]?.match_count) : null\n const matches = counted !== null && counted >= total ? counted : truncated ? null : total\n\n // More match than are listed: the newest page. A failed or refused page\n // leaves the answer as the oldest list, which the hint calls a part.\n let newestPage: TokenCandidate[] | null = null\n if (truncated && form === 'counted') {\n const page = await readAssets(deps, network, matchedOn, symbol, 'newest')\n if (page.kind === 'rows') {\n newestPage = page.rows\n .map(candidateOf)\n .filter((candidate): candidate is TokenCandidate => candidate !== null)\n }\n }\n const listed = new Set(candidates.map((candidate) => candidate.contract))\n const verified = candidates.filter((candidate) => candidate.verified)\n const anchor =\n verified.length === 1 && verified[0]!.first_seen_timestamp !== null ? verified[0]! : null\n const after = (candidate: TokenCandidate): boolean =>\n anchor !== null &&\n candidate.first_seen_timestamp !== null &&\n candidate.first_seen_timestamp > anchor.first_seen_timestamp!\n let firstSeenAfterVerified: MetaTokenLookupResult['first_seen_after_verified'] = null\n if (anchor) {\n // Every later contract is known when the lists reach back to the verified\n // one: nothing was cut, or the newest page holds a row that is not later.\n const pool = !truncated ? candidates : (newestPage ?? candidates)\n const reachesBack =\n !truncated ||\n (newestPage !== null &&\n (newestPage.length < CANDIDATES_MAX || newestPage.some((row) => !after(row))))\n firstSeenAfterVerified = {\n verified_contract: anchor.contract,\n count: pool.filter(after).length,\n at_least: !reachesBack,\n }\n }\n const newest = (newestPage ?? []).filter((candidate) => !listed.has(candidate.contract))\n\n const creatorsNotRead =\n candidates.length > 0 ? await readCreators(deps, network, [...candidates, ...newest]) : null\n const result = {\n ...base,\n matched_on: candidates.length > 0 ? matchedOn : null,\n candidates,\n truncated,\n matches,\n newest,\n first_seen_after_verified: firstSeenAfterVerified,\n }\n return textResult({ ...result, hint: hintFor(result, creatorsNotRead) })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,yBAAyB;AACtC,MAAa,2BAA2B;AACxC,MAAa,0BAA0B;AACvC,MAAa,gCACX;AAMF,MAAa,gCAAgC;CAC3C,cAAc;CACd,gBAAgB;CAChB,eAAe;AACjB;;AAIA,MAAa,iBAAiB;AAC9B,MAAa,YAAY;;AAEzB,MAAa,oBAAoB;AACj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AI,KAAK,SAAS,QAChB,aAAa,KAAK,KACf,IAAI,WAAW,CAAC,CAChB,QAAQ,cAA2C,cAAc,IAAI;CAE5E;CACA,MAAM,SAAS,IAAI,IAAI,WAAW,KAAK,cAAc,UAAU,QAAQ,CAAC;CACxE,MAAM,WAAW,WAAW,QAAQ,cAAc,UAAU,QAAQ;CACpE,MAAM,SACJ,SAAS,WAAW,KAAK,SAAS,EAAE,CAAE,yBAAyB,OAAO,SAAS,KAAM;CACvF,MAAM,SAAS,cACb,WAAW,QACX,UAAU,yBAAyB,QACnC,UAAU,uBAAuB,OAAO;CAC1C,IAAI,yBAA6E;CACjF,IAAI,QAAQ;EAGV,MAAM,OAAO,CAAC,YAAY,aAAc,cAAc;EACtD,MAAM,cACJ,CAAC,aACA,eAAe,SACb,WAAW,SAAS,kBAAkB,WAAW,MAAM,QAAQ,CAAC,MAAM,GAAG,CAAC;EAC/E,yBAAyB;GACvB,mBAAmB,OAAO;GAC1B,OAAO,KAAK,OAAO,KAAK,CAAC,CAAC;GAC1B,UAAU,CAAC;EACb;CACF;CACA,MAAM,UAAU,cAAc,CAAC,EAAA,CAAG,QAAQ,cAAc,CAAC,OAAO,IAAI,UAAU,QAAQ,CAAC;CAEvF,MAAM,kBACJ,WAAW,SAAS,IAAI,MAAM,aAAa,MAAM,SAAS,CAAC,GAAG,YAAY,GAAG,MAAM,CAAC,IAAI;CAC1F,MAAM,SAAS;EACb,GAAG;EACH,YAAY,WAAW,SAAS,IAAI,YAAY;EAChD;EACA;EACA;EACA;EACA,2BAA2B;CAC7B;CACA,OAAO,WAAW;EAAE,GAAG;EAAQ,MAAM,QAAQ,QAAQ,eAAe;CAAE,CAAC;AACzE"}
@@ -1,6 +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_dex_registry = require("./dex-registry-BhGJUG9_.cjs");
3
+ const require_dex_registry = require("./dex-registry-CyR3GyRr.cjs");
4
4
  const require_print_result = require("./print-result-BYppJlUi.cjs");
5
5
  // src/mcp/token-lookup.ts
6
6
  /**