@esseyonsui/sui-mcp-v3 0.1.8 → 0.2.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/README.md +37 -7
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +2 -2
- package/dist/args.d.ts +11 -2
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +37 -10
- package/dist/artifact-cache.d.ts +14 -0
- package/dist/artifact-cache.d.ts.map +1 -0
- package/dist/artifact-cache.js +48 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -3
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/fund.d.ts.map +1 -1
- package/dist/fund.js +2 -2
- package/dist/handles.d.ts +23 -0
- package/dist/handles.d.ts.map +1 -0
- package/dist/handles.js +142 -0
- package/dist/http.d.ts +6 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +5 -0
- package/dist/init.d.ts +7 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +18 -11
- package/dist/io.d.ts +22 -12
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +194 -142
- package/dist/keys.d.ts +2 -0
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +14 -1
- package/dist/main.js +21 -9
- package/dist/records.d.ts +21 -4
- package/dist/records.d.ts.map +1 -1
- package/dist/records.js +74 -21
- package/dist/reveal.d.ts +7 -0
- package/dist/reveal.d.ts.map +1 -0
- package/dist/reveal.js +40 -0
- package/dist/snapshot.d.ts +13 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +29 -0
- package/dist/tools-badge.js +3 -3
- package/dist/tools-more.d.ts +9 -5
- package/dist/tools-more.d.ts.map +1 -1
- package/dist/tools-more.js +56 -12
- package/dist/tools-sales.d.ts.map +1 -1
- package/dist/tools-sales.js +34 -24
- package/dist/tools.d.ts +3 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +64 -30
- package/package.json +4 -3
package/dist/tools.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DemoClient } from "./client.ts";
|
|
2
|
+
import type { Handles } from "./handles.ts";
|
|
2
3
|
import type { ToolDef } from "./protocol.ts";
|
|
3
4
|
import type { Records } from "./records.ts";
|
|
4
5
|
export type ToolContext = {
|
|
@@ -14,6 +15,8 @@ export type ToolContext = {
|
|
|
14
15
|
* counts as false: the step landed, so it is never reported as an error.
|
|
15
16
|
*/
|
|
16
17
|
waitIndexed?(landedAtMs: number): Promise<boolean>;
|
|
18
|
+
/** Unset is `ESSEY_MCP_OUTPUT=clear`: results carry ids, digests, tickets and amounts as they are. */
|
|
19
|
+
handles?: Handles;
|
|
17
20
|
};
|
|
18
21
|
type Args = Record<string, unknown>;
|
|
19
22
|
type ToolKind = "read" | "call";
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,gGAAgG;IAChG,OAAO,EAAE,OAAO,CAAC;IACjB,8FAA8F;IAC9F,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,yFAAyF;IACzF,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,sGAAsG;IACtG,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpC,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG;IACzC,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD,CAAC;AA8cF,eAAO,MAAM,KAAK,EAAE,IAAI,EAUvB,CAAC;AAoBF,+GAA+G;AAC/G,wBAAgB,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,GAAE,IAAI,EAAU,GAAG,OAAO,EAAE,CA4BvE"}
|
package/dist/tools.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { COINS, v3 } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
-
import { FORCE, HEARTBEAT_SCHEMA, LIST_SCHEMA, LOAN_SCHEMA, OFFER_SCHEMA, OPEN_SCHEMA, PAYEES, TOPUP_SCHEMA, TRANSFER_SCHEMA, VIEW_SCHEMA, parseAmount, parseCoin,
|
|
1
|
+
import { COINS, v3, } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
+
import { ALLOW_REUSE, AMOUNT, COLLECT_SCHEMA, FORCE, HEARTBEAT_SCHEMA, LIST_SCHEMA, LOAN_SCHEMA, OFFER_SCHEMA, OPEN_SCHEMA, PAYEES, TOPUP_SCHEMA, TRANSFER_SCHEMA, VIEW_SCHEMA, parseAmount, parseCoin, parseCollect, parseDenominations, parseHeartbeat, parseListAll, parseLoanId, parseOfferArgs, parseOpen, parsePayees, parseReceiver, parseRole, parseSpend, parseTopup, parseView, } from "./args.js";
|
|
3
3
|
import { assertNoSecrets, failureOf, ToolRefusal } from "./failure.js";
|
|
4
4
|
import { WAITS_LONG, WAITS_MEDIUM, WAITS_SEIZED, WAITS_SHORT } from "./pace.js";
|
|
5
5
|
import { redact } from "./redact.js";
|
|
6
6
|
import { BADGE_TOOLS } from "./tools-badge.js";
|
|
7
|
-
import { MORE,
|
|
7
|
+
import { MORE, RECORD_TOOLS, refuseWhilePaying, SPLIT, staged } from "./tools-more.js";
|
|
8
8
|
import { SALE_TOOLS } from "./tools-sales.js";
|
|
9
9
|
const UNITS = "whole-number string in the coin's smallest unit";
|
|
10
10
|
const BIDDING = v3.LOAN_LIFECYCLE.indexOf("bidding");
|
|
@@ -20,6 +20,22 @@ function bad(msg) {
|
|
|
20
20
|
function landed(row) {
|
|
21
21
|
return { ok: true, digest: row.digest, ticket: row.ticket };
|
|
22
22
|
}
|
|
23
|
+
/** No floor and no amount; on failure the SDK code only (`bind` never passes an SDK message). */
|
|
24
|
+
function cover(c) {
|
|
25
|
+
if (c.ok)
|
|
26
|
+
return { ...landed(c), expiryMs: c.expiryMs };
|
|
27
|
+
return {
|
|
28
|
+
ok: false,
|
|
29
|
+
error: c.code,
|
|
30
|
+
hint: "Call essey_loan_heartbeat now: until it lands any keeper can read the loan.",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const HELD = " By default nothing is sent: the note is held, and the next call that spends own notes of that coin spends it." +
|
|
34
|
+
" Returns held: true. With sweep: true it is moved now by a self-transfer instead, returning the digest.";
|
|
35
|
+
/** No amount either way: a held note sent nothing, a swept one names only its transaction. */
|
|
36
|
+
function collected(r) {
|
|
37
|
+
return r.held ? { ok: true, held: true } : landed(r);
|
|
38
|
+
}
|
|
23
39
|
function credential(info) {
|
|
24
40
|
if (!info)
|
|
25
41
|
return { ok: true, credential: null };
|
|
@@ -83,7 +99,7 @@ const NOTES = [
|
|
|
83
99
|
{
|
|
84
100
|
name: "essey_faucet",
|
|
85
101
|
kind: "call",
|
|
86
|
-
description: "Ask the testnet faucet for one shielded note of this coin. Returns the digest
|
|
102
|
+
description: "Ask the testnet faucet for one shielded note of this coin. Returns the digest.",
|
|
87
103
|
inputSchema: obj({ coin: { type: "string", enum: [...COINS], description: "tusdsui, usdc or sui" } }, [
|
|
88
104
|
"coin",
|
|
89
105
|
]),
|
|
@@ -96,7 +112,7 @@ const NOTES = [
|
|
|
96
112
|
"omit it to let the SDK decide. The agent wallet (ESSEY_AGENT_KEY_FILE) pays it in; essey_notes_recover retries one that stopped.",
|
|
97
113
|
inputSchema: obj({
|
|
98
114
|
coin: { type: "string", enum: [...COINS] },
|
|
99
|
-
amount:
|
|
115
|
+
amount: AMOUNT,
|
|
100
116
|
denominations: { type: "boolean", description: "split into deployment denominations" },
|
|
101
117
|
}, ["coin", "amount"]),
|
|
102
118
|
run: async (ctx, args) => {
|
|
@@ -125,14 +141,19 @@ const NOTES = [
|
|
|
125
141
|
description: `Withdraw ${UNITS} of a coin. Amount and address are public on chain, so with denominations the amount goes ` +
|
|
126
142
|
"out as denomination pieces, each to its own address in to; an amount that is not such a sum is refused with " +
|
|
127
143
|
"the largest one below it. force: true, or a coin without denominations: one exact withdraw to one address. " +
|
|
128
|
-
`Returns
|
|
144
|
+
`Returns the piece's digest and address, left and notBeforeMs.${SPLIT}${WAITS_LONG}`,
|
|
129
145
|
inputSchema: obj({
|
|
130
146
|
coin: { type: "string", enum: [...COINS] },
|
|
131
|
-
amount:
|
|
147
|
+
amount: AMOUNT,
|
|
132
148
|
to: PAYEES,
|
|
133
149
|
force: FORCE,
|
|
150
|
+
allowReuse: ALLOW_REUSE,
|
|
134
151
|
}, ["coin", "amount", "to"]),
|
|
135
|
-
run: async (ctx, args) =>
|
|
152
|
+
run: async (ctx, args) => {
|
|
153
|
+
const [coin, amount, to, o] = [parseCoin(args), parseAmount(args), parsePayees(args), parseSpend(args)];
|
|
154
|
+
refuseWhilePaying(ctx);
|
|
155
|
+
return staged(ctx, await ctx.client.notes.withdrawFirst(coin, amount, to, o));
|
|
156
|
+
},
|
|
136
157
|
},
|
|
137
158
|
{
|
|
138
159
|
name: "essey_notes_receive_address",
|
|
@@ -155,7 +176,7 @@ const BORROWER = [
|
|
|
155
176
|
name: "essey_loan_open",
|
|
156
177
|
kind: "call",
|
|
157
178
|
description: `Borrower: lock collateral from own notes and open a sealed loan request lenders offer on until the window ends. ${PLANNED} ` +
|
|
158
|
-
"Returns the loan id
|
|
179
|
+
"Returns the loan id and digest.",
|
|
159
180
|
inputSchema: OPEN_SCHEMA,
|
|
160
181
|
run: async (ctx, args) => {
|
|
161
182
|
const p = parseOpen(args);
|
|
@@ -168,17 +189,19 @@ const BORROWER = [
|
|
|
168
189
|
name: "essey_loan_settle",
|
|
169
190
|
kind: "call",
|
|
170
191
|
description: "Borrower, after the offer window: open every sealed offer and settle on the lowest eligible rate; the principal " +
|
|
171
|
-
|
|
192
|
+
"arrives as an own note. The first heartbeat follows at once (cover: its digest and expiry, or an error code). " +
|
|
193
|
+
`Returns the digest, rate, amount owed, maturity and cover.${WAITS_MEDIUM}`,
|
|
172
194
|
inputSchema: LOAN_SCHEMA,
|
|
173
195
|
run: async (ctx, args) => {
|
|
174
196
|
const loan = parseLoanId(args);
|
|
175
|
-
const r = await ctx.client.loans.accept(loan);
|
|
197
|
+
const r = await ctx.client.loans.accept({ loan, collAmt: ctx.records.loan(loan).collAmt });
|
|
176
198
|
ctx.records.saveLoan(loan, { collAmt: r.collAmt, terms: r.terms, borrowerPk: r.borrowerPk });
|
|
177
199
|
return {
|
|
178
200
|
...landed(r),
|
|
179
201
|
rateBps: r.rateBps,
|
|
180
202
|
owed: r.terms.owed,
|
|
181
203
|
maturityS: r.terms.maturityS,
|
|
204
|
+
cover: cover(r.cover),
|
|
182
205
|
};
|
|
183
206
|
},
|
|
184
207
|
},
|
|
@@ -244,7 +267,7 @@ const BORROWER = [
|
|
|
244
267
|
{
|
|
245
268
|
name: "essey_loan_topup",
|
|
246
269
|
kind: "call",
|
|
247
|
-
description: `Borrower: add collateral from own notes to an active loan. Returns the digest
|
|
270
|
+
description: `Borrower: add collateral from own notes to an active loan. Returns the digest and the new locked amount.${WAITS_SHORT}`,
|
|
248
271
|
inputSchema: TOPUP_SCHEMA,
|
|
249
272
|
run: async (ctx, args) => {
|
|
250
273
|
const { loan, add, asBorrower } = parseTopup(args);
|
|
@@ -262,11 +285,11 @@ const BORROWER = [
|
|
|
262
285
|
{
|
|
263
286
|
name: "essey_loan_collect_surplus",
|
|
264
287
|
kind: "call",
|
|
265
|
-
description: `Borrower, after a liquidation or default: the collateral the seizure left over
|
|
266
|
-
inputSchema:
|
|
288
|
+
description: `Borrower, after a liquidation or default: the collateral the seizure left over as an own note.${HELD}${WAITS_SEIZED}`,
|
|
289
|
+
inputSchema: COLLECT_SCHEMA,
|
|
267
290
|
run: async (ctx, args) => {
|
|
268
|
-
const
|
|
269
|
-
return { ...
|
|
291
|
+
const { loan, ...sweep } = parseCollect(args);
|
|
292
|
+
return collected(await ctx.client.loans.collectSurplus({ ...settled(ctx, loan), ...sweep }));
|
|
270
293
|
},
|
|
271
294
|
},
|
|
272
295
|
];
|
|
@@ -313,7 +336,7 @@ const LENDER = [
|
|
|
313
336
|
name: "essey_loan_offer",
|
|
314
337
|
kind: "call",
|
|
315
338
|
description: `Lender: offer the requested principal at rateBps from own notes of the loan coin, sealed to the borrower. ${PLANNED} ` +
|
|
316
|
-
`Returns the digest,
|
|
339
|
+
`Returns the digest, and the principal and rate offered.${WAITS_MEDIUM}`,
|
|
317
340
|
inputSchema: OFFER_SCHEMA,
|
|
318
341
|
run: async (ctx, args) => {
|
|
319
342
|
const p = parseOfferArgs(args);
|
|
@@ -325,12 +348,11 @@ const LENDER = [
|
|
|
325
348
|
{
|
|
326
349
|
name: "essey_loan_collect",
|
|
327
350
|
kind: "call",
|
|
328
|
-
description: `Lender, after the borrower repaid: the repayment
|
|
329
|
-
inputSchema:
|
|
351
|
+
description: `Lender, after the borrower repaid: the repayment as an own note.${HELD}${WAITS_LONG}`,
|
|
352
|
+
inputSchema: COLLECT_SCHEMA,
|
|
330
353
|
run: async (ctx, args) => {
|
|
331
|
-
const loan =
|
|
332
|
-
|
|
333
|
-
return { ...landed(r), value: r.value };
|
|
354
|
+
const { loan, ...sweep } = parseCollect(args);
|
|
355
|
+
return collected(await ctx.client.loans.collect({ loan, offer: ctx.records.offer(loan), ...sweep }));
|
|
334
356
|
},
|
|
335
357
|
},
|
|
336
358
|
{
|
|
@@ -346,12 +368,11 @@ const LENDER = [
|
|
|
346
368
|
{
|
|
347
369
|
name: "essey_loan_collect_seized",
|
|
348
370
|
kind: "call",
|
|
349
|
-
description: `Lender, after a liquidation or default: its share of the seized collateral
|
|
350
|
-
inputSchema:
|
|
371
|
+
description: `Lender, after a liquidation or default: its share of the seized collateral as an own note.${HELD}${WAITS_SEIZED}`,
|
|
372
|
+
inputSchema: COLLECT_SCHEMA,
|
|
351
373
|
run: async (ctx, args) => {
|
|
352
|
-
const loan =
|
|
353
|
-
|
|
354
|
-
return { ...landed(r), value: r.value };
|
|
374
|
+
const { loan, ...sweep } = parseCollect(args);
|
|
375
|
+
return collected(await ctx.client.loans.collectSeized({ loan, offer: ctx.records.offer(loan), ...sweep }));
|
|
355
376
|
},
|
|
356
377
|
},
|
|
357
378
|
];
|
|
@@ -418,6 +439,17 @@ function assertKnownArgs(tool, args) {
|
|
|
418
439
|
if (!known.includes(k))
|
|
419
440
|
bad("an argument is not in this tool's input schema");
|
|
420
441
|
}
|
|
442
|
+
function hiddenFailure(handles, reply) {
|
|
443
|
+
if (!handles || reply.message === undefined)
|
|
444
|
+
return reply;
|
|
445
|
+
try {
|
|
446
|
+
return { ...reply, message: handles.hideMessage(reply.message) };
|
|
447
|
+
}
|
|
448
|
+
catch {
|
|
449
|
+
const { message: _, ...rest } = reply;
|
|
450
|
+
return rest;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
421
453
|
/** Binds every tool. A refusal comes back as `{ ok: false, error, hint }` and never carries an SDK message. */
|
|
422
454
|
export function bind(ctx, tools = TOOLS) {
|
|
423
455
|
return tools.map((tool) => ({
|
|
@@ -428,7 +460,8 @@ export function bind(ctx, tools = TOOLS) {
|
|
|
428
460
|
try {
|
|
429
461
|
assertNoSecrets(args);
|
|
430
462
|
assertKnownArgs(tool, args ?? {});
|
|
431
|
-
const
|
|
463
|
+
const input = ctx.handles ? ctx.handles.resolve(args ?? {}) : (args ?? {});
|
|
464
|
+
const fields = redact(await tool.run(ctx, input), ctx.redact);
|
|
432
465
|
const landedAtMs = Date.now();
|
|
433
466
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields))
|
|
434
467
|
throw new Error("result");
|
|
@@ -437,12 +470,13 @@ export function bind(ctx, tools = TOOLS) {
|
|
|
437
470
|
ctx.waitIndexed &&
|
|
438
471
|
!(await ctx.waitIndexed(landedAtMs).catch(() => false));
|
|
439
472
|
const out = lagging ? { ...fields, indexed: false } : fields;
|
|
440
|
-
|
|
473
|
+
const shown = ctx.handles ? ctx.handles.hide(out) : out;
|
|
474
|
+
return { text: JSON.stringify({ ...shown, ok: true }, null, 2), isError: false };
|
|
441
475
|
}
|
|
442
476
|
catch (err) {
|
|
443
477
|
const reply = failureOf(err, ctx.redact);
|
|
444
478
|
ctx.onError?.(`${tool.name} failed [${reply.error}]`);
|
|
445
|
-
return { text: JSON.stringify(reply), isError: true };
|
|
479
|
+
return { text: JSON.stringify(hiddenFailure(ctx.handles, reply)), isError: true };
|
|
446
480
|
}
|
|
447
481
|
},
|
|
448
482
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esseyonsui/sui-mcp-v3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
],
|
|
15
15
|
"bin": {
|
|
16
16
|
"essey-sui-mcp-v3": "./dist/main.js",
|
|
17
|
-
"essey-sui-mcp-v3-init": "./dist/init.js"
|
|
17
|
+
"essey-sui-mcp-v3-init": "./dist/init.js",
|
|
18
|
+
"essey-sui-mcp-v3-reveal": "./dist/reveal.js"
|
|
18
19
|
},
|
|
19
20
|
"exports": {
|
|
20
21
|
"./io": {
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@esseyonsui/sui-sdk-v3": "0.
|
|
33
|
+
"@esseyonsui/sui-sdk-v3": "0.2.0",
|
|
33
34
|
"@mysten/seal": "1.5.1",
|
|
34
35
|
"@mysten/sui": "2.37.0",
|
|
35
36
|
"@noble/ciphers": "2.4.0",
|