@mcsherrylabs/evolver-mcp 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application-signer.d.ts +1 -1
- package/dist/application-signer.d.ts.map +1 -1
- package/dist/attachments.d.ts +1 -1
- package/dist/attachments.d.ts.map +1 -1
- package/dist/attachments.js +2 -2
- package/dist/attachments.js.map +1 -1
- package/dist/content-file-tools.js +1 -1
- package/dist/content-file-tools.js.map +1 -1
- package/dist/content-files.d.ts +1 -1
- package/dist/content-files.d.ts.map +1 -1
- package/dist/content-files.js +1 -1
- package/dist/content-files.js.map +1 -1
- package/dist/content-ranges.d.ts +1 -1
- package/dist/content-ranges.d.ts.map +1 -1
- package/dist/group-crypto-tools.js +1 -1
- package/dist/group-crypto-tools.js.map +1 -1
- package/dist/group-crypto.d.ts +2 -2
- package/dist/group-crypto.d.ts.map +1 -1
- package/dist/group-crypto.js +1 -1
- package/dist/group-crypto.js.map +1 -1
- package/dist/inbox.d.ts +1 -1
- package/dist/inbox.d.ts.map +1 -1
- package/dist/inbox.js +1 -1
- package/dist/inbox.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/login.d.ts +1 -1
- package/dist/login.d.ts.map +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.d.ts.map +1 -1
- package/dist/p2p.d.ts +1 -1
- package/dist/p2p.d.ts.map +1 -1
- package/dist/p2p.js +1 -1
- package/dist/p2p.js.map +1 -1
- package/dist/processor.d.ts +1 -1
- package/dist/processor.d.ts.map +1 -1
- package/dist/processor.js +1 -1
- package/dist/processor.js.map +1 -1
- package/dist/signed-http.d.ts +1 -1
- package/dist/signed-http.d.ts.map +1 -1
- package/dist/tools.d.ts +3 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +10 -10
- package/dist/tools.js.map +1 -1
- package/dist/transaction-interchange-tools.js +1 -1
- package/dist/transaction-interchange-tools.js.map +1 -1
- package/dist/transaction-interchange.d.ts +2 -2
- package/dist/transaction-interchange.d.ts.map +1 -1
- package/dist/transaction-interchange.js +2 -2
- package/dist/transaction-interchange.js.map +1 -1
- package/package.json +4 -16
- package/dist/amount.d.ts +0 -23
- package/dist/amount.d.ts.map +0 -1
- package/dist/amount.js +0 -53
- package/dist/amount.js.map +0 -1
- package/dist/channel.d.ts +0 -77
- package/dist/channel.d.ts.map +0 -1
- package/dist/channel.js +0 -287
- package/dist/channel.js.map +0 -1
- package/dist/claim.d.ts +0 -48
- package/dist/claim.d.ts.map +0 -1
- package/dist/claim.js +0 -81
- package/dist/claim.js.map +0 -1
- package/dist/content.d.ts +0 -94
- package/dist/content.d.ts.map +0 -1
- package/dist/content.js +0 -215
- package/dist/content.js.map +0 -1
- package/dist/group-ownership.d.ts +0 -78
- package/dist/group-ownership.d.ts.map +0 -1
- package/dist/group-ownership.js +0 -324
- package/dist/group-ownership.js.map +0 -1
- package/dist/group.d.ts +0 -60
- package/dist/group.d.ts.map +0 -1
- package/dist/group.js +0 -204
- package/dist/group.js.map +0 -1
- package/dist/identity.d.ts +0 -87
- package/dist/identity.d.ts.map +0 -1
- package/dist/identity.js +0 -236
- package/dist/identity.js.map +0 -1
- package/dist/node-transport.d.ts +0 -14
- package/dist/node-transport.d.ts.map +0 -1
- package/dist/node-transport.js +0 -54
- package/dist/node-transport.js.map +0 -1
- package/dist/read.d.ts +0 -252
- package/dist/read.d.ts.map +0 -1
- package/dist/read.js +0 -320
- package/dist/read.js.map +0 -1
- package/dist/result.d.ts +0 -110
- package/dist/result.d.ts.map +0 -1
- package/dist/result.js +0 -97
- package/dist/result.js.map +0 -1
- package/dist/signer.d.ts +0 -37
- package/dist/signer.d.ts.map +0 -1
- package/dist/signer.js +0 -76
- package/dist/signer.js.map +0 -1
- package/dist/write.d.ts +0 -214
- package/dist/write.d.ts.map +0 -1
- package/dist/write.js +0 -399
- package/dist/write.js.map +0 -1
package/dist/read.js
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
// Chain reads, including bounded node-owned transaction observations. Exact lookup never walks
|
|
2
|
-
// the feed, proves absence, or touches session signing records. A cache miss is not permission
|
|
3
|
-
// to retry a payment. Structural seams permit focused checks without a live node.
|
|
4
|
-
import { ok, partial, wrongKind } from "./result.js";
|
|
5
|
-
/** Small on purpose: the reader is a model, and a page it did not need is context it cannot get
|
|
6
|
-
* back. 200 is the node's own clamp, so the tool never asks for what it cannot get. */
|
|
7
|
-
export const DEFAULT_LIMIT = 20;
|
|
8
|
-
export const MAX_LIMIT = 200;
|
|
9
|
-
/** The node's clamp for the ledger-owners and keys explorer pages (`ExplorerApiHandler`). */
|
|
10
|
-
export const INVENTORY_MAX_LIMIT = 100;
|
|
11
|
-
/** The node parses `offset` as a JVM Int and reads anything larger as 0 — page one, silently. */
|
|
12
|
-
export const MAX_OFFSET = 2_147_483_647;
|
|
13
|
-
/** Exact page arguments, or why not. Only an ABSENT value takes the default; a present one must
|
|
14
|
-
* already be an in-range safe integer. Nothing is clamped, coerced or rounded: the node would
|
|
15
|
-
* clamp silently, and an answer to a page nobody asked for reads as the page they did. */
|
|
16
|
-
export function pageArgs(limit, offset, maxLimit) {
|
|
17
|
-
const lim = limit === undefined ? DEFAULT_LIMIT : limit;
|
|
18
|
-
const off = offset === undefined ? 0 : offset;
|
|
19
|
-
const shown = (v) => typeof v === "string" ? JSON.stringify(v) : String(v);
|
|
20
|
-
if (typeof lim !== "number" || !Number.isSafeInteger(lim) || lim < 1 || lim > maxLimit)
|
|
21
|
-
return `limit must be an integer 1-${maxLimit} (omit for ${DEFAULT_LIMIT}); got ${shown(limit)}`;
|
|
22
|
-
if (typeof off !== "number" || !Number.isSafeInteger(off) || off < 0 || off > MAX_OFFSET)
|
|
23
|
-
return `offset must be an integer 0-${MAX_OFFSET} (omit for 0); got ${shown(offset)}`;
|
|
24
|
-
return { limit: lim, offset: off };
|
|
25
|
-
}
|
|
26
|
-
/** A node that answered outside the page contract is `partial` — retrying will not change it;
|
|
27
|
-
* only failing to get an answer is `unreachable`. The SDK throws `<method>: HTTP <status>`. */
|
|
28
|
-
function pageFailure(what, e) {
|
|
29
|
-
const cause = e instanceof Error ? e.message : String(e);
|
|
30
|
-
if (e instanceof SyntaxError)
|
|
31
|
-
return partial(what, `malformed node response (${cause}); no scan fallback`);
|
|
32
|
-
if (/: HTTP (404|405|501)$/.test(cause))
|
|
33
|
-
return partial(what, `unsupported by this node (${cause}); no scan fallback`);
|
|
34
|
-
return { kind: "unreachable", chain: "", cause };
|
|
35
|
-
}
|
|
36
|
-
const malformedPage = (what, fields) => partial(what, `malformed node page: expected an array of at most limit rows with string ${fields}; no scan fallback`);
|
|
37
|
-
const stringFields = (v, fields) => typeof v === "object" && v !== null && fields.every((f) => typeof v[f] === "string");
|
|
38
|
-
/** Every declared `FeedTx` field, checked before a row is rendered — a renderer handed a partial row
|
|
39
|
-
* would manufacture `undefined` fields. Values are checked, never converted or decoded. */
|
|
40
|
-
const isFeedTx = (v) => {
|
|
41
|
-
if (!stringFields(v, ["txId", "ledgerId", "txType", "sender"]))
|
|
42
|
-
return false;
|
|
43
|
-
const { roundNum, details } = v;
|
|
44
|
-
return typeof roundNum === "number" && Number.isSafeInteger(roundNum) && roundNum >= 0 &&
|
|
45
|
-
Array.isArray(details) && details.every((d) => stringFields(d, ["label", "value"]));
|
|
46
|
-
};
|
|
47
|
-
export async function chainHeight(reads) {
|
|
48
|
-
try {
|
|
49
|
-
const raw = await reads.nodeStatus();
|
|
50
|
-
// The node's field names travel as far as this line and no further. The tool answers in
|
|
51
|
-
// held/applied/heard, because a model reading `blockHeight` alongside `appliedRound` has to
|
|
52
|
-
// infer that the first is also a round and that they are comparable — which is the inference
|
|
53
|
-
// that went wrong.
|
|
54
|
-
const h = { held: raw.blockHeight, applied: raw.appliedRound, heard: raw.heardRound };
|
|
55
|
-
const applyLag = h.applied === null ? null : Math.max(0, h.held - h.applied);
|
|
56
|
-
const syncLag = Math.max(0, h.heard - h.held);
|
|
57
|
-
// Say what the numbers MEAN, because the consumer is a model and a bare triple invites the
|
|
58
|
-
// same conflation the single number caused.
|
|
59
|
-
const note = applyLag !== null && applyLag > 0
|
|
60
|
-
? `state is applied only to ${h.applied}, ${applyLag} round(s) behind what this node holds — ` +
|
|
61
|
-
`a read of anything created above round ${h.applied} will answer not_found here even though the chain has it`
|
|
62
|
-
: syncLag > 0
|
|
63
|
-
? `this node is ${syncLag} round(s) behind the highest round it has heard of`
|
|
64
|
-
: h.applied === null
|
|
65
|
-
? "not a processing node: state applies at commit, so held is what reads answer as of"
|
|
66
|
-
: "state is applied up to what this node holds; reads are current";
|
|
67
|
-
return { kind: "ok", value: { ...h, applyLag, syncLag, note } };
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export async function transaction(reads, txId) {
|
|
74
|
-
const what = "transaction observation";
|
|
75
|
-
if (typeof txId !== "string" || !/^[0-9a-f]{64}$/.test(txId))
|
|
76
|
-
return { kind: "partial", what, cause: "invalid txId: use the original 64-character lowercase signed-intent ID" };
|
|
77
|
-
if (typeof reads.getTransaction !== "function")
|
|
78
|
-
return { kind: "partial", what, cause: "unsupported SDK: getTransaction requires SDK 0.21+ and node #101; no scan fallback" };
|
|
79
|
-
try {
|
|
80
|
-
return { kind: "ok", value: await reads.getTransaction(txId) };
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
const cause = e instanceof Error ? e.message : String(e);
|
|
84
|
-
if (/unsupported transaction lookup|malformed transaction lookup/.test(cause))
|
|
85
|
-
return { kind: "partial", what, cause };
|
|
86
|
-
return { kind: "unreachable", chain: "", cause };
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/** One newest-first page of the explorer feed at the exact validated offset. A display tail, never
|
|
90
|
-
* a lookup: an empty page says nothing about whether a transaction exists. */
|
|
91
|
-
export async function recent(reads, limit, offset) {
|
|
92
|
-
const what = "recent transactions";
|
|
93
|
-
const page = pageArgs(limit, offset, MAX_LIMIT);
|
|
94
|
-
if (typeof page === "string")
|
|
95
|
-
return partial(what, page);
|
|
96
|
-
try {
|
|
97
|
-
const rows = await reads.recentTransactions(page.limit, page.offset);
|
|
98
|
-
if (!Array.isArray(rows) || rows.length > page.limit || !rows.every(isFeedTx))
|
|
99
|
-
return malformedPage(what, "txId/ledgerId/txType/sender, a nonnegative integer roundNum and label/value details");
|
|
100
|
-
return ok({ transactions: rows, ...page });
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
return pageFailure(what, e);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/** One page of the chain-wide ledger-owner listing, exactly as the node orders and reports it.
|
|
107
|
-
* `ownerNodeId` carries no identity/group kind on this row, so none is invented here.
|
|
108
|
-
*
|
|
109
|
-
* ⚠️ NO TOTAL. SDK 0.21.0 substitutes `0` for an absent node total, so a zero cannot be told from
|
|
110
|
-
* a missing field; a count that may be fabricated is not reported. */
|
|
111
|
-
export async function ledgerOwnersPage(reads, limit, offset) {
|
|
112
|
-
const what = "ledger owners page";
|
|
113
|
-
const page = pageArgs(limit, offset, INVENTORY_MAX_LIMIT);
|
|
114
|
-
if (typeof page === "string")
|
|
115
|
-
return partial(what, page);
|
|
116
|
-
if (typeof reads.listLedgerOwners !== "function")
|
|
117
|
-
return partial(what, "unsupported client: listLedgerOwners is unavailable; no scan fallback");
|
|
118
|
-
try {
|
|
119
|
-
const rows = (await reads.listLedgerOwners(page.limit, page.offset))?.owners;
|
|
120
|
-
if (!Array.isArray(rows) || rows.length > page.limit || !rows.every((o) => stringFields(o, ["ledgerId", "ownerNodeId"])))
|
|
121
|
-
return malformedPage(what, "ledgerId/ownerNodeId");
|
|
122
|
-
const owners = rows
|
|
123
|
-
.map((o) => ({ ledgerId: o.ledgerId, ownerNodeId: o.ownerNodeId }));
|
|
124
|
-
return ok({ owners, ...page });
|
|
125
|
-
}
|
|
126
|
-
catch (e) {
|
|
127
|
-
return pageFailure(what, e);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/** One page of the chain-wide registered PUBLIC key metadata. Never the route to one identity's
|
|
131
|
-
* keys — that is `keys(name)`, a direct read. The SDK returns no total for this page. */
|
|
132
|
-
export async function chainKeysPage(reads, limit, offset) {
|
|
133
|
-
const what = "chain keys page";
|
|
134
|
-
const page = pageArgs(limit, offset, INVENTORY_MAX_LIMIT);
|
|
135
|
-
if (typeof page === "string")
|
|
136
|
-
return partial(what, page);
|
|
137
|
-
if (typeof reads.getKeys !== "function")
|
|
138
|
-
return partial(what, "unsupported client: getKeys is unavailable; no scan fallback");
|
|
139
|
-
const fields = ["nodeId", "keyType", "label", "publicKeyHex"];
|
|
140
|
-
try {
|
|
141
|
-
const rows = await reads.getKeys(page.limit, page.offset);
|
|
142
|
-
if (!Array.isArray(rows) || rows.length > page.limit || !rows.every((k) => stringFields(k, fields)))
|
|
143
|
-
return malformedPage(what, fields.join("/"));
|
|
144
|
-
const keys = rows
|
|
145
|
-
.map((k) => ({ nodeId: k.nodeId, keyType: k.keyType, label: k.label, publicKeyHex: k.publicKeyHex }));
|
|
146
|
-
return ok({ keys, ...page });
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
return pageFailure(what, e);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/** The one read with a DEFINITIVE negative: the chain answered and has no such identity. The
|
|
153
|
-
* height it answered at travels with it, so a lagging node is visible rather than confident.
|
|
154
|
-
*
|
|
155
|
-
* ⚠️ AND A NEGATIVE IS CHECKED AGAINST THE OTHER KIND BEFORE IT IS REPORTED. `/api/identity`
|
|
156
|
-
* answers only for identities, so a GROUP name 404s there — and reporting that as `not_found`
|
|
157
|
-
* tells a model "no such thing" about a name the chain holds. A name is one kind or the other
|
|
158
|
-
* (the two share one namespace, with uniqueness enforced across both), so the second read
|
|
159
|
-
* settles it. */
|
|
160
|
-
export async function identity(reads, name) {
|
|
161
|
-
try {
|
|
162
|
-
const found = await reads.getIdentity(name);
|
|
163
|
-
if (found === null) {
|
|
164
|
-
let atHeight;
|
|
165
|
-
try {
|
|
166
|
-
atHeight = await reads.currentRound();
|
|
167
|
-
}
|
|
168
|
-
catch { /* the negative still stands */ }
|
|
169
|
-
// Best-effort, and deliberately so: if THIS read fails we still report the identity
|
|
170
|
-
// negative, which the node gave definitively. A group we cannot confirm must not turn a
|
|
171
|
-
// definitive answer into an unreachable one.
|
|
172
|
-
let asGroup = null;
|
|
173
|
-
try {
|
|
174
|
-
asGroup = await reads.getGroup(name);
|
|
175
|
-
}
|
|
176
|
-
catch { /* the identity negative still stands */ }
|
|
177
|
-
if (asGroup !== null)
|
|
178
|
-
return wrongKind(`identity "${name}"`, "group", "evolver_group", atHeight);
|
|
179
|
-
return { kind: "not_found", what: `identity "${name}"`, atHeight };
|
|
180
|
-
}
|
|
181
|
-
return { kind: "ok", value: found };
|
|
182
|
-
}
|
|
183
|
-
catch (e) {
|
|
184
|
-
return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/** The mirror read: one group and who is in it.
|
|
188
|
-
*
|
|
189
|
-
* ⚠️ IT REPORTS THE OTHER KIND TOO, in the other direction. Asking about an identity by this
|
|
190
|
-
* verb is the same mistake and deserves the same answer — otherwise closing half the gap would
|
|
191
|
-
* leave a model told "no such group" about an identity it can see elsewhere.
|
|
192
|
-
*
|
|
193
|
-
* ⚠️ AN EMPTY MEMBER LIST IS AN ANSWER, NOT AN ABSENCE: a group exists before anyone is added to
|
|
194
|
-
* it, and `members: []` is what that looks like. The existence question is answered by the read
|
|
195
|
-
* returning at all. */
|
|
196
|
-
export async function group(reads, name) {
|
|
197
|
-
try {
|
|
198
|
-
const found = await reads.getGroup(name);
|
|
199
|
-
if (found !== null)
|
|
200
|
-
return { kind: "ok", value: found };
|
|
201
|
-
let atHeight;
|
|
202
|
-
try {
|
|
203
|
-
atHeight = await reads.currentRound();
|
|
204
|
-
}
|
|
205
|
-
catch { /* the negative still stands */ }
|
|
206
|
-
let asIdentity = null;
|
|
207
|
-
try {
|
|
208
|
-
asIdentity = await reads.getIdentity(name);
|
|
209
|
-
}
|
|
210
|
-
catch { /* the group negative still stands */ }
|
|
211
|
-
if (asIdentity !== null)
|
|
212
|
-
return wrongKind(`group "${name}"`, "identity", "evolver_identity", atHeight);
|
|
213
|
-
return { kind: "not_found", what: `group "${name}"`, atHeight };
|
|
214
|
-
}
|
|
215
|
-
catch (e) {
|
|
216
|
-
return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
/** A name (or ledger id) that must be supplied for the read to mean anything. `partial` — a
|
|
220
|
-
* refusal, not an answer — because the chain was never asked: there is nothing to retry. */
|
|
221
|
-
const refuseRead = (what, cause) => ({ kind: "partial", what, cause });
|
|
222
|
-
/** An identity's complete registered keys, read directly.
|
|
223
|
-
*
|
|
224
|
-
* ⚠️ AN EMPTY LIST IS AN ANSWER AND NOT AN ABSENCE: an identity exists before it holds keys, and
|
|
225
|
-
* an empty set is what that looks like. `not_found` means the chain has no such identity. */
|
|
226
|
-
export async function keys(reads, identityName) {
|
|
227
|
-
const who = String(identityName ?? "").trim();
|
|
228
|
-
if (who.length === 0)
|
|
229
|
-
return refuseRead("keys", "which identity? a name is required");
|
|
230
|
-
try {
|
|
231
|
-
// Older key endpoints returned [] for groups too. Probe the other kind first so even
|
|
232
|
-
// those nodes cannot turn an empty group into a fabricated keyless identity. Two direct
|
|
233
|
-
// by-name reads, no chain-wide keys/groups scan. A failed kind read is not absence.
|
|
234
|
-
if (await reads.getGroup(who) !== null)
|
|
235
|
-
return wrongKind(`identity keys "${who}"`, "group", "evolver_group");
|
|
236
|
-
const rows = await reads.getIdentityKeys(who);
|
|
237
|
-
if (rows === null)
|
|
238
|
-
return { kind: "not_found", what: `identity "${who}"` };
|
|
239
|
-
return {
|
|
240
|
-
kind: "ok",
|
|
241
|
-
value: {
|
|
242
|
-
identity: who,
|
|
243
|
-
keys: rows.map((r) => ({ keyType: r.keyType, label: r.label, publicKeyHex: r.publicKeyHex })),
|
|
244
|
-
complete: true,
|
|
245
|
-
scanned: rows.length,
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
catch (e) {
|
|
250
|
-
return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
/** A channel's terms: who owns it, who may write, what a write costs, who holds the bodies.
|
|
254
|
-
*
|
|
255
|
-
* ⚠️ `owners: []` IS AN ANSWER AND IT IS NOT AN ERROR. A channel is not a registered entity —
|
|
256
|
-
* an unclaimed ledger id simply has no owner and no terms, and is therefore open to everyone.
|
|
257
|
-
* So this never reports `not_found`: it reports `claimed: false`, which is the fact. */
|
|
258
|
-
export async function channelTerms(reads, ledgerId) {
|
|
259
|
-
const id = String(ledgerId ?? "").trim();
|
|
260
|
-
if (id.length === 0)
|
|
261
|
-
return refuseRead("channel terms", "which channel? a ledger id is required");
|
|
262
|
-
try {
|
|
263
|
-
const t = await reads.getChannelTerms(id);
|
|
264
|
-
return {
|
|
265
|
-
kind: "ok",
|
|
266
|
-
value: {
|
|
267
|
-
ledgerId: id,
|
|
268
|
-
claimed: t.owners.length > 0,
|
|
269
|
-
owners: t.owners,
|
|
270
|
-
// A decimal STRING on the way out: an amount is an int64 and a JSON number silently
|
|
271
|
-
// loses precision above 2^53, which for a toll means being wrong about what a write costs.
|
|
272
|
-
toll: t.toll === null ? null : { amount: t.toll.amount.toString(), recipient: t.toll.recipient },
|
|
273
|
-
da: t.da,
|
|
274
|
-
// ABSENCE IS THE DEFAULT: no row means owner_or_group. `null` is therefore an answer, not
|
|
275
|
-
// a gap, and is resolved here so the agent never sees an unexplained null.
|
|
276
|
-
writePolicy: t.writePolicy ?? "owner_or_group",
|
|
277
|
-
},
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
catch (e) {
|
|
281
|
-
return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
/** Every group on the chain, each with its owner.
|
|
285
|
-
*
|
|
286
|
-
* ⚠️ THIS IS THE ONLY READ THAT CARRIES AN OWNER. Reading one group by name returns its members
|
|
287
|
-
* and NOT who owns it, so "who owns this group?" is answered here or nowhere. The node returns
|
|
288
|
-
* the whole listing, so the slice below is local and `total` says what it was sliced from. */
|
|
289
|
-
export async function groups(reads, limit = DEFAULT_LIMIT, offset = 0) {
|
|
290
|
-
const lim = Math.max(1, Math.min(MAX_LIMIT, Math.trunc(limit)));
|
|
291
|
-
const off = Math.max(0, Math.trunc(offset));
|
|
292
|
-
try {
|
|
293
|
-
const all = await reads.listGroups();
|
|
294
|
-
return { kind: "ok", value: { groups: all.slice(off, off + lim), total: all.length, limit: lim, offset: off } };
|
|
295
|
-
}
|
|
296
|
-
catch (e) {
|
|
297
|
-
return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
/** One bounded node page. Total is the NODE's filtered count, not an array length. */
|
|
301
|
-
export async function searchPrincipals(reads, q, limit = DEFAULT_LIMIT, offset = 0, mode = "prefix", kind = "all") {
|
|
302
|
-
const query = String(q ?? "").trim();
|
|
303
|
-
if (!query || query.length > 128)
|
|
304
|
-
return refuseRead("search", "query must be 1-128 characters");
|
|
305
|
-
if (!Number.isSafeInteger(limit) || !Number.isSafeInteger(offset) ||
|
|
306
|
-
!["prefix", "contains"].includes(mode) || !["all", "identity", "group", "validator"].includes(kind))
|
|
307
|
-
return refuseRead("search", "use integer limit/offset, mode prefix|contains and kind all|identity|group|validator");
|
|
308
|
-
const lim = Math.max(1, Math.min(100, limit)), off = Math.max(0, offset);
|
|
309
|
-
if (!reads.searchPrincipalPage)
|
|
310
|
-
return refuseRead("search", "requires evolver-client 0.21+ and the node #64 principal-page contract; upgrade both (no scan fallback)");
|
|
311
|
-
try {
|
|
312
|
-
const { results, ...page } = await reads.searchPrincipalPage(query, { limit: lim, offset: off, mode, kind });
|
|
313
|
-
const matches = results.map(r => ({ ...r, balance: r.balance === null ? null : r.balance.toString() }));
|
|
314
|
-
return { kind: "ok", value: { query, matches, ...page } };
|
|
315
|
-
}
|
|
316
|
-
catch (e) {
|
|
317
|
-
return { kind: "unreachable", chain: "", cause: e instanceof Error ? e.message : String(e) };
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
//# sourceMappingURL=read.js.map
|
package/dist/read.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,+FAA+F;AAC/F,kFAAkF;AAGlF,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAwDrD;wFACwF;AACxF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAChC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,6FAA6F;AAC7F,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,iGAAiG;AACjG,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;AAExC;;2FAE2F;AAC3F,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,MAAe,EAAE,QAAgB;IACxE,MAAM,GAAG,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;IACxD,MAAM,GAAG,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9C,MAAM,KAAK,GAAG,CAAC,CAAU,EAAU,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAA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G,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;QACxG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC;IAC5D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/F,CAAC;AACH,CAAC"}
|
package/dist/result.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
export declare const TOOL_RESULT_KINDS: readonly ["ok", "unreachable", "not_found", "partial", "wrong_kind", "misconfigured"];
|
|
2
|
-
export type ToolResultKind = (typeof TOOL_RESULT_KINDS)[number];
|
|
3
|
-
export type ToolResult<T> = {
|
|
4
|
-
readonly kind: "ok";
|
|
5
|
-
readonly value: T;
|
|
6
|
-
}
|
|
7
|
-
/** The chain could not be contacted. NEVER an answer about the world. */
|
|
8
|
-
| {
|
|
9
|
-
readonly kind: "unreachable";
|
|
10
|
-
readonly chain: string;
|
|
11
|
-
readonly cause: string;
|
|
12
|
-
}
|
|
13
|
-
/** The chain answered and has no such thing — definitive, at the height it answered from. */
|
|
14
|
-
| {
|
|
15
|
-
readonly kind: "not_found";
|
|
16
|
-
readonly what: string;
|
|
17
|
-
readonly atHeight?: number;
|
|
18
|
-
}
|
|
19
|
-
/** A scan was interrupted before it finished. Not a bound — a bound would be a lie. */
|
|
20
|
-
| {
|
|
21
|
-
readonly kind: "partial";
|
|
22
|
-
readonly what: string;
|
|
23
|
-
readonly cause: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The name EXISTS, as the other kind of principal.
|
|
27
|
-
*
|
|
28
|
-
* ⚠️ WHY THIS IS NOT `not_found`. A name on an evolver chain is either an identity or a group —
|
|
29
|
-
* one registry, one name, one kind, uniqueness enforced across both. So an identity lookup of a
|
|
30
|
-
* GROUP name used to answer `not_found`, which a model correctly reads as "there is no such
|
|
31
|
-
* thing" — and reported that about something the chain holds. Observed live: a tool said
|
|
32
|
-
* `not_found` for a name that was a group all along.
|
|
33
|
-
*
|
|
34
|
-
* The failure is in the KIND, not in the payload: a model branches on `kind`, so enriching
|
|
35
|
-
* `not_found` with an extra field would have left the wrong conclusion one field-read away.
|
|
36
|
-
* `use` names the tool that WILL answer, because a model's next move should not need a guess.
|
|
37
|
-
*/
|
|
38
|
-
| {
|
|
39
|
-
readonly kind: "wrong_kind";
|
|
40
|
-
readonly what: string;
|
|
41
|
-
readonly found: "identity" | "group";
|
|
42
|
-
readonly use: string;
|
|
43
|
-
readonly atHeight?: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* This agent is not set up to answer that, and no amount of retrying will change it.
|
|
47
|
-
*
|
|
48
|
-
* ⚠️ WHY NOT `unreachable`. Both mean "no answer", and that is exactly the collapse this
|
|
49
|
-
* taxonomy exists to prevent. `unreachable` says the chain was TRIED and did not respond — a
|
|
50
|
-
* model should wait and retry, and an operator should look at the network. `misconfigured`
|
|
51
|
-
* says nothing was tried because this agent does not know where to try. Retrying is futile and
|
|
52
|
-
* waiting is worse than futile; a HUMAN has to set something.
|
|
53
|
-
*
|
|
54
|
-
* `fix` is the sentence that says what. A refusal that does not say how to stop being refused
|
|
55
|
-
* makes the model guess.
|
|
56
|
-
*/
|
|
57
|
-
| {
|
|
58
|
-
readonly kind: "misconfigured";
|
|
59
|
-
readonly what: string;
|
|
60
|
-
readonly fix: string;
|
|
61
|
-
};
|
|
62
|
-
export declare const ok: <T>(value: T) => ToolResult<T>;
|
|
63
|
-
export declare const misconfigured: (what: string, fix: string) => ToolResult<never>;
|
|
64
|
-
export declare const notFound: (what: string, atHeight?: number) => ToolResult<never>;
|
|
65
|
-
export declare const wrongKind: (what: string, found: "identity" | "group", use: string, atHeight?: number) => ToolResult<never>;
|
|
66
|
-
export declare const partial: (what: string, cause: string) => ToolResult<never>;
|
|
67
|
-
/** Turn anything thrown into `unreachable`, naming the chain that was tried.
|
|
68
|
-
*
|
|
69
|
-
* This exists because the harness signals an error by the tool throwing, and the client throws
|
|
70
|
-
* on any non-OK response while the transport rejects on failure. An escaped throw hands the
|
|
71
|
-
* model a bare error string and collapses this taxonomy at exactly the point it protects. */
|
|
72
|
-
export declare const unreachableFrom: (e: unknown, chain: string) => ToolResult<never>;
|
|
73
|
-
import type { SubmitResult } from "@mcsherrylabs/evolver-client";
|
|
74
|
-
export type SubmissionOutcome =
|
|
75
|
-
/** ORDERED. ⚠️ Not the same as PAID: an instruction can be abandoned at apply with the charge
|
|
76
|
-
* burned and no fine. "Did my payment land" is answered by the balance, not by ordering. */
|
|
77
|
-
{
|
|
78
|
-
readonly kind: "committed";
|
|
79
|
-
readonly txId: string;
|
|
80
|
-
}
|
|
81
|
-
/** Ordered, charged a fee AND a fine, and the payment did not happen. */
|
|
82
|
-
| {
|
|
83
|
-
readonly kind: "fined";
|
|
84
|
-
readonly reason: string;
|
|
85
|
-
readonly message: string;
|
|
86
|
-
readonly txId: string;
|
|
87
|
-
}
|
|
88
|
-
/** The node decided. Final: nothing was ordered and nothing was charged. */
|
|
89
|
-
| {
|
|
90
|
-
readonly kind: "refused";
|
|
91
|
-
readonly reason: string;
|
|
92
|
-
readonly message: string;
|
|
93
|
-
readonly txId?: string;
|
|
94
|
-
}
|
|
95
|
-
/** No readable answer. It MAY have committed. Resolve by looking it up — never by re-signing. */
|
|
96
|
-
| {
|
|
97
|
-
readonly kind: "unknown";
|
|
98
|
-
readonly why: string;
|
|
99
|
-
readonly txId?: string;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Map what the client reports onto what we tell the model.
|
|
103
|
-
*
|
|
104
|
-
* ⚠️ The trap this exists to avoid: reporting an unread reply as `refused`, which tells the model
|
|
105
|
-
* nothing happened, whose repair is to SIGN AGAIN. The expiry round is folded into the id, so a
|
|
106
|
-
* re-signed payment is a different transaction replay protection cannot recognise — both may
|
|
107
|
-
* commit. An unknown/`timeout`/unrecognised reason is therefore OPEN, never `refused`.
|
|
108
|
-
*/
|
|
109
|
-
export declare function classifySubmit(r: SubmitResult): SubmissionOutcome;
|
|
110
|
-
//# sourceMappingURL=result.d.ts.map
|
package/dist/result.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,iBAAiB,uFAOpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,MAAM,MAAM,UAAU,CAAC,CAAC,IACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE;AAC5C,yEAAyE;GACvE;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAClF,6FAA6F;GAC3F;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;AACnF,uFAAuF;GACrF;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC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,MAAM,MAAM,iBAAiB;AAC3B;6FAC6F;AAC3F;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACvD,yEAAyE;GACvE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACtG,4EAA4E;GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;AACzG,iGAAiG;GAC/F;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAuC/E;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,GAAG,iBAAiB,CAgBjE"}
|
package/dist/result.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// The failure taxonomy every Phase-1 read tool answers in.
|
|
2
|
-
//
|
|
3
|
-
// Two shapes live here in the reference implementation — `ToolResult<T>` (what a READ answers)
|
|
4
|
-
// and `SubmissionOutcome` (what a WRITE answers). Phase 1 is read-only, so only the read half is
|
|
5
|
-
// ported: the six kinds the Phase-1 tools actually emit. `not_found_within` is scan-only (it
|
|
6
|
-
// serves the deferred `evolver_transaction`) and `classifySubmit` is the write path (Phase 2), so
|
|
7
|
-
// neither is ported — and the union, the `ToolResultKind` discriminator set, and `toMcpResult`
|
|
8
|
-
//'s branch all agree on exactly these six, leaving no dangling union/branch.
|
|
9
|
-
//
|
|
10
|
-
// The distinctions are the point. A reader is a model, and it cannot tell "the chain says no such
|
|
11
|
-
// thing" from "I could not reach the chain" unless the answer says which — so the kinds are never
|
|
12
|
-
// allowed to collapse into one another.
|
|
13
|
-
export const TOOL_RESULT_KINDS = [
|
|
14
|
-
"ok",
|
|
15
|
-
"unreachable",
|
|
16
|
-
"not_found",
|
|
17
|
-
"partial",
|
|
18
|
-
"wrong_kind",
|
|
19
|
-
"misconfigured",
|
|
20
|
-
];
|
|
21
|
-
export const ok = (value) => ({ kind: "ok", value });
|
|
22
|
-
export const misconfigured = (what, fix) => ({ kind: "misconfigured", what, fix });
|
|
23
|
-
export const notFound = (what, atHeight) => ({ kind: "not_found", what, atHeight });
|
|
24
|
-
export const wrongKind = (what, found, use, atHeight) => ({ kind: "wrong_kind", what, found, use, atHeight });
|
|
25
|
-
export const partial = (what, cause) => ({ kind: "partial", what, cause });
|
|
26
|
-
/** Turn anything thrown into `unreachable`, naming the chain that was tried.
|
|
27
|
-
*
|
|
28
|
-
* This exists because the harness signals an error by the tool throwing, and the client throws
|
|
29
|
-
* on any non-OK response while the transport rejects on failure. An escaped throw hands the
|
|
30
|
-
* model a bare error string and collapses this taxonomy at exactly the point it protects. */
|
|
31
|
-
export const unreachableFrom = (e, chain) => ({
|
|
32
|
-
kind: "unreachable",
|
|
33
|
-
chain,
|
|
34
|
-
cause: e instanceof Error ? e.message : String(e),
|
|
35
|
-
});
|
|
36
|
-
import { FAILURE_REASONS } from "@mcsherrylabs/evolver-client";
|
|
37
|
-
/**
|
|
38
|
-
* Which failure reasons are a genuine, final answer from the node, and which leave the outcome
|
|
39
|
-
* open.
|
|
40
|
-
*
|
|
41
|
-
* ⚠️ Typed `Record<FailureReason, …>` ON PURPOSE. Adding a reason to the client makes this file
|
|
42
|
-
* FAIL TO COMPILE until somebody classifies it — a new reason cannot quietly inherit a default
|
|
43
|
-
* that happens to be wrong. The dangerous direction is `refused`: it asserts nothing happened.
|
|
44
|
-
*/
|
|
45
|
-
const REASON_CLASS = {
|
|
46
|
-
// ── client-side or otherwise open: the transaction MAY have been ordered ──
|
|
47
|
-
internal: "unknown",
|
|
48
|
-
confirmation_timeout: "unknown",
|
|
49
|
-
duplicate: "unknown",
|
|
50
|
-
// ── genuine, final node answers: nothing was ordered and nothing was charged ──
|
|
51
|
-
malformed_signed_tx: "refused",
|
|
52
|
-
unknown_ledger_id: "refused",
|
|
53
|
-
node_not_ready: "refused",
|
|
54
|
-
queue_full: "refused",
|
|
55
|
-
invalid_signature: "refused",
|
|
56
|
-
insufficient_balance: "refused",
|
|
57
|
-
invalid_identity_body: "refused",
|
|
58
|
-
invalid_group_body: "refused",
|
|
59
|
-
invalid_owners_body: "refused",
|
|
60
|
-
invalid_list_body: "refused",
|
|
61
|
-
rejected: "refused",
|
|
62
|
-
ttl_expired: "refused",
|
|
63
|
-
ttl_too_far: "refused",
|
|
64
|
-
unknown_key: "refused",
|
|
65
|
-
unauthorized: "refused",
|
|
66
|
-
toll_ceiling_too_low: "refused",
|
|
67
|
-
insufficient_da: "refused",
|
|
68
|
-
too_many_auths: "refused",
|
|
69
|
-
da_unavailable: "refused",
|
|
70
|
-
channel_store_full: "refused",
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Map what the client reports onto what we tell the model.
|
|
74
|
-
*
|
|
75
|
-
* ⚠️ The trap this exists to avoid: reporting an unread reply as `refused`, which tells the model
|
|
76
|
-
* nothing happened, whose repair is to SIGN AGAIN. The expiry round is folded into the id, so a
|
|
77
|
-
* re-signed payment is a different transaction replay protection cannot recognise — both may
|
|
78
|
-
* commit. An unknown/`timeout`/unrecognised reason is therefore OPEN, never `refused`.
|
|
79
|
-
*/
|
|
80
|
-
export function classifySubmit(r) {
|
|
81
|
-
switch (r.kind) {
|
|
82
|
-
case "committed":
|
|
83
|
-
return { kind: "committed", txId: r.txIdHex };
|
|
84
|
-
case "fined":
|
|
85
|
-
return { kind: "fined", reason: r.reason, message: r.message, txId: r.txIdHex };
|
|
86
|
-
case "timeout":
|
|
87
|
-
return { kind: "unknown", why: "no reply before the deadline — it may have committed", txId: r.txIdHex };
|
|
88
|
-
case "failed": {
|
|
89
|
-
const known = FAILURE_REASONS.includes(r.reason);
|
|
90
|
-
const cls = known ? REASON_CLASS[r.reason] : "unknown";
|
|
91
|
-
return cls === "refused"
|
|
92
|
-
? { kind: "refused", reason: r.reason, message: r.message, txId: r.txIdHex }
|
|
93
|
-
: { kind: "unknown", why: `${r.reason}: ${r.message}`, txId: r.txIdHex };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=result.js.map
|
package/dist/result.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,+FAA+F;AAC/F,iGAAiG;AACjG,6FAA6F;AAC7F,kGAAkG;AAClG,+FAA+F;AAC/F,6EAA6E;AAC7E,EAAE;AACF,kGAAkG;AAClG,kGAAkG;AAClG,wCAAwC;AAExC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI;IACJ,aAAa;IACb,WAAW;IACX,SAAS;IACT,YAAY;IACZ,eAAe;CACP,CAAC;AA8CX,MAAM,CAAC,MAAM,EAAE,GAAG,CAAI,KAAQ,EAAiB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAE1E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,GAAW,EAAqB,EAAE,CAC5E,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,QAAiB,EAAqB,EAAE,CAC7E,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QA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AAC;QAC7E,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/signer.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Signer } from "@mcsherrylabs/evolver-client";
|
|
2
|
-
/** The env var naming a path to a base64-encoded key file. Signing is impossible without it. */
|
|
3
|
-
export declare const EVOLVER_KEY_PATH = "EVOLVER_KEY_PATH";
|
|
4
|
-
/** The env var naming the key type: `"bls"` (default) or `"ed25519"`. */
|
|
5
|
-
export declare const EVOLVER_KEY_TYPE = "EVOLVER_KEY_TYPE";
|
|
6
|
-
/** The key types this module understands, so a misspelt type is refused here rather than by the
|
|
7
|
-
* SDK with an error that echoes nothing useful. */
|
|
8
|
-
export declare const SIGNER_TYPE: readonly ["bls", "ed25519"];
|
|
9
|
-
export type KeySource = (typeof SIGNER_TYPE)[number];
|
|
10
|
-
export type SignerResult = {
|
|
11
|
-
readonly ok: true;
|
|
12
|
-
readonly signer: Signer;
|
|
13
|
-
} | {
|
|
14
|
-
readonly ok: false;
|
|
15
|
-
readonly error: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Resolve the host-held signing key from the environment. Pure of the config file on purpose:
|
|
19
|
-
* the config is a committable file and key material has no place in it (D-07).
|
|
20
|
-
*
|
|
21
|
-
* ⚠️ The error text names the PATH, never the key bytes. A key is the one thing in this process
|
|
22
|
-
* whose value must not appear in a log line or a tool result, so a failure reports where the key
|
|
23
|
-
* was looked for and what was missing about it — nothing more. The bytes themselves are only ever
|
|
24
|
-
* read into memory, base64-decoded, and folded into the `Signer` that closes over them.
|
|
25
|
-
*/
|
|
26
|
-
export declare function loadSigner(source: KeySource, raw: Uint8Array | null): SignerResult;
|
|
27
|
-
/**
|
|
28
|
-
* Read the key from the environment and construct the `Signer`. The only function that touches
|
|
29
|
-
* a filesystem here — `loadSigner` itself stays pure so the resolution rule can be exercised
|
|
30
|
-
* without a key file.
|
|
31
|
-
*
|
|
32
|
-
* Reads `process.env.EVOLVER_KEY_PATH` and `process.env.EVOLVER_KEY_TYPE`; neither is ever read
|
|
33
|
-
* from config. Returns `{ ok: false, error }` (naming the PATH, never the key) when the env var
|
|
34
|
-
* is unset, the file is missing, or the decoded bytes are empty.
|
|
35
|
-
*/
|
|
36
|
-
export declare function loadSignerFromEnv(env: NodeJS.ProcessEnv): SignerResult;
|
|
37
|
-
//# sourceMappingURL=signer.d.ts.map
|
package/dist/signer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAE3D,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD;oDACoD;AACpD,eAAO,MAAM,WAAW,6BAA8B,CAAC;AACvD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,GAAG,YAAY,CAgBlF;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,YAAY,CA0BtE"}
|