@esseyonsui/sui-mcp-v3 0.1.4 → 0.1.6
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 +5 -2
- package/dist/args.d.ts +4 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +23 -4
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -2
- package/dist/io.d.ts +6 -5
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +8 -23
- package/dist/main.js +2 -2
- package/dist/records.d.ts +13 -4
- package/dist/records.d.ts.map +1 -1
- package/dist/records.js +108 -8
- package/dist/tools-more.d.ts +2 -0
- package/dist/tools-more.d.ts.map +1 -1
- package/dist/tools-more.js +29 -2
- package/dist/tools-sales.d.ts.map +1 -1
- package/dist/tools-sales.js +4 -1
- package/dist/tools.d.ts +2 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +34 -10
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ of a coin, at most two, less fees), `essey_notes_recover` (retries a deposit tha
|
|
|
47
47
|
|
|
48
48
|
Borrower: `essey_loan_open` (collateral coin and amount, loan coin, principal, max rate, term, offer window),
|
|
49
49
|
`essey_loan_settle`, `essey_loan_repay`, `essey_loan_release`, `essey_loan_cancel`, `essey_loan_reclaim_coll`,
|
|
50
|
+
`essey_loan_recover` (rebuilds a lost record of an own bidding or cancelled loan from the note key and chain),
|
|
50
51
|
`essey_loan_heartbeat`, `essey_loan_topup`, `essey_loan_collect_surplus`, `essey_loan_slash` (an offer whose
|
|
51
52
|
sealed copy does not open its commit), `essey_loan_liquidate` and `essey_loan_seize_default` (from this server's
|
|
52
53
|
own terms).
|
|
@@ -79,8 +80,10 @@ Bidder: `essey_sale_list`, `essey_sale_view`, `essey_sale_bid` (room, sealed pri
|
|
|
79
80
|
the bid won, or as `seller` after a cancel or expiry; `to` defaults to the agent address).
|
|
80
81
|
|
|
81
82
|
The seller's keys and price bounds and the bidder's bid record go to `sale-<room>.json` and `bid-<room>.json`,
|
|
82
|
-
mode 600, beside the loan records
|
|
83
|
-
|
|
83
|
+
mode 600, beside the loan records. Every record file is sealed (XChaCha20-Poly1305) under a key derived from the
|
|
84
|
+
note key; a plaintext file `scripts/v3/live/run.mts` wrote is still read, and sealed on its next save. No tool
|
|
85
|
+
returns them. `essey_records_export` copies them all into one sealed mode-600 file at an absolute path, and
|
|
86
|
+
`essey_records_import` reads it back under the same note key, keeping any record already held. The item vault is found on chain by its room. The sellable item type on testnet is the demo
|
|
84
87
|
`0x48db0307be9b6aadbf9f29c28561e1b450348ab2786ea4853a8d7249c22979a1::demo::Badge`, which anyone can mint with
|
|
85
88
|
its public `demo::mint` and transfer to the agent address.
|
|
86
89
|
|
package/dist/args.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { PublicLoan } from "./loan-view.ts";
|
|
|
4
4
|
type Rec = Record<string, unknown>;
|
|
5
5
|
export type JsonSchema = Record<string, unknown>;
|
|
6
6
|
export declare const AMOUNT: JsonSchema;
|
|
7
|
+
export declare const FORCE: JsonSchema;
|
|
7
8
|
export declare const COIN: JsonSchema;
|
|
8
9
|
export declare const ADDRESS: JsonSchema;
|
|
9
10
|
export declare const MS: JsonSchema;
|
|
@@ -11,6 +12,9 @@ export declare const objectSchema: (properties: Record<string, JsonSchema>, requ
|
|
|
11
12
|
export declare function address(a: Rec, k: string): string;
|
|
12
13
|
export declare function payee(a: Rec, k: string): string;
|
|
13
14
|
export declare function optBool(a: Rec, k: string): boolean | undefined;
|
|
15
|
+
export declare function parseForce(args: Rec): {
|
|
16
|
+
force: boolean;
|
|
17
|
+
} | undefined;
|
|
14
18
|
export declare function int(a: Rec, k: string, min: number, max: number): number;
|
|
15
19
|
export declare function parseRole(args: Rec): "member" | "keeper" | undefined;
|
|
16
20
|
export declare function parseCoin(args: Rec, k?: string): CoinKey;
|
package/dist/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
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G;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAE3E;AAED,eAAO,MAAM,gBAAgB,YAU5B,CAAC;AAEF,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAKtE;AAED,eAAO,MAAM,YAAY,YAOxB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAKzF;AAED,eAAO,MAAM,WAAW,YAGvB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,MAAM,GAAG,KAAG,OAAwC,CAAC;AA2BlF,eAAO,MAAM,WAAW,YAmBvB,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,UAAU,CAmB/C"}
|
package/dist/args.js
CHANGED
|
@@ -2,7 +2,7 @@ import { COINS, v3 } from "@esseyonsui/sui-sdk-v3";
|
|
|
2
2
|
import { ToolRefusal } from "./failure.js";
|
|
3
3
|
const U64 = 1n << 64n;
|
|
4
4
|
const MAX_BPS = 10_000;
|
|
5
|
-
const {
|
|
5
|
+
const { HEARTBEAT_KS } = v3.collateral;
|
|
6
6
|
function bad(msg) {
|
|
7
7
|
throw new ToolRefusal(msg);
|
|
8
8
|
}
|
|
@@ -16,6 +16,10 @@ export const AMOUNT = {
|
|
|
16
16
|
pattern: "^[1-9][0-9]*$",
|
|
17
17
|
description: "whole-number string in the coin's smallest unit",
|
|
18
18
|
};
|
|
19
|
+
export const FORCE = {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
description: "send even when the amount equals a faucet grant or an own note's exact value or deposit, which links them on chain; default false",
|
|
22
|
+
};
|
|
19
23
|
export const COIN = { type: "string", enum: [...COINS], description: "tusdsui, usdc or sui" };
|
|
20
24
|
export const ADDRESS = {
|
|
21
25
|
type: "string",
|
|
@@ -81,6 +85,10 @@ export function optBool(a, k) {
|
|
|
81
85
|
bad(`${k} must be true or false`);
|
|
82
86
|
return a[k];
|
|
83
87
|
}
|
|
88
|
+
export function parseForce(args) {
|
|
89
|
+
const force = optBool(args, "force");
|
|
90
|
+
return force === undefined ? undefined : { force };
|
|
91
|
+
}
|
|
84
92
|
export function int(a, k, min, max) {
|
|
85
93
|
const v = a[k];
|
|
86
94
|
if (typeof v !== "number" || !Number.isInteger(v) || v < min || v > max)
|
|
@@ -133,7 +141,10 @@ export const OPEN_SCHEMA = objectSchema({
|
|
|
133
141
|
principal: { ...AMOUNT, description: "principal to borrow, in the loan coin's smallest unit" },
|
|
134
142
|
maxRateBps: { ...BPS, description: "highest rate accepted, basis points" },
|
|
135
143
|
termMs: { ...MS, description: "loan term after settle, milliseconds" },
|
|
136
|
-
offerWindowMs: {
|
|
144
|
+
offerWindowMs: {
|
|
145
|
+
...MS,
|
|
146
|
+
description: "how long lenders may offer, milliseconds; the close rounds up to the next whole UTC hour",
|
|
147
|
+
},
|
|
137
148
|
}, ["collateralCoin", "collateral", "loanCoin", "principal", "maxRateBps", "termMs", "offerWindowMs"]);
|
|
138
149
|
export function parseOpen(args) {
|
|
139
150
|
const collateralCoin = coin(args, "collateralCoin");
|
|
@@ -159,11 +170,19 @@ export function parseOfferArgs(args) {
|
|
|
159
170
|
}
|
|
160
171
|
export const HEARTBEAT_SCHEMA = objectSchema({
|
|
161
172
|
loan: LOAN,
|
|
162
|
-
k: {
|
|
173
|
+
k: {
|
|
174
|
+
type: "integer",
|
|
175
|
+
enum: [...HEARTBEAT_KS],
|
|
176
|
+
description: "health bucket: 1 (floor 95 % of the price, the default), 4 (80 %) or 8 (60 %)",
|
|
177
|
+
},
|
|
163
178
|
}, ["loan"]);
|
|
164
179
|
export function parseHeartbeat(args) {
|
|
165
180
|
const loan = parseLoanId(args);
|
|
166
|
-
|
|
181
|
+
if (args.k === undefined)
|
|
182
|
+
return { loan };
|
|
183
|
+
if (!HEARTBEAT_KS.includes(args.k))
|
|
184
|
+
bad("k must be 1, 4 or 8");
|
|
185
|
+
return { loan, k: args.k };
|
|
167
186
|
}
|
|
168
187
|
export const TOPUP_SCHEMA = objectSchema({
|
|
169
188
|
loan: LOAN,
|
package/dist/client.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type OpenParams = Extract<Parameters<Loans["open"]>[0], {
|
|
|
12
12
|
export type DemoClient = {
|
|
13
13
|
credential: Essey["credential"];
|
|
14
14
|
notes: Pick<Essey["notes"], "faucet" | "deposit" | "scan" | "withdraw" | "transfer" | "receiveAddress" | "exit" | "recoverStranded">;
|
|
15
|
-
loans: Pick<Loans, "request" | "lend" | "accept" | "payBack" | "release" | "collect" | "cancelOwn" | "reclaimCollateral" | "reclaimOffer" | "collectSeized" | "collectSurplus" | "heartbeat" | "topup" | "list" | "view" | "openRefi" | "settleRefi" | "cancelRefi" | "slash" | "fault" | "liquidate" | "seizeDefault" | "faultLiquidate" | "keeperLiquidate"> & {
|
|
15
|
+
loans: Pick<Loans, "request" | "lend" | "accept" | "payBack" | "release" | "collect" | "cancelOwn" | "reclaimCollateral" | "recover" | "reclaimOffer" | "collectSeized" | "collectSurplus" | "heartbeat" | "topup" | "list" | "view" | "openRefi" | "settleRefi" | "cancelRefi" | "slash" | "fault" | "liquidate" | "seizeDefault" | "faultLiquidate" | "keeperLiquidate"> & {
|
|
16
16
|
open(p: OpenParams): Promise<{
|
|
17
17
|
id: string;
|
|
18
18
|
} & Landed>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC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ACT,cAAc,GACd,eAAe,GACf,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,OAAO,GACP,OAAO,GACP,WAAW,GACX,cAAc,GACd,gBAAgB,GAChB,iBAAiB,CACpB,GAAG;QACF,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,GAAG,MAAM,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;KAC/C,CAAC;IACF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IAClC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;CAChE,CAAC;AAEF,+FAA+F;AAC/F,MAAM,MAAM,SAAS,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC;AASzF,wBAAgB,QAAQ,CACtB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,SAAS,EAChB,MAAM,GAAE,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,CAA6C,GAChF,UAAU,CAgEZ;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,CAShF"}
|
package/dist/client.js
CHANGED
|
@@ -14,10 +14,10 @@ export function clientOf(essey, chain, health = (loan) => Promise.resolve(status
|
|
|
14
14
|
faucet: (coin) => notes.faucet(coin),
|
|
15
15
|
deposit: (coin, amount, o) => notes.deposit(coin, amount, o),
|
|
16
16
|
scan: (coin) => notes.scan(coin),
|
|
17
|
-
withdraw: (coin, amount, to) => notes.withdraw(coin, amount, to),
|
|
17
|
+
withdraw: (coin, amount, to, o) => notes.withdraw(coin, amount, to, o),
|
|
18
18
|
transfer: (coin, amount, to) => notes.transfer(coin, amount, to),
|
|
19
19
|
receiveAddress: () => notes.receiveAddress(),
|
|
20
|
-
exit: (coin, to) => notes.exit(coin, to),
|
|
20
|
+
exit: (coin, to, o) => notes.exit(coin, to, o),
|
|
21
21
|
recoverStranded: () => notes.recoverStranded(),
|
|
22
22
|
},
|
|
23
23
|
loans: {
|
|
@@ -30,6 +30,7 @@ export function clientOf(essey, chain, health = (loan) => Promise.resolve(status
|
|
|
30
30
|
collect: (p) => loans.collect(p),
|
|
31
31
|
cancelOwn: (id) => loans.cancelOwn(id),
|
|
32
32
|
reclaimCollateral: (p) => loans.reclaimCollateral(p),
|
|
33
|
+
recover: (p) => loans.recover(p),
|
|
33
34
|
reclaimOffer: (p) => loans.reclaimOffer(p),
|
|
34
35
|
collectSeized: (p) => loans.collectSeized(p),
|
|
35
36
|
collectSurplus: (p) => loans.collectSurplus(p),
|
package/dist/io.d.ts
CHANGED
|
@@ -25,11 +25,12 @@ export declare function invertReading(spot: bigint, ema: bigint, spotExpo: bigin
|
|
|
25
25
|
expo: bigint;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
|
-
* True once public GraphQL
|
|
29
|
-
*
|
|
30
|
-
* and refi_open were refused against the old state.
|
|
28
|
+
* True once public GraphQL's latest checkpoint is stamped at or after `landedAtMs`, so every read it serves sees
|
|
29
|
+
* a step that landed by then. Stress run 2: loan reads lagged a landed step by about 4 s and repay, release,
|
|
30
|
+
* heartbeat and refi_open were refused against the old state. Asking by the step's digest would tell GraphQL
|
|
31
|
+
* which transaction is the member's (NET-05). False after `INDEX_POLLS` polls.
|
|
31
32
|
*/
|
|
32
|
-
export declare function waitIndexed(gql: Gql,
|
|
33
|
+
export declare function waitIndexed(gql: Gql, landedAtMs: number, pauseMs: number): Promise<boolean>;
|
|
33
34
|
type SealPackage = "loan" | "sale";
|
|
34
35
|
type SealArg = {
|
|
35
36
|
pure: "vector<u8>" | "u256" | "u64";
|
|
@@ -48,7 +49,7 @@ type SealRequest = {
|
|
|
48
49
|
signer?: Signer;
|
|
49
50
|
};
|
|
50
51
|
export declare function chainIo(config: Json, o: ChainIoOptions): {
|
|
51
|
-
waitIndexed: (
|
|
52
|
+
waitIndexed: (landedAtMs: number) => Promise<boolean>;
|
|
52
53
|
prover: v3.Prover;
|
|
53
54
|
readPrice: (market: string) => Promise<{
|
|
54
55
|
spot: bigint;
|
package/dist/io.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAMvD,OAAO,EAAE,EAAE,EAAE,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9C,KAAK,IAAI,GAAG,GAAG,CAAC;AAChB,KAAK,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AACpE,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhF,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mGAAmG;IACnG,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,mFAAmF;IACnF,MAAM,CAAC,EA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CAAC;QACf,IAAI,EAAE,UAAU,CAAC;QACjB,GAAG,CAAC,EAAE,UAAU,CAAC;QACjB,GAAG,CAAC,EAAE,WAAW,CAAC;KACnB;qBAgDgB,WAAW,GAAG;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE;yBAOpC,WAAW,GAAG;QAAE,EAAE,EAAE,UAAU,CAAA;KAAE;mBA4ChC,MAAM,UAAU,MAAM;;;;wBACjB,MAAM,GAAG,IAAI;;;;;;;;;;0BAGL,MAAM;4BAEJ,MAAM;qBACb,MAAM;;;;;;;;EAkBhC"}
|
package/dist/io.js
CHANGED
|
@@ -220,31 +220,16 @@ async function readSaleOpened(gql, digest) {
|
|
|
220
220
|
}
|
|
221
221
|
const INDEX_POLLS = 20;
|
|
222
222
|
/**
|
|
223
|
-
* True once public GraphQL
|
|
224
|
-
*
|
|
225
|
-
* and refi_open were refused against the old state.
|
|
223
|
+
* True once public GraphQL's latest checkpoint is stamped at or after `landedAtMs`, so every read it serves sees
|
|
224
|
+
* a step that landed by then. Stress run 2: loan reads lagged a landed step by about 4 s and repay, release,
|
|
225
|
+
* heartbeat and refi_open were refused against the old state. Asking by the step's digest would tell GraphQL
|
|
226
|
+
* which transaction is the member's (NET-05). False after `INDEX_POLLS` polls.
|
|
226
227
|
*/
|
|
227
|
-
export async function waitIndexed(gql,
|
|
228
|
+
export async function waitIndexed(gql, landedAtMs, pauseMs) {
|
|
228
229
|
const pause = () => new Promise((r) => setTimeout(r, pauseMs));
|
|
229
|
-
let changed = null;
|
|
230
230
|
for (let i = 0; i < INDEX_POLLS; i++, await pause()) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const nodes = d.transaction?.effects?.objectChanges?.nodes;
|
|
234
|
-
if (!nodes)
|
|
235
|
-
continue;
|
|
236
|
-
changed = nodes
|
|
237
|
-
.filter((n) => n.outputState)
|
|
238
|
-
.map((n) => ({ address: n.address, version: Number(n.outputState.version) }));
|
|
239
|
-
}
|
|
240
|
-
const pending = [];
|
|
241
|
-
for (const c of changed) {
|
|
242
|
-
const d = await gql(`query($a: SuiAddress!) { object(address: $a) { version } }`, { a: c.address });
|
|
243
|
-
if (!(Number(d.object?.version) >= c.version))
|
|
244
|
-
pending.push(c);
|
|
245
|
-
}
|
|
246
|
-
changed = pending;
|
|
247
|
-
if (changed.length === 0)
|
|
231
|
+
const d = await gql(`query { checkpoint { timestamp } }`, {});
|
|
232
|
+
if (Date.parse(d.checkpoint?.timestamp) >= landedAtMs)
|
|
248
233
|
return true;
|
|
249
234
|
}
|
|
250
235
|
return false;
|
|
@@ -412,7 +397,7 @@ export function chainIo(config, o) {
|
|
|
412
397
|
return v3.loadCircuitArtifacts(fetch, config.circuits, circuit);
|
|
413
398
|
};
|
|
414
399
|
return {
|
|
415
|
-
waitIndexed: (
|
|
400
|
+
waitIndexed: (landedAtMs) => waitIndexed(gql, landedAtMs, o.indexPauseMs ?? 1500),
|
|
416
401
|
prover: v3.groth16Prover(snarkjs.groth16, artifacts),
|
|
417
402
|
readPrice: (market) => readPrice(gql, market),
|
|
418
403
|
readReading: (market) => readReading(gql, market),
|
package/dist/main.js
CHANGED
|
@@ -9,7 +9,7 @@ import { agentDepositIo } from "./fund.js";
|
|
|
9
9
|
import { chainIo } from "./io.js";
|
|
10
10
|
import { loadAgentKey, loadNoteSeed } from "./keys.js";
|
|
11
11
|
import { serve } from "./protocol.js";
|
|
12
|
-
import { fileRecords } from "./records.js";
|
|
12
|
+
import { fileRecords, recordKey } from "./records.js";
|
|
13
13
|
import { bind } from "./tools.js";
|
|
14
14
|
const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"))
|
|
15
15
|
.version;
|
|
@@ -87,7 +87,7 @@ async function start() {
|
|
|
87
87
|
const client = withInvite(clientOf(essey, sale), cfg.invite);
|
|
88
88
|
const tools = bind({
|
|
89
89
|
client,
|
|
90
|
-
records: fileRecords(dirname(cfg.stateFile)),
|
|
90
|
+
records: fileRecords(dirname(cfg.stateFile), recordKey(seed)),
|
|
91
91
|
redact: cfg.invite ? [cfg.invite] : [],
|
|
92
92
|
onError: (line) => process.stderr.write(`essey-v3-mcp: ${line}\n`),
|
|
93
93
|
waitIndexed: io.waitIndexed,
|
package/dist/records.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export type LoanRecord = {
|
|
|
10
10
|
borrowerPk?: bigint;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
* What a cycle step needs from an earlier one and no chain read gives back
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
13
|
+
* What a cycle step needs from an earlier one and no chain read gives back: `loan-<id>.json`, `offer-<id>.json`,
|
|
14
|
+
* `sale-<room>.json`, `bid-<room>.json`, mode 600 beside the state file, sealed under `recordKey`. A file written
|
|
15
|
+
* before sealing (the JSON `scripts/v3/live/run.mts` writes) is still read, and sealed on its next save.
|
|
16
16
|
*/
|
|
17
17
|
export type Records = {
|
|
18
18
|
loan(id: string): LoanRecord;
|
|
@@ -23,6 +23,15 @@ export type Records = {
|
|
|
23
23
|
saveSale(room: string, record: SaleRecord): void;
|
|
24
24
|
bid(room: string): BidRecord;
|
|
25
25
|
saveBid(room: string, record: BidRecord): void;
|
|
26
|
+
/** Every record into one new sealed mode-600 file at `path`. Returns how many it holds. */
|
|
27
|
+
exportTo(path: string): number;
|
|
28
|
+
/** The records of an `exportTo` file. One this server already holds is kept, not overwritten. */
|
|
29
|
+
importFrom(path: string): {
|
|
30
|
+
imported: number;
|
|
31
|
+
kept: number;
|
|
32
|
+
};
|
|
26
33
|
};
|
|
27
|
-
|
|
34
|
+
/** The records key: HKDF-SHA256 of the note seed under a fixed label, so the seed itself never leaves `main.ts`. */
|
|
35
|
+
export declare function recordKey(seed: Uint8Array): Uint8Array;
|
|
36
|
+
export declare function fileRecords(dir: string, key: Uint8Array): Records;
|
|
28
37
|
//# sourceMappingURL=records.d.ts.map
|
package/dist/records.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceR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IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACjD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/C,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,iGAAiG;IACjG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9D,CAAC;AAyBF,oHAAoH;AACpH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEtD;AA2CD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CA+GjE"}
|
package/dist/records.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
2
|
+
import { chmodSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join } from "node:path";
|
|
4
|
+
import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
5
|
+
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
6
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
4
7
|
import { ToolRefusal } from "./failure.js";
|
|
5
8
|
const LOAN_ID = /^0x[0-9a-f]{64}$/;
|
|
9
|
+
const RECORD_FILE = /^(loan|offer|sale|bid)-(0x[0-9a-f]{64})\.json$/;
|
|
10
|
+
const KINDS = ["loan", "offer", "sale", "bid"];
|
|
11
|
+
const EXPORT_LABEL = "export";
|
|
12
|
+
const NONCE = 24;
|
|
6
13
|
const plain = (v) => JSON.stringify(v, (_k, x) => (typeof x === "bigint" ? x.toString() : x));
|
|
7
14
|
const big = (v) => (v === undefined ? undefined : BigInt(v));
|
|
15
|
+
const utf8 = (s) => new TextEncoder().encode(s);
|
|
8
16
|
const MISSING = {
|
|
9
17
|
loan: "this server holds no borrower record for that loan: open it from this server first",
|
|
10
18
|
offer: "this server holds no offer record for that loan: offer on it from this server first",
|
|
@@ -14,29 +22,88 @@ const MISSING = {
|
|
|
14
22
|
function noRecord(kind) {
|
|
15
23
|
throw new ToolRefusal(MISSING[kind]);
|
|
16
24
|
}
|
|
17
|
-
|
|
25
|
+
/** The records key: HKDF-SHA256 of the note seed under a fixed label, so the seed itself never leaves `main.ts`. */
|
|
26
|
+
export function recordKey(seed) {
|
|
27
|
+
return hkdf(sha256, seed, undefined, utf8("essey-v3-mcp records v1"), 32);
|
|
28
|
+
}
|
|
29
|
+
/** `label` is the AAD: a sealed file opens only under the name it was written for. */
|
|
30
|
+
function seal(key, label, v) {
|
|
31
|
+
const nonce = randomBytes(NONCE);
|
|
32
|
+
const box = xchacha20poly1305(key, nonce, utf8(label)).encrypt(utf8(plain(v)));
|
|
33
|
+
return JSON.stringify({ sealed: Buffer.concat([nonce, box]).toString("base64") });
|
|
34
|
+
}
|
|
35
|
+
function unseal(key, label, sealed) {
|
|
36
|
+
const bytes = Buffer.from(sealed, "base64");
|
|
37
|
+
const text = xchacha20poly1305(key, bytes.subarray(0, NONCE), utf8(label)).decrypt(bytes.subarray(NONCE));
|
|
38
|
+
return JSON.parse(new TextDecoder().decode(text));
|
|
39
|
+
}
|
|
40
|
+
function writePrivate(target, text) {
|
|
41
|
+
const tmp = `${target}.${randomBytes(6).toString("hex")}.tmp`;
|
|
42
|
+
writeFileSync(tmp, text, { mode: 0o600, flag: "wx" });
|
|
43
|
+
chmodSync(tmp, 0o600);
|
|
44
|
+
renameSync(tmp, target);
|
|
45
|
+
}
|
|
46
|
+
function exportRows(text, key) {
|
|
47
|
+
let rows;
|
|
48
|
+
try {
|
|
49
|
+
rows = unseal(key, EXPORT_LABEL, JSON.parse(text).sealed).records;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
throw new ToolRefusal("that file is not a records export sealed by this note key");
|
|
53
|
+
}
|
|
54
|
+
if (!Array.isArray(rows))
|
|
55
|
+
throw new ToolRefusal("that file is not a records export sealed by this note key");
|
|
56
|
+
return rows.map((r) => {
|
|
57
|
+
if (!KINDS.includes(r?.kind) ||
|
|
58
|
+
!LOAN_ID.test(r?.id) ||
|
|
59
|
+
typeof r?.record !== "object" ||
|
|
60
|
+
r.record === null)
|
|
61
|
+
throw new ToolRefusal("that records export holds a malformed row");
|
|
62
|
+
return r;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function fileRecords(dir, key) {
|
|
18
66
|
const path = (kind, id) => {
|
|
19
67
|
if (!LOAN_ID.test(id))
|
|
20
68
|
throw new ToolRefusal("loan must be 0x and 64 hex digits");
|
|
21
69
|
return join(dir, `${kind}-${id}.json`);
|
|
22
70
|
};
|
|
23
71
|
const read = (kind, id) => {
|
|
72
|
+
let v;
|
|
24
73
|
try {
|
|
25
|
-
|
|
74
|
+
v = JSON.parse(readFileSync(path(kind, id), "utf8"));
|
|
26
75
|
}
|
|
27
76
|
catch (err) {
|
|
28
77
|
if (err.code === "ENOENT")
|
|
29
78
|
return null;
|
|
30
79
|
throw err;
|
|
31
80
|
}
|
|
81
|
+
return typeof v.sealed === "string" ? unseal(key, `${kind}-${id}`, v.sealed) : v;
|
|
32
82
|
};
|
|
33
83
|
const write = (kind, id, v) => {
|
|
34
84
|
const target = path(kind, id);
|
|
35
|
-
const tmp = `${target}.${randomBytes(6).toString("hex")}.tmp`;
|
|
36
85
|
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
86
|
+
writePrivate(target, seal(key, `${kind}-${id}`, v));
|
|
87
|
+
};
|
|
88
|
+
const held = () => {
|
|
89
|
+
let names;
|
|
90
|
+
try {
|
|
91
|
+
names = readdirSync(dir);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
if (err.code === "ENOENT")
|
|
95
|
+
return [];
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
return names.flatMap((n) => {
|
|
99
|
+
const m = RECORD_FILE.exec(n);
|
|
100
|
+
return m ? [{ kind: m[1], id: m[2] }] : [];
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const absolute = (p) => {
|
|
104
|
+
if (!isAbsolute(p))
|
|
105
|
+
throw new ToolRefusal("path must be absolute");
|
|
106
|
+
return p;
|
|
40
107
|
};
|
|
41
108
|
return {
|
|
42
109
|
loan: (id) => {
|
|
@@ -82,5 +149,38 @@ export function fileRecords(dir) {
|
|
|
82
149
|
};
|
|
83
150
|
},
|
|
84
151
|
saveBid: (room, record) => write("bid", room, record),
|
|
152
|
+
exportTo: (target) => {
|
|
153
|
+
const records = held().map(({ kind, id }) => ({ kind, id, record: read(kind, id) }));
|
|
154
|
+
try {
|
|
155
|
+
writeFileSync(absolute(target), seal(key, EXPORT_LABEL, { records }), { mode: 0o600, flag: "wx" });
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
if (err.code === "EEXIST")
|
|
159
|
+
throw new ToolRefusal("a file already exists at path");
|
|
160
|
+
throw err;
|
|
161
|
+
}
|
|
162
|
+
chmodSync(target, 0o600);
|
|
163
|
+
return records.length;
|
|
164
|
+
},
|
|
165
|
+
importFrom: (source) => {
|
|
166
|
+
let text;
|
|
167
|
+
try {
|
|
168
|
+
text = readFileSync(absolute(source), "utf8");
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
if (err.code === "ENOENT")
|
|
172
|
+
throw new ToolRefusal("no file at path");
|
|
173
|
+
throw err;
|
|
174
|
+
}
|
|
175
|
+
const rows = exportRows(text, key);
|
|
176
|
+
let imported = 0;
|
|
177
|
+
for (const { kind, id, record } of rows) {
|
|
178
|
+
if (read(kind, id))
|
|
179
|
+
continue;
|
|
180
|
+
write(kind, id, record);
|
|
181
|
+
imported++;
|
|
182
|
+
}
|
|
183
|
+
return { imported, kept: rows.length - imported };
|
|
184
|
+
},
|
|
85
185
|
};
|
|
86
186
|
}
|
package/dist/tools-more.d.ts
CHANGED
package/dist/tools-more.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-more.d.ts","sourceRoot":"","sources":["../src/tools-more.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools-more.d.ts","sourceRoot":"","sources":["../src/tools-more.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAiRpD,6DAA6D;AAC7D,eAAO,MAAM,YAAY,EAAE,IAAI,EAoB9B,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IAAI,EAA6C,CAAC"}
|
package/dist/tools-more.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { COINS } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
-
import { LOAN_SCHEMA, OPEN_SCHEMA, int, parseAmount, parseCoin, parseLoanId, parsePayee } from "./args.js";
|
|
2
|
+
import { FORCE, LOAN_SCHEMA, OPEN_SCHEMA, int, parseAmount, parseCoin, parseForce, parseLoanId, parsePayee, } from "./args.js";
|
|
3
3
|
import { isSdkCode, ToolRefusal } from "./failure.js";
|
|
4
4
|
/** `move/v3/loan/sources/loan.move:40` MAX_OFFERS = 16. */
|
|
5
5
|
const MAX_SEQ = 15;
|
|
@@ -215,8 +215,9 @@ const NOTES = [
|
|
|
215
215
|
inputSchema: obj({
|
|
216
216
|
coin: { type: "string", enum: [...COINS] },
|
|
217
217
|
to: { type: "string", pattern: "^0x[0-9a-fA-F]{64}$", description: "recipient address" },
|
|
218
|
+
force: FORCE,
|
|
218
219
|
}, ["coin", "to"]),
|
|
219
|
-
run: async (ctx, args) => landed(await ctx.client.notes.exit(parseCoin(args), parsePayee(args))),
|
|
220
|
+
run: async (ctx, args) => landed(await ctx.client.notes.exit(parseCoin(args), parsePayee(args), parseForce(args))),
|
|
220
221
|
},
|
|
221
222
|
{
|
|
222
223
|
name: "essey_notes_recover",
|
|
@@ -230,4 +231,30 @@ const NOTES = [
|
|
|
230
231
|
}),
|
|
231
232
|
},
|
|
232
233
|
];
|
|
234
|
+
const PATH = { type: "string", description: "absolute file path on this server" };
|
|
235
|
+
function parsePath(args) {
|
|
236
|
+
if (typeof args.path !== "string" || args.path === "")
|
|
237
|
+
bad("path must be an absolute file path");
|
|
238
|
+
return args.path;
|
|
239
|
+
}
|
|
240
|
+
/** No SDK call behind either, so they sit outside `MORE`. */
|
|
241
|
+
export const RECORD_TOOLS = [
|
|
242
|
+
{
|
|
243
|
+
name: "essey_records_export",
|
|
244
|
+
kind: "read",
|
|
245
|
+
description: "Copy every loan, offer, seller and bid record this server holds into one new mode-600 file at path, sealed " +
|
|
246
|
+
"under a key derived from the note key, so a lost server can be rebuilt with essey_records_import. Returns " +
|
|
247
|
+
"how many records it holds.",
|
|
248
|
+
inputSchema: obj({ path: PATH }, ["path"]),
|
|
249
|
+
run: async (ctx, args) => ({ ok: true, records: ctx.records.exportTo(parsePath(args)) }),
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: "essey_records_import",
|
|
253
|
+
kind: "call",
|
|
254
|
+
description: "Read a file essey_records_export wrote under the same note key and save its records here. A record this " +
|
|
255
|
+
"server already holds is kept. Returns how many were imported and kept.",
|
|
256
|
+
inputSchema: obj({ path: PATH }, ["path"]),
|
|
257
|
+
run: async (ctx, args) => ({ ok: true, ...ctx.records.importFrom(parsePath(args)) }),
|
|
258
|
+
},
|
|
259
|
+
];
|
|
233
260
|
export const MORE = [...REFI, ...SEIZE, ...KEEPER, ...NOTES];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-sales.d.ts","sourceRoot":"","sources":["../src/tools-sales.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tools-sales.d.ts","sourceRoot":"","sources":["../src/tools-sales.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAwQpD,eAAO,MAAM,UAAU,EAAE,IAAI,EAA2B,CAAC"}
|
package/dist/tools-sales.js
CHANGED
|
@@ -101,7 +101,10 @@ const SELLER = [
|
|
|
101
101
|
coin: { ...COIN, description: "the coin bids are paid in" },
|
|
102
102
|
minPrice: { ...AMOUNT, description: "lowest price accepted; sealed, never shown to bidders" },
|
|
103
103
|
maxPrice: { ...AMOUNT, description: "highest price settled at; sealed, never shown to bidders" },
|
|
104
|
-
bidWindowMs: {
|
|
104
|
+
bidWindowMs: {
|
|
105
|
+
...MS,
|
|
106
|
+
description: "how long bids are taken from now, milliseconds; the close rounds up to the next whole UTC hour",
|
|
107
|
+
},
|
|
105
108
|
finishWindowMs: { ...MS, description: "how long after close the seller may finish, milliseconds" },
|
|
106
109
|
maxBids: { type: "integer", minimum: 1, maximum: SLOTS, description: `1 to ${SLOTS}` },
|
|
107
110
|
}, ["itemId", "itemType", "coin", "minPrice", "maxPrice", "bidWindowMs", "finishWindowMs", "maxBids"]),
|
package/dist/tools.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ export type ToolContext = {
|
|
|
10
10
|
/** Tool name and error code only. The callback must not be given the error's message. */
|
|
11
11
|
onError?(line: string): void;
|
|
12
12
|
/**
|
|
13
|
-
* After a call lands: true once
|
|
13
|
+
* After a call lands: true once chain reads reflect the moment it landed (`io.ts` waitIndexed). A failed read
|
|
14
14
|
* counts as false: the step landed, so it is never reported as an error.
|
|
15
15
|
*/
|
|
16
|
-
waitIndexed?(
|
|
16
|
+
waitIndexed?(landedAtMs: number): Promise<boolean>;
|
|
17
17
|
};
|
|
18
18
|
type Args = Record<string, unknown>;
|
|
19
19
|
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":"AA2BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,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,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;AA0bF,eAAO,MAAM,KAAK,EAAE,IAAI,EAUvB,CAAC;AAUF,+GAA+G;AAC/G,wBAAgB,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,GAAE,IAAI,EAAU,GAAG,OAAO,EAAE,CA0BvE"}
|
package/dist/tools.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { COINS, v3 } from "@esseyonsui/sui-sdk-v3";
|
|
2
|
-
import { HEARTBEAT_SCHEMA, LIST_SCHEMA, LOAN_SCHEMA, OFFER_SCHEMA, OPEN_SCHEMA, TOPUP_SCHEMA, TRANSFER_SCHEMA, VIEW_SCHEMA, parseAmount, parseCoin, parseDenominations, parseHeartbeat, parseListAll, parseLoanId, parseOfferArgs, parseOpen, parsePayee, parseReceiver, parseRole, parseTopup, parseView, } from "./args.js";
|
|
2
|
+
import { FORCE, HEARTBEAT_SCHEMA, LIST_SCHEMA, LOAN_SCHEMA, OFFER_SCHEMA, OPEN_SCHEMA, TOPUP_SCHEMA, TRANSFER_SCHEMA, VIEW_SCHEMA, parseAmount, parseCoin, parseDenominations, parseForce, parseHeartbeat, parseListAll, parseLoanId, parseOfferArgs, parseOpen, parsePayee, parseReceiver, parseRole, parseTopup, parseView, } from "./args.js";
|
|
3
3
|
import { assertNoSecrets, failureOf, ToolRefusal } from "./failure.js";
|
|
4
4
|
import { redact } from "./redact.js";
|
|
5
5
|
import { BADGE_TOOLS } from "./tools-badge.js";
|
|
6
|
-
import { MORE } from "./tools-more.js";
|
|
6
|
+
import { MORE, RECORD_TOOLS } from "./tools-more.js";
|
|
7
7
|
import { SALE_TOOLS } from "./tools-sales.js";
|
|
8
8
|
const UNITS = "whole-number string in the coin's smallest unit";
|
|
9
9
|
const BIDDING = v3.LOAN_LIFECYCLE.indexOf("bidding");
|
|
@@ -66,9 +66,16 @@ const CREDENTIAL = [
|
|
|
66
66
|
{
|
|
67
67
|
name: "essey_credential_renew",
|
|
68
68
|
kind: "call",
|
|
69
|
-
description: "Renew the credential already in the state file. Returns role, expiry and
|
|
69
|
+
description: "Renew the credential already in the state file. Returns role, expiry, epoch and renewed; when the issuer " +
|
|
70
|
+
"kept the held expiry, renewed is false and message says when renew opens.",
|
|
70
71
|
inputSchema: obj(),
|
|
71
|
-
run: async (ctx) =>
|
|
72
|
+
run: async (ctx) => {
|
|
73
|
+
const r = await ctx.client.credential.renew();
|
|
74
|
+
if (r.renewed)
|
|
75
|
+
return { ...credential(r), renewed: true };
|
|
76
|
+
const opens = new Date(Number(r.renewOpensMs)).toISOString();
|
|
77
|
+
return { ...credential(r), renewed: false, message: `renew opens at ${opens}` };
|
|
78
|
+
},
|
|
72
79
|
},
|
|
73
80
|
];
|
|
74
81
|
const NOTES = [
|
|
@@ -119,8 +126,9 @@ const NOTES = [
|
|
|
119
126
|
coin: { type: "string", enum: [...COINS] },
|
|
120
127
|
amount: { type: "string", pattern: "^[1-9][0-9]*$", description: UNITS },
|
|
121
128
|
to: { type: "string", pattern: "^0x[0-9a-fA-F]{64}$", description: "recipient address" },
|
|
129
|
+
force: FORCE,
|
|
122
130
|
}, ["coin", "amount", "to"]),
|
|
123
|
-
run: async (ctx, args) => landed(await ctx.client.notes.withdraw(parseCoin(args), parseAmount(args), parsePayee(args))),
|
|
131
|
+
run: async (ctx, args) => landed(await ctx.client.notes.withdraw(parseCoin(args), parseAmount(args), parsePayee(args), parseForce(args))),
|
|
124
132
|
},
|
|
125
133
|
{
|
|
126
134
|
name: "essey_notes_receive_address",
|
|
@@ -205,6 +213,19 @@ const BORROWER = [
|
|
|
205
213
|
return landed(await ctx.client.loans.reclaimCollateral({ loan, collAmt }));
|
|
206
214
|
},
|
|
207
215
|
},
|
|
216
|
+
{
|
|
217
|
+
name: "essey_loan_recover",
|
|
218
|
+
kind: "call",
|
|
219
|
+
description: "Borrower whose loan record was lost: rebuild it for an own bidding or cancelled loan from the note key and " +
|
|
220
|
+
"chain reads alone, and keep it, so essey_loan_reclaim_coll works again. Returns the locked amount.",
|
|
221
|
+
inputSchema: LOAN_SCHEMA,
|
|
222
|
+
run: async (ctx, args) => {
|
|
223
|
+
const loan = parseLoanId(args);
|
|
224
|
+
const r = await ctx.client.loans.recover({ loan });
|
|
225
|
+
ctx.records.saveLoan(loan, { collAmt: r.collAmt, borrowerPk: r.borrowerPk });
|
|
226
|
+
return { ok: true, loan, collateral: r.collAmt };
|
|
227
|
+
},
|
|
228
|
+
},
|
|
208
229
|
{
|
|
209
230
|
name: "essey_loan_heartbeat",
|
|
210
231
|
kind: "call",
|
|
@@ -355,7 +376,8 @@ const VIEWS = [
|
|
|
355
376
|
name: "essey_loan_view",
|
|
356
377
|
kind: "read",
|
|
357
378
|
description: "Read-only loan status and health from public fields: state, whether the floor still covers, LTV, " +
|
|
358
|
-
"underwater, liquidation price and
|
|
379
|
+
"underwater, liquidation price and whether a heartbeat at the default bucket (k 1) proves it healthy. Does not " +
|
|
380
|
+
"read a key and does not send a transaction.",
|
|
359
381
|
inputSchema: VIEW_SCHEMA,
|
|
360
382
|
run: async (ctx, args) => {
|
|
361
383
|
const status = await ctx.client.loans.health(parseView(args));
|
|
@@ -366,7 +388,8 @@ const VIEWS = [
|
|
|
366
388
|
ltvBps: status.ltvBps,
|
|
367
389
|
underwater: status.underwater,
|
|
368
390
|
liquidationPrice: status.liquidationPrice,
|
|
369
|
-
|
|
391
|
+
// LOAN-06: k 1 has the highest floor, so any healthy bucket means k 1 is healthy; the deepest k is not shown.
|
|
392
|
+
coveredAtDefaultK: status.bestBucketK !== null,
|
|
370
393
|
};
|
|
371
394
|
},
|
|
372
395
|
},
|
|
@@ -380,6 +403,7 @@ export const TOOLS = [
|
|
|
380
403
|
...SALE_TOOLS,
|
|
381
404
|
...BADGE_TOOLS,
|
|
382
405
|
...MORE,
|
|
406
|
+
...RECORD_TOOLS,
|
|
383
407
|
];
|
|
384
408
|
function assertKnownArgs(tool, args) {
|
|
385
409
|
const schema = tool.inputSchema;
|
|
@@ -401,13 +425,13 @@ export function bind(ctx, tools = TOOLS) {
|
|
|
401
425
|
assertNoSecrets(args);
|
|
402
426
|
assertKnownArgs(tool, args ?? {});
|
|
403
427
|
const fields = redact(await tool.run(ctx, args ?? {}), ctx.redact);
|
|
428
|
+
const landedAtMs = Date.now();
|
|
404
429
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields))
|
|
405
430
|
throw new Error("result");
|
|
406
|
-
const digest = fields.digest;
|
|
407
431
|
const lagging = tool.kind === "call" &&
|
|
408
|
-
typeof digest === "string" &&
|
|
432
|
+
typeof fields.digest === "string" &&
|
|
409
433
|
ctx.waitIndexed &&
|
|
410
|
-
!(await ctx.waitIndexed(
|
|
434
|
+
!(await ctx.waitIndexed(landedAtMs).catch(() => false));
|
|
411
435
|
const out = lagging ? { ...fields, indexed: false } : fields;
|
|
412
436
|
return { text: JSON.stringify({ ...out, ok: true }, null, 2), isError: false };
|
|
413
437
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esseyonsui/sui-mcp-v3",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,9 +29,11 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@esseyonsui/sui-sdk-v3": "0.1.
|
|
32
|
+
"@esseyonsui/sui-sdk-v3": "0.1.6",
|
|
33
33
|
"@mysten/seal": "1.5.1",
|
|
34
34
|
"@mysten/sui": "2.37.0",
|
|
35
|
+
"@noble/ciphers": "2.4.0",
|
|
36
|
+
"@noble/hashes": "2.4.0",
|
|
35
37
|
"snarkjs": "0.7.6"
|
|
36
38
|
}
|
|
37
39
|
}
|