@esseyonsui/sui-mcp-v3 0.1.3 → 0.1.4
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/failure.d.ts +4 -2
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +15 -3
- package/dist/io.d.ts +11 -1
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +36 -4
- package/dist/main.js +1 -0
- package/dist/tools-more.d.ts.map +1 -1
- package/dist/tools-more.js +9 -3
- package/dist/tools.d.ts +5 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +7 -1
- package/package.json +2 -2
package/dist/failure.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type Failure = {
|
|
|
5
5
|
error: string;
|
|
6
6
|
hint: string;
|
|
7
7
|
reason?: string;
|
|
8
|
+
message?: string;
|
|
8
9
|
abort?: {
|
|
9
10
|
module: string;
|
|
10
11
|
code: number;
|
|
@@ -20,8 +21,9 @@ export declare class ToolRefusal extends Error {
|
|
|
20
21
|
constructor(hint: string);
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
|
-
* An SDK message can quote a service reply.
|
|
24
|
-
* Anything else, including a lookalike `{ code }` on a plain Error,
|
|
24
|
+
* An SDK message can quote a service reply. A code from the SDK's own list is returned with a fixed hint, and its
|
|
25
|
+
* message only when it is plain prose (`PROSE`). Anything else, including a lookalike `{ code }` on a plain Error,
|
|
26
|
+
* is withheld.
|
|
25
27
|
*/
|
|
26
28
|
export declare function failureOf(err: unknown, secrets?: readonly string[]): Failure;
|
|
27
29
|
export declare const isSdkCode: (err: unknown) => err is EsseyError;
|
package/dist/failure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAgB,MAAM,wBAAwB,CAAC;AAIrF,eAAO,MAAM,QAAQ,6DAA6D,CAAC;AAEnF,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,UAAU,EAAgB,MAAM,wBAAwB,CAAC;AAIrF,eAAO,MAAM,QAAQ,6DAA6D,CAAC;AAEnF,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;AAuCF;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM;IADjC,QAAQ,CAAC,IAAI,sBAAsB;gBACd,IAAI,EAAE,MAAM;CAGlC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,SAAS,MAAM,EAAO,GAAG,OAAO,CAOhF;AAED,eAAO,MAAM,SAAS,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,UACkC,CAAC;AAEnF,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAcpD"}
|
package/dist/failure.js
CHANGED
|
@@ -5,6 +5,17 @@ export const WITHHELD = "The tool failed inside a library; its error is withheld
|
|
|
5
5
|
const SERVICE_CODE = /^(?:v3api|relayer) refused: ([A-Z_]{3,40})$/;
|
|
6
6
|
const CODE = /^[A-Z_]{3,40}$/;
|
|
7
7
|
const MODULE = /^[a-z0-9_]{1,40}::[a-z0-9_]{1,40}$/;
|
|
8
|
+
/** The SDK's own refusal wording: lowercase prose, no long token, so no key, salt, id or digest fits it. */
|
|
9
|
+
const PROSE = /^[a-z0-9 :;,.'()/_-]{3,240}$/;
|
|
10
|
+
const LONG_TOKEN = /[a-z0-9]{25,}|[0-9]{7,}/;
|
|
11
|
+
/** These can quote a service reply; their code reaches the caller as `reason` instead. */
|
|
12
|
+
const SERVICE_WORDED = new Set(["SERVICE_REFUSED", "RELAY_REFUSED", "RELAY_FAILED", "RELAY_OUTCOME_UNKNOWN"]);
|
|
13
|
+
function messageOf(err, secrets) {
|
|
14
|
+
if (SERVICE_WORDED.has(err.code))
|
|
15
|
+
return {};
|
|
16
|
+
const text = redactText(err.message, secrets);
|
|
17
|
+
return PROSE.test(text) && !LONG_TOKEN.test(text) ? { message: text } : {};
|
|
18
|
+
}
|
|
8
19
|
/** The relayer's own code (`ServiceDetail.error`) and Move abort, both a fixed shape a key cannot take. */
|
|
9
20
|
function relayReason(err) {
|
|
10
21
|
const { error, abort } = err.detail ?? {};
|
|
@@ -37,15 +48,16 @@ export class ToolRefusal extends Error {
|
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
50
|
/**
|
|
40
|
-
* An SDK message can quote a service reply.
|
|
41
|
-
* Anything else, including a lookalike `{ code }` on a plain Error,
|
|
51
|
+
* An SDK message can quote a service reply. A code from the SDK's own list is returned with a fixed hint, and its
|
|
52
|
+
* message only when it is plain prose (`PROSE`). Anything else, including a lookalike `{ code }` on a plain Error,
|
|
53
|
+
* is withheld.
|
|
42
54
|
*/
|
|
43
55
|
export function failureOf(err, secrets = []) {
|
|
44
56
|
if (err instanceof ToolRefusal)
|
|
45
57
|
return { ok: false, error: err.code, hint: redactText(err.hint, secrets) };
|
|
46
58
|
if (isEsseyError(err) && ESSEY_ERROR_CODES.includes(err.code)) {
|
|
47
59
|
const hint = `Look up ${err.code} in the sdk/errors reference.`;
|
|
48
|
-
return { ok: false, error: err.code, hint, ...reasonOf(err) };
|
|
60
|
+
return { ok: false, error: err.code, hint, ...reasonOf(err), ...messageOf(err, secrets) };
|
|
49
61
|
}
|
|
50
62
|
return { ok: false, error: "UNEXPECTED", hint: WITHHELD };
|
|
51
63
|
}
|
package/dist/io.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ import { v3, type EsseyIo } from "@esseyonsui/sui-sdk-v3";
|
|
|
3
3
|
export { TESTNET_GRAPHQL } from "./config.ts";
|
|
4
4
|
type Json = any;
|
|
5
5
|
type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
6
|
+
type Gql = (query: string, variables: Record<string, unknown>) => Promise<Json>;
|
|
6
7
|
export type ChainIoOptions = {
|
|
7
8
|
graphql: string;
|
|
8
9
|
fetch?: Fetch;
|
|
10
|
+
/** Pause between index polls after a step lands; tests pass 0. */
|
|
11
|
+
indexPauseMs?: number;
|
|
9
12
|
/** Circuit name to local `{ wasm, zkey }` paths, for a circuit `/v3/config` does not serve yet. */
|
|
10
13
|
localArtifacts?: Record<string, {
|
|
11
14
|
wasm: string;
|
|
@@ -21,6 +24,12 @@ export declare function invertReading(spot: bigint, ema: bigint, spotExpo: bigin
|
|
|
21
24
|
ema: bigint;
|
|
22
25
|
expo: bigint;
|
|
23
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* True once public GraphQL serves every object `digest` changed at its new version or later, so the next step's
|
|
29
|
+
* read sees this one. Stress run 2: loan reads lagged a landed step by about 4 s and repay, release, heartbeat
|
|
30
|
+
* and refi_open were refused against the old state. False after `INDEX_POLLS` polls.
|
|
31
|
+
*/
|
|
32
|
+
export declare function waitIndexed(gql: Gql, digest: string, pauseMs: number): Promise<boolean>;
|
|
24
33
|
type SealPackage = "loan" | "sale";
|
|
25
34
|
type SealArg = {
|
|
26
35
|
pure: "vector<u8>" | "u256" | "u64";
|
|
@@ -39,6 +48,7 @@ type SealRequest = {
|
|
|
39
48
|
signer?: Signer;
|
|
40
49
|
};
|
|
41
50
|
export declare function chainIo(config: Json, o: ChainIoOptions): {
|
|
51
|
+
waitIndexed: (digest: string) => Promise<boolean>;
|
|
42
52
|
prover: v3.Prover;
|
|
43
53
|
readPrice: (market: string) => Promise<{
|
|
44
54
|
spot: bigint;
|
|
@@ -99,7 +109,7 @@ export declare function chainIo(config: Json, o: ChainIoOptions): {
|
|
|
99
109
|
sealDerivedKeys: (r: SealRequest & {
|
|
100
110
|
id: Uint8Array;
|
|
101
111
|
}) => Promise<Map<string, Uint8Array<ArrayBuffer>>>;
|
|
102
|
-
readLoan: (id: string) => Promise<{
|
|
112
|
+
readLoan: (id: string, round?: bigint) => Promise<{
|
|
103
113
|
json: any;
|
|
104
114
|
round: any;
|
|
105
115
|
}>;
|
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;
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"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"}
|
package/dist/io.js
CHANGED
|
@@ -218,11 +218,42 @@ async function readSaleOpened(gql, digest) {
|
|
|
218
218
|
throw new Error(`transaction ${digest} created no sale room and vault`);
|
|
219
219
|
return { room, vault };
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
const INDEX_POLLS = 20;
|
|
222
|
+
/**
|
|
223
|
+
* True once public GraphQL serves every object `digest` changed at its new version or later, so the next step's
|
|
224
|
+
* read sees this one. Stress run 2: loan reads lagged a landed step by about 4 s and repay, release, heartbeat
|
|
225
|
+
* and refi_open were refused against the old state. False after `INDEX_POLLS` polls.
|
|
226
|
+
*/
|
|
227
|
+
export async function waitIndexed(gql, digest, pauseMs) {
|
|
228
|
+
const pause = () => new Promise((r) => setTimeout(r, pauseMs));
|
|
229
|
+
let changed = null;
|
|
230
|
+
for (let i = 0; i < INDEX_POLLS; i++, await pause()) {
|
|
231
|
+
if (!changed) {
|
|
232
|
+
const d = await gql(`query($d: String!) { transaction(digest: $d) { effects { objectChanges { nodes { address outputState { version } } } } } }`, { d: digest });
|
|
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)
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
/** The loan and its `Round` `round` (the current one when omitted), a `Table<u64, Round>` entry under `rounds`. */
|
|
253
|
+
async function readLoan(gql, id, round) {
|
|
223
254
|
const json = (await objectOf(gql, id)).asMoveObject.contents.json;
|
|
224
255
|
const key = Buffer.alloc(8);
|
|
225
|
-
key.writeBigUInt64LE(BigInt(json.round));
|
|
256
|
+
key.writeBigUInt64LE(round ?? BigInt(json.round));
|
|
226
257
|
const d = await gql(`query($t: SuiAddress!, $k: Base64!) { address(address: $t) { dynamicField(name: { type: "u64", bcs: $k }) { value { ... on MoveValue { json } } } } }`, { t: json.rounds.id, k: key.toString("base64") });
|
|
227
258
|
return { json, round: d.address?.dynamicField?.value?.json };
|
|
228
259
|
}
|
|
@@ -381,6 +412,7 @@ export function chainIo(config, o) {
|
|
|
381
412
|
return v3.loadCircuitArtifacts(fetch, config.circuits, circuit);
|
|
382
413
|
};
|
|
383
414
|
return {
|
|
415
|
+
waitIndexed: (digest) => waitIndexed(gql, digest, o.indexPauseMs ?? 1500),
|
|
384
416
|
prover: v3.groth16Prover(snarkjs.groth16, artifacts),
|
|
385
417
|
readPrice: (market) => readPrice(gql, market),
|
|
386
418
|
readReading: (market) => readReading(gql, market),
|
|
@@ -401,7 +433,7 @@ export function chainIo(config, o) {
|
|
|
401
433
|
sealEncrypt: sealerFor(config, o.graphql, o.garble ?? (() => false)),
|
|
402
434
|
sealDecrypt: unsealerFor(config, o.graphql),
|
|
403
435
|
sealDerivedKeys: deriverFor(config, o.graphql),
|
|
404
|
-
readLoan: (id) => readLoan(gql, id),
|
|
436
|
+
readLoan: (id, round) => readLoan(gql, id, round),
|
|
405
437
|
readLoans: (cursor) => readLoans(gql, config.packageOrigins.loan, cursor),
|
|
406
438
|
priceUpdate: async () => Uint8Array.of(0),
|
|
407
439
|
fundDeposit: o.fundDeposit,
|
package/dist/main.js
CHANGED
|
@@ -90,6 +90,7 @@ async function start() {
|
|
|
90
90
|
records: fileRecords(dirname(cfg.stateFile)),
|
|
91
91
|
redact: cfg.invite ? [cfg.invite] : [],
|
|
92
92
|
onError: (line) => process.stderr.write(`essey-v3-mcp: ${line}\n`),
|
|
93
|
+
waitIndexed: io.waitIndexed,
|
|
93
94
|
});
|
|
94
95
|
process.stderr.write("essey-v3-mcp: testnet, note key and agent key files accepted\n");
|
|
95
96
|
await serve(tools, { name: "essey-v3", version: VERSION, instructions: INSTRUCTIONS }, process.stdin, process.stdout);
|
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":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"tools-more.d.ts","sourceRoot":"","sources":["../src/tools-more.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAwQpD,eAAO,MAAM,IAAI,EAAE,IAAI,EAA6C,CAAC"}
|
package/dist/tools-more.js
CHANGED
|
@@ -59,18 +59,24 @@ const REFI = [
|
|
|
59
59
|
"Returns the digest, ticket, round and when offers close.",
|
|
60
60
|
inputSchema: obj({
|
|
61
61
|
loan: LOAN,
|
|
62
|
-
principal: {
|
|
62
|
+
principal: {
|
|
63
|
+
...REQUEST.principal,
|
|
64
|
+
description: "new principal; above what is owed now, which it pays with the fee",
|
|
65
|
+
},
|
|
63
66
|
maxRateBps: REQUEST.maxRateBps,
|
|
64
67
|
termMs: REQUEST.termMs,
|
|
65
68
|
offerWindowMs: REQUEST.offerWindowMs,
|
|
66
69
|
}, ["loan", "principal", "maxRateBps", "termMs", "offerWindowMs"]),
|
|
67
70
|
run: async (ctx, args) => {
|
|
68
|
-
const { loan, borrowerPk, collAmt } = own(ctx, parseLoanId(args));
|
|
71
|
+
const { loan, borrowerPk, collAmt, terms } = own(ctx, parseLoanId(args));
|
|
72
|
+
const principal = parseAmount(args, "principal");
|
|
73
|
+
if (principal <= terms.owed)
|
|
74
|
+
bad("principal must be above what the loan owes now: it pays the current lender and the fee");
|
|
69
75
|
const r = await ctx.client.loans.openRefi({
|
|
70
76
|
loan,
|
|
71
77
|
borrowerPk,
|
|
72
78
|
collAmt,
|
|
73
|
-
principal
|
|
79
|
+
principal,
|
|
74
80
|
maxRateBps: int(args, "maxRateBps", 0, 10_000),
|
|
75
81
|
termMs: int(args, "termMs", 1, MAX_MS),
|
|
76
82
|
offerWindowMs: int(args, "offerWindowMs", 1, MAX_MS),
|
package/dist/tools.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export type ToolContext = {
|
|
|
9
9
|
redact: readonly string[];
|
|
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
|
+
/**
|
|
13
|
+
* After a call lands: true once a chain read shows its digest's changes (`io.ts` waitIndexed). A failed read
|
|
14
|
+
* counts as false: the step landed, so it is never reported as an error.
|
|
15
|
+
*/
|
|
16
|
+
waitIndexed?(digest: string): Promise<boolean>;
|
|
12
17
|
};
|
|
13
18
|
type Args = Record<string, unknown>;
|
|
14
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":"AAyBA,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;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAyBA,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,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD,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;AA2ZF,eAAO,MAAM,KAAK,EAAE,IAAI,EASvB,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
|
@@ -403,7 +403,13 @@ export function bind(ctx, tools = TOOLS) {
|
|
|
403
403
|
const fields = redact(await tool.run(ctx, args ?? {}), ctx.redact);
|
|
404
404
|
if (fields === null || typeof fields !== "object" || Array.isArray(fields))
|
|
405
405
|
throw new Error("result");
|
|
406
|
-
|
|
406
|
+
const digest = fields.digest;
|
|
407
|
+
const lagging = tool.kind === "call" &&
|
|
408
|
+
typeof digest === "string" &&
|
|
409
|
+
ctx.waitIndexed &&
|
|
410
|
+
!(await ctx.waitIndexed(digest).catch(() => false));
|
|
411
|
+
const out = lagging ? { ...fields, indexed: false } : fields;
|
|
412
|
+
return { text: JSON.stringify({ ...out, ok: true }, null, 2), isError: false };
|
|
407
413
|
}
|
|
408
414
|
catch (err) {
|
|
409
415
|
const reply = failureOf(err, ctx.redact);
|
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.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
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.4",
|
|
33
33
|
"@mysten/seal": "1.5.1",
|
|
34
34
|
"@mysten/sui": "2.37.0",
|
|
35
35
|
"snarkjs": "0.7.6"
|