dero-mcp-server 0.1.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -6
- package/data/docs-index.json +5702 -0
- package/dist/citations.d.ts +70 -0
- package/dist/citations.d.ts.map +1 -0
- package/dist/citations.js +162 -0
- package/dist/citations.js.map +1 -0
- package/dist/composites/_shared.d.ts +119 -0
- package/dist/composites/_shared.d.ts.map +1 -0
- package/dist/composites/_shared.js +152 -0
- package/dist/composites/_shared.js.map +1 -0
- package/dist/composites/diagnose-chain-health.d.ts +64 -0
- package/dist/composites/diagnose-chain-health.d.ts.map +1 -0
- package/dist/composites/diagnose-chain-health.js +144 -0
- package/dist/composites/diagnose-chain-health.js.map +1 -0
- package/dist/composites/estimate-deploy-cost.d.ts +83 -0
- package/dist/composites/estimate-deploy-cost.d.ts.map +1 -0
- package/dist/composites/estimate-deploy-cost.js +116 -0
- package/dist/composites/estimate-deploy-cost.js.map +1 -0
- package/dist/composites/explain-smart-contract.d.ts +64 -0
- package/dist/composites/explain-smart-contract.d.ts.map +1 -0
- package/dist/composites/explain-smart-contract.js +149 -0
- package/dist/composites/explain-smart-contract.js.map +1 -0
- package/dist/composites/recommend-docs-path.d.ts +97 -0
- package/dist/composites/recommend-docs-path.d.ts.map +1 -0
- package/dist/composites/recommend-docs-path.js +149 -0
- package/dist/composites/recommend-docs-path.js.map +1 -0
- package/dist/composites/trace-transaction-with-context.d.ts +107 -0
- package/dist/composites/trace-transaction-with-context.d.ts.map +1 -0
- package/dist/composites/trace-transaction-with-context.js +217 -0
- package/dist/composites/trace-transaction-with-context.js.map +1 -0
- package/dist/docs-parse.d.ts +30 -0
- package/dist/docs-parse.d.ts.map +1 -0
- package/dist/docs-parse.js +147 -0
- package/dist/docs-parse.js.map +1 -0
- package/dist/docs.d.ts +101 -0
- package/dist/docs.d.ts.map +1 -0
- package/dist/docs.js +172 -0
- package/dist/docs.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +417 -100
- package/dist/server.js.map +1 -1
- package/dist/tool-descriptions.d.ts +50 -0
- package/dist/tool-descriptions.d.ts.map +1 -0
- package/dist/tool-descriptions.js +246 -0
- package/dist/tool-descriptions.js.map +1 -0
- package/package.json +15 -3
- package/.github/workflows/ci.yml +0 -62
- package/docs/example-agent-flows.md +0 -236
- package/docs/mcp-agent-ready-evidence.md +0 -108
- package/glama.json +0 -6
- package/scripts/doctor.sh +0 -85
- package/scripts/flow-test.ts +0 -257
- package/scripts/mcp-smoke-probes.ts +0 -168
- package/server.json +0 -23
- package/src/index.ts +0 -30
- package/src/rpc.ts +0 -60
- package/src/server.ts +0 -636
- package/tsconfig.json +0 -16
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Citation helper for DERO MCP tool responses.
|
|
3
|
+
*
|
|
4
|
+
* The wedge for this server is the combination of live chain reads and the
|
|
5
|
+
* in-process bundled docs index (145+ pages across derod, tela, hologram,
|
|
6
|
+
* deropay). Citations let agents link their responses back to authoritative
|
|
7
|
+
* docs without a second tool call, and they give downstream composite tools
|
|
8
|
+
* a uniform shape to compose.
|
|
9
|
+
*
|
|
10
|
+
* Design contract:
|
|
11
|
+
* - One shape, used by primitives and composites alike.
|
|
12
|
+
* - URLs are produced by the same builder used by `dero_docs_*` so the
|
|
13
|
+
* citation always points at the same canonical page the agent would
|
|
14
|
+
* reach via dero_docs_get_page.
|
|
15
|
+
* - The slug is duplicated as `page_id` to give composites a stable join
|
|
16
|
+
* key across tools (mirrors the FoodNearMe COMPOSITES.md citation pattern).
|
|
17
|
+
* - The map of related docs per tool is hand-maintained and validated by
|
|
18
|
+
* `scripts/check-citations.ts` (added alongside this helper) so a docs
|
|
19
|
+
* reorganization cannot silently produce 404 citations in production.
|
|
20
|
+
*/
|
|
21
|
+
import { type DeroDocProduct } from './docs-parse.js';
|
|
22
|
+
export type DeroCitation = {
|
|
23
|
+
/** Always `'dero_docs'` for now; future sources (e.g. `'dero_chain'`) can extend this. */
|
|
24
|
+
source: 'dero_docs';
|
|
25
|
+
product: DeroDocProduct;
|
|
26
|
+
slug: string;
|
|
27
|
+
title: string;
|
|
28
|
+
canonical_url: string;
|
|
29
|
+
/** Alias of `slug` so composites can use a single join key across tools. */
|
|
30
|
+
page_id: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Build a DeroCitation pointing at one bundled docs page.
|
|
34
|
+
*
|
|
35
|
+
* The title is required (not derived from the bundled index) so this helper
|
|
36
|
+
* stays synchronous and zero-IO. It must match the docs page title; the
|
|
37
|
+
* citation guard validates this against the bundled index in CI.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildDeroCitation(product: DeroDocProduct, slug: string, title: string): DeroCitation;
|
|
40
|
+
/**
|
|
41
|
+
* Map of MCP tool name → hand-curated related docs pages.
|
|
42
|
+
*
|
|
43
|
+
* Keep this list tight — only add entries when a tool's response is
|
|
44
|
+
* meaningfully improved by linking the agent at a specific page. The CI
|
|
45
|
+
* guard verifies every slug resolves against the bundled docs index, so any
|
|
46
|
+
* docs reorganization will fail the build before it ships.
|
|
47
|
+
*
|
|
48
|
+
* Adding a tool here:
|
|
49
|
+
* 1. Use `dero_docs_search` to find the right slug(s).
|
|
50
|
+
* 2. Add an entry with product + slug + exact page title.
|
|
51
|
+
* 3. Run `npm run check:citations` to confirm slugs resolve.
|
|
52
|
+
*/
|
|
53
|
+
type RelatedDocsEntry = {
|
|
54
|
+
product: DeroDocProduct;
|
|
55
|
+
slug: string;
|
|
56
|
+
title: string;
|
|
57
|
+
};
|
|
58
|
+
export declare const RELATED_DOCS_BY_TOOL: Record<string, readonly RelatedDocsEntry[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Resolve the hand-curated related docs list for a tool name and return it
|
|
61
|
+
* as fully-built `DeroCitation` objects. Returns `undefined` when the tool
|
|
62
|
+
* has no related docs configured.
|
|
63
|
+
*
|
|
64
|
+
* Use in tool handlers like:
|
|
65
|
+
* const related_docs = relatedDocsFor('dero_get_sc')
|
|
66
|
+
* return { ...rpcResult, ...(related_docs ? { related_docs } : {}) }
|
|
67
|
+
*/
|
|
68
|
+
export declare function relatedDocsFor(toolName: string): DeroCitation[] | undefined;
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=citations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citations.d.ts","sourceRoot":"","sources":["../src/citations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEpE,MAAM,MAAM,YAAY,GAAG;IACzB,0FAA0F;IAC1F,MAAM,EAAE,WAAW,CAAA;IACnB,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAQD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,YAAY,CASd;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,gBAAgB,GAAG;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAqGnE,CAAA;AAEV;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAAE,GAAG,SAAS,CAI3E"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Citation helper for DERO MCP tool responses.
|
|
3
|
+
*
|
|
4
|
+
* The wedge for this server is the combination of live chain reads and the
|
|
5
|
+
* in-process bundled docs index (145+ pages across derod, tela, hologram,
|
|
6
|
+
* deropay). Citations let agents link their responses back to authoritative
|
|
7
|
+
* docs without a second tool call, and they give downstream composite tools
|
|
8
|
+
* a uniform shape to compose.
|
|
9
|
+
*
|
|
10
|
+
* Design contract:
|
|
11
|
+
* - One shape, used by primitives and composites alike.
|
|
12
|
+
* - URLs are produced by the same builder used by `dero_docs_*` so the
|
|
13
|
+
* citation always points at the same canonical page the agent would
|
|
14
|
+
* reach via dero_docs_get_page.
|
|
15
|
+
* - The slug is duplicated as `page_id` to give composites a stable join
|
|
16
|
+
* key across tools (mirrors the FoodNearMe COMPOSITES.md citation pattern).
|
|
17
|
+
* - The map of related docs per tool is hand-maintained and validated by
|
|
18
|
+
* `scripts/check-citations.ts` (added alongside this helper) so a docs
|
|
19
|
+
* reorganization cannot silently produce 404 citations in production.
|
|
20
|
+
*/
|
|
21
|
+
import { DOC_BASE_URLS } from './docs-parse.js';
|
|
22
|
+
function buildCanonicalUrl(product, slug) {
|
|
23
|
+
const trimmed = slug.replace(/^\/+|\/+$/g, '');
|
|
24
|
+
if (!trimmed)
|
|
25
|
+
return `${DOC_BASE_URLS[product]}/`;
|
|
26
|
+
return `${DOC_BASE_URLS[product]}/${trimmed}`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build a DeroCitation pointing at one bundled docs page.
|
|
30
|
+
*
|
|
31
|
+
* The title is required (not derived from the bundled index) so this helper
|
|
32
|
+
* stays synchronous and zero-IO. It must match the docs page title; the
|
|
33
|
+
* citation guard validates this against the bundled index in CI.
|
|
34
|
+
*/
|
|
35
|
+
export function buildDeroCitation(product, slug, title) {
|
|
36
|
+
return {
|
|
37
|
+
source: 'dero_docs',
|
|
38
|
+
product,
|
|
39
|
+
slug,
|
|
40
|
+
title,
|
|
41
|
+
canonical_url: buildCanonicalUrl(product, slug),
|
|
42
|
+
page_id: slug,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export const RELATED_DOCS_BY_TOOL = {
|
|
46
|
+
dero_get_info: [
|
|
47
|
+
{
|
|
48
|
+
product: 'derod',
|
|
49
|
+
slug: 'rpc-api/daemon-rpc-api',
|
|
50
|
+
title: 'DERO Daemon RPC API: Complete Reference Guide | DERO Blockchain',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
product: 'derod',
|
|
54
|
+
slug: 'basics/daemon',
|
|
55
|
+
title: 'DERO Daemon: Backbone of the Privacy Blockchain | DERO Blockchain',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
dero_get_sc: [
|
|
59
|
+
{
|
|
60
|
+
product: 'derod',
|
|
61
|
+
slug: 'dvm/smart-contract-fundamentals',
|
|
62
|
+
title: 'Smart Contract Fundamentals: Understanding DERO Contracts | DERO Blockchain',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
product: 'derod',
|
|
66
|
+
slug: 'dvm/dero-virtual-machine',
|
|
67
|
+
title: 'DERO Virtual Machine (DVM): Private Smart Contract Platform | DERO Blockchain',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
dero_get_gas_estimate: [
|
|
71
|
+
{
|
|
72
|
+
product: 'derod',
|
|
73
|
+
slug: 'rpc-api/daemon-rpc-api',
|
|
74
|
+
title: 'DERO Daemon RPC API: Complete Reference Guide | DERO Blockchain',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
product: 'derod',
|
|
78
|
+
slug: 'dvm/create-deploy-use-smart-contract',
|
|
79
|
+
title: 'Create, Deploy & Use a Smart Contract on DERO | Step-by-Step Tutorial',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
diagnose_chain_health: [
|
|
83
|
+
{
|
|
84
|
+
product: 'derod',
|
|
85
|
+
slug: 'basics/daemon',
|
|
86
|
+
title: 'DERO Daemon: Backbone of the Privacy Blockchain | DERO Blockchain',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
product: 'derod',
|
|
90
|
+
slug: 'rpc-api/daemon-rpc-api',
|
|
91
|
+
title: 'DERO Daemon RPC API: Complete Reference Guide | DERO Blockchain',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
trace_transaction_with_context: [
|
|
95
|
+
{
|
|
96
|
+
product: 'derod',
|
|
97
|
+
slug: 'rpc-api/daemon-rpc-api',
|
|
98
|
+
title: 'DERO Daemon RPC API: Complete Reference Guide | DERO Blockchain',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
product: 'derod',
|
|
102
|
+
slug: 'dvm/smart-contract-fundamentals',
|
|
103
|
+
title: 'Smart Contract Fundamentals: Understanding DERO Contracts | DERO Blockchain',
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
estimate_deploy_cost: [
|
|
107
|
+
{
|
|
108
|
+
product: 'derod',
|
|
109
|
+
slug: 'dvm/create-deploy-use-smart-contract',
|
|
110
|
+
title: 'Create, Deploy & Use a Smart Contract on DERO | Step-by-Step Tutorial',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
product: 'derod',
|
|
114
|
+
slug: 'dvm/dvm-basic',
|
|
115
|
+
title: "DVM-BASIC: DERO's Smart Contract Language Guide | DERO Blockchain",
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
// Composite #2 (`explain_smart_contract`) curates all four DVM docs so its
|
|
119
|
+
// heuristic can elevate whichever page best matches the detected surface
|
|
120
|
+
// (token / registry / minimal / generic). The composite re-orders this
|
|
121
|
+
// array at runtime; the static ordering here is the fallback when the
|
|
122
|
+
// heuristic returns the same slug already at index 0 (the universal
|
|
123
|
+
// "fundamentals" default).
|
|
124
|
+
explain_smart_contract: [
|
|
125
|
+
{
|
|
126
|
+
product: 'derod',
|
|
127
|
+
slug: 'dvm/smart-contract-fundamentals',
|
|
128
|
+
title: 'Smart Contract Fundamentals: Understanding DERO Contracts | DERO Blockchain',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
product: 'derod',
|
|
132
|
+
slug: 'dvm/dvm-basic',
|
|
133
|
+
title: "DVM-BASIC: DERO's Smart Contract Language Guide | DERO Blockchain",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
product: 'derod',
|
|
137
|
+
slug: 'dvm/dero-virtual-machine',
|
|
138
|
+
title: 'DERO Virtual Machine (DVM): Private Smart Contract Platform | DERO Blockchain',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
product: 'derod',
|
|
142
|
+
slug: 'dvm/create-deploy-use-smart-contract',
|
|
143
|
+
title: 'Create, Deploy & Use a Smart Contract on DERO | Step-by-Step Tutorial',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Resolve the hand-curated related docs list for a tool name and return it
|
|
149
|
+
* as fully-built `DeroCitation` objects. Returns `undefined` when the tool
|
|
150
|
+
* has no related docs configured.
|
|
151
|
+
*
|
|
152
|
+
* Use in tool handlers like:
|
|
153
|
+
* const related_docs = relatedDocsFor('dero_get_sc')
|
|
154
|
+
* return { ...rpcResult, ...(related_docs ? { related_docs } : {}) }
|
|
155
|
+
*/
|
|
156
|
+
export function relatedDocsFor(toolName) {
|
|
157
|
+
const entries = RELATED_DOCS_BY_TOOL[toolName];
|
|
158
|
+
if (!entries || entries.length === 0)
|
|
159
|
+
return undefined;
|
|
160
|
+
return entries.map((entry) => buildDeroCitation(entry.product, entry.slug, entry.title));
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=citations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citations.js","sourceRoot":"","sources":["../src/citations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EAAuB,MAAM,iBAAiB,CAAA;AAapE,SAAS,iBAAiB,CAAC,OAAuB,EAAE,IAAY;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EA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KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AAC1F,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for DERO MCP composite tools.
|
|
3
|
+
*
|
|
4
|
+
* A composite tool stitches several primitives (daemon RPC reads + bundled
|
|
5
|
+
* docs lookups) into one intent-shaped response. These utilities exist so
|
|
6
|
+
* every composite handles failures, latency tracking, and citation
|
|
7
|
+
* attachment the same way.
|
|
8
|
+
*
|
|
9
|
+
* Anything reused by more than one composite belongs here. Composite-local
|
|
10
|
+
* helpers (e.g. narrative builders specific to one composite's response
|
|
11
|
+
* shape) should live next to that composite, not in this file.
|
|
12
|
+
*
|
|
13
|
+
* See `docs/composites.md` for the design contract that governs which
|
|
14
|
+
* utilities live here and the gate every composite must satisfy before it
|
|
15
|
+
* lands on main.
|
|
16
|
+
*/
|
|
17
|
+
import { type DeroCitation } from '../citations.js';
|
|
18
|
+
/**
|
|
19
|
+
* One step in a composite's internal chain.
|
|
20
|
+
*
|
|
21
|
+
* `required: true` aborts the chain if the step throws (use for liveness
|
|
22
|
+
* gates like `DERO.Ping`). `required: false` lets the chain continue with
|
|
23
|
+
* a degraded payload (use for enrichments like a mempool snapshot).
|
|
24
|
+
*/
|
|
25
|
+
export type ChainStep<T = unknown> = {
|
|
26
|
+
name: string;
|
|
27
|
+
required?: boolean;
|
|
28
|
+
fn: () => Promise<T>;
|
|
29
|
+
};
|
|
30
|
+
export type ChainStepResult = {
|
|
31
|
+
name: string;
|
|
32
|
+
ok: boolean;
|
|
33
|
+
value?: unknown;
|
|
34
|
+
error?: {
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
37
|
+
latencyMs: number;
|
|
38
|
+
};
|
|
39
|
+
export type ChainResult = {
|
|
40
|
+
results: ChainStepResult[];
|
|
41
|
+
haltedAt: string | null;
|
|
42
|
+
totalMs: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Run a chain of named primitive calls sequentially. Required-step
|
|
46
|
+
* failures halt the chain and record `haltedAt`; non-required failures
|
|
47
|
+
* are recorded and the chain continues. Step latencies are captured so
|
|
48
|
+
* composites can attach diagnostics to a degraded response.
|
|
49
|
+
*/
|
|
50
|
+
export declare function runChain(steps: readonly ChainStep[]): Promise<ChainResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Extract a single step's successful return value from a ChainResult.
|
|
53
|
+
* Returns null when the step was skipped (chain halted earlier), failed,
|
|
54
|
+
* or simply was not part of the chain.
|
|
55
|
+
*/
|
|
56
|
+
export declare function stepValue<T = unknown>(chain: ChainResult, name: string): T | null;
|
|
57
|
+
/**
|
|
58
|
+
* Per-step latency map suitable for embedding in a composite's response
|
|
59
|
+
* under a `_diagnostics` field. Lets agents and operators see which step
|
|
60
|
+
* was slow without needing to instrument the host.
|
|
61
|
+
*/
|
|
62
|
+
export declare function stepLatencies(chain: ChainResult): Record<string, number>;
|
|
63
|
+
/**
|
|
64
|
+
* Attach curated `related_docs` citations to a composite's payload.
|
|
65
|
+
* Mirrors how primitives attach citations so the response shape stays
|
|
66
|
+
* uniform across primitives and composites. Returns the payload
|
|
67
|
+
* unchanged when no curated docs are configured for the tool name.
|
|
68
|
+
*/
|
|
69
|
+
export declare function attachCitations<T extends Record<string, unknown>>(payload: T, toolName: string): T & {
|
|
70
|
+
related_docs?: DeroCitation[];
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Shape used by the JSON-RPC `rpc` closure created in `src/server.ts`.
|
|
74
|
+
* Re-declared here so composites can take it as a dependency without
|
|
75
|
+
* importing from the server module (keeps the composite layer free of
|
|
76
|
+
* `McpServer` coupling).
|
|
77
|
+
*/
|
|
78
|
+
export type DeroDaemonRpc = <T = unknown>(method: string, params?: unknown) => Promise<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Loose representation of a `DERO.GetSC` response. Field names match the
|
|
81
|
+
* daemon's actual JSON keys observed on the public node. `uint64keys` is
|
|
82
|
+
* frequently absent (the daemon omits empty maps), so it is optional.
|
|
83
|
+
*/
|
|
84
|
+
export type DeroGetScResult = {
|
|
85
|
+
code?: string;
|
|
86
|
+
status?: string;
|
|
87
|
+
balance?: number;
|
|
88
|
+
balances?: Record<string, number>;
|
|
89
|
+
stringkeys?: Record<string, unknown>;
|
|
90
|
+
uint64keys?: Record<string, unknown>;
|
|
91
|
+
[k: string]: unknown;
|
|
92
|
+
};
|
|
93
|
+
export type DvmFunctionSignature = {
|
|
94
|
+
name: string;
|
|
95
|
+
args: string[];
|
|
96
|
+
returns: string;
|
|
97
|
+
};
|
|
98
|
+
export type DeroScSurface = {
|
|
99
|
+
functions: DvmFunctionSignature[];
|
|
100
|
+
stringkeys: string[];
|
|
101
|
+
uint64keys: string[];
|
|
102
|
+
balances: Record<string, number | string>;
|
|
103
|
+
raw_code_length: number;
|
|
104
|
+
has_code: boolean;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Convert a raw DERO.GetSC payload into a stable, agent-friendly surface.
|
|
108
|
+
*
|
|
109
|
+
* Behavior:
|
|
110
|
+
* - Returns `functions: []` when `code` is missing or the regex finds
|
|
111
|
+
* no Function declarations. Never throws on malformed code.
|
|
112
|
+
* - Sorts `stringkeys` / `uint64keys` alphabetically for deterministic
|
|
113
|
+
* output across invocations.
|
|
114
|
+
* - `balances` is passed through unchanged so callers can render asset
|
|
115
|
+
* balances; native DERO balance lives under `balance` on the raw
|
|
116
|
+
* payload and is left for callers to decide whether to surface.
|
|
117
|
+
*/
|
|
118
|
+
export declare function extractScSurface(raw: DeroGetScResult | null | undefined): DeroScSurface;
|
|
119
|
+
//# sourceMappingURL=_shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../src/composites/_shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnE;;;;;;GAMG;AAC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MAAM,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;AAUzF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,oBAAoB,EAAE,CAAA;IACjC,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;IACzC,eAAe,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AA+BD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,CAqBvF"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for DERO MCP composite tools.
|
|
3
|
+
*
|
|
4
|
+
* A composite tool stitches several primitives (daemon RPC reads + bundled
|
|
5
|
+
* docs lookups) into one intent-shaped response. These utilities exist so
|
|
6
|
+
* every composite handles failures, latency tracking, and citation
|
|
7
|
+
* attachment the same way.
|
|
8
|
+
*
|
|
9
|
+
* Anything reused by more than one composite belongs here. Composite-local
|
|
10
|
+
* helpers (e.g. narrative builders specific to one composite's response
|
|
11
|
+
* shape) should live next to that composite, not in this file.
|
|
12
|
+
*
|
|
13
|
+
* See `docs/composites.md` for the design contract that governs which
|
|
14
|
+
* utilities live here and the gate every composite must satisfy before it
|
|
15
|
+
* lands on main.
|
|
16
|
+
*/
|
|
17
|
+
import { relatedDocsFor } from '../citations.js';
|
|
18
|
+
/**
|
|
19
|
+
* Run a chain of named primitive calls sequentially. Required-step
|
|
20
|
+
* failures halt the chain and record `haltedAt`; non-required failures
|
|
21
|
+
* are recorded and the chain continues. Step latencies are captured so
|
|
22
|
+
* composites can attach diagnostics to a degraded response.
|
|
23
|
+
*/
|
|
24
|
+
export async function runChain(steps) {
|
|
25
|
+
const results = [];
|
|
26
|
+
const startedAt = performance.now();
|
|
27
|
+
let haltedAt = null;
|
|
28
|
+
for (const step of steps) {
|
|
29
|
+
const stepStart = performance.now();
|
|
30
|
+
try {
|
|
31
|
+
const value = await step.fn();
|
|
32
|
+
results.push({
|
|
33
|
+
name: step.name,
|
|
34
|
+
ok: true,
|
|
35
|
+
value,
|
|
36
|
+
latencyMs: Math.round(performance.now() - stepStart),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
results.push({
|
|
41
|
+
name: step.name,
|
|
42
|
+
ok: false,
|
|
43
|
+
error: { message: error instanceof Error ? error.message : String(error) },
|
|
44
|
+
latencyMs: Math.round(performance.now() - stepStart),
|
|
45
|
+
});
|
|
46
|
+
if (step.required) {
|
|
47
|
+
haltedAt = step.name;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
results,
|
|
54
|
+
haltedAt,
|
|
55
|
+
totalMs: Math.round(performance.now() - startedAt),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Extract a single step's successful return value from a ChainResult.
|
|
60
|
+
* Returns null when the step was skipped (chain halted earlier), failed,
|
|
61
|
+
* or simply was not part of the chain.
|
|
62
|
+
*/
|
|
63
|
+
export function stepValue(chain, name) {
|
|
64
|
+
const entry = chain.results.find((r) => r.name === name);
|
|
65
|
+
if (!entry || !entry.ok)
|
|
66
|
+
return null;
|
|
67
|
+
return entry.value;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Per-step latency map suitable for embedding in a composite's response
|
|
71
|
+
* under a `_diagnostics` field. Lets agents and operators see which step
|
|
72
|
+
* was slow without needing to instrument the host.
|
|
73
|
+
*/
|
|
74
|
+
export function stepLatencies(chain) {
|
|
75
|
+
const out = {};
|
|
76
|
+
for (const r of chain.results)
|
|
77
|
+
out[r.name] = r.latencyMs;
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Attach curated `related_docs` citations to a composite's payload.
|
|
82
|
+
* Mirrors how primitives attach citations so the response shape stays
|
|
83
|
+
* uniform across primitives and composites. Returns the payload
|
|
84
|
+
* unchanged when no curated docs are configured for the tool name.
|
|
85
|
+
*/
|
|
86
|
+
export function attachCitations(payload, toolName) {
|
|
87
|
+
const related_docs = relatedDocsFor(toolName);
|
|
88
|
+
if (!related_docs || related_docs.length === 0)
|
|
89
|
+
return payload;
|
|
90
|
+
return { ...payload, related_docs };
|
|
91
|
+
}
|
|
92
|
+
// DVM-BASIC function declaration:
|
|
93
|
+
// Function Name(arg Type, ...) Uint64|String
|
|
94
|
+
//
|
|
95
|
+
// Anchored with `/m` so each line of source is examined independently.
|
|
96
|
+
// Tolerant of leading whitespace and varied spacing inside the parens.
|
|
97
|
+
const DVM_FUNCTION_REGEX = /^[ \t]*Function[ \t]+([A-Za-z_][A-Za-z0-9_]*)[ \t]*\(([^)]*)\)[ \t]*(Uint64|String)\b/gm;
|
|
98
|
+
function parseDvmFunctions(code) {
|
|
99
|
+
const out = [];
|
|
100
|
+
const seen = new Set();
|
|
101
|
+
for (const match of code.matchAll(DVM_FUNCTION_REGEX)) {
|
|
102
|
+
const name = match[1];
|
|
103
|
+
if (seen.has(name))
|
|
104
|
+
continue;
|
|
105
|
+
seen.add(name);
|
|
106
|
+
const argsRaw = (match[2] ?? '').trim();
|
|
107
|
+
const returns = match[3] ?? '';
|
|
108
|
+
const args = argsRaw.length === 0
|
|
109
|
+
? []
|
|
110
|
+
: argsRaw
|
|
111
|
+
.split(',')
|
|
112
|
+
.map((s) => s.trim())
|
|
113
|
+
.filter((s) => s.length > 0);
|
|
114
|
+
out.push({ name, args, returns });
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Convert a raw DERO.GetSC payload into a stable, agent-friendly surface.
|
|
120
|
+
*
|
|
121
|
+
* Behavior:
|
|
122
|
+
* - Returns `functions: []` when `code` is missing or the regex finds
|
|
123
|
+
* no Function declarations. Never throws on malformed code.
|
|
124
|
+
* - Sorts `stringkeys` / `uint64keys` alphabetically for deterministic
|
|
125
|
+
* output across invocations.
|
|
126
|
+
* - `balances` is passed through unchanged so callers can render asset
|
|
127
|
+
* balances; native DERO balance lives under `balance` on the raw
|
|
128
|
+
* payload and is left for callers to decide whether to surface.
|
|
129
|
+
*/
|
|
130
|
+
export function extractScSurface(raw) {
|
|
131
|
+
const code = typeof raw?.code === 'string' ? raw.code : '';
|
|
132
|
+
const functions = code.length > 0 ? parseDvmFunctions(code) : [];
|
|
133
|
+
const stringkeys = raw?.stringkeys ? Object.keys(raw.stringkeys).sort() : [];
|
|
134
|
+
const uint64keys = raw?.uint64keys ? Object.keys(raw.uint64keys).sort() : [];
|
|
135
|
+
const balances = {};
|
|
136
|
+
if (raw?.balances && typeof raw.balances === 'object') {
|
|
137
|
+
for (const [scid, amount] of Object.entries(raw.balances)) {
|
|
138
|
+
if (typeof amount === 'number' || typeof amount === 'string') {
|
|
139
|
+
balances[scid] = amount;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
functions,
|
|
145
|
+
stringkeys,
|
|
146
|
+
uint64keys,
|
|
147
|
+
balances,
|
|
148
|
+
raw_code_length: code.length,
|
|
149
|
+
has_code: code.length > 0,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=_shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../src/composites/_shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAqB,MAAM,iBAAiB,CAAA;AA6BnE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,KAA2B;IACxD,MAAM,OAAO,GAAsB,EAAE,CAAA;IACrC,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IACnC,IAAI,QAAQ,GAAkB,IAAI,CAAA;IAElC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QACnC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,EAAE,EAAE,CAAA;YAC7B,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,EAAE,EAAE,IAAI;gBACR,KAAK;gBACL,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;aACrD,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAA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
* (`DERO.Ping` + `DERO.GetInfo` + `DERO.GetHeight` + `DERO.GetTxPool`) and
|
|
6
|
+
* the "what does this field mean?" docs lookup with a single narrative
|
|
7
|
+
* response carrying chain metadata, mempool snapshot, narrative summary,
|
|
8
|
+
* and curated docs citations.
|
|
9
|
+
*
|
|
10
|
+
* Design contract: `docs/composites.md` § 1 (lowest-risk composite, ships
|
|
11
|
+
* first to prove the composite plumbing — shared utils + flow test pattern
|
|
12
|
+
* + smoke assertions — end-to-end).
|
|
13
|
+
*
|
|
14
|
+
* Failure model:
|
|
15
|
+
* - `DERO.Ping` is the only required step. Its failure halts the chain
|
|
16
|
+
* and the handler throws so `withStructuredErrors` surfaces a
|
|
17
|
+
* structured `RPC_UNREACHABLE` error.
|
|
18
|
+
* - `DERO.GetInfo`, `DERO.GetHeight`, and `DERO.GetTxPool` are
|
|
19
|
+
* non-required. Their failures degrade `status` to `partial` and
|
|
20
|
+
* leave the corresponding response field null, but the composite
|
|
21
|
+
* still returns a useful payload.
|
|
22
|
+
*/
|
|
23
|
+
import { z } from 'zod';
|
|
24
|
+
import { type DeroDaemonRpc } from './_shared.js';
|
|
25
|
+
export declare const diagnoseChainHealthInputSchema: {
|
|
26
|
+
readonly include_tx_pool: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
};
|
|
28
|
+
type DiagnoseInput = {
|
|
29
|
+
include_tx_pool?: boolean;
|
|
30
|
+
};
|
|
31
|
+
type DiagnoseStatus = 'healthy' | 'lagging' | 'partial' | 'unreachable';
|
|
32
|
+
type DiagnoseSignal = {
|
|
33
|
+
key: string;
|
|
34
|
+
value: string | number;
|
|
35
|
+
note?: string;
|
|
36
|
+
};
|
|
37
|
+
export declare function diagnoseChainHealth(rpc: DeroDaemonRpc, args: DiagnoseInput): Promise<{
|
|
38
|
+
status: DiagnoseStatus;
|
|
39
|
+
narrative: string;
|
|
40
|
+
signals: DiagnoseSignal[];
|
|
41
|
+
chain: {
|
|
42
|
+
topoheight: number;
|
|
43
|
+
stableheight: number | null;
|
|
44
|
+
height: number | null;
|
|
45
|
+
network: string | null;
|
|
46
|
+
version: string | null;
|
|
47
|
+
difficulty: string | number | null;
|
|
48
|
+
total_supply: string | number | null;
|
|
49
|
+
} | null;
|
|
50
|
+
mempool: {
|
|
51
|
+
pending: number;
|
|
52
|
+
sample: string[];
|
|
53
|
+
} | null;
|
|
54
|
+
_diagnostics: {
|
|
55
|
+
step_latency_ms: Record<string, number>;
|
|
56
|
+
total_ms: number;
|
|
57
|
+
halted_at: string | null;
|
|
58
|
+
include_tx_pool: boolean;
|
|
59
|
+
};
|
|
60
|
+
} & {
|
|
61
|
+
related_docs?: import("../citations.js").DeroCitation[];
|
|
62
|
+
}>;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=diagnose-chain-health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnose-chain-health.d.ts","sourceRoot":"","sources":["../../src/composites/diagnose-chain-health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AAErB,eAAO,MAAM,8BAA8B;;CAKjC,CAAA;AAEV,KAAK,aAAa,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAyBlD,KAAK,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAA;AAEvE,KAAK,cAAc,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AA4E5E,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;GA+DhF"}
|