@t2000/mcp 5.14.3 → 5.15.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 +271 -57
- package/dist/bin.js.map +1 -1
- package/dist/index.js +271 -57
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -5036,10 +5036,10 @@ var require_codegen = __commonJS({
|
|
|
5036
5036
|
return this._leafNode(new Throw(error2));
|
|
5037
5037
|
}
|
|
5038
5038
|
// start self-balancing block
|
|
5039
|
-
block(
|
|
5039
|
+
block(body2, nodeCount) {
|
|
5040
5040
|
this._blockStarts.push(this._nodes.length);
|
|
5041
|
-
if (
|
|
5042
|
-
this.code(
|
|
5041
|
+
if (body2)
|
|
5042
|
+
this.code(body2).endBlock(nodeCount);
|
|
5043
5043
|
return this;
|
|
5044
5044
|
}
|
|
5045
5045
|
// end the current self-balancing block
|
|
@@ -6449,15 +6449,15 @@ var require_validate = __commonJS({
|
|
|
6449
6449
|
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
6450
6450
|
}
|
|
6451
6451
|
exports$1.validateFunctionCode = validateFunctionCode;
|
|
6452
|
-
function validateFunction({ gen, validateName, schema, schemaEnv, opts },
|
|
6452
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body2) {
|
|
6453
6453
|
if (opts.code.es5) {
|
|
6454
6454
|
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
|
|
6455
6455
|
gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
6456
6456
|
destructureValCxtES5(gen, opts);
|
|
6457
|
-
gen.code(
|
|
6457
|
+
gen.code(body2);
|
|
6458
6458
|
});
|
|
6459
6459
|
} else {
|
|
6460
|
-
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(
|
|
6460
|
+
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body2));
|
|
6461
6461
|
}
|
|
6462
6462
|
}
|
|
6463
6463
|
function destructureValCxt(opts) {
|
|
@@ -16985,7 +16985,7 @@ var init_mvr = __esm({
|
|
|
16985
16985
|
}));
|
|
16986
16986
|
return results;
|
|
16987
16987
|
}
|
|
16988
|
-
async #fetch(url2,
|
|
16988
|
+
async #fetch(url2, body2) {
|
|
16989
16989
|
if (!this.#url) throw new Error("MVR Api URL is not set for the current client");
|
|
16990
16990
|
const response = await fetch(`${this.#url}${url2}`, {
|
|
16991
16991
|
method: "POST",
|
|
@@ -16993,7 +16993,7 @@ var init_mvr = __esm({
|
|
|
16993
16993
|
"Content-Type": "application/json",
|
|
16994
16994
|
...MVR_API_HEADER
|
|
16995
16995
|
},
|
|
16996
|
-
body: JSON.stringify(
|
|
16996
|
+
body: JSON.stringify(body2)
|
|
16997
16997
|
});
|
|
16998
16998
|
if (!response.ok) {
|
|
16999
16999
|
const errorBody = await response.json().catch(() => ({}));
|
|
@@ -31656,14 +31656,14 @@ function createGrpcWebRequestHeader(headers, format, timeout, meta, userAgent) {
|
|
|
31656
31656
|
return headers;
|
|
31657
31657
|
}
|
|
31658
31658
|
function createGrpcWebRequestBody(message, format) {
|
|
31659
|
-
let
|
|
31660
|
-
|
|
31659
|
+
let body2 = new Uint8Array(5 + message.length);
|
|
31660
|
+
body2[0] = GrpcWebFrame.DATA;
|
|
31661
31661
|
for (let msgLen = message.length, i = 4; i > 0; i--) {
|
|
31662
|
-
|
|
31662
|
+
body2[i] = msgLen % 256;
|
|
31663
31663
|
msgLen >>>= 8;
|
|
31664
31664
|
}
|
|
31665
|
-
|
|
31666
|
-
return format === "binary" ?
|
|
31665
|
+
body2.set(message, 5);
|
|
31666
|
+
return format === "binary" ? body2 : base64encode(body2);
|
|
31667
31667
|
}
|
|
31668
31668
|
function readGrpcWebResponseHeader(headersOrFetchResponse, httpStatus, httpStatusText) {
|
|
31669
31669
|
if (arguments.length === 1) {
|
|
@@ -32735,7 +32735,7 @@ var init_dist6 = __esm({
|
|
|
32735
32735
|
super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url2), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {
|
|
32736
32736
|
var _a2;
|
|
32737
32737
|
__privateGet(this, _parser).reset();
|
|
32738
|
-
const { body, redirected, status, headers } = response;
|
|
32738
|
+
const { body: body2, redirected, status, headers } = response;
|
|
32739
32739
|
if (status === 204) {
|
|
32740
32740
|
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
|
32741
32741
|
return;
|
|
@@ -32752,11 +32752,11 @@ var init_dist6 = __esm({
|
|
|
32752
32752
|
return;
|
|
32753
32753
|
__privateSet(this, _readyState, this.OPEN);
|
|
32754
32754
|
const openEvent = new Event("open");
|
|
32755
|
-
if ((_a2 = __privateGet(this, _onOpen)) == null || _a2.call(this, openEvent), this.dispatchEvent(openEvent), typeof
|
|
32755
|
+
if ((_a2 = __privateGet(this, _onOpen)) == null || _a2.call(this, openEvent), this.dispatchEvent(openEvent), typeof body2 != "object" || !body2 || !("getReader" in body2)) {
|
|
32756
32756
|
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
|
|
32757
32757
|
return;
|
|
32758
32758
|
}
|
|
32759
|
-
const decoder = new TextDecoder(), reader =
|
|
32759
|
+
const decoder = new TextDecoder(), reader = body2.getReader();
|
|
32760
32760
|
let open = true;
|
|
32761
32761
|
do {
|
|
32762
32762
|
const { done, value } = await reader.read();
|
|
@@ -46109,8 +46109,8 @@ function fromDataURI(uri, asBlob, options) {
|
|
|
46109
46109
|
}
|
|
46110
46110
|
const mime = match[1];
|
|
46111
46111
|
const isBase64 = match[2];
|
|
46112
|
-
const
|
|
46113
|
-
const buffer = Buffer.from(decodeURIComponent(
|
|
46112
|
+
const body2 = match[3];
|
|
46113
|
+
const buffer = Buffer.from(decodeURIComponent(body2), isBase64 ? "base64" : "utf8");
|
|
46114
46114
|
if (asBlob) {
|
|
46115
46115
|
if (!_Blob) {
|
|
46116
46116
|
throw new AxiosError_default("Blob is not supported", AxiosError_default.ERR_NOT_SUPPORT);
|
|
@@ -46660,15 +46660,15 @@ function estimateDataURLDecodedBytes(url2) {
|
|
|
46660
46660
|
const comma = url2.indexOf(",");
|
|
46661
46661
|
if (comma < 0) return 0;
|
|
46662
46662
|
const meta = url2.slice(5, comma);
|
|
46663
|
-
const
|
|
46663
|
+
const body2 = url2.slice(comma + 1);
|
|
46664
46664
|
const isBase64 = /;base64/i.test(meta);
|
|
46665
46665
|
if (isBase64) {
|
|
46666
|
-
let effectiveLen =
|
|
46667
|
-
const len =
|
|
46666
|
+
let effectiveLen = body2.length;
|
|
46667
|
+
const len = body2.length;
|
|
46668
46668
|
for (let i = 0; i < len; i++) {
|
|
46669
|
-
if (
|
|
46670
|
-
const a =
|
|
46671
|
-
const b =
|
|
46669
|
+
if (body2.charCodeAt(i) === 37 && i + 2 < len) {
|
|
46670
|
+
const a = body2.charCodeAt(i + 1);
|
|
46671
|
+
const b = body2.charCodeAt(i + 2);
|
|
46672
46672
|
const isHex3 = (a >= 48 && a <= 57 || a >= 65 && a <= 70 || a >= 97 && a <= 102) && (b >= 48 && b <= 57 || b >= 65 && b <= 70 || b >= 97 && b <= 102);
|
|
46673
46673
|
if (isHex3) {
|
|
46674
46674
|
effectiveLen -= 2;
|
|
@@ -46678,11 +46678,11 @@ function estimateDataURLDecodedBytes(url2) {
|
|
|
46678
46678
|
}
|
|
46679
46679
|
let pad = 0;
|
|
46680
46680
|
let idx = len - 1;
|
|
46681
|
-
const tailIsPct3D = (j) => j >= 2 &&
|
|
46682
|
-
|
|
46683
|
-
(
|
|
46681
|
+
const tailIsPct3D = (j) => j >= 2 && body2.charCodeAt(j - 2) === 37 && // '%'
|
|
46682
|
+
body2.charCodeAt(j - 1) === 51 && // '3'
|
|
46683
|
+
(body2.charCodeAt(j) === 68 || body2.charCodeAt(j) === 100);
|
|
46684
46684
|
if (idx >= 0) {
|
|
46685
|
-
if (
|
|
46685
|
+
if (body2.charCodeAt(idx) === 61) {
|
|
46686
46686
|
pad++;
|
|
46687
46687
|
idx--;
|
|
46688
46688
|
} else if (tailIsPct3D(idx)) {
|
|
@@ -46691,7 +46691,7 @@ function estimateDataURLDecodedBytes(url2) {
|
|
|
46691
46691
|
}
|
|
46692
46692
|
}
|
|
46693
46693
|
if (pad === 1 && idx >= 0) {
|
|
46694
|
-
if (
|
|
46694
|
+
if (body2.charCodeAt(idx) === 61) {
|
|
46695
46695
|
pad++;
|
|
46696
46696
|
} else if (tailIsPct3D(idx)) {
|
|
46697
46697
|
pad++;
|
|
@@ -46701,7 +46701,7 @@ function estimateDataURLDecodedBytes(url2) {
|
|
|
46701
46701
|
const bytes = groups * 3 - (pad || 0);
|
|
46702
46702
|
return bytes > 0 ? bytes : 0;
|
|
46703
46703
|
}
|
|
46704
|
-
return Buffer.byteLength(
|
|
46704
|
+
return Buffer.byteLength(body2, "utf8");
|
|
46705
46705
|
}
|
|
46706
46706
|
var init_estimateDataURLDecodedBytes = __esm({
|
|
46707
46707
|
"../../node_modules/.pnpm/axios@1.15.2/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js"() {
|
|
@@ -48107,33 +48107,33 @@ var init_fetch = __esm({
|
|
|
48107
48107
|
});
|
|
48108
48108
|
});
|
|
48109
48109
|
})();
|
|
48110
|
-
const getBodyLength = async (
|
|
48111
|
-
if (
|
|
48110
|
+
const getBodyLength = async (body2) => {
|
|
48111
|
+
if (body2 == null) {
|
|
48112
48112
|
return 0;
|
|
48113
48113
|
}
|
|
48114
|
-
if (utils_default.isBlob(
|
|
48115
|
-
return
|
|
48114
|
+
if (utils_default.isBlob(body2)) {
|
|
48115
|
+
return body2.size;
|
|
48116
48116
|
}
|
|
48117
|
-
if (utils_default.isSpecCompliantForm(
|
|
48117
|
+
if (utils_default.isSpecCompliantForm(body2)) {
|
|
48118
48118
|
const _request = new Request(platform_default.origin, {
|
|
48119
48119
|
method: "POST",
|
|
48120
|
-
body
|
|
48120
|
+
body: body2
|
|
48121
48121
|
});
|
|
48122
48122
|
return (await _request.arrayBuffer()).byteLength;
|
|
48123
48123
|
}
|
|
48124
|
-
if (utils_default.isArrayBufferView(
|
|
48125
|
-
return
|
|
48124
|
+
if (utils_default.isArrayBufferView(body2) || utils_default.isArrayBuffer(body2)) {
|
|
48125
|
+
return body2.byteLength;
|
|
48126
48126
|
}
|
|
48127
|
-
if (utils_default.isURLSearchParams(
|
|
48128
|
-
|
|
48127
|
+
if (utils_default.isURLSearchParams(body2)) {
|
|
48128
|
+
body2 = body2 + "";
|
|
48129
48129
|
}
|
|
48130
|
-
if (utils_default.isString(
|
|
48131
|
-
return (await encodeText(
|
|
48130
|
+
if (utils_default.isString(body2)) {
|
|
48131
|
+
return (await encodeText(body2)).byteLength;
|
|
48132
48132
|
}
|
|
48133
48133
|
};
|
|
48134
|
-
const resolveBodyLength = async (headers,
|
|
48134
|
+
const resolveBodyLength = async (headers, body2) => {
|
|
48135
48135
|
const length = utils_default.toFiniteNumber(headers.getContentLength());
|
|
48136
|
-
return length == null ? getBodyLength(
|
|
48136
|
+
return length == null ? getBodyLength(body2) : length;
|
|
48137
48137
|
};
|
|
48138
48138
|
return async (config3) => {
|
|
48139
48139
|
let {
|
|
@@ -78726,9 +78726,9 @@ async function payWithMpp(args) {
|
|
|
78726
78726
|
}
|
|
78727
78727
|
async function pickSuiExactRequirements(response, network) {
|
|
78728
78728
|
try {
|
|
78729
|
-
const
|
|
78729
|
+
const body2 = await response.clone().json();
|
|
78730
78730
|
const want = `sui:${network === "testnet" ? "testnet" : "mainnet"}`;
|
|
78731
|
-
return
|
|
78731
|
+
return body2.accepts?.find((a) => a.scheme === "exact" && a.network === want);
|
|
78732
78732
|
} catch {
|
|
78733
78733
|
return void 0;
|
|
78734
78734
|
}
|
|
@@ -78807,13 +78807,13 @@ async function ensureAddressBalanceCovers(args) {
|
|
|
78807
78807
|
}
|
|
78808
78808
|
async function finalize(response, opts) {
|
|
78809
78809
|
const contentType = response.headers.get("content-type") ?? "";
|
|
78810
|
-
let
|
|
78810
|
+
let body2;
|
|
78811
78811
|
try {
|
|
78812
|
-
|
|
78812
|
+
body2 = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
78813
78813
|
} catch {
|
|
78814
|
-
|
|
78814
|
+
body2 = null;
|
|
78815
78815
|
}
|
|
78816
|
-
return { status: response.status, body, paid: opts.paid };
|
|
78816
|
+
return { status: response.status, body: body2, paid: opts.paid };
|
|
78817
78817
|
}
|
|
78818
78818
|
async function makeGrpcBuildClient(client) {
|
|
78819
78819
|
const { SuiGrpcClient: SuiGrpcClient2 } = await Promise.resolve().then(() => (init_grpc(), grpc_exports));
|
|
@@ -79325,6 +79325,138 @@ async function resolveSuinsViaRpc(rawName, ctx = {}) {
|
|
|
79325
79325
|
return res.data?.address?.address ?? null;
|
|
79326
79326
|
}
|
|
79327
79327
|
init_errors3();
|
|
79328
|
+
init_errors3();
|
|
79329
|
+
var DEFAULT_API_BASE = "https://api.t2000.ai/v1";
|
|
79330
|
+
function envApiKey() {
|
|
79331
|
+
return typeof process !== "undefined" ? process.env?.T2000_API_KEY : void 0;
|
|
79332
|
+
}
|
|
79333
|
+
function resolveApiKey(apiKey) {
|
|
79334
|
+
const key = apiKey ?? envApiKey();
|
|
79335
|
+
if (!key) {
|
|
79336
|
+
throw new T2000Error(
|
|
79337
|
+
"INVALID_KEY",
|
|
79338
|
+
"No Private API key. Pass `apiKey` or set T2000_API_KEY. Generate one at platform.t2000.ai (Pro/Max)."
|
|
79339
|
+
);
|
|
79340
|
+
}
|
|
79341
|
+
return key;
|
|
79342
|
+
}
|
|
79343
|
+
async function failBody(res) {
|
|
79344
|
+
const text = await res.text().catch(() => "");
|
|
79345
|
+
let msg = text.slice(0, 300);
|
|
79346
|
+
try {
|
|
79347
|
+
const j = JSON.parse(text);
|
|
79348
|
+
msg = (typeof j.error === "object" ? j.error?.message : j.error) ?? msg;
|
|
79349
|
+
} catch {
|
|
79350
|
+
}
|
|
79351
|
+
throw new T2000Error(
|
|
79352
|
+
"INFERENCE_FAILED",
|
|
79353
|
+
`Inference request failed (${res.status}): ${msg}`,
|
|
79354
|
+
{ status: res.status },
|
|
79355
|
+
res.status >= 500
|
|
79356
|
+
);
|
|
79357
|
+
}
|
|
79358
|
+
function usageOf(raw) {
|
|
79359
|
+
const u2 = raw?.usage;
|
|
79360
|
+
if (!u2) {
|
|
79361
|
+
return;
|
|
79362
|
+
}
|
|
79363
|
+
return {
|
|
79364
|
+
promptTokens: u2.prompt_tokens,
|
|
79365
|
+
completionTokens: u2.completion_tokens,
|
|
79366
|
+
totalTokens: u2.total_tokens
|
|
79367
|
+
};
|
|
79368
|
+
}
|
|
79369
|
+
function body(params, stream4) {
|
|
79370
|
+
return JSON.stringify({
|
|
79371
|
+
model: params.model,
|
|
79372
|
+
messages: params.messages,
|
|
79373
|
+
...stream4 ? { stream: true } : {},
|
|
79374
|
+
...params.maxTokens != null ? { max_tokens: params.maxTokens } : {},
|
|
79375
|
+
...params.temperature != null ? { temperature: params.temperature } : {}
|
|
79376
|
+
});
|
|
79377
|
+
}
|
|
79378
|
+
async function chatCompletion(params) {
|
|
79379
|
+
const key = resolveApiKey(params.apiKey);
|
|
79380
|
+
const base = params.apiBase ?? DEFAULT_API_BASE;
|
|
79381
|
+
const res = await fetch(`${base}/chat/completions`, {
|
|
79382
|
+
method: "POST",
|
|
79383
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
79384
|
+
body: body(params, false)
|
|
79385
|
+
});
|
|
79386
|
+
if (!res.ok) {
|
|
79387
|
+
await failBody(res);
|
|
79388
|
+
}
|
|
79389
|
+
const raw = await res.json();
|
|
79390
|
+
const content = raw?.choices?.[0]?.message?.content ?? "";
|
|
79391
|
+
return {
|
|
79392
|
+
content,
|
|
79393
|
+
model: raw?.model ?? params.model,
|
|
79394
|
+
usage: usageOf(raw),
|
|
79395
|
+
raw
|
|
79396
|
+
};
|
|
79397
|
+
}
|
|
79398
|
+
async function* chatCompletionStream(params) {
|
|
79399
|
+
const key = resolveApiKey(params.apiKey);
|
|
79400
|
+
const base = params.apiBase ?? DEFAULT_API_BASE;
|
|
79401
|
+
const res = await fetch(`${base}/chat/completions`, {
|
|
79402
|
+
method: "POST",
|
|
79403
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
79404
|
+
body: body(params, true)
|
|
79405
|
+
});
|
|
79406
|
+
if (!(res.ok && res.body)) {
|
|
79407
|
+
await failBody(res);
|
|
79408
|
+
return;
|
|
79409
|
+
}
|
|
79410
|
+
const reader = res.body.getReader();
|
|
79411
|
+
const decoder = new TextDecoder();
|
|
79412
|
+
let buffer = "";
|
|
79413
|
+
while (true) {
|
|
79414
|
+
const { done, value } = await reader.read();
|
|
79415
|
+
if (done) {
|
|
79416
|
+
break;
|
|
79417
|
+
}
|
|
79418
|
+
buffer += decoder.decode(value, { stream: true });
|
|
79419
|
+
const lines = buffer.split("\n");
|
|
79420
|
+
buffer = lines.pop() ?? "";
|
|
79421
|
+
for (const line of lines) {
|
|
79422
|
+
const trimmed = line.trim();
|
|
79423
|
+
if (!trimmed.startsWith("data:")) {
|
|
79424
|
+
continue;
|
|
79425
|
+
}
|
|
79426
|
+
const data = trimmed.slice(5).trim();
|
|
79427
|
+
if (data === "[DONE]") {
|
|
79428
|
+
return;
|
|
79429
|
+
}
|
|
79430
|
+
try {
|
|
79431
|
+
const json = JSON.parse(data);
|
|
79432
|
+
const delta = json.choices?.[0]?.delta?.content;
|
|
79433
|
+
if (typeof delta === "string" && delta) {
|
|
79434
|
+
yield delta;
|
|
79435
|
+
}
|
|
79436
|
+
} catch {
|
|
79437
|
+
}
|
|
79438
|
+
}
|
|
79439
|
+
}
|
|
79440
|
+
}
|
|
79441
|
+
async function listModels(opts) {
|
|
79442
|
+
const base = opts?.apiBase ?? DEFAULT_API_BASE;
|
|
79443
|
+
const key = opts?.apiKey ?? envApiKey();
|
|
79444
|
+
const res = await fetch(`${base}/models`, {
|
|
79445
|
+
headers: key ? { authorization: `Bearer ${key}` } : {}
|
|
79446
|
+
});
|
|
79447
|
+
if (!res.ok) {
|
|
79448
|
+
await failBody(res);
|
|
79449
|
+
}
|
|
79450
|
+
const json = await res.json();
|
|
79451
|
+
const data = Array.isArray(json.data) ? json.data : [];
|
|
79452
|
+
return data.map((m) => ({
|
|
79453
|
+
id: m.id,
|
|
79454
|
+
contextWindow: m.context_window ?? m.context_length,
|
|
79455
|
+
inputPer1M: m.pricing?.input_per_1m ?? m.pricing?.prompt,
|
|
79456
|
+
outputPer1M: m.pricing?.output_per_1m ?? m.pricing?.completion,
|
|
79457
|
+
privacy: m.privacy ?? m.privacy_tier
|
|
79458
|
+
}));
|
|
79459
|
+
}
|
|
79328
79460
|
var DEFAULT_CONFIG_DIR = join$1(homedir(), ".t2000");
|
|
79329
79461
|
function resolveConfigPath(configDir) {
|
|
79330
79462
|
return join$1(configDir ?? DEFAULT_CONFIG_DIR, "config.json");
|
|
@@ -79587,6 +79719,24 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
79587
79719
|
// but there is no longer any way to MINT or REDEEM vSUI through t2000.
|
|
79588
79720
|
// History: see spec/archive/v07e/AUDIT_V07E_EARNS_ITS_KEEP_2026-05-23.md
|
|
79589
79721
|
// and the S.323 build-tracker entry.
|
|
79722
|
+
// -- Private Inference API (SPEC_AUDRIC_API, S.575) --
|
|
79723
|
+
//
|
|
79724
|
+
// Inference as a wallet verb — the agent's brain + wallet in one package.
|
|
79725
|
+
// Key-based today (`apiKey` / `T2000_API_KEY`); the x402 no-key pay-per-call
|
|
79726
|
+
// path is a later add. The model runs on the t2000 Private API (ZDR; a
|
|
79727
|
+
// `phala/*` confidential tier runs in a GPU-TEE).
|
|
79728
|
+
/** Non-streaming chat completion against the Private API. */
|
|
79729
|
+
async chat(params) {
|
|
79730
|
+
return chatCompletion(params);
|
|
79731
|
+
}
|
|
79732
|
+
/** Streaming chat completion — async-iterate the assistant text deltas. */
|
|
79733
|
+
chatStream(params) {
|
|
79734
|
+
return chatCompletionStream(params);
|
|
79735
|
+
}
|
|
79736
|
+
/** The Private API model catalog (`GET /v1/models`). */
|
|
79737
|
+
async models(opts) {
|
|
79738
|
+
return listModels(opts);
|
|
79739
|
+
}
|
|
79590
79740
|
// -- Swap --
|
|
79591
79741
|
async swap(params) {
|
|
79592
79742
|
this.limits.assert({
|
|
@@ -80206,10 +80356,10 @@ Common examples:
|
|
|
80206
80356
|
headers: external_exports.record(external_exports.string()).optional().describe("Additional HTTP headers"),
|
|
80207
80357
|
maxPrice: external_exports.number().default(1).describe("Max USD to pay (default: $1.00). Set higher for commerce services.")
|
|
80208
80358
|
},
|
|
80209
|
-
async ({ url: url2, method, body, headers, maxPrice }) => {
|
|
80359
|
+
async ({ url: url2, method, body: body2, headers, maxPrice }) => {
|
|
80210
80360
|
try {
|
|
80211
80361
|
const result = await mutex.run(
|
|
80212
|
-
() => agent.pay({ url: url2, method, body, headers, maxPrice })
|
|
80362
|
+
() => agent.pay({ url: url2, method, body: body2, headers, maxPrice })
|
|
80213
80363
|
);
|
|
80214
80364
|
let text = JSON.stringify(result);
|
|
80215
80365
|
try {
|
|
@@ -80268,6 +80418,69 @@ Use the returned values to inform the user about their own configured caps befor
|
|
|
80268
80418
|
);
|
|
80269
80419
|
}
|
|
80270
80420
|
|
|
80421
|
+
// src/tools/chat.ts
|
|
80422
|
+
init_zod();
|
|
80423
|
+
var DEFAULT_MODEL = "zai/glm-5.2";
|
|
80424
|
+
function registerChatTools(server) {
|
|
80425
|
+
server.tool(
|
|
80426
|
+
"t2000_chat",
|
|
80427
|
+
"Run private inference on the t2000 Private API (OpenAI-compatible; ZDR by default, a `phala/*` tier is GPU-TEE confidential), billed to the user's t2000 credit. Requires T2000_API_KEY in the server env (generate at platform.t2000.ai \u2014 Pro/Max). Pass a single `prompt`, or a full `messages` list. Discover model ids with t2000_models; defaults to GLM 5.2.",
|
|
80428
|
+
{
|
|
80429
|
+
prompt: external_exports.string().optional().describe("User prompt (shorthand for a single user message)"),
|
|
80430
|
+
messages: external_exports.array(
|
|
80431
|
+
external_exports.object({
|
|
80432
|
+
role: external_exports.enum(["system", "user", "assistant"]),
|
|
80433
|
+
content: external_exports.string()
|
|
80434
|
+
})
|
|
80435
|
+
).optional().describe("Full message list (overrides `prompt` when present)"),
|
|
80436
|
+
model: external_exports.string().optional().describe(`Model id (default ${DEFAULT_MODEL}; see t2000_models)`),
|
|
80437
|
+
maxTokens: external_exports.number().optional().describe("Max output tokens"),
|
|
80438
|
+
temperature: external_exports.number().optional().describe("Sampling temperature (0\u20132)")
|
|
80439
|
+
},
|
|
80440
|
+
async ({ prompt, messages, model, maxTokens, temperature }) => {
|
|
80441
|
+
try {
|
|
80442
|
+
const msgs = messages ?? (prompt ? [{ role: "user", content: prompt }] : []);
|
|
80443
|
+
if (msgs.length === 0) {
|
|
80444
|
+
throw new Error("Provide `prompt` or `messages`.");
|
|
80445
|
+
}
|
|
80446
|
+
const res = await chatCompletion({
|
|
80447
|
+
model: model ?? DEFAULT_MODEL,
|
|
80448
|
+
messages: msgs,
|
|
80449
|
+
maxTokens,
|
|
80450
|
+
temperature
|
|
80451
|
+
});
|
|
80452
|
+
return {
|
|
80453
|
+
content: [
|
|
80454
|
+
{
|
|
80455
|
+
type: "text",
|
|
80456
|
+
text: JSON.stringify({
|
|
80457
|
+
model: res.model,
|
|
80458
|
+
content: res.content,
|
|
80459
|
+
usage: res.usage
|
|
80460
|
+
})
|
|
80461
|
+
}
|
|
80462
|
+
]
|
|
80463
|
+
};
|
|
80464
|
+
} catch (err) {
|
|
80465
|
+
return errorResult(err);
|
|
80466
|
+
}
|
|
80467
|
+
}
|
|
80468
|
+
);
|
|
80469
|
+
server.tool(
|
|
80470
|
+
"t2000_models",
|
|
80471
|
+
"List the t2000 Private API model catalog (id \xB7 privacy tier \xB7 per-1M pricing). Call before t2000_chat to pick a model.",
|
|
80472
|
+
{},
|
|
80473
|
+
async () => {
|
|
80474
|
+
try {
|
|
80475
|
+
const models = await listModels();
|
|
80476
|
+
return { content: [{ type: "text", text: JSON.stringify({ models }) }] };
|
|
80477
|
+
} catch (err) {
|
|
80478
|
+
return errorResult(err);
|
|
80479
|
+
}
|
|
80480
|
+
}
|
|
80481
|
+
);
|
|
80482
|
+
}
|
|
80483
|
+
|
|
80271
80484
|
// src/skills-prompts.ts
|
|
80272
80485
|
var cachedSkills = null;
|
|
80273
80486
|
function getBakedSkills() {
|
|
@@ -80296,10 +80509,10 @@ async function fetchLiveSkillBody(name) {
|
|
|
80296
80509
|
const res = await fetch(`${SKILLS_BASE_URL}/${name}`, { signal: controller.signal });
|
|
80297
80510
|
clearTimeout(timer);
|
|
80298
80511
|
if (!res.ok) return null;
|
|
80299
|
-
const
|
|
80300
|
-
if (!
|
|
80301
|
-
liveBodyCache.set(name,
|
|
80302
|
-
return
|
|
80512
|
+
const body2 = stripFrontmatter(await res.text()).trim();
|
|
80513
|
+
if (!body2) return null;
|
|
80514
|
+
liveBodyCache.set(name, body2);
|
|
80515
|
+
return body2;
|
|
80303
80516
|
} catch {
|
|
80304
80517
|
return null;
|
|
80305
80518
|
}
|
|
@@ -80339,7 +80552,7 @@ CRITICAL: When the user asks to use any external or paid API, names a provider (
|
|
|
80339
80552
|
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.`;
|
|
80340
80553
|
|
|
80341
80554
|
// src/index.ts
|
|
80342
|
-
var PKG_VERSION = "5.
|
|
80555
|
+
var PKG_VERSION = "5.15.0" ;
|
|
80343
80556
|
console.log = (...args) => console.error("[log]", ...args);
|
|
80344
80557
|
console.warn = (...args) => console.error("[warn]", ...args);
|
|
80345
80558
|
async function startMcpServer(opts) {
|
|
@@ -80351,6 +80564,7 @@ async function startMcpServer(opts) {
|
|
|
80351
80564
|
registerReadTools(server, agent);
|
|
80352
80565
|
registerWriteTools(server, agent);
|
|
80353
80566
|
registerLimitTool(server);
|
|
80567
|
+
registerChatTools(server);
|
|
80354
80568
|
registerSkillPrompts(server);
|
|
80355
80569
|
const transport = new StdioServerTransport();
|
|
80356
80570
|
await server.connect(transport);
|