@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.
Files changed (52) hide show
  1. package/README.md +37 -7
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +2 -2
  4. package/dist/args.d.ts +11 -2
  5. package/dist/args.d.ts.map +1 -1
  6. package/dist/args.js +37 -10
  7. package/dist/artifact-cache.d.ts +14 -0
  8. package/dist/artifact-cache.d.ts.map +1 -0
  9. package/dist/artifact-cache.js +48 -0
  10. package/dist/client.d.ts +1 -1
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +5 -3
  13. package/dist/config.d.ts +2 -0
  14. package/dist/config.d.ts.map +1 -1
  15. package/dist/config.js +5 -0
  16. package/dist/fund.d.ts.map +1 -1
  17. package/dist/fund.js +2 -2
  18. package/dist/handles.d.ts +23 -0
  19. package/dist/handles.d.ts.map +1 -0
  20. package/dist/handles.js +142 -0
  21. package/dist/http.d.ts +6 -0
  22. package/dist/http.d.ts.map +1 -0
  23. package/dist/http.js +5 -0
  24. package/dist/init.d.ts +7 -0
  25. package/dist/init.d.ts.map +1 -1
  26. package/dist/init.js +18 -11
  27. package/dist/io.d.ts +22 -12
  28. package/dist/io.d.ts.map +1 -1
  29. package/dist/io.js +194 -142
  30. package/dist/keys.d.ts +2 -0
  31. package/dist/keys.d.ts.map +1 -1
  32. package/dist/keys.js +14 -1
  33. package/dist/main.js +21 -9
  34. package/dist/records.d.ts +21 -4
  35. package/dist/records.d.ts.map +1 -1
  36. package/dist/records.js +74 -21
  37. package/dist/reveal.d.ts +7 -0
  38. package/dist/reveal.d.ts.map +1 -0
  39. package/dist/reveal.js +40 -0
  40. package/dist/snapshot.d.ts +13 -0
  41. package/dist/snapshot.d.ts.map +1 -0
  42. package/dist/snapshot.js +29 -0
  43. package/dist/tools-badge.js +3 -3
  44. package/dist/tools-more.d.ts +9 -5
  45. package/dist/tools-more.d.ts.map +1 -1
  46. package/dist/tools-more.js +56 -12
  47. package/dist/tools-sales.d.ts.map +1 -1
  48. package/dist/tools-sales.js +34 -24
  49. package/dist/tools.d.ts +3 -0
  50. package/dist/tools.d.ts.map +1 -1
  51. package/dist/tools.js +64 -30
  52. 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";
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,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;CACpD,CAAC;AAEF,KAAK,IAAI,GAAG,MAAM,CAAC,MAA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AM,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, parseDenominations, parseForce, parseHeartbeat, parseListAll, parseLoanId, parseOfferArgs, parseOpen, parsePayees, parseReceiver, parseRole, parseTopup, parseView, } from "./args.js";
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, paidOut, RECORD_TOOLS } from "./tools-more.js";
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 and ticket.",
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: { type: "string", pattern: "^[1-9][0-9]*$", description: UNITS },
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 each piece's digest, ticket, amount and address.${WAITS_LONG}`,
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: { type: "string", pattern: "^[1-9][0-9]*$", description: UNITS },
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) => paidOut(await ctx.client.notes.withdraw(parseCoin(args), parseAmount(args), parsePayees(args), parseForce(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, digest and ticket.",
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
- `arrives as an own note. Returns the digest, ticket, rate, amount owed and maturity.${WAITS_MEDIUM}`,
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, ticket and the new locked amount.${WAITS_SHORT}`,
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 to an own note. Returns the value.${WAITS_SEIZED}`,
266
- inputSchema: LOAN_SCHEMA,
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 r = await ctx.client.loans.collectSurplus(settled(ctx, parseLoanId(args)));
269
- return { ...landed(r), value: r.value };
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, ticket, and the principal and rate offered.${WAITS_MEDIUM}`,
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 to an own note. Returns the value.${WAITS_LONG}`,
329
- inputSchema: LOAN_SCHEMA,
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 = parseLoanId(args);
332
- const r = await ctx.client.loans.collect({ loan, offer: ctx.records.offer(loan) });
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 to an own note.${WAITS_SEIZED}`,
350
- inputSchema: LOAN_SCHEMA,
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 = parseLoanId(args);
353
- const r = await ctx.client.loans.collectSeized({ loan, offer: ctx.records.offer(loan) });
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 fields = redact(await tool.run(ctx, args ?? {}), ctx.redact);
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
- return { text: JSON.stringify({ ...out, ok: true }, null, 2), isError: false };
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.1.8",
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.1.8",
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",