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