@esseyonsui/sui-mcp-v3 0.1.7 → 0.1.9

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 CHANGED
@@ -92,6 +92,19 @@ and `covered` on the public fields in its arguments and reads nothing.
92
92
 
93
93
  Amounts are whole-number strings in the coin's smallest unit.
94
94
 
95
+ ## Waits
96
+
97
+ So a loan's closing steps do not land seconds apart, each proved action first waits a random time drawn by its
98
+ class, before it reads the chain (`@esseyonsui/sui-sdk-v3` `src/v3/pace.ts`): 2 to 30 min for withdraw, exit,
99
+ transfer, every collect and every reclaim; 20 s to 3 min for repay, release, offer, settle and bid; 0 to 30 s for
100
+ heartbeat, topup, liquidate and fault. A wait is capped 2 min before the action's deadline (offer close,
101
+ settle-by, bid close, heartbeat expiry, maturity plus grace for a repay). An offer, settle or bid already inside
102
+ those 2 min is refused unsent; a heartbeat, topup or repay there goes without a wait. A wait of
103
+ 30 s or less runs inside the call. A longer one returns `{ ok: false, error: "NOT_BEFORE", notBeforeMs }` with
104
+ nothing sent; the same call before `notBeforeMs` returns the same time, and at or after it runs. A seizure's
105
+ collect waits again while nothing has landed in the pool since the seizure. The times are kept in memory, so a
106
+ restart draws new ones. `ESSEY_SUBMIT_DELAY=off` sends at once.
107
+
95
108
  ## Configuration
96
109
 
97
110
  | variable | |
@@ -104,6 +117,7 @@ Amounts are whole-number strings in the coin's smallest unit.
104
117
  | `ESSEY_INVITE` | optional invite token, 1..256 characters without whitespace |
105
118
  | `ESSEY_RELAYER` | `clear` (default) or `onion` |
106
119
  | `ESSEY_GRAPHQL` | Sui GraphQL URL, `https` or `http` on localhost (default `https://graphql.testnet.sui.io/graphql`) |
120
+ | `ESSEY_SUBMIT_DELAY` | `default` (default) or `off`: the SDK's `delays` option, a random wait before each proved action (see Waits) |
107
121
 
108
122
  Any other `ESSEY_*` variable stops the server, and so does a name containing `OWNER` or a value holding a private key.
109
123
 
package/dist/args.d.ts CHANGED
@@ -20,7 +20,8 @@ export declare function parseRole(args: Rec): "member" | "keeper" | undefined;
20
20
  export declare function parseCoin(args: Rec, k?: string): CoinKey;
21
21
  export declare function parseAmount(args: Rec, k?: string): bigint;
22
22
  export declare function parseDenominations(args: Rec): boolean | undefined;
23
- export declare function parsePayee(args: Rec): string;
23
+ export declare const PAYEES: JsonSchema;
24
+ export declare function parsePayees(args: Rec): string[];
24
25
  export declare const parseLoanId: (args: Rec) => string;
25
26
  export declare const LOAN_SCHEMA: JsonSchema;
26
27
  export declare const TRANSFER_SCHEMA: JsonSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMnC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAOjD,eAAO,MAAM,MAAM,EAAE,UAIpB,CAAC;AACF,eAAO,MAAM,KAAK,EAAE,UAInB,CAAC;AACF,eAAO,MAAM,IAAI,EAAE,UAAsF,CAAC;AAC1G,eAAO,MAAM,OAAO,EAAE,UAIrB,CAAC;AAMF,eAAO,MAAM,EAAE,EAAE,UAA8E,CAAC;AAEhG,eAAO,MAAM,YAAY,GAAI,YAAY,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,MAAM,EAAE,KAAG,UAKxF,CAAC;AAyBH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,GAA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AAE,GAAG,GAAG,UAAU,CAa/C;AAED,eAAO,MAAM,YAAY,YAGvB,CAAC;AAEH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,GAAG;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
@@ -18,7 +18,7 @@ export const AMOUNT = {
18
18
  };
19
19
  export const FORCE = {
20
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",
21
+ description: "one exact withdraw to one address, not split into denominations, sent 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
22
  };
23
23
  export const COIN = { type: "string", enum: [...COINS], description: "tusdsui, usdc or sui" };
24
24
  export const ADDRESS = {
@@ -114,8 +114,18 @@ export function parseAmount(args, k = "amount") {
114
114
  export function parseDenominations(args) {
115
115
  return optBool(args, "denominations");
116
116
  }
117
- export function parsePayee(args) {
118
- return payee(args, "to");
117
+ const PAYEE = { type: "string", pattern: "^0x[0-9a-fA-F]{64}$" };
118
+ export const PAYEES = {
119
+ anyOf: [PAYEE, { type: "array", items: PAYEE, minItems: 1, maxItems: v3.notes.MAX_SPLIT_PIECES }],
120
+ description: "0x addresses of 64 hex digits, all different, one per denomination piece; force: true or a coin without denominations takes one",
121
+ };
122
+ export function parsePayees(args) {
123
+ const v = args.to;
124
+ if (!Array.isArray(v))
125
+ return [payee(args, "to")];
126
+ if (v.length === 0 || v.length > v3.notes.MAX_SPLIT_PIECES)
127
+ bad(`to must list 1 to ${v3.notes.MAX_SPLIT_PIECES} addresses`);
128
+ return v.map((to) => payee({ to }, "to"));
119
129
  }
120
130
  export const parseLoanId = (args) => address(args, "loan");
121
131
  export const LOAN_SCHEMA = objectSchema({ loan: LOAN }, ["loan"]);
@@ -0,0 +1,14 @@
1
+ type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
2
+ /**
3
+ * PRV-05: every circuit's files are fetched once, in the deployment's order, into `dir` named by sha256, so no
4
+ * request names the circuit an action is about to prove. Each read checks the pin again.
5
+ */
6
+ export declare function artifactCache(fetch: Fetch, circuits: Record<string, unknown>, dir: string): {
7
+ prefetch: () => Promise<void>;
8
+ load(circuit: string): Promise<{
9
+ wasm: Uint8Array;
10
+ zkey: Uint8Array;
11
+ }>;
12
+ };
13
+ export {};
14
+ //# sourceMappingURL=artifact-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-cache.d.ts","sourceRoot":"","sources":["../src/artifact-cache.ts"],"names":[],"mappings":"AAKA,KAAK,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAGpE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM;;kBA6BlE,MAAM;cAMA,UAAU;cAAQ,UAAU;;EAGzD"}
@@ -0,0 +1,48 @@
1
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { EsseyError, v3 } from "@esseyonsui/sui-sdk-v3";
4
+ /**
5
+ * PRV-05: every circuit's files are fetched once, in the deployment's order, into `dir` named by sha256, so no
6
+ * request names the circuit an action is about to prove. Each read checks the pin again.
7
+ */
8
+ export function artifactCache(fetch, circuits, dir) {
9
+ const fileOf = (pin) => join(dir, pin.sha256);
10
+ const cached = (pin) => {
11
+ if (!existsSync(fileOf(pin)))
12
+ return undefined;
13
+ const bytes = new Uint8Array(readFileSync(fileOf(pin)));
14
+ return v3.sha256Hex(bytes) === pin.sha256 ? bytes : undefined;
15
+ };
16
+ const pins = (circuit) => v3.circuitPins(circuits, circuit);
17
+ const fill = async () => {
18
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
19
+ for (const circuit of Object.keys(circuits))
20
+ for (const pin of [pins(circuit).wasm, pins(circuit).zkey]) {
21
+ if (cached(pin))
22
+ continue;
23
+ const bytes = await v3.fetchPinned(fetch, pin.url, pin.sha256);
24
+ const tmp = `${fileOf(pin)}.tmp`;
25
+ writeFileSync(tmp, bytes, { mode: 0o600 });
26
+ renameSync(tmp, fileOf(pin));
27
+ }
28
+ };
29
+ let all;
30
+ const prefetch = () => {
31
+ all ??= fill().catch((error) => {
32
+ all = undefined;
33
+ throw error;
34
+ });
35
+ return all;
36
+ };
37
+ return {
38
+ prefetch,
39
+ async load(circuit) {
40
+ await prefetch();
41
+ const { wasm, zkey } = pins(circuit);
42
+ const files = { wasm: cached(wasm), zkey: cached(zkey) };
43
+ if (!files.wasm || !files.zkey)
44
+ throw new EsseyError("ARTIFACT_MISMATCH", "refused: a cached artifact no longer matches its pin");
45
+ return files;
46
+ },
47
+ };
48
+ }
package/dist/config.d.ts CHANGED
@@ -19,6 +19,8 @@ export type McpConfig = {
19
19
  /** Invite gate token. Unset: credential obtain uses the proof-of-work challenge. Never a tool argument. */
20
20
  invite: string | null;
21
21
  relayer: "clear" | "onion";
22
+ /** The SDK's `delays` option: "default" waits a drawn time before each proved action, "off" sends at once. */
23
+ delays: "default" | "off";
22
24
  };
23
25
  export declare const TESTNET_GRAPHQL = "https://graphql.testnet.sui.io/graphql";
24
26
  export declare class ConfigError extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,SAAS,CAAC;IACnB,4EAA4E;IAC5E,MAAM,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE,iHAAiH;IACjH,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,wGAAwG;IACxG,WAAW,EAAE,MAAM,CAAC;IACpB,+IAA+I;IAC/I,YAAY,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,eAAe,2CAA2C,CAAC;AAaxE,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,oBAAoB;CAClC;AAWD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CA0B7D"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,SAAS,CAAC;IACnB,4EAA4E;IAC5E,MAAM,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE,iHAAiH;IACjH,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,wGAAwG;IACxG,WAAW,EAAE,MAAM,CAAC;IACpB,+IAA+I;IAC/I,YAAY,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3B,8GAA8G;IAC9G,MAAM,EAAE,SAAS,GAAG,KAAK,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,eAAe,2CAA2C,CAAC;AAcxE,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,oBAAoB;CAClC;AAWD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS,CA6B7D"}
package/dist/config.js CHANGED
@@ -8,6 +8,7 @@ const KNOWN = [
8
8
  "ESSEY_INVITE",
9
9
  "ESSEY_RELAYER",
10
10
  "ESSEY_GRAPHQL",
11
+ "ESSEY_SUBMIT_DELAY",
11
12
  ];
12
13
  export class ConfigError extends Error {
13
14
  code = "INVALID_CONFIG";
@@ -41,6 +42,9 @@ export function parseConfig(env) {
41
42
  const relayer = env.ESSEY_RELAYER ?? "clear";
42
43
  if (relayer !== "clear" && relayer !== "onion")
43
44
  fail("ESSEY_RELAYER must be clear or onion");
45
+ const delays = env.ESSEY_SUBMIT_DELAY || "default";
46
+ if (delays !== "default" && delays !== "off")
47
+ fail("ESSEY_SUBMIT_DELAY must be default or off");
44
48
  const noteKeyFile = need("ESSEY_NOTE_KEY_FILE");
45
49
  const agentKeyFile = need("ESSEY_AGENT_KEY_FILE");
46
50
  if (/^[0-9a-fA-F]{64}$/.test(noteKeyFile) || /^[0-9a-fA-F]{64}$/.test(agentKeyFile))
@@ -54,6 +58,7 @@ export function parseConfig(env) {
54
58
  agentKeyFile,
55
59
  invite: inviteOf(env.ESSEY_INVITE),
56
60
  relayer,
61
+ delays,
57
62
  };
58
63
  }
59
64
  function configOf(v) {
package/dist/failure.d.ts CHANGED
@@ -15,6 +15,8 @@ export type Failure = {
15
15
  kind?: string;
16
16
  class?: string;
17
17
  };
18
+ /** NOT_BEFORE only: unix ms from which the same call runs. Nothing was proved or sent. */
19
+ notBeforeMs?: number;
18
20
  };
19
21
  /**
20
22
  * A refusal this server words itself. The hint is a rule, never a value the caller sent.
@@ -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,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,kHAAkH;IAClH,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C,CAAC;AA+DF;;;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,CAQhF;AAED,eAAO,MAA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
  import { ESSEY_ERROR_CODES, isEsseyError } from "@esseyonsui/sui-sdk-v3";
2
+ import { NotBefore } from "./pace.js";
2
3
  import { redactText, secretArgument } from "./redact.js";
3
4
  export const WITHHELD = "The tool failed inside a library; its error is withheld.";
5
+ const NOT_BEFORE_HINT = "Nothing was sent. Call the same tool with the same arguments at or after notBeforeMs.";
4
6
  /** First match wins. Each label is a fixed word; the message it was read from is never returned. */
5
7
  const CAUSES = [
6
8
  ["seal_access", /does not have access/i],
@@ -79,6 +81,8 @@ export class ToolRefusal extends Error {
79
81
  export function failureOf(err, secrets = []) {
80
82
  if (err instanceof ToolRefusal)
81
83
  return { ok: false, error: err.code, hint: redactText(err.hint, secrets) };
84
+ if (err instanceof NotBefore)
85
+ return { ok: false, error: err.code, hint: NOT_BEFORE_HINT, notBeforeMs: err.notBeforeMs };
82
86
  if (isEsseyError(err) && ESSEY_ERROR_CODES.includes(err.code)) {
83
87
  const hint = `Look up ${err.code} in the sdk/errors reference.`;
84
88
  return { ok: false, error: err.code, hint, ...reasonOf(err), ...messageOf(err, secrets) };
package/dist/init.d.ts CHANGED
@@ -8,4 +8,10 @@ export type InitResult = {
8
8
  error: string;
9
9
  };
10
10
  export declare function init(dir: string, configUrl?: string): InitResult;
11
+ /** PRV-14: the client starts this exact release, never whatever the registry serves that day. */
12
+ export declare function serverEntry(env: Record<string, string>, version?: string): {
13
+ command: string;
14
+ args: string[];
15
+ env: Record<string, string>;
16
+ };
11
17
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";AASA,eAAO,MAAM,kBAAkB,yDAAyD,CAAC;AAEzF,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElG,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAqB,GAAG,UAAU,CAkB5E"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";AASA,eAAO,MAAM,kBAAkB,yDAAyD,CAAC;AAEzF,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElG,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAqB,GAAG,UAAU,CAkB5E;AAKD,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,SAAU;;;;EAEzE"}
package/dist/init.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { randomBytes } from "node:crypto";
3
- import { chmodSync, existsSync, mkdirSync, realpathSync, writeFileSync } from "node:fs";
3
+ import { chmodSync, existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
4
4
  import { homedir } from "node:os";
5
5
  import { resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -26,6 +26,12 @@ export function init(dir, configUrl = DEFAULT_CONFIG_URL) {
26
26
  },
27
27
  };
28
28
  }
29
+ const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"))
30
+ .version;
31
+ /** PRV-14: the client starts this exact release, never whatever the registry serves that day. */
32
+ export function serverEntry(env, version = VERSION) {
33
+ return { command: "npx", args: ["-y", "-p", `@esseyonsui/sui-mcp-v3@${version}`, "essey-sui-mcp-v3"], env };
34
+ }
29
35
  function main() {
30
36
  const dir = resolve(process.argv[2] ?? `${homedir()}/.essey-v3`);
31
37
  const r = init(dir, process.env.ESSEY_V3_CONFIG ?? DEFAULT_CONFIG_URL);
@@ -33,11 +39,7 @@ function main() {
33
39
  console.error(r.error);
34
40
  process.exit(1);
35
41
  }
36
- const server = {
37
- command: "npx",
38
- args: ["-y", "-p", "@esseyonsui/sui-mcp-v3", "essey-sui-mcp-v3"],
39
- env: r.env,
40
- };
42
+ const server = serverEntry(r.env);
41
43
  console.log(`Wrote mode-600 key files in ${dir}. Add this server to your MCP client:\n`);
42
44
  console.log(JSON.stringify({ mcpServers: { "essey-v3": server } }, null, 2));
43
45
  }
package/dist/io.d.ts CHANGED
@@ -14,6 +14,8 @@ export type ChainIoOptions = {
14
14
  wasm: string;
15
15
  zkey: string;
16
16
  }>;
17
+ /** PRV-05: where every circuit's files are kept, fetched once; without it each is fetched on first use. */
18
+ artifactDir?: string;
17
19
  /** Test only: seal random bytes of the same length for the plaintexts it picks. */
18
20
  garble?: (data: Uint8Array) => boolean;
19
21
  fundDeposit?: EsseyIo["fundDeposit"];
@@ -49,6 +51,7 @@ type SealRequest = {
49
51
  signer?: Signer;
50
52
  };
51
53
  export declare function chainIo(config: Json, o: ChainIoOptions): {
54
+ prefetchArtifacts: () => Promise<void> | undefined;
52
55
  waitIndexed: (landedAtMs: number) => Promise<boolean>;
53
56
  prover: v3.Prover;
54
57
  readPrice: (market: string) => Promise<{
@@ -71,7 +74,6 @@ export declare function chainIo(config: Json, o: ChainIoOptions): {
71
74
  readSettleTime: (loanId: string) => Promise<bigint>;
72
75
  readTopupDelivery: (loanId: string) => Promise<[bigint, bigint, bigint] | null>;
73
76
  readKeeperCt: (loanId: string) => Promise<Uint8Array<ArrayBufferLike>>;
74
- readCreated: (digest: string) => Promise<string | null>;
75
77
  readBadge: (digest: string) => Promise<{
76
78
  id: string;
77
79
  json: any;
package/dist/io.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"m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AAU,CAAA;KAAE;mBA6ChC,MAAM,UAAU,MAAM;;;;wBACjB,MAAM,GAAG,IAAI;;;;;;;;;;0BAGL,MAAM;4BAEJ,MAAM;qBACb,MAAM;;;;;;;;EAkBhC"}
package/dist/io.js CHANGED
@@ -8,6 +8,7 @@ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
8
8
  import { Transaction } from "@mysten/sui/transactions";
9
9
  import { normalizeSuiAddress } from "@mysten/sui/utils";
10
10
  import { v3 } from "@esseyonsui/sui-sdk-v3";
11
+ import { artifactCache } from "./artifact-cache.js";
11
12
  export { TESTNET_GRAPHQL } from "./config.js";
12
13
  const require = createRequire(import.meta.url);
13
14
  const snarkjs = require("snarkjs");
@@ -189,10 +190,6 @@ async function createdBy(gql, digest) {
189
190
  }
190
191
  return null;
191
192
  }
192
- async function readCreated(gql, digest) {
193
- const created = await createdBy(gql, digest);
194
- return created?.find((n) => /::loan::ShieldedLoan</.test(n.type))?.address ?? null;
195
- }
196
193
  /** Query shape as `scripts/v3/upgrade-testnet.ts:94` reads an owner. */
197
194
  async function readObjectRef(gql, id) {
198
195
  const d = await gql(`query($id: SuiAddress!) { object(address: $id) { version digest owner { __typename ... on AddressOwner { address { address } } } } }`, { id });
@@ -390,13 +387,15 @@ export function chainIo(config, o) {
390
387
  const gql = graphql(o.graphql, fetch);
391
388
  const pools = config.objects.pools;
392
389
  const pkg = config.packages.pool;
390
+ const cache = o.artifactDir ? artifactCache(fetch, config.circuits, o.artifactDir) : undefined;
393
391
  const artifacts = (circuit) => {
394
392
  const local = o.localArtifacts?.[circuit];
395
393
  if (local)
396
394
  return Promise.resolve({ wasm: readFileSync(local.wasm), zkey: readFileSync(local.zkey) });
397
- return v3.loadCircuitArtifacts(fetch, config.circuits, circuit);
395
+ return cache ? cache.load(circuit) : v3.loadCircuitArtifacts(fetch, config.circuits, circuit);
398
396
  };
399
397
  return {
398
+ prefetchArtifacts: () => cache?.prefetch(),
400
399
  waitIndexed: (landedAtMs) => waitIndexed(gql, landedAtMs, o.indexPauseMs ?? 1500),
401
400
  prover: v3.groth16Prover(snarkjs.groth16, artifacts),
402
401
  readPrice: (market) => readPrice(gql, market),
@@ -405,7 +404,6 @@ export function chainIo(config, o) {
405
404
  readSettleTime: (loanId) => readSettleTime(gql, loanId),
406
405
  readTopupDelivery: (loanId) => readTopupDelivery(gql, loanId),
407
406
  readKeeperCt: (loanId) => readKeeperCt(gql, loanId),
408
- readCreated: (digest) => readCreated(gql, digest),
409
407
  readBadge: (digest) => readBadge(gql, digest),
410
408
  readSaleOpened: (digest) => readSaleOpened(gql, digest),
411
409
  readObjectRef: (id) => readObjectRef(gql, id),
@@ -9,7 +9,7 @@ export type LoanStatus = {
9
9
  ltvBps: string | null;
10
10
  underwater: boolean;
11
11
  liquidationPrice: string | null;
12
- bestBucketK: number | null;
12
+ coveredAtDefaultK: boolean;
13
13
  };
14
14
  /**
15
15
  * Read-only health. The SDK's `publicLoanStatus` (D-SPEC §6.2:589) takes the public numbers
@@ -1 +1 @@
1
- {"version":3,"file":"loan-view.d.ts","sourceRoot":"","sources":["../src/loan-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEjE,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,IAAI,CAAC;IACT,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAErD"}
1
+ {"version":3,"file":"loan-view.d.ts","sourceRoot":"","sources":["../src/loan-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEjE,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,IAAI,CAAC;IACT,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAErD"}
package/dist/main.js CHANGED
@@ -8,6 +8,7 @@ import { ConfigError, parseConfig } from "./config.js";
8
8
  import { agentDepositIo } from "./fund.js";
9
9
  import { chainIo } from "./io.js";
10
10
  import { loadAgentKey, loadNoteSeed } from "./keys.js";
11
+ import { toolPace } from "./pace.js";
11
12
  import { serve } from "./protocol.js";
12
13
  import { fileRecords, recordKey } from "./records.js";
13
14
  import { bind } from "./tools.js";
@@ -25,7 +26,8 @@ const INSTRUCTIONS = "Essey V3 private testnet tools. Note and agent keys are fi
25
26
  "essey_agent_address, essey_sale_open, after close essey_sale_finish (essey_sale_slash each bid it names " +
26
27
  "first); or essey_sale_cancel before any bid, or essey_sale_expire after the finish window, then " +
27
28
  "essey_sale_claim as seller. Buy: essey_sale_list, essey_sale_bid, and once the room ended essey_sale_claim as " +
28
- "bidder if won and essey_sale_reclaim (residual if won, else the deposit).";
29
+ "bidder if won and essey_sale_reclaim (residual if won, else the deposit). A proved call may answer NOT_BEFORE " +
30
+ "with notBeforeMs: nothing was sent; make the same call again at or after that time.";
29
31
  /**
30
32
  * `source` is what `Essey.connect` takes: the URL, which names the v3api, or the parsed file. The io reads the
31
33
  * same record as JSON (Seal set, pools, circuit pins).
@@ -76,13 +78,21 @@ async function start() {
76
78
  const seed = loadNoteSeed(cfg.noteKeyFile);
77
79
  try {
78
80
  const { source, raw } = await deploymentOf(cfg);
79
- const io = chainIo(raw, { graphql: cfg.graphql });
81
+ const io = chainIo(raw, { graphql: cfg.graphql, artifactDir: `${dirname(cfg.stateFile)}/artifacts` });
82
+ io.prefetchArtifacts()?.catch(() => { });
80
83
  const deliverSaleItem = itemHandOver({
81
84
  signer: agent,
82
85
  execute: graphqlExecute(cfg.graphql, agent),
83
86
  readObjectRef: io.readObjectRef,
84
87
  });
85
- const essey = await Essey.connect({ network: "testnet", statePath: cfg.stateFile, config: source, seed, relayer: cfg.relayer }, { ...io, ...agentDepositIo(raw, cfg.agentKeyFile, cfg.graphql), deliverSaleItem });
88
+ const essey = await Essey.connect({
89
+ network: "testnet",
90
+ statePath: cfg.stateFile,
91
+ config: source,
92
+ seed,
93
+ relayer: cfg.relayer,
94
+ delays: cfg.delays,
95
+ }, { ...io, ...agentDepositIo(raw, cfg.agentKeyFile, cfg.graphql), deliverSaleItem, pace: toolPace() });
86
96
  const sale = { agentAddress: agent.toSuiAddress(), vaultOf: io.readVaultOf };
87
97
  const client = withInvite(clientOf(essey, sale), cfg.invite);
88
98
  const tools = bind({
package/dist/pace.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { Pause } from "@esseyonsui/sui-sdk-v3";
2
+ /** A tool call may wait this long inline; a longer drawn wait is answered with the time it ends. */
3
+ export declare const INLINE_MAX_MS = 30000;
4
+ export declare const WAITS_LONG = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 2 to 30 min: the call answers NOT_BEFORE with notBeforeMs, and the same call at or after that time runs.";
5
+ export declare const WAITS_SEIZED = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 2 to 30 min: the call answers NOT_BEFORE with notBeforeMs, and the same call at or after that time runs. While nothing has landed in the pool since the seizure it waits again.";
6
+ export declare const WAITS_MEDIUM = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 20 s to 3 min, capped by the action's deadline; a wait over 30 s answers NOT_BEFORE with notBeforeMs, and the same call at or after that time runs.";
7
+ export declare const WAITS_SHORT = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 0 to 30 s inside the call.";
8
+ export declare class NotBefore extends Error {
9
+ readonly notBeforeMs: number;
10
+ readonly code = "NOT_BEFORE";
11
+ constructor(notBeforeMs: number);
12
+ }
13
+ /**
14
+ * The SDK's `io.pace` for a tool server. A drawn wait over `INLINE_MAX_MS` throws `NotBefore` and is kept in
15
+ * memory per action and subject, so a repeat call before that time gets the same time and one at or after it runs.
16
+ */
17
+ export declare function toolPace(o?: {
18
+ now?: () => number;
19
+ sleep?: (ms: number) => Promise<void>;
20
+ }): (p: Pause) => Promise<void>;
21
+ //# sourceMappingURL=pace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pace.d.ts","sourceRoot":"","sources":["../src/pace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAEpD,oGAAoG;AACpG,eAAO,MAAM,aAAa,QAAS,CAAC;AAGpC,eAAO,MAAM,UAAU,uKAA8F,CAAC;AACtH,eAAO,MAAM,YAAY,8OAAyF,CAAC;AACnH,eAAO,MAAM,YAAY,kNAAyI,CAAC;AACnK,eAAO,MAAM,WAAW,yFACgE,CAAC;AAEzF,qBAAa,SAAU,SAAQ,KAAK;IAEtB,QAAQ,CAAC,WAAW,EAAE,MAAM;IADxC,QAAQ,CAAC,IAAI,gBAAgB;gBACR,WAAW,EAAE,MAAM;CAGzC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAAO,IAI9E,GAAG,KAAK,KAAG,OAAO,CAAC,IAAI,CAAC,CAYvC"}
package/dist/pace.js ADDED
@@ -0,0 +1,38 @@
1
+ /** A tool call may wait this long inline; a longer drawn wait is answered with the time it ends. */
2
+ export const INLINE_MAX_MS = 30_000;
3
+ const AGAIN = "answers NOT_BEFORE with notBeforeMs, and the same call at or after that time runs";
4
+ export const WAITS_LONG = ` Unless ESSEY_SUBMIT_DELAY is off it first waits a random 2 to 30 min: the call ${AGAIN}.`;
5
+ export const WAITS_SEIZED = `${WAITS_LONG} While nothing has landed in the pool since the seizure it waits again.`;
6
+ export const WAITS_MEDIUM = ` Unless ESSEY_SUBMIT_DELAY is off it first waits a random 20 s to 3 min, capped by the action's deadline; a wait over 30 s ${AGAIN}.`;
7
+ export const WAITS_SHORT = " Unless ESSEY_SUBMIT_DELAY is off it first waits a random 0 to 30 s inside the call.";
8
+ export class NotBefore extends Error {
9
+ notBeforeMs;
10
+ code = "NOT_BEFORE";
11
+ constructor(notBeforeMs) {
12
+ super("not before");
13
+ this.notBeforeMs = notBeforeMs;
14
+ }
15
+ }
16
+ /**
17
+ * The SDK's `io.pace` for a tool server. A drawn wait over `INLINE_MAX_MS` throws `NotBefore` and is kept in
18
+ * memory per action and subject, so a repeat call before that time gets the same time and one at or after it runs.
19
+ */
20
+ export function toolPace(o = {}) {
21
+ const now = o.now ?? Date.now;
22
+ const sleep = o.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
23
+ const due = new Map();
24
+ return async (p) => {
25
+ const key = `${p.action} ${p.subject}`;
26
+ const held = due.get(key);
27
+ if (held !== undefined && now() < held)
28
+ throw new NotBefore(held);
29
+ if (held !== undefined) {
30
+ due.delete(key);
31
+ return;
32
+ }
33
+ if (p.delayMs <= INLINE_MAX_MS)
34
+ return sleep(p.delayMs);
35
+ due.set(key, p.notBeforeMs);
36
+ throw new NotBefore(p.notBeforeMs);
37
+ };
38
+ }
package/dist/records.d.ts CHANGED
@@ -10,9 +10,10 @@ 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: `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.
13
+ * What a cycle step needs from an earlier one and no chain read gives back, mode 600 beside the state file, sealed
14
+ * under `recordKey`. PRV-10: each file is `r-<hmac of kind and id>.json`, so a listing names no loan or room; the
15
+ * kind and id are inside the seal. A `loan-<id>.json`-style file (older servers, or the plain JSON
16
+ * `scripts/v3/live/run.mts` writes) is moved to its blind name when the store opens.
16
17
  */
17
18
  export type Records = {
18
19
  loan(id: string): LoanRecord;
@@ -1 +1 @@
1
- {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOhE,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AACtE,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAC/E,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,sHAAsH;AACtH,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;C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,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9D,CAAC;AA0BF,oHAAoH;AACpH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAEtD;AA2CD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAgIjE"}
package/dist/records.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { randomBytes } from "node:crypto";
2
- import { chmodSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
2
+ import { chmodSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
3
3
  import { isAbsolute, join } from "node:path";
4
4
  import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
5
5
  import { hkdf } from "@noble/hashes/hkdf.js";
6
+ import { hmac } from "@noble/hashes/hmac.js";
6
7
  import { sha256 } from "@noble/hashes/sha2.js";
7
8
  import { ToolRefusal } from "./failure.js";
8
9
  const LOAN_ID = /^0x[0-9a-f]{64}$/;
9
- const RECORD_FILE = /^(loan|offer|sale|bid)-(0x[0-9a-f]{64})\.json$/;
10
+ const NAMED_FILE = /^(loan|offer|sale|bid)-(0x[0-9a-f]{64})\.json$/;
11
+ const BLIND_FILE = /^r-[0-9a-f]{32}\.json$/;
10
12
  const KINDS = ["loan", "offer", "sale", "bid"];
11
13
  const EXPORT_LABEL = "export";
12
14
  const NONCE = 24;
@@ -63,43 +65,60 @@ function exportRows(text, key) {
63
65
  });
64
66
  }
65
67
  export function fileRecords(dir, key) {
66
- const path = (kind, id) => {
68
+ const nameKey = hkdf(sha256, key, undefined, utf8("essey-v3-mcp record names v1"), 32);
69
+ const blindName = (kind, id) => {
67
70
  if (!LOAN_ID.test(id))
68
71
  throw new ToolRefusal("loan must be 0x and 64 hex digits");
69
- return join(dir, `${kind}-${id}.json`);
72
+ return `r-${Buffer.from(hmac(sha256, nameKey, utf8(`${kind}-${id}`)))
73
+ .toString("hex")
74
+ .slice(0, 32)}.json`;
70
75
  };
71
- const read = (kind, id) => {
76
+ const opened = (name) => {
72
77
  let v;
73
78
  try {
74
- v = JSON.parse(readFileSync(path(kind, id), "utf8"));
79
+ v = JSON.parse(readFileSync(join(dir, name), "utf8"));
75
80
  }
76
81
  catch (err) {
77
82
  if (err.code === "ENOENT")
78
83
  return null;
79
84
  throw err;
80
85
  }
81
- return typeof v.sealed === "string" ? unseal(key, `${kind}-${id}`, v.sealed) : v;
86
+ return unseal(key, name, String(v.sealed));
87
+ };
88
+ const read = (kind, id) => {
89
+ const row = opened(blindName(kind, id));
90
+ if (row && (row.kind !== kind || row.id !== id))
91
+ throw new ToolRefusal("a record file holds another record");
92
+ return row?.record ?? null;
82
93
  };
83
- const write = (kind, id, v) => {
84
- const target = path(kind, id);
94
+ const write = (kind, id, record) => {
95
+ const name = blindName(kind, id);
85
96
  mkdirSync(dir, { recursive: true, mode: 0o700 });
86
- writePrivate(target, seal(key, `${kind}-${id}`, v));
97
+ writePrivate(join(dir, name), seal(key, name, { kind, id, record }));
87
98
  };
88
- const held = () => {
89
- let names;
99
+ const names = () => {
90
100
  try {
91
- names = readdirSync(dir);
101
+ return readdirSync(dir);
92
102
  }
93
103
  catch (err) {
94
104
  if (err.code === "ENOENT")
95
105
  return [];
96
106
  throw err;
97
107
  }
98
- return names.flatMap((n) => {
99
- const m = RECORD_FILE.exec(n);
100
- return m ? [{ kind: m[1], id: m[2] }] : [];
101
- });
102
108
  };
109
+ const held = () => names().flatMap((n) => {
110
+ const row = BLIND_FILE.test(n) ? opened(n) : null;
111
+ return row ? [{ kind: row.kind, id: row.id }] : [];
112
+ });
113
+ for (const n of names()) {
114
+ const m = NAMED_FILE.exec(n);
115
+ if (!m)
116
+ continue;
117
+ const [kind, id] = [m[1], m[2]];
118
+ const v = JSON.parse(readFileSync(join(dir, n), "utf8"));
119
+ write(kind, id, typeof v.sealed === "string" ? unseal(key, `${kind}-${id}`, v.sealed) : v);
120
+ unlinkSync(join(dir, n));
121
+ }
103
122
  const absolute = (p) => {
104
123
  if (!isAbsolute(p))
105
124
  throw new ToolRefusal("path must be absolute");
@@ -1,4 +1,16 @@
1
+ import { type Payout } from "@esseyonsui/sui-sdk-v3";
1
2
  import type { Tool } from "./tools.ts";
3
+ /** The top-level digest is the last piece's, the one `bind` waits to see indexed. */
4
+ export declare function paidOut(rows: Payout[]): {
5
+ ok: true;
6
+ digest: string;
7
+ payouts: {
8
+ digest: string;
9
+ ticket: string;
10
+ amount: string;
11
+ to: string;
12
+ }[];
13
+ };
2
14
  /** No SDK call behind either, so they sit outside `MORE`. */
3
15
  export declare const RECORD_TOOLS: Tool[];
4
16
  export declare const MORE: Tool[];
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"tools-more.d.ts","sourceRoot":"","sources":["../src/tools-more.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,MAAM,EAAkB,MAAM,wBAAwB,CAAC;AAgB5F,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAsCpD,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE;;;;;;;;;EAMrC;AAiPD,6DAA6D;AAC7D,eAAO,MAAM,YAAY,EAAE,IAAI,EAoB9B,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IAAI,EAA6C,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { COINS } from "@esseyonsui/sui-sdk-v3";
2
- import { FORCE, LOAN_SCHEMA, OPEN_SCHEMA, int, parseAmount, parseCoin, parseForce, parseLoanId, parsePayee, } from "./args.js";
2
+ import { FORCE, LOAN_SCHEMA, OPEN_SCHEMA, PAYEES, int, parseAmount, parseCoin, parseForce, parseLoanId, parsePayees, } from "./args.js";
3
3
  import { isSdkCode, ToolRefusal } from "./failure.js";
4
+ import { WAITS_LONG, WAITS_MEDIUM, WAITS_SHORT } from "./pace.js";
4
5
  /** `move/v3/loan/sources/loan.move:40` MAX_OFFERS = 16. */
5
6
  const MAX_SEQ = 15;
6
7
  const MAX_MS = Number.MAX_SAFE_INTEGER;
@@ -26,6 +27,14 @@ function bad(msg) {
26
27
  function landed(row) {
27
28
  return { ok: true, digest: row.digest, ticket: row.ticket };
28
29
  }
30
+ /** The top-level digest is the last piece's, the one `bind` waits to see indexed. */
31
+ export function paidOut(rows) {
32
+ return {
33
+ ok: true,
34
+ digest: rows[rows.length - 1].digest,
35
+ payouts: rows.map((r) => ({ digest: r.digest, ticket: r.ticket, amount: r.amount.toString(), to: r.to })),
36
+ };
37
+ }
29
38
  function keeperArgs(args) {
30
39
  const loan = parseLoanId(args);
31
40
  if (args.via === undefined)
@@ -88,7 +97,7 @@ const REFI = [
88
97
  name: "essey_loan_refi_settle",
89
98
  kind: "call",
90
99
  description: "Borrower, after the refinance window: take the lowest eligible offer. The old lender is paid and collects with " +
91
- "essey_loan_collect; this server keeps the new terms. Returns the digest, ticket, rate, amount owed and maturity.",
100
+ `essey_loan_collect; this server keeps the new terms. Returns the digest, ticket, rate, amount owed and maturity.${WAITS_MEDIUM}`,
92
101
  inputSchema: LOAN_SCHEMA,
93
102
  run: async (ctx, args) => {
94
103
  const settled = own(ctx, parseLoanId(args));
@@ -122,7 +131,7 @@ const SEIZE = [
122
131
  name: "essey_loan_liquidate",
123
132
  kind: "call",
124
133
  description: "Borrower of a loan settled from this server: seize it while it is underwater, from this server's own terms. " +
125
- "The lender takes its share with essey_loan_collect_seized, the borrower the rest with essey_loan_collect_surplus.",
134
+ `The lender takes its share with essey_loan_collect_seized, the borrower the rest with essey_loan_collect_surplus.${WAITS_SHORT}`,
126
135
  inputSchema: LOAN_SCHEMA,
127
136
  run: async (ctx, args) => landed(await ctx.client.loans.liquidate(own(ctx, parseLoanId(args)))),
128
137
  },
@@ -130,7 +139,7 @@ const SEIZE = [
130
139
  name: "essey_loan_seize_default",
131
140
  kind: "call",
132
141
  description: "Borrower of a loan settled from this server: seize it once it is past maturity plus grace, from this server's " +
133
- "own terms. Then essey_loan_collect_seized (lender) and essey_loan_collect_surplus (borrower).",
142
+ `own terms. Then essey_loan_collect_seized (lender) and essey_loan_collect_surplus (borrower).${WAITS_SHORT}`,
134
143
  inputSchema: LOAN_SCHEMA,
135
144
  run: async (ctx, args) => landed(await ctx.client.loans.seizeDefault(own(ctx, parseLoanId(args)))),
136
145
  },
@@ -138,7 +147,7 @@ const SEIZE = [
138
147
  name: "essey_loan_fault_liquidate",
139
148
  kind: "call",
140
149
  description: "Lender, from the offer this server made, of a loan a keeper marked FAULT with essey_keeper_fault: seize it. " +
141
- "Then essey_loan_collect_seized.",
150
+ `Then essey_loan_collect_seized.${WAITS_SHORT}`,
142
151
  inputSchema: LOAN_SCHEMA,
143
152
  run: async (ctx, args) => {
144
153
  const loan = parseLoanId(args);
@@ -193,7 +202,7 @@ const KEEPER = [
193
202
  name: "essey_keeper_fault",
194
203
  kind: "call",
195
204
  description: "Keeper: mark an active loan FAULT when its retained borrower keeper ciphertext does not open its lock. The " +
196
- "chain refuses an honest ciphertext. The lender then calls essey_loan_fault_liquidate.",
205
+ `chain refuses an honest ciphertext. The lender then calls essey_loan_fault_liquidate.${WAITS_SHORT}`,
197
206
  inputSchema: KEEPER_SCHEMA,
198
207
  run: async (ctx, args) => landed(await ctx.client.loans.fault(keeperArgs(args))),
199
208
  },
@@ -201,7 +210,7 @@ const KEEPER = [
201
210
  name: "essey_keeper_liquidate",
202
211
  kind: "call",
203
212
  description: "Keeper: seize an underwater loan from its Seal read of the keeper ciphertext. The keeper fee arrives as an own " +
204
- "note; the lender and borrower collect with essey_loan_collect_seized and essey_loan_collect_surplus.",
213
+ `note; the lender and borrower collect with essey_loan_collect_seized and essey_loan_collect_surplus.${WAITS_SHORT}`,
205
214
  inputSchema: KEEPER_SCHEMA,
206
215
  run: async (ctx, args) => landed(await ctx.client.loans.keeperLiquidate(keeperArgs(args))),
207
216
  },
@@ -210,14 +219,19 @@ const NOTES = [
210
219
  {
211
220
  name: "essey_notes_exit",
212
221
  kind: "call",
213
- description: "Withdraw every note of a coin, at most two, less fees, to a 0x address of 64 hex digits. Returns the digest " +
214
- "and ticket.",
222
+ description: "Withdraw the notes of a coin, at most two. With denominations, the largest denomination sum they cover with " +
223
+ "every piece's fees goes out as pieces, each to its own address in to, and kept stays in a note; a refusal " +
224
+ "names how many addresses it needs. force: true, or a coin without denominations: everything less fees to " +
225
+ `one address. Returns each piece's digest, ticket, amount and address.${WAITS_LONG}`,
215
226
  inputSchema: obj({
216
227
  coin: { type: "string", enum: [...COINS] },
217
- to: { type: "string", pattern: "^0x[0-9a-fA-F]{64}$", description: "recipient address" },
228
+ to: PAYEES,
218
229
  force: FORCE,
219
230
  }, ["coin", "to"]),
220
- run: async (ctx, args) => landed(await ctx.client.notes.exit(parseCoin(args), parsePayee(args), parseForce(args))),
231
+ run: async (ctx, args) => {
232
+ const out = await ctx.client.notes.exit(parseCoin(args), parsePayees(args), parseForce(args));
233
+ return { ...paidOut(out.payouts), kept: out.kept.toString() };
234
+ },
221
235
  },
222
236
  {
223
237
  name: "essey_notes_recover",
@@ -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;AAwQpD,eAAO,MAAM,UAAU,EAAE,IAAI,EAA2B,CAAC"}
1
+ {"version":3,"file":"tools-sales.d.ts","sourceRoot":"","sources":["../src/tools-sales.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,YAAY,CAAC;AAwQpD,eAAO,MAAM,UAAU,EAAE,IAAI,EAA2B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { isEsseyError, v3 } from "@esseyonsui/sui-sdk-v3";
2
2
  import { ADDRESS, AMOUNT, COIN, MS, address, int, objectSchema, optBool, parseAmount, parseCoin, payee, } from "./args.js";
3
3
  import { ToolRefusal } from "./failure.js";
4
+ import { WAITS_LONG, WAITS_MEDIUM } from "./pace.js";
4
5
  const SLOTS = v3.sales.SLOTS;
5
6
  /** `sale_room.move:30-33`. */
6
7
  const ROOM_STATES = ["open", "settled", "expired", "cancelled"];
@@ -172,7 +173,7 @@ const BIDDER = [
172
173
  name: "essey_sale_bid",
173
174
  kind: "call",
174
175
  description: "Bidder: lock deposit from own notes of the room's coin behind a sealed bid of price. Only the seller opens " +
175
- "it, after close. The bid record stays in a mode-600 file. Returns the digest and ticket.",
176
+ `it, after close. The bid record stays in a mode-600 file. Returns the digest and ticket.${WAITS_MEDIUM}`,
176
177
  inputSchema: objectSchema({
177
178
  room: ROOM,
178
179
  price: { ...AMOUNT, description: "the sealed bid, in the room coin's smallest unit" },
@@ -192,7 +193,7 @@ const BIDDER = [
192
193
  name: "essey_sale_reclaim",
193
194
  kind: "call",
194
195
  description: "Bidder, once the room settled or expired: a losing bid's deposit back to an own note, or with residual true " +
195
- "the winner's change. Returns the value.",
196
+ `the winner's change. Returns the value.${WAITS_LONG}`,
196
197
  inputSchema: objectSchema({
197
198
  room: ROOM,
198
199
  residual: { type: "boolean", description: "the winner's change instead of the deposit" },
@@ -1 +1 @@
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,UA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AE,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;AA4bF,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,10 @@
1
1
  import { COINS, v3 } from "@esseyonsui/sui-sdk-v3";
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";
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";
3
3
  import { assertNoSecrets, failureOf, ToolRefusal } from "./failure.js";
4
+ import { WAITS_LONG, WAITS_MEDIUM, WAITS_SEIZED, WAITS_SHORT } from "./pace.js";
4
5
  import { redact } from "./redact.js";
5
6
  import { BADGE_TOOLS } from "./tools-badge.js";
6
- import { MORE, RECORD_TOOLS } from "./tools-more.js";
7
+ import { MORE, paidOut, RECORD_TOOLS } from "./tools-more.js";
7
8
  import { SALE_TOOLS } from "./tools-sales.js";
8
9
  const UNITS = "whole-number string in the coin's smallest unit";
9
10
  const BIDDING = v3.LOAN_LIFECYCLE.indexOf("bidding");
@@ -121,14 +122,17 @@ const NOTES = [
121
122
  {
122
123
  name: "essey_notes_withdraw",
123
124
  kind: "call",
124
- description: `Withdraw ${UNITS} of a coin to a 0x address of 64 hex digits. Returns the digest and ticket.`,
125
+ description: `Withdraw ${UNITS} of a coin. Amount and address are public on chain, so with denominations the amount goes ` +
126
+ "out as denomination pieces, each to its own address in to; an amount that is not such a sum is refused with " +
127
+ "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}`,
125
129
  inputSchema: obj({
126
130
  coin: { type: "string", enum: [...COINS] },
127
131
  amount: { type: "string", pattern: "^[1-9][0-9]*$", description: UNITS },
128
- to: { type: "string", pattern: "^0x[0-9a-fA-F]{64}$", description: "recipient address" },
132
+ to: PAYEES,
129
133
  force: FORCE,
130
134
  }, ["coin", "amount", "to"]),
131
- run: async (ctx, args) => landed(await ctx.client.notes.withdraw(parseCoin(args), parseAmount(args), parsePayee(args), parseForce(args))),
135
+ run: async (ctx, args) => paidOut(await ctx.client.notes.withdraw(parseCoin(args), parseAmount(args), parsePayees(args), parseForce(args))),
132
136
  },
133
137
  {
134
138
  name: "essey_notes_receive_address",
@@ -140,7 +144,7 @@ const NOTES = [
140
144
  {
141
145
  name: "essey_notes_transfer",
142
146
  kind: "call",
143
- description: `Pay ${UNITS} into a note only the holder of a v3note address can open. No public amount moves.`,
147
+ description: `Pay ${UNITS} into a note only the holder of a v3note address can open. No public amount moves.${WAITS_LONG}`,
144
148
  inputSchema: TRANSFER_SCHEMA,
145
149
  run: async (ctx, args) => landed(await ctx.client.notes.transfer(parseCoin(args), parseAmount(args), parseReceiver(args))),
146
150
  },
@@ -164,7 +168,7 @@ const BORROWER = [
164
168
  name: "essey_loan_settle",
165
169
  kind: "call",
166
170
  description: "Borrower, after the offer window: open every sealed offer and settle on the lowest eligible rate; the principal " +
167
- "arrives as an own note. Returns the digest, ticket, rate, amount owed and maturity.",
171
+ `arrives as an own note. Returns the digest, ticket, rate, amount owed and maturity.${WAITS_MEDIUM}`,
168
172
  inputSchema: LOAN_SCHEMA,
169
173
  run: async (ctx, args) => {
170
174
  const loan = parseLoanId(args);
@@ -181,7 +185,7 @@ const BORROWER = [
181
185
  {
182
186
  name: "essey_loan_repay",
183
187
  kind: "call",
184
- description: "Borrower: repay the amount owed from own notes of the loan coin. Then call essey_loan_release.",
188
+ description: `Borrower: repay the amount owed from own notes of the loan coin. Then call essey_loan_release.${WAITS_MEDIUM}`,
185
189
  inputSchema: LOAN_SCHEMA,
186
190
  run: async (ctx, args) => {
187
191
  const { loan, terms, borrowerPk } = settled(ctx, parseLoanId(args));
@@ -191,7 +195,7 @@ const BORROWER = [
191
195
  {
192
196
  name: "essey_loan_release",
193
197
  kind: "call",
194
- description: "Borrower, after repay: the whole collateral back to an own note, and the loan closes.",
198
+ description: `Borrower, after repay: the whole collateral back to an own note, and the loan closes.${WAITS_MEDIUM}`,
195
199
  inputSchema: LOAN_SCHEMA,
196
200
  run: async (ctx, args) => landed(await ctx.client.loans.release(settled(ctx, parseLoanId(args)))),
197
201
  },
@@ -205,7 +209,7 @@ const BORROWER = [
205
209
  {
206
210
  name: "essey_loan_reclaim_coll",
207
211
  kind: "call",
208
- description: "Borrower, after cancel: the collateral of the cancelled loan back to an own note.",
212
+ description: `Borrower, after cancel: the collateral of the cancelled loan back to an own note.${WAITS_LONG}`,
209
213
  inputSchema: LOAN_SCHEMA,
210
214
  run: async (ctx, args) => {
211
215
  const loan = parseLoanId(args);
@@ -229,7 +233,8 @@ const BORROWER = [
229
233
  {
230
234
  name: "essey_loan_heartbeat",
231
235
  kind: "call",
232
- description: "Borrower: re-prove an active loan healthy at a heartbeat bucket's price floor.",
236
+ description: "Borrower: re-prove an active loan healthy at a heartbeat bucket's price floor. k is 1, 4 or 8 (default 1); " +
237
+ `the floor is public and a deeper k shows a lower LTV, so the coarser k 1 leaks the least.${WAITS_SHORT}`,
233
238
  inputSchema: HEARTBEAT_SCHEMA,
234
239
  run: async (ctx, args) => {
235
240
  const { loan, k } = parseHeartbeat(args);
@@ -239,7 +244,7 @@ const BORROWER = [
239
244
  {
240
245
  name: "essey_loan_topup",
241
246
  kind: "call",
242
- description: "Borrower: add collateral from own notes to an active loan. Returns the digest, ticket and the new locked amount.",
247
+ description: `Borrower: add collateral from own notes to an active loan. Returns the digest, ticket and the new locked amount.${WAITS_SHORT}`,
243
248
  inputSchema: TOPUP_SCHEMA,
244
249
  run: async (ctx, args) => {
245
250
  const { loan, add, asBorrower } = parseTopup(args);
@@ -257,7 +262,7 @@ const BORROWER = [
257
262
  {
258
263
  name: "essey_loan_collect_surplus",
259
264
  kind: "call",
260
- description: "Borrower, after a liquidation or default: the collateral the seizure left over to an own note. Returns the value.",
265
+ description: `Borrower, after a liquidation or default: the collateral the seizure left over to an own note. Returns the value.${WAITS_SEIZED}`,
261
266
  inputSchema: LOAN_SCHEMA,
262
267
  run: async (ctx, args) => {
263
268
  const r = await ctx.client.loans.collectSurplus(settled(ctx, parseLoanId(args)));
@@ -308,7 +313,7 @@ const LENDER = [
308
313
  name: "essey_loan_offer",
309
314
  kind: "call",
310
315
  description: `Lender: offer the requested principal at rateBps from own notes of the loan coin, sealed to the borrower. ${PLANNED} ` +
311
- "Returns the digest, ticket, and the principal and rate offered.",
316
+ `Returns the digest, ticket, and the principal and rate offered.${WAITS_MEDIUM}`,
312
317
  inputSchema: OFFER_SCHEMA,
313
318
  run: async (ctx, args) => {
314
319
  const p = parseOfferArgs(args);
@@ -320,7 +325,7 @@ const LENDER = [
320
325
  {
321
326
  name: "essey_loan_collect",
322
327
  kind: "call",
323
- description: "Lender, after the borrower repaid: the repayment to an own note. Returns the value.",
328
+ description: `Lender, after the borrower repaid: the repayment to an own note. Returns the value.${WAITS_LONG}`,
324
329
  inputSchema: LOAN_SCHEMA,
325
330
  run: async (ctx, args) => {
326
331
  const loan = parseLoanId(args);
@@ -331,7 +336,7 @@ const LENDER = [
331
336
  {
332
337
  name: "essey_loan_reclaim",
333
338
  kind: "call",
334
- description: "Lender: take back the principal an offer locked once the round resolved without it.",
339
+ description: `Lender: take back the principal an offer locked once the round resolved without it.${WAITS_LONG}`,
335
340
  inputSchema: LOAN_SCHEMA,
336
341
  run: async (ctx, args) => {
337
342
  const loan = parseLoanId(args);
@@ -341,7 +346,7 @@ const LENDER = [
341
346
  {
342
347
  name: "essey_loan_collect_seized",
343
348
  kind: "call",
344
- description: "Lender, after a liquidation or default: its share of the seized collateral to an own note.",
349
+ description: `Lender, after a liquidation or default: its share of the seized collateral to an own note.${WAITS_SEIZED}`,
345
350
  inputSchema: LOAN_SCHEMA,
346
351
  run: async (ctx, args) => {
347
352
  const loan = parseLoanId(args);
@@ -388,8 +393,7 @@ const VIEWS = [
388
393
  ltvBps: status.ltvBps,
389
394
  underwater: status.underwater,
390
395
  liquidationPrice: status.liquidationPrice,
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,
396
+ coveredAtDefaultK: status.coveredAtDefaultK,
393
397
  };
394
398
  },
395
399
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esseyonsui/sui-mcp-v3",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
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.7",
32
+ "@esseyonsui/sui-sdk-v3": "0.1.9",
33
33
  "@mysten/seal": "1.5.1",
34
34
  "@mysten/sui": "2.37.0",
35
35
  "@noble/ciphers": "2.4.0",