@t2000/cli 5.14.3 → 5.15.1
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/{dist-PMYELDIE.js → dist-JDPHHZMS.js} +270 -58
- package/dist/dist-JDPHHZMS.js.map +1 -0
- package/dist/index.js +267 -43
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/dist-PMYELDIE.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -27693,9 +27693,9 @@ async function payWithMpp(args) {
|
|
|
27693
27693
|
}
|
|
27694
27694
|
async function pickSuiExactRequirements(response, network) {
|
|
27695
27695
|
try {
|
|
27696
|
-
const
|
|
27696
|
+
const body2 = await response.clone().json();
|
|
27697
27697
|
const want = `sui:${network === "testnet" ? "testnet" : "mainnet"}`;
|
|
27698
|
-
return
|
|
27698
|
+
return body2.accepts?.find((a) => a.scheme === "exact" && a.network === want);
|
|
27699
27699
|
} catch {
|
|
27700
27700
|
return void 0;
|
|
27701
27701
|
}
|
|
@@ -27774,13 +27774,13 @@ async function ensureAddressBalanceCovers(args) {
|
|
|
27774
27774
|
}
|
|
27775
27775
|
async function finalize(response, opts) {
|
|
27776
27776
|
const contentType = response.headers.get("content-type") ?? "";
|
|
27777
|
-
let
|
|
27777
|
+
let body2;
|
|
27778
27778
|
try {
|
|
27779
|
-
|
|
27779
|
+
body2 = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
27780
27780
|
} catch {
|
|
27781
|
-
|
|
27781
|
+
body2 = null;
|
|
27782
27782
|
}
|
|
27783
|
-
return { status: response.status, body, paid: opts.paid };
|
|
27783
|
+
return { status: response.status, body: body2, paid: opts.paid };
|
|
27784
27784
|
}
|
|
27785
27785
|
async function makeGrpcBuildClient(client) {
|
|
27786
27786
|
const { SuiGrpcClient: SuiGrpcClient2 } = await import("./grpc-OLWNGPHN.js");
|
|
@@ -28295,6 +28295,138 @@ async function resolveSuinsViaRpc(rawName, ctx = {}) {
|
|
|
28295
28295
|
return res.data?.address?.address ?? null;
|
|
28296
28296
|
}
|
|
28297
28297
|
init_errors();
|
|
28298
|
+
init_errors();
|
|
28299
|
+
var DEFAULT_API_BASE = "https://api.t2000.ai/v1";
|
|
28300
|
+
function envApiKey() {
|
|
28301
|
+
return typeof process !== "undefined" ? process.env?.T2000_API_KEY : void 0;
|
|
28302
|
+
}
|
|
28303
|
+
function resolveApiKey(apiKey) {
|
|
28304
|
+
const key = apiKey ?? envApiKey();
|
|
28305
|
+
if (!key) {
|
|
28306
|
+
throw new T2000Error(
|
|
28307
|
+
"INVALID_KEY",
|
|
28308
|
+
"No Private API key. Pass `apiKey` or set T2000_API_KEY. Generate one at platform.t2000.ai (Pro/Max)."
|
|
28309
|
+
);
|
|
28310
|
+
}
|
|
28311
|
+
return key;
|
|
28312
|
+
}
|
|
28313
|
+
async function failBody(res) {
|
|
28314
|
+
const text = await res.text().catch(() => "");
|
|
28315
|
+
let msg = text.slice(0, 300);
|
|
28316
|
+
try {
|
|
28317
|
+
const j = JSON.parse(text);
|
|
28318
|
+
msg = (typeof j.error === "object" ? j.error?.message : j.error) ?? msg;
|
|
28319
|
+
} catch {
|
|
28320
|
+
}
|
|
28321
|
+
throw new T2000Error(
|
|
28322
|
+
"INFERENCE_FAILED",
|
|
28323
|
+
`Inference request failed (${res.status}): ${msg}`,
|
|
28324
|
+
{ status: res.status },
|
|
28325
|
+
res.status >= 500
|
|
28326
|
+
);
|
|
28327
|
+
}
|
|
28328
|
+
function usageOf(raw) {
|
|
28329
|
+
const u = raw?.usage;
|
|
28330
|
+
if (!u) {
|
|
28331
|
+
return;
|
|
28332
|
+
}
|
|
28333
|
+
return {
|
|
28334
|
+
promptTokens: u.prompt_tokens,
|
|
28335
|
+
completionTokens: u.completion_tokens,
|
|
28336
|
+
totalTokens: u.total_tokens
|
|
28337
|
+
};
|
|
28338
|
+
}
|
|
28339
|
+
function body(params, stream) {
|
|
28340
|
+
return JSON.stringify({
|
|
28341
|
+
model: params.model,
|
|
28342
|
+
messages: params.messages,
|
|
28343
|
+
...stream ? { stream: true } : {},
|
|
28344
|
+
...params.maxTokens != null ? { max_tokens: params.maxTokens } : {},
|
|
28345
|
+
...params.temperature != null ? { temperature: params.temperature } : {}
|
|
28346
|
+
});
|
|
28347
|
+
}
|
|
28348
|
+
async function chatCompletion(params) {
|
|
28349
|
+
const key = resolveApiKey(params.apiKey);
|
|
28350
|
+
const base = params.apiBase ?? DEFAULT_API_BASE;
|
|
28351
|
+
const res = await fetch(`${base}/chat/completions`, {
|
|
28352
|
+
method: "POST",
|
|
28353
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
28354
|
+
body: body(params, false)
|
|
28355
|
+
});
|
|
28356
|
+
if (!res.ok) {
|
|
28357
|
+
await failBody(res);
|
|
28358
|
+
}
|
|
28359
|
+
const raw = await res.json();
|
|
28360
|
+
const content = raw?.choices?.[0]?.message?.content ?? "";
|
|
28361
|
+
return {
|
|
28362
|
+
content,
|
|
28363
|
+
model: raw?.model ?? params.model,
|
|
28364
|
+
usage: usageOf(raw),
|
|
28365
|
+
raw
|
|
28366
|
+
};
|
|
28367
|
+
}
|
|
28368
|
+
async function* chatCompletionStream(params) {
|
|
28369
|
+
const key = resolveApiKey(params.apiKey);
|
|
28370
|
+
const base = params.apiBase ?? DEFAULT_API_BASE;
|
|
28371
|
+
const res = await fetch(`${base}/chat/completions`, {
|
|
28372
|
+
method: "POST",
|
|
28373
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
28374
|
+
body: body(params, true)
|
|
28375
|
+
});
|
|
28376
|
+
if (!(res.ok && res.body)) {
|
|
28377
|
+
await failBody(res);
|
|
28378
|
+
return;
|
|
28379
|
+
}
|
|
28380
|
+
const reader = res.body.getReader();
|
|
28381
|
+
const decoder = new TextDecoder();
|
|
28382
|
+
let buffer = "";
|
|
28383
|
+
while (true) {
|
|
28384
|
+
const { done, value } = await reader.read();
|
|
28385
|
+
if (done) {
|
|
28386
|
+
break;
|
|
28387
|
+
}
|
|
28388
|
+
buffer += decoder.decode(value, { stream: true });
|
|
28389
|
+
const lines = buffer.split("\n");
|
|
28390
|
+
buffer = lines.pop() ?? "";
|
|
28391
|
+
for (const line of lines) {
|
|
28392
|
+
const trimmed = line.trim();
|
|
28393
|
+
if (!trimmed.startsWith("data:")) {
|
|
28394
|
+
continue;
|
|
28395
|
+
}
|
|
28396
|
+
const data = trimmed.slice(5).trim();
|
|
28397
|
+
if (data === "[DONE]") {
|
|
28398
|
+
return;
|
|
28399
|
+
}
|
|
28400
|
+
try {
|
|
28401
|
+
const json = JSON.parse(data);
|
|
28402
|
+
const delta = json.choices?.[0]?.delta?.content;
|
|
28403
|
+
if (typeof delta === "string" && delta) {
|
|
28404
|
+
yield delta;
|
|
28405
|
+
}
|
|
28406
|
+
} catch {
|
|
28407
|
+
}
|
|
28408
|
+
}
|
|
28409
|
+
}
|
|
28410
|
+
}
|
|
28411
|
+
async function listModels(opts) {
|
|
28412
|
+
const base = opts?.apiBase ?? DEFAULT_API_BASE;
|
|
28413
|
+
const key = opts?.apiKey ?? envApiKey();
|
|
28414
|
+
const res = await fetch(`${base}/models`, {
|
|
28415
|
+
headers: key ? { authorization: `Bearer ${key}` } : {}
|
|
28416
|
+
});
|
|
28417
|
+
if (!res.ok) {
|
|
28418
|
+
await failBody(res);
|
|
28419
|
+
}
|
|
28420
|
+
const json = await res.json();
|
|
28421
|
+
const data = Array.isArray(json.data) ? json.data : [];
|
|
28422
|
+
return data.map((m) => ({
|
|
28423
|
+
id: m.id,
|
|
28424
|
+
contextWindow: m.context_window ?? m.context_length,
|
|
28425
|
+
inputPer1M: m.pricing?.input_per_1m ?? m.pricing?.prompt,
|
|
28426
|
+
outputPer1M: m.pricing?.output_per_1m ?? m.pricing?.completion,
|
|
28427
|
+
privacy: m.privacy ?? m.privacy_tier
|
|
28428
|
+
}));
|
|
28429
|
+
}
|
|
28298
28430
|
var DEFAULT_CONFIG_DIR = join2(homedir(), ".t2000");
|
|
28299
28431
|
function resolveConfigPath(configDir) {
|
|
28300
28432
|
return join2(configDir ?? DEFAULT_CONFIG_DIR, "config.json");
|
|
@@ -28557,6 +28689,24 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
28557
28689
|
// but there is no longer any way to MINT or REDEEM vSUI through t2000.
|
|
28558
28690
|
// History: see spec/archive/v07e/AUDIT_V07E_EARNS_ITS_KEEP_2026-05-23.md
|
|
28559
28691
|
// and the S.323 build-tracker entry.
|
|
28692
|
+
// -- Private Inference API (SPEC_AUDRIC_API, S.575) --
|
|
28693
|
+
//
|
|
28694
|
+
// Inference as a wallet verb — the agent's brain + wallet in one package.
|
|
28695
|
+
// Key-based today (`apiKey` / `T2000_API_KEY`); the x402 no-key pay-per-call
|
|
28696
|
+
// path is a later add. The model runs on the t2000 Private API (ZDR; a
|
|
28697
|
+
// `phala/*` confidential tier runs in a GPU-TEE).
|
|
28698
|
+
/** Non-streaming chat completion against the Private API. */
|
|
28699
|
+
async chat(params) {
|
|
28700
|
+
return chatCompletion(params);
|
|
28701
|
+
}
|
|
28702
|
+
/** Streaming chat completion — async-iterate the assistant text deltas. */
|
|
28703
|
+
chatStream(params) {
|
|
28704
|
+
return chatCompletionStream(params);
|
|
28705
|
+
}
|
|
28706
|
+
/** The Private API model catalog (`GET /v1/models`). */
|
|
28707
|
+
async models(opts) {
|
|
28708
|
+
return listModels(opts);
|
|
28709
|
+
}
|
|
28560
28710
|
// -- Swap --
|
|
28561
28711
|
async swap(params) {
|
|
28562
28712
|
this.limits.assert({
|
|
@@ -31132,13 +31282,13 @@ var esm_default10 = createPrompt((config, done) => {
|
|
|
31132
31282
|
}
|
|
31133
31283
|
const description = selectedChoice?.description;
|
|
31134
31284
|
const header = [prefix, message, searchStr].filter(Boolean).join(" ").trimEnd();
|
|
31135
|
-
const
|
|
31285
|
+
const body2 = [
|
|
31136
31286
|
error ?? page,
|
|
31137
31287
|
" ",
|
|
31138
31288
|
description ? theme.style.description(description) : "",
|
|
31139
31289
|
helpLine
|
|
31140
31290
|
].filter(Boolean).join("\n").trimEnd();
|
|
31141
|
-
return [header,
|
|
31291
|
+
return [header, body2];
|
|
31142
31292
|
});
|
|
31143
31293
|
|
|
31144
31294
|
// ../../node_modules/.pnpm/@inquirer+select@4.4.2_@types+node@20.19.37/node_modules/@inquirer/select/dist/esm/index.js
|
|
@@ -31314,11 +31464,11 @@ async function askHidden(message) {
|
|
|
31314
31464
|
}
|
|
31315
31465
|
|
|
31316
31466
|
// src/lib/agent-register.ts
|
|
31317
|
-
async function postJson(url,
|
|
31467
|
+
async function postJson(url, body2) {
|
|
31318
31468
|
const res = await fetch(url, {
|
|
31319
31469
|
method: "POST",
|
|
31320
31470
|
headers: { "Content-Type": "application/json" },
|
|
31321
|
-
body: JSON.stringify(
|
|
31471
|
+
body: JSON.stringify(body2)
|
|
31322
31472
|
});
|
|
31323
31473
|
const json = await res.json().catch(() => ({}));
|
|
31324
31474
|
if (!res.ok) {
|
|
@@ -31370,7 +31520,7 @@ async function registerWallet(opts) {
|
|
|
31370
31520
|
}
|
|
31371
31521
|
|
|
31372
31522
|
// src/commands/init.ts
|
|
31373
|
-
var
|
|
31523
|
+
var DEFAULT_API_BASE2 = process.env.T2000_API_URL ?? "https://api.t2000.ai/v1";
|
|
31374
31524
|
var REGISTER_TIMEOUT_MS = 1e4;
|
|
31375
31525
|
var DEFAULT_PER_TX_USD = 25;
|
|
31376
31526
|
var DEFAULT_DAILY_USD = 100;
|
|
@@ -31412,7 +31562,7 @@ function registerInit(program3) {
|
|
|
31412
31562
|
if (opts.register !== false) {
|
|
31413
31563
|
try {
|
|
31414
31564
|
await Promise.race([
|
|
31415
|
-
registerWallet({ keypair: signingKeypair, address, base:
|
|
31565
|
+
registerWallet({ keypair: signingKeypair, address, base: DEFAULT_API_BASE2 }),
|
|
31416
31566
|
new Promise(
|
|
31417
31567
|
(_, reject) => setTimeout(() => reject(new Error("timeout")), REGISTER_TIMEOUT_MS)
|
|
31418
31568
|
)
|
|
@@ -32114,7 +32264,7 @@ async function runEstimate(url, opts) {
|
|
|
32114
32264
|
body: canHaveBody ? opts.data : void 0
|
|
32115
32265
|
});
|
|
32116
32266
|
if (response.status !== 402) {
|
|
32117
|
-
const
|
|
32267
|
+
const body2 = await response.text().catch(() => "");
|
|
32118
32268
|
if (isJsonMode()) {
|
|
32119
32269
|
printJson({
|
|
32120
32270
|
url,
|
|
@@ -32122,7 +32272,7 @@ async function runEstimate(url, opts) {
|
|
|
32122
32272
|
status: response.status,
|
|
32123
32273
|
estimate: null,
|
|
32124
32274
|
note: response.status >= 200 && response.status < 300 ? "Endpoint responded without a 402 challenge \u2014 no payment required." : `Endpoint responded with ${response.status} (not a 402 payment challenge).`,
|
|
32125
|
-
body
|
|
32275
|
+
body: body2
|
|
32126
32276
|
});
|
|
32127
32277
|
return;
|
|
32128
32278
|
}
|
|
@@ -32131,17 +32281,17 @@ async function runEstimate(url, opts) {
|
|
|
32131
32281
|
} else {
|
|
32132
32282
|
printInfo(`Status ${response.status} \u2014 not a 402 payment challenge.`);
|
|
32133
32283
|
}
|
|
32134
|
-
if (
|
|
32284
|
+
if (body2) {
|
|
32135
32285
|
printBlank();
|
|
32136
|
-
console.log(
|
|
32286
|
+
console.log(body2);
|
|
32137
32287
|
printBlank();
|
|
32138
32288
|
}
|
|
32139
32289
|
return;
|
|
32140
32290
|
}
|
|
32141
32291
|
let accepts = [];
|
|
32142
32292
|
try {
|
|
32143
|
-
const
|
|
32144
|
-
accepts =
|
|
32293
|
+
const body2 = await response.json();
|
|
32294
|
+
accepts = body2.accepts ?? [];
|
|
32145
32295
|
} catch {
|
|
32146
32296
|
accepts = [];
|
|
32147
32297
|
}
|
|
@@ -32226,6 +32376,77 @@ function describeSchemaFields(schema) {
|
|
|
32226
32376
|
});
|
|
32227
32377
|
}
|
|
32228
32378
|
|
|
32379
|
+
// src/commands/chat.ts
|
|
32380
|
+
var DEFAULT_MODEL = "zai/glm-5.2";
|
|
32381
|
+
function numOrUndef(v) {
|
|
32382
|
+
if (v === void 0) {
|
|
32383
|
+
return;
|
|
32384
|
+
}
|
|
32385
|
+
const n = Number(v);
|
|
32386
|
+
return Number.isFinite(n) ? n : void 0;
|
|
32387
|
+
}
|
|
32388
|
+
function registerChat(program3) {
|
|
32389
|
+
program3.command("chat").argument("<message...>", "Your prompt").description(
|
|
32390
|
+
"Chat with a model on the t2000 Private API (OpenAI-compatible, ZDR; a phala/* tier is GPU-TEE confidential). Needs an API key \u2014 generate one at platform.t2000.ai, then pass --api-key or set T2000_API_KEY."
|
|
32391
|
+
).option("--model <id>", `Model id (default ${DEFAULT_MODEL}; see \`t2 models\`)`, DEFAULT_MODEL).option("--system <text>", "System prompt").option("--max-tokens <n>", "Max output tokens").option("--temperature <t>", "Sampling temperature (0\u20132)").option("--no-stream", "Wait for the full response instead of streaming").option("--api-key <key>", "Private API key (or set T2000_API_KEY)").option("--api <url>", "API base URL (default https://api.t2000.ai/v1)").action(
|
|
32392
|
+
async (messageParts, opts) => {
|
|
32393
|
+
try {
|
|
32394
|
+
const messages = [];
|
|
32395
|
+
if (opts.system) {
|
|
32396
|
+
messages.push({ role: "system", content: opts.system });
|
|
32397
|
+
}
|
|
32398
|
+
messages.push({ role: "user", content: messageParts.join(" ") });
|
|
32399
|
+
const params = {
|
|
32400
|
+
model: opts.model,
|
|
32401
|
+
messages,
|
|
32402
|
+
apiKey: opts.apiKey,
|
|
32403
|
+
apiBase: opts.api,
|
|
32404
|
+
maxTokens: numOrUndef(opts.maxTokens),
|
|
32405
|
+
temperature: numOrUndef(opts.temperature)
|
|
32406
|
+
};
|
|
32407
|
+
if (isJsonMode() || opts.stream === false) {
|
|
32408
|
+
const res = await chatCompletion(params);
|
|
32409
|
+
if (isJsonMode()) {
|
|
32410
|
+
printJson({ model: res.model, content: res.content, usage: res.usage });
|
|
32411
|
+
return;
|
|
32412
|
+
}
|
|
32413
|
+
printBlank();
|
|
32414
|
+
printLine(res.content);
|
|
32415
|
+
printBlank();
|
|
32416
|
+
return;
|
|
32417
|
+
}
|
|
32418
|
+
let any = false;
|
|
32419
|
+
for await (const delta of chatCompletionStream(params)) {
|
|
32420
|
+
process.stdout.write(delta);
|
|
32421
|
+
any = true;
|
|
32422
|
+
}
|
|
32423
|
+
process.stdout.write(any ? "\n" : "");
|
|
32424
|
+
} catch (error) {
|
|
32425
|
+
handleError(error);
|
|
32426
|
+
}
|
|
32427
|
+
}
|
|
32428
|
+
);
|
|
32429
|
+
program3.command("models").description("List the t2000 Private API model catalog (id \xB7 privacy tier \xB7 per-1M pricing).").option("--api-key <key>", "Private API key (or set T2000_API_KEY)").option("--api <url>", "API base URL (default https://api.t2000.ai/v1)").action(async (opts) => {
|
|
32430
|
+
try {
|
|
32431
|
+
const models = await listModels({ apiKey: opts.apiKey, apiBase: opts.api });
|
|
32432
|
+
if (isJsonMode()) {
|
|
32433
|
+
printJson({ models });
|
|
32434
|
+
return;
|
|
32435
|
+
}
|
|
32436
|
+
const usd = (n) => n == null ? "?" : `$${Number(n.toFixed(4))}`;
|
|
32437
|
+
printBlank();
|
|
32438
|
+
for (const m of models) {
|
|
32439
|
+
const price = m.inputPer1M != null ? ` \u2014 ${usd(m.inputPer1M)}/${usd(m.outputPer1M)} per 1M` : "";
|
|
32440
|
+
const priv = m.privacy ? ` [${m.privacy}]` : "";
|
|
32441
|
+
printLine(` ${m.id}${priv}${price}`);
|
|
32442
|
+
}
|
|
32443
|
+
printBlank();
|
|
32444
|
+
} catch (error) {
|
|
32445
|
+
handleError(error);
|
|
32446
|
+
}
|
|
32447
|
+
});
|
|
32448
|
+
}
|
|
32449
|
+
|
|
32229
32450
|
// src/commands/services/search.ts
|
|
32230
32451
|
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
32231
32452
|
|
|
@@ -32580,7 +32801,7 @@ function registerMcpStart(parent) {
|
|
|
32580
32801
|
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) => {
|
|
32581
32802
|
let mod2;
|
|
32582
32803
|
try {
|
|
32583
|
-
mod2 = await import("./dist-
|
|
32804
|
+
mod2 = await import("./dist-JDPHHZMS.js");
|
|
32584
32805
|
} catch {
|
|
32585
32806
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
32586
32807
|
process.exit(1);
|
|
@@ -32921,7 +33142,7 @@ For MCP-aware clients (Claude Desktop, Cursor, Windsurf), prefer
|
|
|
32921
33142
|
|
|
32922
33143
|
// src/commands/agent/index.ts
|
|
32923
33144
|
import { createHash } from "crypto";
|
|
32924
|
-
var
|
|
33145
|
+
var DEFAULT_API_BASE3 = process.env.T2000_API_URL ?? "https://api.t2000.ai/v1";
|
|
32925
33146
|
var DEFAULT_GATEWAY = process.env.T2000_GATEWAY_URL ?? "https://mpp.t2000.ai";
|
|
32926
33147
|
var DEFAULT_RAIL = process.env.T2000_RAIL_URL ?? "https://x402.t2000.ai";
|
|
32927
33148
|
function collectHeader(value, previous) {
|
|
@@ -32976,10 +33197,10 @@ Subcommands:
|
|
|
32976
33197
|
$ t2 agent onboard Already funded \u2192 just mint a key
|
|
32977
33198
|
`
|
|
32978
33199
|
);
|
|
32979
|
-
group.command("onboard").description("Fund credit (gasless USDC/USDsui) + mint an API key for this wallet.").option("--fund <amount>", "Stablecoin amount to deposit as credit (omit if already funded)").option("--asset <asset>", "USDC (default) or USDsui", "USDC").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33200
|
+
group.command("onboard").description("Fund credit (gasless USDC/USDsui) + mint an API key for this wallet.").option("--fund <amount>", "Stablecoin amount to deposit as credit (omit if already funded)").option("--asset <asset>", "USDC (default) or USDsui", "USDC").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(
|
|
32980
33201
|
async (opts) => {
|
|
32981
33202
|
try {
|
|
32982
|
-
const base = opts.api ??
|
|
33203
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
32983
33204
|
const agent = await withAgent({ keyPath: opts.key });
|
|
32984
33205
|
const address = agent.address();
|
|
32985
33206
|
if (opts.fund !== void 0) {
|
|
@@ -33037,10 +33258,10 @@ Subcommands:
|
|
|
33037
33258
|
);
|
|
33038
33259
|
group.command("topup").argument("<amount>", "Stablecoin amount to deposit as credit").description(
|
|
33039
33260
|
"Top up this wallet's t2000 credit with gasless USDC/USDsui (no new key). The 'never runs dry' primitive \u2014 call it on a 402 or a schedule."
|
|
33040
|
-
).option("--asset <asset>", "USDC (default) or USDsui", "USDC").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33261
|
+
).option("--asset <asset>", "USDC (default) or USDsui", "USDC").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(
|
|
33041
33262
|
async (amount, opts) => {
|
|
33042
33263
|
try {
|
|
33043
|
-
const base = opts.api ??
|
|
33264
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33044
33265
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33045
33266
|
const funded = await fundCredit(agent, base, amount, opts.asset);
|
|
33046
33267
|
if (isJsonMode()) {
|
|
@@ -33064,9 +33285,9 @@ Subcommands:
|
|
|
33064
33285
|
);
|
|
33065
33286
|
group.command("register").description(
|
|
33066
33287
|
"Register this wallet on-chain as an Agent ID (sponsored, gasless). Idempotent \u2014 safe to re-run."
|
|
33067
|
-
).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33288
|
+
).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(async (opts) => {
|
|
33068
33289
|
try {
|
|
33069
|
-
const base = opts.api ??
|
|
33290
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33070
33291
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33071
33292
|
const address = agent.address();
|
|
33072
33293
|
const reg = await registerWallet({ keypair: agent.keypair, address, base });
|
|
@@ -33094,9 +33315,9 @@ Subcommands:
|
|
|
33094
33315
|
});
|
|
33095
33316
|
group.command("link").argument("<owner>", "The owner's Sui address (Passport) to propose").description(
|
|
33096
33317
|
"Propose an owner for this agent (two-sided \u2014 the owner must then confirm). Sponsored, gasless."
|
|
33097
|
-
).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33318
|
+
).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(async (owner, opts) => {
|
|
33098
33319
|
try {
|
|
33099
|
-
const base = opts.api ??
|
|
33320
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33100
33321
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33101
33322
|
const address = agent.address();
|
|
33102
33323
|
if (!isValidSuiAddress(owner)) {
|
|
@@ -33133,9 +33354,9 @@ Subcommands:
|
|
|
33133
33354
|
});
|
|
33134
33355
|
group.command("confirm").argument("<agent>", "The agent Sui address to confirm ownership of").description(
|
|
33135
33356
|
"Confirm ownership of an agent that proposed you as its owner. Sponsored, gasless."
|
|
33136
|
-
).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33357
|
+
).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(async (agentAddress, opts) => {
|
|
33137
33358
|
try {
|
|
33138
|
-
const base = opts.api ??
|
|
33359
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33139
33360
|
const owner = await withAgent({ keyPath: opts.key });
|
|
33140
33361
|
const address = owner.address();
|
|
33141
33362
|
const { digest } = await runSponsoredTx({
|
|
@@ -33159,7 +33380,7 @@ Subcommands:
|
|
|
33159
33380
|
});
|
|
33160
33381
|
group.command("profile").description(
|
|
33161
33382
|
"Set this agent's public profile (name \xB7 image \xB7 description \xB7 links). Signed, no gas \u2014 shows in the directory."
|
|
33162
|
-
).option("--name <name>", "Display name").option("--image <url>", "Image URL (https)").option("--description <text>", "Short description").option("--website <url>", "Website link (https)").option("--twitter <url>", "X / Twitter link (https)").option("--github <url>", "GitHub link (https)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33383
|
+
).option("--name <name>", "Display name").option("--image <url>", "Image URL (https)").option("--description <text>", "Short description").option("--website <url>", "Website link (https)").option("--twitter <url>", "X / Twitter link (https)").option("--github <url>", "GitHub link (https)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(
|
|
33163
33384
|
async (opts) => {
|
|
33164
33385
|
try {
|
|
33165
33386
|
if (!(opts.name || opts.image || opts.description || opts.website || opts.twitter || opts.github)) {
|
|
@@ -33167,7 +33388,7 @@ Subcommands:
|
|
|
33167
33388
|
"Provide at least one of --name, --image, --description, --website, --twitter, --github."
|
|
33168
33389
|
);
|
|
33169
33390
|
}
|
|
33170
|
-
const base = opts.api ??
|
|
33391
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33171
33392
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33172
33393
|
const address = agent.address();
|
|
33173
33394
|
const challenge = await fetchJson(`${base}/agent/challenge`, {
|
|
@@ -33211,7 +33432,7 @@ Subcommands:
|
|
|
33211
33432
|
).option("--mcp-endpoint <url>", "Your agent service endpoint (https)").option(
|
|
33212
33433
|
"--payment-methods <list>",
|
|
33213
33434
|
'Comma-separated methods you accept, e.g. "x402"'
|
|
33214
|
-
).option("--price <usdc>", "Price per call in USDC (e.g. 0.02) \u2014 buyers pay this").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33435
|
+
).option("--price <usdc>", "Price per call in USDC (e.g. 0.02) \u2014 buyers pay this").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(
|
|
33215
33436
|
async (opts) => {
|
|
33216
33437
|
try {
|
|
33217
33438
|
if (opts.mcpEndpoint === void 0 && opts.paymentMethods === void 0 && opts.price === void 0) {
|
|
@@ -33225,7 +33446,7 @@ Subcommands:
|
|
|
33225
33446
|
throw new Error(`--price must be a positive number (got "${opts.price}").`);
|
|
33226
33447
|
}
|
|
33227
33448
|
}
|
|
33228
|
-
const base = opts.api ??
|
|
33449
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33229
33450
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33230
33451
|
const address = agent.address();
|
|
33231
33452
|
const prepareBody = { address };
|
|
@@ -33274,10 +33495,10 @@ Subcommands:
|
|
|
33274
33495
|
"Header to inject into upstream calls (repeatable; e.g. your API key)",
|
|
33275
33496
|
collectHeader,
|
|
33276
33497
|
{}
|
|
33277
|
-
).option("--method <method>", "Upstream method: GET or POST (default POST)").option("--price <usdc>", "Price per call in USDC (e.g. 0.02)").option("--remove", "Take down the deployed service").option("--gateway <url>", `Gateway base URL (default ${DEFAULT_GATEWAY})`).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33498
|
+
).option("--method <method>", "Upstream method: GET or POST (default POST)").option("--price <usdc>", "Price per call in USDC (e.g. 0.02)").option("--remove", "Take down the deployed service").option("--gateway <url>", `Gateway base URL (default ${DEFAULT_GATEWAY})`).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(
|
|
33278
33499
|
async (opts) => {
|
|
33279
33500
|
try {
|
|
33280
|
-
const base = opts.api ??
|
|
33501
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33281
33502
|
const gateway = opts.gateway ?? DEFAULT_GATEWAY;
|
|
33282
33503
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33283
33504
|
const address = agent.address();
|
|
@@ -33389,8 +33610,8 @@ Subcommands:
|
|
|
33389
33610
|
maxPrice,
|
|
33390
33611
|
force: opts.force
|
|
33391
33612
|
});
|
|
33392
|
-
const
|
|
33393
|
-
const receipt =
|
|
33613
|
+
const body2 = result.body;
|
|
33614
|
+
const receipt = body2?.receipt;
|
|
33394
33615
|
const chargedMicros = receipt?.chargedMicros ?? receipt?.grossMicros;
|
|
33395
33616
|
const paidUsd = typeof chargedMicros === "number" ? chargedMicros / 1e6 : opts.amount ? Number.parseFloat(opts.amount) : result.cost ?? 0;
|
|
33396
33617
|
if (isJsonMode()) {
|
|
@@ -33400,7 +33621,7 @@ Subcommands:
|
|
|
33400
33621
|
paid: result.paid,
|
|
33401
33622
|
cost: result.cost,
|
|
33402
33623
|
receipt,
|
|
33403
|
-
response:
|
|
33624
|
+
response: body2?.response
|
|
33404
33625
|
});
|
|
33405
33626
|
return;
|
|
33406
33627
|
}
|
|
@@ -33425,10 +33646,10 @@ Subcommands:
|
|
|
33425
33646
|
printKeyValue("Settlement tx", receipt.forwardDigest);
|
|
33426
33647
|
}
|
|
33427
33648
|
}
|
|
33428
|
-
if (
|
|
33649
|
+
if (body2?.response !== void 0) {
|
|
33429
33650
|
printBlank();
|
|
33430
33651
|
printInfo("Service response:");
|
|
33431
|
-
printLine(JSON.stringify(
|
|
33652
|
+
printLine(JSON.stringify(body2.response, null, 2));
|
|
33432
33653
|
}
|
|
33433
33654
|
printBlank();
|
|
33434
33655
|
} catch (error) {
|
|
@@ -33466,10 +33687,10 @@ Subcommands:
|
|
|
33466
33687
|
});
|
|
33467
33688
|
group.command("handle").argument("<label>", "Handle label (3\u201320 chars: lowercase a\u2013z, 0\u20139, hyphens)").description(
|
|
33468
33689
|
"Claim <label>.agent-id.sui \u2192 this wallet (custody-minted, gasless). Use --release to give it up."
|
|
33469
|
-
).option("--release", "Release (revoke) this handle instead of claiming it").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${
|
|
33690
|
+
).option("--release", "Release (revoke) this handle instead of claiming it").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(
|
|
33470
33691
|
async (label, opts) => {
|
|
33471
33692
|
try {
|
|
33472
|
-
const base = opts.api ??
|
|
33693
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33473
33694
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33474
33695
|
const address = agent.address();
|
|
33475
33696
|
const challenge = await fetchJson(`${base}/agent/challenge`, {
|
|
@@ -33526,6 +33747,8 @@ Examples:
|
|
|
33526
33747
|
$ t2 balance Show USDC / USDsui / SUI holdings
|
|
33527
33748
|
$ t2 send 5 USDC alice.sui Send 5 USDC (gasless; asset required)
|
|
33528
33749
|
$ t2 swap 100 USDC SUI Swap 100 USDC for SUI via Cetus
|
|
33750
|
+
$ t2 chat "Summarize Sui in 3 lines" Private inference (OpenAI-compatible; needs T2000_API_KEY)
|
|
33751
|
+
$ t2 models List the Private API model catalog
|
|
33529
33752
|
$ t2 pay <url> --estimate Preview an x402 service's price + input schema (no payment)
|
|
33530
33753
|
$ t2 services search "image" Discover x402 services in the gateway catalog
|
|
33531
33754
|
$ t2 limit set --daily 100 Change the daily spend cap (default $100/day)
|
|
@@ -33540,6 +33763,7 @@ Examples:
|
|
|
33540
33763
|
registerSend(program3);
|
|
33541
33764
|
registerSwap(program3);
|
|
33542
33765
|
registerPay(program3);
|
|
33766
|
+
registerChat(program3);
|
|
33543
33767
|
registerServices(program3);
|
|
33544
33768
|
registerLimit(program3);
|
|
33545
33769
|
registerMcp(program3);
|