@t2000/cli 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/{dist-PMYELDIE.js → dist-UVKQOQSP.js} +270 -58
- package/dist/dist-UVKQOQSP.js.map +1 -0
- package/dist/index.js +266 -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,76 @@ 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
|
+
printBlank();
|
|
32437
|
+
for (const m of models) {
|
|
32438
|
+
const price = m.inputPer1M != null ? ` \u2014 $${m.inputPer1M}/$${m.outputPer1M} per 1M` : "";
|
|
32439
|
+
const priv = m.privacy ? ` [${m.privacy}]` : "";
|
|
32440
|
+
printLine(` ${m.id}${priv}${price}`);
|
|
32441
|
+
}
|
|
32442
|
+
printBlank();
|
|
32443
|
+
} catch (error) {
|
|
32444
|
+
handleError(error);
|
|
32445
|
+
}
|
|
32446
|
+
});
|
|
32447
|
+
}
|
|
32448
|
+
|
|
32229
32449
|
// src/commands/services/search.ts
|
|
32230
32450
|
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
32231
32451
|
|
|
@@ -32580,7 +32800,7 @@ function registerMcpStart(parent) {
|
|
|
32580
32800
|
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
32801
|
let mod2;
|
|
32582
32802
|
try {
|
|
32583
|
-
mod2 = await import("./dist-
|
|
32803
|
+
mod2 = await import("./dist-UVKQOQSP.js");
|
|
32584
32804
|
} catch {
|
|
32585
32805
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
32586
32806
|
process.exit(1);
|
|
@@ -32921,7 +33141,7 @@ For MCP-aware clients (Claude Desktop, Cursor, Windsurf), prefer
|
|
|
32921
33141
|
|
|
32922
33142
|
// src/commands/agent/index.ts
|
|
32923
33143
|
import { createHash } from "crypto";
|
|
32924
|
-
var
|
|
33144
|
+
var DEFAULT_API_BASE3 = process.env.T2000_API_URL ?? "https://api.t2000.ai/v1";
|
|
32925
33145
|
var DEFAULT_GATEWAY = process.env.T2000_GATEWAY_URL ?? "https://mpp.t2000.ai";
|
|
32926
33146
|
var DEFAULT_RAIL = process.env.T2000_RAIL_URL ?? "https://x402.t2000.ai";
|
|
32927
33147
|
function collectHeader(value, previous) {
|
|
@@ -32976,10 +33196,10 @@ Subcommands:
|
|
|
32976
33196
|
$ t2 agent onboard Already funded \u2192 just mint a key
|
|
32977
33197
|
`
|
|
32978
33198
|
);
|
|
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 ${
|
|
33199
|
+
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
33200
|
async (opts) => {
|
|
32981
33201
|
try {
|
|
32982
|
-
const base = opts.api ??
|
|
33202
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
32983
33203
|
const agent = await withAgent({ keyPath: opts.key });
|
|
32984
33204
|
const address = agent.address();
|
|
32985
33205
|
if (opts.fund !== void 0) {
|
|
@@ -33037,10 +33257,10 @@ Subcommands:
|
|
|
33037
33257
|
);
|
|
33038
33258
|
group.command("topup").argument("<amount>", "Stablecoin amount to deposit as credit").description(
|
|
33039
33259
|
"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 ${
|
|
33260
|
+
).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
33261
|
async (amount, opts) => {
|
|
33042
33262
|
try {
|
|
33043
|
-
const base = opts.api ??
|
|
33263
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33044
33264
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33045
33265
|
const funded = await fundCredit(agent, base, amount, opts.asset);
|
|
33046
33266
|
if (isJsonMode()) {
|
|
@@ -33064,9 +33284,9 @@ Subcommands:
|
|
|
33064
33284
|
);
|
|
33065
33285
|
group.command("register").description(
|
|
33066
33286
|
"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 ${
|
|
33287
|
+
).option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE3})`).action(async (opts) => {
|
|
33068
33288
|
try {
|
|
33069
|
-
const base = opts.api ??
|
|
33289
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33070
33290
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33071
33291
|
const address = agent.address();
|
|
33072
33292
|
const reg = await registerWallet({ keypair: agent.keypair, address, base });
|
|
@@ -33094,9 +33314,9 @@ Subcommands:
|
|
|
33094
33314
|
});
|
|
33095
33315
|
group.command("link").argument("<owner>", "The owner's Sui address (Passport) to propose").description(
|
|
33096
33316
|
"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 ${
|
|
33317
|
+
).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
33318
|
try {
|
|
33099
|
-
const base = opts.api ??
|
|
33319
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33100
33320
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33101
33321
|
const address = agent.address();
|
|
33102
33322
|
if (!isValidSuiAddress(owner)) {
|
|
@@ -33133,9 +33353,9 @@ Subcommands:
|
|
|
33133
33353
|
});
|
|
33134
33354
|
group.command("confirm").argument("<agent>", "The agent Sui address to confirm ownership of").description(
|
|
33135
33355
|
"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 ${
|
|
33356
|
+
).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
33357
|
try {
|
|
33138
|
-
const base = opts.api ??
|
|
33358
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33139
33359
|
const owner = await withAgent({ keyPath: opts.key });
|
|
33140
33360
|
const address = owner.address();
|
|
33141
33361
|
const { digest } = await runSponsoredTx({
|
|
@@ -33159,7 +33379,7 @@ Subcommands:
|
|
|
33159
33379
|
});
|
|
33160
33380
|
group.command("profile").description(
|
|
33161
33381
|
"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 ${
|
|
33382
|
+
).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
33383
|
async (opts) => {
|
|
33164
33384
|
try {
|
|
33165
33385
|
if (!(opts.name || opts.image || opts.description || opts.website || opts.twitter || opts.github)) {
|
|
@@ -33167,7 +33387,7 @@ Subcommands:
|
|
|
33167
33387
|
"Provide at least one of --name, --image, --description, --website, --twitter, --github."
|
|
33168
33388
|
);
|
|
33169
33389
|
}
|
|
33170
|
-
const base = opts.api ??
|
|
33390
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33171
33391
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33172
33392
|
const address = agent.address();
|
|
33173
33393
|
const challenge = await fetchJson(`${base}/agent/challenge`, {
|
|
@@ -33211,7 +33431,7 @@ Subcommands:
|
|
|
33211
33431
|
).option("--mcp-endpoint <url>", "Your agent service endpoint (https)").option(
|
|
33212
33432
|
"--payment-methods <list>",
|
|
33213
33433
|
'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 ${
|
|
33434
|
+
).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
33435
|
async (opts) => {
|
|
33216
33436
|
try {
|
|
33217
33437
|
if (opts.mcpEndpoint === void 0 && opts.paymentMethods === void 0 && opts.price === void 0) {
|
|
@@ -33225,7 +33445,7 @@ Subcommands:
|
|
|
33225
33445
|
throw new Error(`--price must be a positive number (got "${opts.price}").`);
|
|
33226
33446
|
}
|
|
33227
33447
|
}
|
|
33228
|
-
const base = opts.api ??
|
|
33448
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33229
33449
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33230
33450
|
const address = agent.address();
|
|
33231
33451
|
const prepareBody = { address };
|
|
@@ -33274,10 +33494,10 @@ Subcommands:
|
|
|
33274
33494
|
"Header to inject into upstream calls (repeatable; e.g. your API key)",
|
|
33275
33495
|
collectHeader,
|
|
33276
33496
|
{}
|
|
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 ${
|
|
33497
|
+
).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
33498
|
async (opts) => {
|
|
33279
33499
|
try {
|
|
33280
|
-
const base = opts.api ??
|
|
33500
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33281
33501
|
const gateway = opts.gateway ?? DEFAULT_GATEWAY;
|
|
33282
33502
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33283
33503
|
const address = agent.address();
|
|
@@ -33389,8 +33609,8 @@ Subcommands:
|
|
|
33389
33609
|
maxPrice,
|
|
33390
33610
|
force: opts.force
|
|
33391
33611
|
});
|
|
33392
|
-
const
|
|
33393
|
-
const receipt =
|
|
33612
|
+
const body2 = result.body;
|
|
33613
|
+
const receipt = body2?.receipt;
|
|
33394
33614
|
const chargedMicros = receipt?.chargedMicros ?? receipt?.grossMicros;
|
|
33395
33615
|
const paidUsd = typeof chargedMicros === "number" ? chargedMicros / 1e6 : opts.amount ? Number.parseFloat(opts.amount) : result.cost ?? 0;
|
|
33396
33616
|
if (isJsonMode()) {
|
|
@@ -33400,7 +33620,7 @@ Subcommands:
|
|
|
33400
33620
|
paid: result.paid,
|
|
33401
33621
|
cost: result.cost,
|
|
33402
33622
|
receipt,
|
|
33403
|
-
response:
|
|
33623
|
+
response: body2?.response
|
|
33404
33624
|
});
|
|
33405
33625
|
return;
|
|
33406
33626
|
}
|
|
@@ -33425,10 +33645,10 @@ Subcommands:
|
|
|
33425
33645
|
printKeyValue("Settlement tx", receipt.forwardDigest);
|
|
33426
33646
|
}
|
|
33427
33647
|
}
|
|
33428
|
-
if (
|
|
33648
|
+
if (body2?.response !== void 0) {
|
|
33429
33649
|
printBlank();
|
|
33430
33650
|
printInfo("Service response:");
|
|
33431
|
-
printLine(JSON.stringify(
|
|
33651
|
+
printLine(JSON.stringify(body2.response, null, 2));
|
|
33432
33652
|
}
|
|
33433
33653
|
printBlank();
|
|
33434
33654
|
} catch (error) {
|
|
@@ -33466,10 +33686,10 @@ Subcommands:
|
|
|
33466
33686
|
});
|
|
33467
33687
|
group.command("handle").argument("<label>", "Handle label (3\u201320 chars: lowercase a\u2013z, 0\u20139, hyphens)").description(
|
|
33468
33688
|
"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 ${
|
|
33689
|
+
).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
33690
|
async (label, opts) => {
|
|
33471
33691
|
try {
|
|
33472
|
-
const base = opts.api ??
|
|
33692
|
+
const base = opts.api ?? DEFAULT_API_BASE3;
|
|
33473
33693
|
const agent = await withAgent({ keyPath: opts.key });
|
|
33474
33694
|
const address = agent.address();
|
|
33475
33695
|
const challenge = await fetchJson(`${base}/agent/challenge`, {
|
|
@@ -33526,6 +33746,8 @@ Examples:
|
|
|
33526
33746
|
$ t2 balance Show USDC / USDsui / SUI holdings
|
|
33527
33747
|
$ t2 send 5 USDC alice.sui Send 5 USDC (gasless; asset required)
|
|
33528
33748
|
$ t2 swap 100 USDC SUI Swap 100 USDC for SUI via Cetus
|
|
33749
|
+
$ t2 chat "Summarize Sui in 3 lines" Private inference (OpenAI-compatible; needs T2000_API_KEY)
|
|
33750
|
+
$ t2 models List the Private API model catalog
|
|
33529
33751
|
$ t2 pay <url> --estimate Preview an x402 service's price + input schema (no payment)
|
|
33530
33752
|
$ t2 services search "image" Discover x402 services in the gateway catalog
|
|
33531
33753
|
$ t2 limit set --daily 100 Change the daily spend cap (default $100/day)
|
|
@@ -33540,6 +33762,7 @@ Examples:
|
|
|
33540
33762
|
registerSend(program3);
|
|
33541
33763
|
registerSwap(program3);
|
|
33542
33764
|
registerPay(program3);
|
|
33765
|
+
registerChat(program3);
|
|
33543
33766
|
registerServices(program3);
|
|
33544
33767
|
registerLimit(program3);
|
|
33545
33768
|
registerMcp(program3);
|