@t2000/cli 5.15.1 → 5.16.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/index.js
CHANGED
|
@@ -28340,7 +28340,9 @@ function body(params, stream) {
|
|
|
28340
28340
|
return JSON.stringify({
|
|
28341
28341
|
model: params.model,
|
|
28342
28342
|
messages: params.messages,
|
|
28343
|
-
|
|
28343
|
+
// include_usage → the final stream chunk carries usage + x_receipt_id
|
|
28344
|
+
// (the confidential attestation receipt) so we can surface it after a stream.
|
|
28345
|
+
...stream ? { stream: true, stream_options: { include_usage: true } } : {},
|
|
28344
28346
|
...params.maxTokens != null ? { max_tokens: params.maxTokens } : {},
|
|
28345
28347
|
...params.temperature != null ? { temperature: params.temperature } : {}
|
|
28346
28348
|
});
|
|
@@ -28356,12 +28358,14 @@ async function chatCompletion(params) {
|
|
|
28356
28358
|
if (!res.ok) {
|
|
28357
28359
|
await failBody(res);
|
|
28358
28360
|
}
|
|
28361
|
+
const receiptId = res.headers.get("x-receipt-id") ?? void 0;
|
|
28359
28362
|
const raw = await res.json();
|
|
28360
28363
|
const content = raw?.choices?.[0]?.message?.content ?? "";
|
|
28361
28364
|
return {
|
|
28362
28365
|
content,
|
|
28363
28366
|
model: raw?.model ?? params.model,
|
|
28364
28367
|
usage: usageOf(raw),
|
|
28368
|
+
receiptId,
|
|
28365
28369
|
raw
|
|
28366
28370
|
};
|
|
28367
28371
|
}
|
|
@@ -28375,11 +28379,12 @@ async function* chatCompletionStream(params) {
|
|
|
28375
28379
|
});
|
|
28376
28380
|
if (!(res.ok && res.body)) {
|
|
28377
28381
|
await failBody(res);
|
|
28378
|
-
return;
|
|
28382
|
+
return {};
|
|
28379
28383
|
}
|
|
28380
28384
|
const reader = res.body.getReader();
|
|
28381
28385
|
const decoder = new TextDecoder();
|
|
28382
28386
|
let buffer = "";
|
|
28387
|
+
let receiptId;
|
|
28383
28388
|
while (true) {
|
|
28384
28389
|
const { done, value } = await reader.read();
|
|
28385
28390
|
if (done) {
|
|
@@ -28395,10 +28400,13 @@ async function* chatCompletionStream(params) {
|
|
|
28395
28400
|
}
|
|
28396
28401
|
const data = trimmed.slice(5).trim();
|
|
28397
28402
|
if (data === "[DONE]") {
|
|
28398
|
-
return;
|
|
28403
|
+
return { receiptId };
|
|
28399
28404
|
}
|
|
28400
28405
|
try {
|
|
28401
28406
|
const json = JSON.parse(data);
|
|
28407
|
+
if (json.x_receipt_id) {
|
|
28408
|
+
receiptId = json.x_receipt_id;
|
|
28409
|
+
}
|
|
28402
28410
|
const delta = json.choices?.[0]?.delta?.content;
|
|
28403
28411
|
if (typeof delta === "string" && delta) {
|
|
28404
28412
|
yield delta;
|
|
@@ -28407,6 +28415,7 @@ async function* chatCompletionStream(params) {
|
|
|
28407
28415
|
}
|
|
28408
28416
|
}
|
|
28409
28417
|
}
|
|
28418
|
+
return { receiptId };
|
|
28410
28419
|
}
|
|
28411
28420
|
async function listModels(opts) {
|
|
28412
28421
|
const base = opts?.apiBase ?? DEFAULT_API_BASE;
|
|
@@ -28699,7 +28708,8 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
28699
28708
|
async chat(params) {
|
|
28700
28709
|
return chatCompletion(params);
|
|
28701
28710
|
}
|
|
28702
|
-
/** Streaming chat completion — async-iterate the assistant text deltas
|
|
28711
|
+
/** Streaming chat completion — async-iterate the assistant text deltas;
|
|
28712
|
+
* the generator returns `{ receiptId }` (confidential attestation) at the end. */
|
|
28703
28713
|
chatStream(params) {
|
|
28704
28714
|
return chatCompletionStream(params);
|
|
28705
28715
|
}
|
|
@@ -32377,6 +32387,12 @@ function describeSchemaFields(schema) {
|
|
|
32377
32387
|
}
|
|
32378
32388
|
|
|
32379
32389
|
// src/commands/chat.ts
|
|
32390
|
+
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
32391
|
+
function receiptLine(receiptId) {
|
|
32392
|
+
if (receiptId) {
|
|
32393
|
+
printLine(import_picocolors9.default.dim(`\u{1F512} confidential \xB7 attested \xB7 receipt ${receiptId}`));
|
|
32394
|
+
}
|
|
32395
|
+
}
|
|
32380
32396
|
var DEFAULT_MODEL = "zai/glm-5.2";
|
|
32381
32397
|
function numOrUndef(v) {
|
|
32382
32398
|
if (v === void 0) {
|
|
@@ -32407,20 +32423,30 @@ function registerChat(program3) {
|
|
|
32407
32423
|
if (isJsonMode() || opts.stream === false) {
|
|
32408
32424
|
const res = await chatCompletion(params);
|
|
32409
32425
|
if (isJsonMode()) {
|
|
32410
|
-
printJson({
|
|
32426
|
+
printJson({
|
|
32427
|
+
model: res.model,
|
|
32428
|
+
content: res.content,
|
|
32429
|
+
usage: res.usage,
|
|
32430
|
+
receiptId: res.receiptId
|
|
32431
|
+
});
|
|
32411
32432
|
return;
|
|
32412
32433
|
}
|
|
32413
32434
|
printBlank();
|
|
32414
32435
|
printLine(res.content);
|
|
32436
|
+
receiptLine(res.receiptId);
|
|
32415
32437
|
printBlank();
|
|
32416
32438
|
return;
|
|
32417
32439
|
}
|
|
32440
|
+
const gen = chatCompletionStream(params);
|
|
32418
32441
|
let any = false;
|
|
32419
|
-
|
|
32420
|
-
|
|
32442
|
+
let next = await gen.next();
|
|
32443
|
+
while (!next.done) {
|
|
32444
|
+
process.stdout.write(next.value);
|
|
32421
32445
|
any = true;
|
|
32446
|
+
next = await gen.next();
|
|
32422
32447
|
}
|
|
32423
32448
|
process.stdout.write(any ? "\n" : "");
|
|
32449
|
+
receiptLine(next.value?.receiptId);
|
|
32424
32450
|
} catch (error) {
|
|
32425
32451
|
handleError(error);
|
|
32426
32452
|
}
|
|
@@ -32448,7 +32474,7 @@ function registerChat(program3) {
|
|
|
32448
32474
|
}
|
|
32449
32475
|
|
|
32450
32476
|
// src/commands/services/search.ts
|
|
32451
|
-
var
|
|
32477
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
32452
32478
|
|
|
32453
32479
|
// src/commands/services/catalog.ts
|
|
32454
32480
|
var DEFAULT_GATEWAY_URL = "https://mpp.t2000.ai";
|
|
@@ -32550,9 +32576,9 @@ Examples:
|
|
|
32550
32576
|
}
|
|
32551
32577
|
function renderServiceLine(svc) {
|
|
32552
32578
|
const minPrice = cheapestEndpointPrice(svc);
|
|
32553
|
-
const priceTag = minPrice !== null ?
|
|
32554
|
-
const catTag = svc.categories.length > 0 ?
|
|
32555
|
-
printKeyValue(
|
|
32579
|
+
const priceTag = minPrice !== null ? import_picocolors10.default.green(`from $${minPrice}`) : import_picocolors10.default.dim("no pricing");
|
|
32580
|
+
const catTag = svc.categories.length > 0 ? import_picocolors10.default.dim(`[${svc.categories.join(", ")}]`) : "";
|
|
32581
|
+
printKeyValue(import_picocolors10.default.bold(svc.name), `${priceTag} ${catTag}`);
|
|
32556
32582
|
printKeyValue(" url", svc.serviceUrl);
|
|
32557
32583
|
printKeyValue(" about", svc.description);
|
|
32558
32584
|
printBlank();
|
|
@@ -32566,7 +32592,7 @@ function cheapestEndpointPrice(svc) {
|
|
|
32566
32592
|
}
|
|
32567
32593
|
|
|
32568
32594
|
// src/commands/services/inspect.ts
|
|
32569
|
-
var
|
|
32595
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
32570
32596
|
function registerServicesInspect(parent) {
|
|
32571
32597
|
parent.command("inspect").description("Show pricing + endpoints for an MPP service or endpoint URL").argument("<url>", "Service base URL or endpoint URL").option("--gateway <url>", "Override gateway base URL (default: https://mpp.t2000.ai)").addHelpText(
|
|
32572
32598
|
"after",
|
|
@@ -32603,7 +32629,7 @@ Examples:
|
|
|
32603
32629
|
return;
|
|
32604
32630
|
}
|
|
32605
32631
|
printBlank();
|
|
32606
|
-
printKeyValue("Service",
|
|
32632
|
+
printKeyValue("Service", import_picocolors11.default.bold(service.name));
|
|
32607
32633
|
printKeyValue("URL", service.serviceUrl);
|
|
32608
32634
|
printKeyValue("About", service.description);
|
|
32609
32635
|
if (service.categories.length > 0) {
|
|
@@ -32633,7 +32659,7 @@ Examples:
|
|
|
32633
32659
|
function renderEndpoint(ep, serviceUrl) {
|
|
32634
32660
|
const price = `$${ep.price}`;
|
|
32635
32661
|
const label = `${ep.method} ${ep.path}`.padEnd(40);
|
|
32636
|
-
printKeyValue(label, `${
|
|
32662
|
+
printKeyValue(label, `${import_picocolors11.default.green(price)} ${import_picocolors11.default.dim(ep.description)}`);
|
|
32637
32663
|
printKeyValue(" url", `${serviceUrl}${ep.path}`);
|
|
32638
32664
|
printBlank();
|
|
32639
32665
|
}
|
|
@@ -32656,7 +32682,7 @@ T2000_GATEWAY_URL or --gateway <url> for local development.
|
|
|
32656
32682
|
}
|
|
32657
32683
|
|
|
32658
32684
|
// src/commands/limit/show.ts
|
|
32659
|
-
var
|
|
32685
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
32660
32686
|
function registerLimitShow(parent) {
|
|
32661
32687
|
parent.command("show").description("Show current spending limits").action(async (opts) => {
|
|
32662
32688
|
try {
|
|
@@ -32679,10 +32705,10 @@ function registerLimitShow(parent) {
|
|
|
32679
32705
|
}
|
|
32680
32706
|
printBlank();
|
|
32681
32707
|
if (limits.perTxUsd !== void 0) {
|
|
32682
|
-
printKeyValue("Per-transaction",
|
|
32708
|
+
printKeyValue("Per-transaction", import_picocolors12.default.green(`$${limits.perTxUsd}`));
|
|
32683
32709
|
}
|
|
32684
32710
|
if (limits.dailyUsd !== void 0) {
|
|
32685
|
-
printKeyValue("Daily (cumulative)",
|
|
32711
|
+
printKeyValue("Daily (cumulative)", import_picocolors12.default.green(`$${limits.dailyUsd}`));
|
|
32686
32712
|
}
|
|
32687
32713
|
printBlank();
|
|
32688
32714
|
printInfo("Use `--force` on `t2 send` / `t2 swap` / `t2 pay` to override per-call.");
|
|
@@ -32694,7 +32720,7 @@ function registerLimitShow(parent) {
|
|
|
32694
32720
|
}
|
|
32695
32721
|
|
|
32696
32722
|
// src/commands/limit/set.ts
|
|
32697
|
-
var
|
|
32723
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
32698
32724
|
function parseLimitSetArgs(opts) {
|
|
32699
32725
|
const perTx = opts.perTx !== void 0 ? parseUsdFlag("--per-tx", opts.perTx) : void 0;
|
|
32700
32726
|
const daily = opts.daily !== void 0 ? parseUsdFlag("--daily", opts.daily) : void 0;
|
|
@@ -32736,10 +32762,10 @@ Examples:
|
|
|
32736
32762
|
printBlank();
|
|
32737
32763
|
printSuccess("Spending limits updated.");
|
|
32738
32764
|
if (next?.perTxUsd !== void 0) {
|
|
32739
|
-
printKeyValue("Per-transaction",
|
|
32765
|
+
printKeyValue("Per-transaction", import_picocolors13.default.green(`$${next.perTxUsd}`));
|
|
32740
32766
|
}
|
|
32741
32767
|
if (next?.dailyUsd !== void 0) {
|
|
32742
|
-
printKeyValue("Daily (cumulative)",
|
|
32768
|
+
printKeyValue("Daily (cumulative)", import_picocolors13.default.green(`$${next.dailyUsd}`));
|
|
32743
32769
|
}
|
|
32744
32770
|
printBlank();
|
|
32745
32771
|
printInfo("Use `t2 limit show` to view; `t2 limit reset` to clear.");
|
|
@@ -32801,7 +32827,7 @@ function registerMcpStart(parent) {
|
|
|
32801
32827
|
parent.command("start", { isDefault: true }).description("Start MCP server (stdio transport \u2014 for AI client integration)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").action(async (opts) => {
|
|
32802
32828
|
let mod2;
|
|
32803
32829
|
try {
|
|
32804
|
-
mod2 = await import("./dist-
|
|
32830
|
+
mod2 = await import("./dist-UPUBYGXT.js");
|
|
32805
32831
|
} catch {
|
|
32806
32832
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
32807
32833
|
process.exit(1);
|