@t2000/mcp 5.1.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +267 -231
- package/dist/bin.js.map +1 -1
- package/dist/index.js +267 -231
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -7081,7 +7081,7 @@ var require_compile = __commonJS({
|
|
|
7081
7081
|
const schOrFunc = root.refs[ref];
|
|
7082
7082
|
if (schOrFunc)
|
|
7083
7083
|
return schOrFunc;
|
|
7084
|
-
let _sch =
|
|
7084
|
+
let _sch = resolve2.call(this, root, ref);
|
|
7085
7085
|
if (_sch === void 0) {
|
|
7086
7086
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
7087
7087
|
const { schemaId } = this.opts;
|
|
@@ -7108,7 +7108,7 @@ var require_compile = __commonJS({
|
|
|
7108
7108
|
function sameSchemaEnv(s1, s2) {
|
|
7109
7109
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
7110
7110
|
}
|
|
7111
|
-
function
|
|
7111
|
+
function resolve2(root, ref) {
|
|
7112
7112
|
let sch;
|
|
7113
7113
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
7114
7114
|
ref = sch;
|
|
@@ -7680,7 +7680,7 @@ var require_fast_uri = __commonJS({
|
|
|
7680
7680
|
}
|
|
7681
7681
|
return uri;
|
|
7682
7682
|
}
|
|
7683
|
-
function
|
|
7683
|
+
function resolve2(baseURI, relativeURI, options) {
|
|
7684
7684
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
7685
7685
|
const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
7686
7686
|
schemelessOptions.skipEscape = true;
|
|
@@ -7907,7 +7907,7 @@ var require_fast_uri = __commonJS({
|
|
|
7907
7907
|
var fastUri = {
|
|
7908
7908
|
SCHEMES,
|
|
7909
7909
|
normalize: normalize2,
|
|
7910
|
-
resolve:
|
|
7910
|
+
resolve: resolve2,
|
|
7911
7911
|
resolveComponent,
|
|
7912
7912
|
equal,
|
|
7913
7913
|
serialize,
|
|
@@ -16203,8 +16203,8 @@ function promiseWithResolvers() {
|
|
|
16203
16203
|
let resolver;
|
|
16204
16204
|
let rejecter;
|
|
16205
16205
|
return {
|
|
16206
|
-
promise: new Promise((
|
|
16207
|
-
resolver =
|
|
16206
|
+
promise: new Promise((resolve2, reject) => {
|
|
16207
|
+
resolver = resolve2;
|
|
16208
16208
|
rejecter = reject;
|
|
16209
16209
|
}),
|
|
16210
16210
|
resolve: resolver,
|
|
@@ -16341,17 +16341,17 @@ var init_dataloader = __esm({
|
|
|
16341
16341
|
const cachedPromise = cacheMap.get(cacheKey);
|
|
16342
16342
|
if (cachedPromise) {
|
|
16343
16343
|
const cacheHits = batch.cacheHits || (batch.cacheHits = []);
|
|
16344
|
-
return new Promise((
|
|
16344
|
+
return new Promise((resolve2) => {
|
|
16345
16345
|
cacheHits.push(() => {
|
|
16346
|
-
|
|
16346
|
+
resolve2(cachedPromise);
|
|
16347
16347
|
});
|
|
16348
16348
|
});
|
|
16349
16349
|
}
|
|
16350
16350
|
}
|
|
16351
16351
|
batch.keys.push(key);
|
|
16352
|
-
const promise = new Promise((
|
|
16352
|
+
const promise = new Promise((resolve2, reject) => {
|
|
16353
16353
|
batch.callbacks.push({
|
|
16354
|
-
resolve:
|
|
16354
|
+
resolve: resolve2,
|
|
16355
16355
|
reject
|
|
16356
16356
|
});
|
|
16357
16357
|
});
|
|
@@ -17934,12 +17934,12 @@ var init_queue = __esm({
|
|
|
17934
17934
|
SerialQueue = class {
|
|
17935
17935
|
#queue = [];
|
|
17936
17936
|
async runTask(task) {
|
|
17937
|
-
return new Promise((
|
|
17937
|
+
return new Promise((resolve2, reject) => {
|
|
17938
17938
|
this.#queue.push(() => {
|
|
17939
17939
|
task().finally(() => {
|
|
17940
17940
|
this.#queue.shift();
|
|
17941
17941
|
if (this.#queue.length > 0) this.#queue[0]();
|
|
17942
|
-
}).then(
|
|
17942
|
+
}).then(resolve2, reject);
|
|
17943
17943
|
});
|
|
17944
17944
|
if (this.#queue.length === 1) this.#queue[0]();
|
|
17945
17945
|
});
|
|
@@ -17952,18 +17952,18 @@ var init_queue = __esm({
|
|
|
17952
17952
|
this.maxTasks = maxTasks;
|
|
17953
17953
|
}
|
|
17954
17954
|
runTask(task) {
|
|
17955
|
-
return new Promise((
|
|
17955
|
+
return new Promise((resolve2, reject) => {
|
|
17956
17956
|
if (this.activeTasks < this.maxTasks) {
|
|
17957
17957
|
this.activeTasks++;
|
|
17958
17958
|
task().finally(() => {
|
|
17959
17959
|
if (this.#queue.length > 0) this.#queue.shift()();
|
|
17960
17960
|
else this.activeTasks--;
|
|
17961
|
-
}).then(
|
|
17961
|
+
}).then(resolve2, reject);
|
|
17962
17962
|
} else this.#queue.push(() => {
|
|
17963
17963
|
task().finally(() => {
|
|
17964
17964
|
if (this.#queue.length > 0) this.#queue.shift()();
|
|
17965
17965
|
else this.activeTasks--;
|
|
17966
|
-
}).then(
|
|
17966
|
+
}).then(resolve2, reject);
|
|
17967
17967
|
});
|
|
17968
17968
|
});
|
|
17969
17969
|
}
|
|
@@ -18171,11 +18171,11 @@ var init_parallel = __esm({
|
|
|
18171
18171
|
await this.#updateCache(() => this.#waitForLastDigest());
|
|
18172
18172
|
}
|
|
18173
18173
|
async executeTransaction(transaction, include, additionalSignatures = []) {
|
|
18174
|
-
const { promise, resolve:
|
|
18174
|
+
const { promise, resolve: resolve2, reject } = promiseWithResolvers();
|
|
18175
18175
|
const usedObjects = await this.#getUsedObjects(transaction);
|
|
18176
18176
|
const execute = () => {
|
|
18177
18177
|
this.#executeQueue.runTask(() => {
|
|
18178
|
-
return this.#execute(transaction, usedObjects, include, additionalSignatures).then(
|
|
18178
|
+
return this.#execute(transaction, usedObjects, include, additionalSignatures).then(resolve2, reject);
|
|
18179
18179
|
});
|
|
18180
18180
|
};
|
|
18181
18181
|
const conflicts = /* @__PURE__ */ new Set();
|
|
@@ -20415,8 +20415,8 @@ var init_core = __esm({
|
|
|
20415
20415
|
if (scheduleIndex < schedule.length) {
|
|
20416
20416
|
const remaining = t0 + schedule[scheduleIndex] - Date.now();
|
|
20417
20417
|
scheduleIndex++;
|
|
20418
|
-
if (remaining > 0) await Promise.race([new Promise((
|
|
20419
|
-
} else await Promise.race([new Promise((
|
|
20418
|
+
if (remaining > 0) await Promise.race([new Promise((resolve2) => setTimeout(resolve2, remaining)), abortPromise]);
|
|
20419
|
+
} else await Promise.race([new Promise((resolve2) => setTimeout(resolve2, lastInterval)), abortPromise]);
|
|
20420
20420
|
abortSignal.throwIfAborted();
|
|
20421
20421
|
try {
|
|
20422
20422
|
return await this.getTransaction({
|
|
@@ -27948,8 +27948,8 @@ var init_deferred = __esm({
|
|
|
27948
27948
|
*/
|
|
27949
27949
|
constructor(preventUnhandledRejectionWarning = true) {
|
|
27950
27950
|
this._state = DeferredState.PENDING;
|
|
27951
|
-
this._promise = new Promise((
|
|
27952
|
-
this._resolve =
|
|
27951
|
+
this._promise = new Promise((resolve2, reject) => {
|
|
27952
|
+
this._resolve = resolve2;
|
|
27953
27953
|
this._reject = reject;
|
|
27954
27954
|
});
|
|
27955
27955
|
if (preventUnhandledRejectionWarning) {
|
|
@@ -28160,11 +28160,11 @@ var init_unary_call = __esm({
|
|
|
28160
28160
|
"../../node_modules/.pnpm/@protobuf-ts+runtime-rpc@2.11.1/node_modules/@protobuf-ts/runtime-rpc/build/es2015/unary-call.js"() {
|
|
28161
28161
|
__awaiter = function(thisArg, _arguments, P3, generator) {
|
|
28162
28162
|
function adopt(value) {
|
|
28163
|
-
return value instanceof P3 ? value : new P3(function(
|
|
28164
|
-
|
|
28163
|
+
return value instanceof P3 ? value : new P3(function(resolve2) {
|
|
28164
|
+
resolve2(value);
|
|
28165
28165
|
});
|
|
28166
28166
|
}
|
|
28167
|
-
return new (P3 || (P3 = Promise))(function(
|
|
28167
|
+
return new (P3 || (P3 = Promise))(function(resolve2, reject) {
|
|
28168
28168
|
function fulfilled(value) {
|
|
28169
28169
|
try {
|
|
28170
28170
|
step(generator.next(value));
|
|
@@ -28180,7 +28180,7 @@ var init_unary_call = __esm({
|
|
|
28180
28180
|
}
|
|
28181
28181
|
}
|
|
28182
28182
|
function step(result) {
|
|
28183
|
-
result.done ?
|
|
28183
|
+
result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
28184
28184
|
}
|
|
28185
28185
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28186
28186
|
});
|
|
@@ -28226,11 +28226,11 @@ var init_server_streaming_call = __esm({
|
|
|
28226
28226
|
"../../node_modules/.pnpm/@protobuf-ts+runtime-rpc@2.11.1/node_modules/@protobuf-ts/runtime-rpc/build/es2015/server-streaming-call.js"() {
|
|
28227
28227
|
__awaiter2 = function(thisArg, _arguments, P3, generator) {
|
|
28228
28228
|
function adopt(value) {
|
|
28229
|
-
return value instanceof P3 ? value : new P3(function(
|
|
28230
|
-
|
|
28229
|
+
return value instanceof P3 ? value : new P3(function(resolve2) {
|
|
28230
|
+
resolve2(value);
|
|
28231
28231
|
});
|
|
28232
28232
|
}
|
|
28233
|
-
return new (P3 || (P3 = Promise))(function(
|
|
28233
|
+
return new (P3 || (P3 = Promise))(function(resolve2, reject) {
|
|
28234
28234
|
function fulfilled(value) {
|
|
28235
28235
|
try {
|
|
28236
28236
|
step(generator.next(value));
|
|
@@ -28246,7 +28246,7 @@ var init_server_streaming_call = __esm({
|
|
|
28246
28246
|
}
|
|
28247
28247
|
}
|
|
28248
28248
|
function step(result) {
|
|
28249
|
-
result.done ?
|
|
28249
|
+
result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
28250
28250
|
}
|
|
28251
28251
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28252
28252
|
});
|
|
@@ -32717,11 +32717,11 @@ var init_grpc_web_format = __esm({
|
|
|
32717
32717
|
init_goog_grpc_status_code();
|
|
32718
32718
|
__awaiter3 = function(thisArg, _arguments, P3, generator) {
|
|
32719
32719
|
function adopt(value) {
|
|
32720
|
-
return value instanceof P3 ? value : new P3(function(
|
|
32721
|
-
|
|
32720
|
+
return value instanceof P3 ? value : new P3(function(resolve2) {
|
|
32721
|
+
resolve2(value);
|
|
32722
32722
|
});
|
|
32723
32723
|
}
|
|
32724
|
-
return new (P3 || (P3 = Promise))(function(
|
|
32724
|
+
return new (P3 || (P3 = Promise))(function(resolve2, reject) {
|
|
32725
32725
|
function fulfilled(value) {
|
|
32726
32726
|
try {
|
|
32727
32727
|
step(generator.next(value));
|
|
@@ -32737,7 +32737,7 @@ var init_grpc_web_format = __esm({
|
|
|
32737
32737
|
}
|
|
32738
32738
|
}
|
|
32739
32739
|
function step(result) {
|
|
32740
|
-
result.done ?
|
|
32740
|
+
result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
32741
32741
|
}
|
|
32742
32742
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32743
32743
|
});
|
|
@@ -45524,10 +45524,10 @@ var init_CanceledError = __esm({
|
|
|
45524
45524
|
});
|
|
45525
45525
|
|
|
45526
45526
|
// ../../node_modules/.pnpm/axios@1.15.2/node_modules/axios/lib/core/settle.js
|
|
45527
|
-
function settle(
|
|
45527
|
+
function settle(resolve2, reject, response) {
|
|
45528
45528
|
const validateStatus2 = response.config.validateStatus;
|
|
45529
45529
|
if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
|
|
45530
|
-
|
|
45530
|
+
resolve2(response);
|
|
45531
45531
|
} else {
|
|
45532
45532
|
reject(
|
|
45533
45533
|
new AxiosError_default(
|
|
@@ -47727,7 +47727,7 @@ var init_http = __esm({
|
|
|
47727
47727
|
http2Sessions = new Http2Sessions();
|
|
47728
47728
|
isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
|
|
47729
47729
|
wrapAsync = (asyncExecutor) => {
|
|
47730
|
-
return new Promise((
|
|
47730
|
+
return new Promise((resolve2, reject) => {
|
|
47731
47731
|
let onDone;
|
|
47732
47732
|
let isDone;
|
|
47733
47733
|
const done = (value, isRejected) => {
|
|
@@ -47737,7 +47737,7 @@ var init_http = __esm({
|
|
|
47737
47737
|
};
|
|
47738
47738
|
const _resolve = (value) => {
|
|
47739
47739
|
done(value);
|
|
47740
|
-
|
|
47740
|
+
resolve2(value);
|
|
47741
47741
|
};
|
|
47742
47742
|
const _reject = (reason) => {
|
|
47743
47743
|
done(reason, true);
|
|
@@ -47784,7 +47784,7 @@ var init_http = __esm({
|
|
|
47784
47784
|
}
|
|
47785
47785
|
};
|
|
47786
47786
|
http_default = isHttpAdapterSupported && function httpAdapter(config3) {
|
|
47787
|
-
return wrapAsync(async function dispatchHttpRequest(
|
|
47787
|
+
return wrapAsync(async function dispatchHttpRequest(resolve2, reject, onDone) {
|
|
47788
47788
|
const own2 = (key) => utils_default.hasOwnProp(config3, key) ? config3[key] : void 0;
|
|
47789
47789
|
let data = own2("data");
|
|
47790
47790
|
let lookup = own2("lookup");
|
|
@@ -47881,7 +47881,7 @@ var init_http = __esm({
|
|
|
47881
47881
|
}
|
|
47882
47882
|
let convertedData;
|
|
47883
47883
|
if (method !== "GET") {
|
|
47884
|
-
return settle(
|
|
47884
|
+
return settle(resolve2, reject, {
|
|
47885
47885
|
status: 405,
|
|
47886
47886
|
statusText: "method not allowed",
|
|
47887
47887
|
headers: {},
|
|
@@ -47903,7 +47903,7 @@ var init_http = __esm({
|
|
|
47903
47903
|
} else if (responseType === "stream") {
|
|
47904
47904
|
convertedData = stream3.Readable.from(convertedData);
|
|
47905
47905
|
}
|
|
47906
|
-
return settle(
|
|
47906
|
+
return settle(resolve2, reject, {
|
|
47907
47907
|
data: convertedData,
|
|
47908
47908
|
status: 200,
|
|
47909
47909
|
statusText: "OK",
|
|
@@ -48187,7 +48187,7 @@ var init_http = __esm({
|
|
|
48187
48187
|
});
|
|
48188
48188
|
}
|
|
48189
48189
|
response.data = responseStream;
|
|
48190
|
-
settle(
|
|
48190
|
+
settle(resolve2, reject, response);
|
|
48191
48191
|
} else {
|
|
48192
48192
|
const responseBuffer = [];
|
|
48193
48193
|
let totalResponseBytes = 0;
|
|
@@ -48237,7 +48237,7 @@ var init_http = __esm({
|
|
|
48237
48237
|
} catch (err) {
|
|
48238
48238
|
return reject(AxiosError_default.from(err, null, config3, response.request, response));
|
|
48239
48239
|
}
|
|
48240
|
-
settle(
|
|
48240
|
+
settle(resolve2, reject, response);
|
|
48241
48241
|
});
|
|
48242
48242
|
}
|
|
48243
48243
|
abortEmitter.once("abort", (err) => {
|
|
@@ -48611,7 +48611,7 @@ var init_xhr = __esm({
|
|
|
48611
48611
|
init_resolveConfig();
|
|
48612
48612
|
isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
48613
48613
|
xhr_default = isXHRAdapterSupported && function(config3) {
|
|
48614
|
-
return new Promise(function dispatchXhrRequest(
|
|
48614
|
+
return new Promise(function dispatchXhrRequest(resolve2, reject) {
|
|
48615
48615
|
const _config = resolveConfig_default(config3);
|
|
48616
48616
|
let requestData = _config.data;
|
|
48617
48617
|
const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
|
|
@@ -48646,7 +48646,7 @@ var init_xhr = __esm({
|
|
|
48646
48646
|
};
|
|
48647
48647
|
settle(
|
|
48648
48648
|
function _resolve(value) {
|
|
48649
|
-
|
|
48649
|
+
resolve2(value);
|
|
48650
48650
|
done();
|
|
48651
48651
|
},
|
|
48652
48652
|
function _reject(err) {
|
|
@@ -49081,8 +49081,8 @@ var init_fetch = __esm({
|
|
|
49081
49081
|
config3
|
|
49082
49082
|
);
|
|
49083
49083
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
49084
|
-
return await new Promise((
|
|
49085
|
-
settle(
|
|
49084
|
+
return await new Promise((resolve2, reject) => {
|
|
49085
|
+
settle(resolve2, reject, {
|
|
49086
49086
|
data: responseData,
|
|
49087
49087
|
headers: AxiosHeaders_default.from(response.headers),
|
|
49088
49088
|
status: response.status,
|
|
@@ -49553,8 +49553,8 @@ var init_CancelToken = __esm({
|
|
|
49553
49553
|
throw new TypeError("executor must be a function.");
|
|
49554
49554
|
}
|
|
49555
49555
|
let resolvePromise;
|
|
49556
|
-
this.promise = new Promise(function promiseExecutor(
|
|
49557
|
-
resolvePromise =
|
|
49556
|
+
this.promise = new Promise(function promiseExecutor(resolve2) {
|
|
49557
|
+
resolvePromise = resolve2;
|
|
49558
49558
|
});
|
|
49559
49559
|
const token = this;
|
|
49560
49560
|
this.promise.then((cancel) => {
|
|
@@ -49567,9 +49567,9 @@ var init_CancelToken = __esm({
|
|
|
49567
49567
|
});
|
|
49568
49568
|
this.promise.then = (onfulfilled) => {
|
|
49569
49569
|
let _resolve;
|
|
49570
|
-
const promise = new Promise((
|
|
49571
|
-
token.subscribe(
|
|
49572
|
-
_resolve =
|
|
49570
|
+
const promise = new Promise((resolve2) => {
|
|
49571
|
+
token.subscribe(resolve2);
|
|
49572
|
+
_resolve = resolve2;
|
|
49573
49573
|
}).then(onfulfilled);
|
|
49574
49574
|
promise.cancel = function reject() {
|
|
49575
49575
|
token.unsubscribe(_resolve);
|
|
@@ -50417,7 +50417,7 @@ var init_hermes_client = __esm({
|
|
|
50417
50417
|
return schema.parse(data);
|
|
50418
50418
|
} catch (error2) {
|
|
50419
50419
|
if (retries > 0 && !(error2 instanceof Error && error2.name === "AbortError")) {
|
|
50420
|
-
await new Promise((
|
|
50420
|
+
await new Promise((resolve2) => setTimeout(resolve2, backoff));
|
|
50421
50421
|
return this.httpRequest(url2, schema, options, retries - 1, backoff * 2);
|
|
50422
50422
|
}
|
|
50423
50423
|
throw error2;
|
|
@@ -72038,7 +72038,7 @@ var Protocol = class {
|
|
|
72038
72038
|
return;
|
|
72039
72039
|
}
|
|
72040
72040
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
72041
|
-
await new Promise((
|
|
72041
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
72042
72042
|
options?.signal?.throwIfAborted();
|
|
72043
72043
|
}
|
|
72044
72044
|
} catch (error2) {
|
|
@@ -72055,7 +72055,7 @@ var Protocol = class {
|
|
|
72055
72055
|
*/
|
|
72056
72056
|
request(request, resultSchema, options) {
|
|
72057
72057
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
72058
|
-
return new Promise((
|
|
72058
|
+
return new Promise((resolve2, reject) => {
|
|
72059
72059
|
const earlyReject = (error2) => {
|
|
72060
72060
|
reject(error2);
|
|
72061
72061
|
};
|
|
@@ -72133,7 +72133,7 @@ var Protocol = class {
|
|
|
72133
72133
|
if (!parseResult.success) {
|
|
72134
72134
|
reject(parseResult.error);
|
|
72135
72135
|
} else {
|
|
72136
|
-
|
|
72136
|
+
resolve2(parseResult.data);
|
|
72137
72137
|
}
|
|
72138
72138
|
} catch (error2) {
|
|
72139
72139
|
reject(error2);
|
|
@@ -72394,12 +72394,12 @@ var Protocol = class {
|
|
|
72394
72394
|
}
|
|
72395
72395
|
} catch {
|
|
72396
72396
|
}
|
|
72397
|
-
return new Promise((
|
|
72397
|
+
return new Promise((resolve2, reject) => {
|
|
72398
72398
|
if (signal.aborted) {
|
|
72399
72399
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
72400
72400
|
return;
|
|
72401
72401
|
}
|
|
72402
|
-
const timeoutId = setTimeout(
|
|
72402
|
+
const timeoutId = setTimeout(resolve2, interval);
|
|
72403
72403
|
signal.addEventListener("abort", () => {
|
|
72404
72404
|
clearTimeout(timeoutId);
|
|
72405
72405
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -73487,7 +73487,7 @@ var McpServer = class {
|
|
|
73487
73487
|
let task = createTaskResult.task;
|
|
73488
73488
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
73489
73489
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
73490
|
-
await new Promise((
|
|
73490
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
73491
73491
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
73492
73492
|
if (!updatedTask) {
|
|
73493
73493
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -74133,12 +74133,12 @@ var StdioServerTransport = class {
|
|
|
74133
74133
|
this.onclose?.();
|
|
74134
74134
|
}
|
|
74135
74135
|
send(message) {
|
|
74136
|
-
return new Promise((
|
|
74136
|
+
return new Promise((resolve2) => {
|
|
74137
74137
|
const json = serializeMessage(message);
|
|
74138
74138
|
if (this._stdout.write(json)) {
|
|
74139
|
-
|
|
74139
|
+
resolve2();
|
|
74140
74140
|
} else {
|
|
74141
|
-
this._stdout.once("drain",
|
|
74141
|
+
this._stdout.once("drain", resolve2);
|
|
74142
74142
|
}
|
|
74143
74143
|
});
|
|
74144
74144
|
}
|
|
@@ -80045,164 +80045,194 @@ async function resolveSuinsViaRpc(rawName, ctx = {}) {
|
|
|
80045
80045
|
return body.result ?? null;
|
|
80046
80046
|
}
|
|
80047
80047
|
init_errors3();
|
|
80048
|
-
var
|
|
80049
|
-
|
|
80050
|
-
|
|
80051
|
-
|
|
80052
|
-
|
|
80053
|
-
|
|
80054
|
-
}
|
|
80055
|
-
|
|
80056
|
-
|
|
80057
|
-
|
|
80058
|
-
|
|
80059
|
-
|
|
80060
|
-
|
|
80061
|
-
|
|
80062
|
-
|
|
80063
|
-
|
|
80064
|
-
|
|
80048
|
+
var DEFAULT_CONFIG_DIR = join$1(homedir(), ".t2000");
|
|
80049
|
+
function resolveConfigPath(configDir) {
|
|
80050
|
+
return join$1(configDir ?? DEFAULT_CONFIG_DIR, "config.json");
|
|
80051
|
+
}
|
|
80052
|
+
function todayUtc() {
|
|
80053
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
80054
|
+
}
|
|
80055
|
+
function readLimitsFile(configDir) {
|
|
80056
|
+
const path = resolveConfigPath(configDir);
|
|
80057
|
+
try {
|
|
80058
|
+
return sanitize(JSON.parse(readFileSync(path, "utf-8")));
|
|
80059
|
+
} catch {
|
|
80060
|
+
return {};
|
|
80061
|
+
}
|
|
80062
|
+
}
|
|
80063
|
+
function writeLimitsFile(file, configDir) {
|
|
80064
|
+
const path = resolveConfigPath(configDir);
|
|
80065
|
+
let existing = {};
|
|
80066
|
+
try {
|
|
80067
|
+
existing = JSON.parse(readFileSync(path, "utf-8"));
|
|
80068
|
+
} catch {
|
|
80069
|
+
existing = {};
|
|
80070
|
+
}
|
|
80071
|
+
for (const dead of ["maxPerTx", "maxDailySend", "dailyUsed", "dailyResetDate", "locked"]) {
|
|
80072
|
+
delete existing[dead];
|
|
80073
|
+
}
|
|
80074
|
+
const merged = { ...existing };
|
|
80075
|
+
if (file.limits && (file.limits.perTxUsd !== void 0 || file.limits.dailyUsd !== void 0)) {
|
|
80076
|
+
merged.limits = file.limits;
|
|
80077
|
+
} else {
|
|
80078
|
+
delete merged.limits;
|
|
80079
|
+
}
|
|
80080
|
+
if (file.dailySpend) merged.dailySpend = file.dailySpend;
|
|
80081
|
+
else delete merged.dailySpend;
|
|
80082
|
+
const dir = dirname(path);
|
|
80083
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
80084
|
+
writeFileSync(path, JSON.stringify(merged, null, 2) + "\n", { mode: 384 });
|
|
80085
|
+
return path;
|
|
80086
|
+
}
|
|
80087
|
+
function getLimits(configDir) {
|
|
80088
|
+
return readLimitsFile(configDir).limits;
|
|
80089
|
+
}
|
|
80090
|
+
function hasLimits(configDir) {
|
|
80091
|
+
const l2 = readLimitsFile(configDir).limits;
|
|
80092
|
+
return !!l2 && (l2.perTxUsd !== void 0 || l2.dailyUsd !== void 0);
|
|
80093
|
+
}
|
|
80094
|
+
function setLimits(limits, configDir) {
|
|
80095
|
+
const file = readLimitsFile(configDir);
|
|
80096
|
+
const merged = { ...file.limits };
|
|
80097
|
+
if (limits.perTxUsd !== void 0) merged.perTxUsd = limits.perTxUsd;
|
|
80098
|
+
if (limits.dailyUsd !== void 0) merged.dailyUsd = limits.dailyUsd;
|
|
80099
|
+
return writeLimitsFile({ ...file, limits: merged }, configDir);
|
|
80100
|
+
}
|
|
80101
|
+
function clearLimits(configDir) {
|
|
80102
|
+
const file = readLimitsFile(configDir);
|
|
80103
|
+
return writeLimitsFile({ ...file, limits: void 0 }, configDir);
|
|
80104
|
+
}
|
|
80105
|
+
function dailySpentToday(configDir) {
|
|
80106
|
+
const { dailySpend } = readLimitsFile(configDir);
|
|
80107
|
+
if (!dailySpend || dailySpend.date !== todayUtc()) return 0;
|
|
80108
|
+
return dailySpend.usd;
|
|
80109
|
+
}
|
|
80110
|
+
function recordDailySpend(usd, configDir) {
|
|
80111
|
+
if (!Number.isFinite(usd) || usd <= 0) return;
|
|
80112
|
+
const file = readLimitsFile(configDir);
|
|
80113
|
+
const today = todayUtc();
|
|
80114
|
+
const prior = file.dailySpend && file.dailySpend.date === today ? file.dailySpend.usd : 0;
|
|
80115
|
+
writeLimitsFile({ ...file, dailySpend: { date: today, usd: prior + usd } }, configDir);
|
|
80116
|
+
}
|
|
80117
|
+
function sanitize(raw) {
|
|
80118
|
+
if (typeof raw !== "object" || raw === null) return {};
|
|
80119
|
+
const r = raw;
|
|
80120
|
+
const out = {};
|
|
80121
|
+
if (typeof r.limits === "object" && r.limits !== null) {
|
|
80122
|
+
const l2 = r.limits;
|
|
80123
|
+
const limits = {};
|
|
80124
|
+
if (typeof l2.perTxUsd === "number" && l2.perTxUsd > 0) limits.perTxUsd = l2.perTxUsd;
|
|
80125
|
+
if (typeof l2.dailyUsd === "number" && l2.dailyUsd > 0) limits.dailyUsd = l2.dailyUsd;
|
|
80126
|
+
else if (typeof l2.dailySendUsd === "number" && l2.dailySendUsd > 0) limits.dailyUsd = l2.dailySendUsd;
|
|
80127
|
+
if (limits.perTxUsd !== void 0 || limits.dailyUsd !== void 0) out.limits = limits;
|
|
80128
|
+
}
|
|
80129
|
+
if (typeof r.dailySpend === "object" && r.dailySpend !== null) {
|
|
80130
|
+
const d = r.dailySpend;
|
|
80131
|
+
if (typeof d.date === "string" && typeof d.usd === "number" && d.usd >= 0) {
|
|
80132
|
+
out.dailySpend = { date: d.date, usd: d.usd };
|
|
80133
|
+
}
|
|
80134
|
+
}
|
|
80135
|
+
return out;
|
|
80136
|
+
}
|
|
80137
|
+
var LimitExceededError = class extends Error {
|
|
80138
|
+
code = "LIMIT_EXCEEDED";
|
|
80139
|
+
operation;
|
|
80140
|
+
limitKind;
|
|
80141
|
+
limit;
|
|
80142
|
+
attempted;
|
|
80143
|
+
constructor(params) {
|
|
80144
|
+
const label = params.limitKind === "perTxUsd" ? "per-transaction limit" : "daily spend limit";
|
|
80145
|
+
super(
|
|
80146
|
+
`Exceeds ${label} ($${params.limit}). Attempted $${params.attempted.toFixed(2)}. Use --force / force:true to override.`
|
|
80147
|
+
);
|
|
80148
|
+
this.name = "LimitExceededError";
|
|
80149
|
+
this.operation = params.operation;
|
|
80150
|
+
this.limitKind = params.limitKind;
|
|
80151
|
+
this.limit = params.limit;
|
|
80152
|
+
this.attempted = params.attempted;
|
|
80065
80153
|
}
|
|
80066
80154
|
toJSON() {
|
|
80067
80155
|
return {
|
|
80068
|
-
error:
|
|
80156
|
+
error: this.code,
|
|
80069
80157
|
message: this.message,
|
|
80070
|
-
|
|
80071
|
-
|
|
80158
|
+
operation: this.operation,
|
|
80159
|
+
limitKind: this.limitKind,
|
|
80160
|
+
limit: this.limit,
|
|
80161
|
+
attempted: this.attempted
|
|
80072
80162
|
};
|
|
80073
80163
|
}
|
|
80074
80164
|
};
|
|
80075
|
-
function
|
|
80076
|
-
|
|
80077
|
-
|
|
80078
|
-
|
|
80079
|
-
|
|
80080
|
-
|
|
80081
|
-
|
|
80082
|
-
|
|
80083
|
-
}
|
|
80084
|
-
|
|
80085
|
-
|
|
80086
|
-
|
|
80087
|
-
|
|
80088
|
-
|
|
80089
|
-
|
|
80090
|
-
|
|
80091
|
-
|
|
80092
|
-
load() {
|
|
80093
|
-
if (!this.configPath) return;
|
|
80094
|
-
try {
|
|
80095
|
-
const raw = JSON.parse(readFileSync(this.configPath, "utf-8"));
|
|
80096
|
-
this.config = {
|
|
80097
|
-
...DEFAULT_SAFEGUARD_CONFIG,
|
|
80098
|
-
locked: raw.locked ?? false,
|
|
80099
|
-
maxPerTx: raw.maxPerTx ?? 0,
|
|
80100
|
-
maxDailySend: raw.maxDailySend ?? 0,
|
|
80101
|
-
dailyUsed: raw.dailyUsed ?? 0,
|
|
80102
|
-
dailyResetDate: raw.dailyResetDate ?? ""
|
|
80103
|
-
};
|
|
80104
|
-
} catch {
|
|
80105
|
-
this.config = { ...DEFAULT_SAFEGUARD_CONFIG };
|
|
80106
|
-
}
|
|
80107
|
-
}
|
|
80108
|
-
assertNotLocked() {
|
|
80109
|
-
this.load();
|
|
80110
|
-
if (this.config.locked) {
|
|
80111
|
-
throw new SafeguardError("locked", {});
|
|
80112
|
-
}
|
|
80113
|
-
}
|
|
80114
|
-
check(metadata) {
|
|
80115
|
-
this.load();
|
|
80116
|
-
if (this.config.locked) {
|
|
80117
|
-
throw new SafeguardError("locked", {});
|
|
80118
|
-
}
|
|
80119
|
-
const amount = metadata.amount ?? 0;
|
|
80120
|
-
if (this.config.maxPerTx > 0 && amount > this.config.maxPerTx) {
|
|
80121
|
-
throw new SafeguardError("maxPerTx", {
|
|
80122
|
-
attempted: amount,
|
|
80123
|
-
limit: this.config.maxPerTx
|
|
80124
|
-
});
|
|
80125
|
-
}
|
|
80126
|
-
this.resetDailyIfNewDay();
|
|
80127
|
-
if (this.config.maxDailySend > 0 && this.config.dailyUsed + amount > this.config.maxDailySend) {
|
|
80128
|
-
throw new SafeguardError("maxDailySend", {
|
|
80129
|
-
attempted: amount,
|
|
80130
|
-
limit: this.config.maxDailySend,
|
|
80131
|
-
current: this.config.dailyUsed
|
|
80132
|
-
});
|
|
80133
|
-
}
|
|
80165
|
+
function approxUsdValue(asset, amount) {
|
|
80166
|
+
const symbol = asset.toUpperCase();
|
|
80167
|
+
if (symbol === "USDC" || symbol === "USDSUI") return amount;
|
|
80168
|
+
return null;
|
|
80169
|
+
}
|
|
80170
|
+
function assertLimitConfig(input) {
|
|
80171
|
+
if (input.force) return;
|
|
80172
|
+
if (!Number.isFinite(input.amountUsd) || input.amountUsd <= 0) return;
|
|
80173
|
+
const { limits } = input;
|
|
80174
|
+
if (!limits) return;
|
|
80175
|
+
if (limits.perTxUsd !== void 0 && input.amountUsd > limits.perTxUsd) {
|
|
80176
|
+
throw new LimitExceededError({
|
|
80177
|
+
operation: input.operation,
|
|
80178
|
+
limitKind: "perTxUsd",
|
|
80179
|
+
limit: limits.perTxUsd,
|
|
80180
|
+
attempted: input.amountUsd
|
|
80181
|
+
});
|
|
80134
80182
|
}
|
|
80135
|
-
|
|
80136
|
-
|
|
80137
|
-
|
|
80138
|
-
|
|
80183
|
+
if (limits.dailyUsd !== void 0 && input.spentTodayUsd + input.amountUsd > limits.dailyUsd) {
|
|
80184
|
+
throw new LimitExceededError({
|
|
80185
|
+
operation: input.operation,
|
|
80186
|
+
limitKind: "dailyUsd",
|
|
80187
|
+
// The cap is total/day; report the cap (attempted is THIS write's USD).
|
|
80188
|
+
limit: limits.dailyUsd,
|
|
80189
|
+
attempted: input.spentTodayUsd + input.amountUsd
|
|
80190
|
+
});
|
|
80139
80191
|
}
|
|
80140
|
-
|
|
80141
|
-
|
|
80142
|
-
|
|
80192
|
+
}
|
|
80193
|
+
var LimitEnforcer = class {
|
|
80194
|
+
constructor(configDir) {
|
|
80195
|
+
this.configDir = configDir;
|
|
80196
|
+
}
|
|
80197
|
+
/** Throws `LimitExceededError` when the write exceeds an opted-in cap. */
|
|
80198
|
+
assert(input) {
|
|
80199
|
+
assertLimitConfig({
|
|
80200
|
+
limits: getLimits(this.configDir),
|
|
80201
|
+
spentTodayUsd: dailySpentToday(this.configDir),
|
|
80202
|
+
operation: input.operation,
|
|
80203
|
+
amountUsd: input.amountUsd,
|
|
80204
|
+
force: input.force
|
|
80205
|
+
});
|
|
80143
80206
|
}
|
|
80144
|
-
|
|
80145
|
-
|
|
80146
|
-
this.
|
|
80207
|
+
/** Add a settled write's USD value to today's cumulative total. */
|
|
80208
|
+
record(amountUsd) {
|
|
80209
|
+
recordDailySpend(amountUsd, this.configDir);
|
|
80147
80210
|
}
|
|
80148
|
-
|
|
80149
|
-
|
|
80150
|
-
this.config.locked = value;
|
|
80151
|
-
} else if (key === "maxPerTx" && typeof value === "number") {
|
|
80152
|
-
this.config.maxPerTx = value;
|
|
80153
|
-
} else if (key === "maxDailySend" && typeof value === "number") {
|
|
80154
|
-
this.config.maxDailySend = value;
|
|
80155
|
-
}
|
|
80156
|
-
this.save();
|
|
80211
|
+
getLimits() {
|
|
80212
|
+
return getLimits(this.configDir);
|
|
80157
80213
|
}
|
|
80158
|
-
|
|
80159
|
-
this.
|
|
80160
|
-
this.resetDailyIfNewDay();
|
|
80161
|
-
return { ...this.config };
|
|
80214
|
+
hasLimits() {
|
|
80215
|
+
return hasLimits(this.configDir);
|
|
80162
80216
|
}
|
|
80163
|
-
|
|
80164
|
-
|
|
80217
|
+
setLimits(limits) {
|
|
80218
|
+
setLimits(limits, this.configDir);
|
|
80165
80219
|
}
|
|
80166
|
-
|
|
80167
|
-
|
|
80168
|
-
if (this.config.dailyResetDate !== today) {
|
|
80169
|
-
this.config.dailyUsed = 0;
|
|
80170
|
-
this.config.dailyResetDate = today;
|
|
80171
|
-
this.save();
|
|
80172
|
-
}
|
|
80220
|
+
clearLimits() {
|
|
80221
|
+
clearLimits(this.configDir);
|
|
80173
80222
|
}
|
|
80174
|
-
|
|
80175
|
-
|
|
80176
|
-
try {
|
|
80177
|
-
let existing = {};
|
|
80178
|
-
try {
|
|
80179
|
-
existing = JSON.parse(readFileSync(this.configPath, "utf-8"));
|
|
80180
|
-
} catch {
|
|
80181
|
-
}
|
|
80182
|
-
const merged = {
|
|
80183
|
-
...existing,
|
|
80184
|
-
locked: this.config.locked,
|
|
80185
|
-
maxPerTx: this.config.maxPerTx,
|
|
80186
|
-
maxDailySend: this.config.maxDailySend,
|
|
80187
|
-
dailyUsed: this.config.dailyUsed,
|
|
80188
|
-
dailyResetDate: this.config.dailyResetDate
|
|
80189
|
-
};
|
|
80190
|
-
const dir = this.configPath.replace(/[/\\][^/\\]+$/, "");
|
|
80191
|
-
if (!existsSync(dir)) {
|
|
80192
|
-
mkdirSync(dir, { recursive: true });
|
|
80193
|
-
}
|
|
80194
|
-
writeFileSync(this.configPath, JSON.stringify(merged, null, 2) + "\n");
|
|
80195
|
-
} catch {
|
|
80196
|
-
}
|
|
80223
|
+
dailySpentToday() {
|
|
80224
|
+
return dailySpentToday(this.configDir);
|
|
80197
80225
|
}
|
|
80198
80226
|
};
|
|
80199
|
-
var
|
|
80227
|
+
var DEFAULT_CONFIG_DIR2 = join$1(homedir(), ".t2000");
|
|
80200
80228
|
var T2000 = class _T2000 extends import_index2.default {
|
|
80201
80229
|
_signer;
|
|
80202
80230
|
_keypair;
|
|
80203
80231
|
client;
|
|
80204
80232
|
_address;
|
|
80205
|
-
|
|
80233
|
+
/** Unified spending-limit gate (per-tx + cumulative daily, USD). Shared by
|
|
80234
|
+
* CLI + MCP + programmatic writes — one gate, no bypass (R-0 Finding 1). */
|
|
80235
|
+
limits;
|
|
80206
80236
|
constructor(keypairOrSigner, client, configDir, isSignerMode) {
|
|
80207
80237
|
super();
|
|
80208
80238
|
if (isSignerMode) {
|
|
@@ -80216,8 +80246,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80216
80246
|
this._address = getAddress(kp);
|
|
80217
80247
|
}
|
|
80218
80248
|
this.client = client;
|
|
80219
|
-
this.
|
|
80220
|
-
this.enforcer.load();
|
|
80249
|
+
this.limits = new LimitEnforcer(configDir);
|
|
80221
80250
|
}
|
|
80222
80251
|
static async create(options = {}) {
|
|
80223
80252
|
const { keyPath, rpcUrl } = options;
|
|
@@ -80230,7 +80259,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80230
80259
|
);
|
|
80231
80260
|
}
|
|
80232
80261
|
const keypair = await loadKey(void 0, keyPath);
|
|
80233
|
-
return new _T2000(keypair, client,
|
|
80262
|
+
return new _T2000(keypair, client, DEFAULT_CONFIG_DIR2);
|
|
80234
80263
|
}
|
|
80235
80264
|
static fromPrivateKey(privateKey, options = {}) {
|
|
80236
80265
|
const keypair = keypairFromPrivateKey(privateKey);
|
|
@@ -80241,7 +80270,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80241
80270
|
const keypair = generateKeypair();
|
|
80242
80271
|
await saveKey(keypair, void 0, options.keyPath);
|
|
80243
80272
|
const client = getSuiClient();
|
|
80244
|
-
const agent = new _T2000(keypair, client,
|
|
80273
|
+
const agent = new _T2000(keypair, client, DEFAULT_CONFIG_DIR2);
|
|
80245
80274
|
const address = agent.address();
|
|
80246
80275
|
return { agent, address };
|
|
80247
80276
|
}
|
|
@@ -80263,11 +80292,10 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80263
80292
|
}
|
|
80264
80293
|
// -- MPP Payments --
|
|
80265
80294
|
async pay(options) {
|
|
80266
|
-
this.
|
|
80267
|
-
this.enforcer.check({ operation: "pay", amount: options.maxPrice ?? 1 });
|
|
80295
|
+
this.limits.assert({ operation: "pay", amountUsd: options.maxPrice ?? 0, force: options.force });
|
|
80268
80296
|
const result = await payWithMpp({ signer: this._signer, client: this.client, options });
|
|
80269
80297
|
if (result.paid) {
|
|
80270
|
-
this.
|
|
80298
|
+
this.limits.record(result.cost ?? options.maxPrice ?? 0);
|
|
80271
80299
|
}
|
|
80272
80300
|
return result;
|
|
80273
80301
|
}
|
|
@@ -80281,7 +80309,11 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80281
80309
|
// and the S.323 build-tracker entry.
|
|
80282
80310
|
// -- Swap --
|
|
80283
80311
|
async swap(params) {
|
|
80284
|
-
this.
|
|
80312
|
+
this.limits.assert({
|
|
80313
|
+
operation: "swap",
|
|
80314
|
+
amountUsd: approxUsdValue(params.from, params.amount) ?? 0,
|
|
80315
|
+
force: params.force
|
|
80316
|
+
});
|
|
80285
80317
|
const { findSwapRoute: findSwapRoute2, buildSwapTx: buildSwapTx2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
80286
80318
|
const fromType = resolveTokenType2(params.from);
|
|
80287
80319
|
const toType = resolveTokenType2(params.to);
|
|
@@ -80373,6 +80405,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80373
80405
|
const fromName = resolveSymbol(fromType);
|
|
80374
80406
|
const toName = resolveSymbol(toType);
|
|
80375
80407
|
const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
|
|
80408
|
+
this.limits.record(approxUsdValue(params.from, params.amount) ?? 0);
|
|
80376
80409
|
return {
|
|
80377
80410
|
success: true,
|
|
80378
80411
|
tx: gasResult.digest,
|
|
@@ -80429,7 +80462,6 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80429
80462
|
* the "build via gRPC, execute via JSON-RPC" hybrid).
|
|
80430
80463
|
*/
|
|
80431
80464
|
async send(params) {
|
|
80432
|
-
this.enforcer.assertNotLocked();
|
|
80433
80465
|
const asset = params.asset;
|
|
80434
80466
|
if (!asset) {
|
|
80435
80467
|
throw new T2000Error(
|
|
@@ -80439,6 +80471,11 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80439
80471
|
}
|
|
80440
80472
|
assertAllowedAsset("send", asset);
|
|
80441
80473
|
const sendableAsset = asset;
|
|
80474
|
+
this.limits.assert({
|
|
80475
|
+
operation: "send",
|
|
80476
|
+
amountUsd: approxUsdValue(sendableAsset, params.amount) ?? 0,
|
|
80477
|
+
force: params.force
|
|
80478
|
+
});
|
|
80442
80479
|
const resolved = await this.resolveRecipient(params.to);
|
|
80443
80480
|
const sendAmount = params.amount;
|
|
80444
80481
|
const sendTo = resolved.address;
|
|
@@ -80450,7 +80487,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
80450
80487
|
() => buildSendTx({ client: this.client, address: this._address, to: sendTo, amount: sendAmount, asset: sendableAsset }),
|
|
80451
80488
|
{ buildClient }
|
|
80452
80489
|
);
|
|
80453
|
-
this.
|
|
80490
|
+
this.limits.record(approxUsdValue(sendableAsset, sendAmount) ?? 0);
|
|
80454
80491
|
const balance = await this.balance();
|
|
80455
80492
|
this.emitBalanceChange(sendableAsset, sendAmount, "send", gasResult.digest);
|
|
80456
80493
|
return {
|
|
@@ -80617,12 +80654,18 @@ init_zod();
|
|
|
80617
80654
|
|
|
80618
80655
|
// src/errors.ts
|
|
80619
80656
|
function mapError(err) {
|
|
80620
|
-
if (err instanceof
|
|
80657
|
+
if (err instanceof LimitExceededError) {
|
|
80621
80658
|
return {
|
|
80622
|
-
code:
|
|
80659
|
+
code: err.code,
|
|
80660
|
+
// 'LIMIT_EXCEEDED'
|
|
80623
80661
|
message: err.message,
|
|
80624
80662
|
retryable: false,
|
|
80625
|
-
details: {
|
|
80663
|
+
details: {
|
|
80664
|
+
operation: err.operation,
|
|
80665
|
+
limitKind: err.limitKind,
|
|
80666
|
+
limit: err.limit,
|
|
80667
|
+
attempted: err.attempted
|
|
80668
|
+
}
|
|
80626
80669
|
};
|
|
80627
80670
|
}
|
|
80628
80671
|
if (err instanceof T2000Error) {
|
|
@@ -80903,25 +80946,18 @@ ${text}`;
|
|
|
80903
80946
|
}
|
|
80904
80947
|
);
|
|
80905
80948
|
}
|
|
80906
|
-
|
|
80907
|
-
|
|
80908
|
-
|
|
80909
|
-
|
|
80910
|
-
const
|
|
80911
|
-
|
|
80912
|
-
|
|
80913
|
-
|
|
80914
|
-
|
|
80915
|
-
|
|
80916
|
-
|
|
80917
|
-
|
|
80918
|
-
const perTxUsd = typeof l2.perTxUsd === "number" && l2.perTxUsd > 0 ? l2.perTxUsd : void 0;
|
|
80919
|
-
const dailySendUsd = typeof l2.dailySendUsd === "number" && l2.dailySendUsd > 0 ? l2.dailySendUsd : void 0;
|
|
80920
|
-
const configured = perTxUsd !== void 0 || dailySendUsd !== void 0;
|
|
80921
|
-
return { configured, perTxUsd, dailySendUsd, configPath: path };
|
|
80922
|
-
} catch {
|
|
80923
|
-
return { configured: false, configPath: path };
|
|
80924
|
-
}
|
|
80949
|
+
|
|
80950
|
+
// src/tools/limit.ts
|
|
80951
|
+
function readLimits(configDir) {
|
|
80952
|
+
const limits = getLimits(configDir);
|
|
80953
|
+
const perTxUsd = limits?.perTxUsd;
|
|
80954
|
+
const dailyUsd = limits?.dailyUsd;
|
|
80955
|
+
return {
|
|
80956
|
+
configured: perTxUsd !== void 0 || dailyUsd !== void 0,
|
|
80957
|
+
perTxUsd,
|
|
80958
|
+
dailyUsd,
|
|
80959
|
+
spentTodayUsd: dailySpentToday(configDir)
|
|
80960
|
+
};
|
|
80925
80961
|
}
|
|
80926
80962
|
function registerLimitTool(server) {
|
|
80927
80963
|
server.tool(
|
|
@@ -80934,7 +80970,7 @@ Use the returned values to inform the user about their own configured caps befor
|
|
|
80934
80970
|
{},
|
|
80935
80971
|
async () => {
|
|
80936
80972
|
try {
|
|
80937
|
-
const view =
|
|
80973
|
+
const view = readLimits();
|
|
80938
80974
|
return { content: [{ type: "text", text: JSON.stringify(view) }] };
|
|
80939
80975
|
} catch (err) {
|
|
80940
80976
|
return errorResult(err);
|
|
@@ -80986,7 +81022,7 @@ CRITICAL: When the user asks to use any external or paid API, names a provider (
|
|
|
80986
81022
|
Spending is the user's own USDC and every t2000_pay call is bounded by maxPrice. For larger or multi-step spends, state the estimated cost first and proceed once the user is happy. Use t2000_balance to check funds. The v4 wallet is payments-only; savings / lending live on audric.ai.`;
|
|
80987
81023
|
|
|
80988
81024
|
// src/index.ts
|
|
80989
|
-
var PKG_VERSION = "5.
|
|
81025
|
+
var PKG_VERSION = "5.3.0" ;
|
|
80990
81026
|
console.log = (...args) => console.error("[log]", ...args);
|
|
80991
81027
|
console.warn = (...args) => console.error("[warn]", ...args);
|
|
80992
81028
|
async function startMcpServer(opts) {
|