@t2000/cli 5.12.0 → 5.13.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.
@@ -80332,7 +80332,7 @@ Through this wallet you can reach essentially any major external API, billed to
80332
80332
  CRITICAL: When the user asks to use any external or paid API, names a provider (e.g. "via fal.ai", "with ElevenLabs"), or requests a capability one of the services above provides, DO NOT say you cannot reach that service, that it isn't on an allowlist, or that there's no connector \u2014 and do NOT fall back to writing a script for the user to run. You CAN do it directly through this wallet. Use t2000_services to discover the endpoint and request shape, then t2000_pay to execute, then show the user the result (display image/audio URLs returned in the response).
80333
80333
 
80334
80334
  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.`;
80335
- var PKG_VERSION = "5.12.0";
80335
+ var PKG_VERSION = "5.13.0";
80336
80336
  console.log = (...args) => console.error("[log]", ...args);
80337
80337
  console.warn = (...args) => console.error("[warn]", ...args);
80338
80338
  async function startMcpServer(opts) {
@@ -80398,4 +80398,4 @@ mime-types/index.js:
80398
80398
  @scure/bip39/index.js:
80399
80399
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
80400
80400
  */
80401
- //# sourceMappingURL=dist-EC5V2CMY.js.map
80401
+ //# sourceMappingURL=dist-VBMR5MD5.js.map
package/dist/index.js CHANGED
@@ -32580,7 +32580,7 @@ function registerMcpStart(parent) {
32580
32580
  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
32581
  let mod2;
32582
32582
  try {
32583
- mod2 = await import("./dist-EC5V2CMY.js");
32583
+ mod2 = await import("./dist-VBMR5MD5.js");
32584
32584
  } catch {
32585
32585
  console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
32586
32586
  process.exit(1);
@@ -32920,8 +32920,16 @@ For MCP-aware clients (Claude Desktop, Cursor, Windsurf), prefer
32920
32920
  }
32921
32921
 
32922
32922
  // src/commands/agent/index.ts
32923
+ import { createHash } from "crypto";
32923
32924
  var DEFAULT_API_BASE2 = process.env.T2000_API_URL ?? "https://api.t2000.ai/v1";
32924
32925
  var DEFAULT_GATEWAY = process.env.T2000_GATEWAY_URL ?? "https://mpp.t2000.ai";
32926
+ function collectHeader(value, previous) {
32927
+ const [key, ...rest] = value.split("=");
32928
+ if (key && rest.length > 0) {
32929
+ previous[key.trim()] = rest.join("=").trim();
32930
+ }
32931
+ return previous;
32932
+ }
32925
32933
  function normalizeTopupAsset(input) {
32926
32934
  return input?.toLowerCase() === "usdsui" ? "USDsui" : "USDC";
32927
32935
  }
@@ -33245,6 +33253,100 @@ Subcommands:
33245
33253
  }
33246
33254
  }
33247
33255
  );
33256
+ group.command("deploy").description(
33257
+ "Deploy a paid service by wrapping any HTTP API \u2014 t2000 hosts the proxy (your key stays server-side, encrypted), lists it, and settles payments. No server needed. Use --remove to take it down. [Agent Commerce]"
33258
+ ).option("--upstream <url>", "The upstream API URL to wrap (https)").option(
33259
+ "--header <k=v>",
33260
+ "Header to inject into upstream calls (repeatable; e.g. your API key)",
33261
+ collectHeader,
33262
+ {}
33263
+ ).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_BASE2})`).action(
33264
+ async (opts) => {
33265
+ try {
33266
+ const base = opts.api ?? DEFAULT_API_BASE2;
33267
+ const gateway = opts.gateway ?? DEFAULT_GATEWAY;
33268
+ const agent = await withAgent({ keyPath: opts.key });
33269
+ const address = agent.address();
33270
+ if (opts.remove) {
33271
+ const ts2 = Date.now();
33272
+ const msg2 = `t2000-deploy-remove:${ts2}`;
33273
+ const { signature: signature2 } = await agent.keypair.signPersonalMessage(
33274
+ new TextEncoder().encode(msg2)
33275
+ );
33276
+ await fetchJson(`${gateway}/deploy/config`, {
33277
+ method: "DELETE",
33278
+ body: { address, timestamp: ts2, signature: signature2 }
33279
+ });
33280
+ await runSponsoredTx({
33281
+ keypair: agent.keypair,
33282
+ actor: address,
33283
+ prepareUrl: `${base}/agent/service/prepare`,
33284
+ prepareBody: { address, mcpEndpoint: "" },
33285
+ submitUrl: `${base}/agent/service/submit`
33286
+ }).catch(() => void 0);
33287
+ if (isJsonMode()) {
33288
+ printJson({ address, removed: true });
33289
+ return;
33290
+ }
33291
+ printBlank();
33292
+ printSuccess("Service taken down.");
33293
+ printBlank();
33294
+ return;
33295
+ }
33296
+ if (!(opts.upstream && opts.price)) {
33297
+ throw new Error("Both --upstream and --price are required (or use --remove).");
33298
+ }
33299
+ const price = Number.parseFloat(opts.price);
33300
+ if (Number.isNaN(price) || price <= 0) {
33301
+ throw new Error(`--price must be a positive number (got "${opts.price}").`);
33302
+ }
33303
+ const method = (opts.method ?? "POST").toUpperCase() === "GET" ? "GET" : "POST";
33304
+ const headers = opts.header ?? {};
33305
+ const ts = Date.now();
33306
+ const bodyHash = createHash("sha256").update(`${opts.upstream}|${method}|${JSON.stringify(headers)}`).digest("hex");
33307
+ const msg = `t2000-deploy:${ts}:${bodyHash}`;
33308
+ const { signature } = await agent.keypair.signPersonalMessage(
33309
+ new TextEncoder().encode(msg)
33310
+ );
33311
+ await fetchJson(`${gateway}/deploy/config`, {
33312
+ method: "POST",
33313
+ body: {
33314
+ address,
33315
+ timestamp: ts,
33316
+ signature,
33317
+ upstreamUrl: opts.upstream,
33318
+ method,
33319
+ headers
33320
+ }
33321
+ });
33322
+ const { digest } = await runSponsoredTx({
33323
+ keypair: agent.keypair,
33324
+ actor: address,
33325
+ prepareUrl: `${base}/agent/service/prepare`,
33326
+ prepareBody: {
33327
+ address,
33328
+ mcpEndpoint: `${gateway}/deploy/${address}`,
33329
+ paymentMethods: ["x402"],
33330
+ priceUsdc: opts.price
33331
+ },
33332
+ submitUrl: `${base}/agent/service/submit`
33333
+ });
33334
+ if (isJsonMode()) {
33335
+ printJson({ address, upstream: opts.upstream, price, digest });
33336
+ return;
33337
+ }
33338
+ printBlank();
33339
+ printSuccess("Service deployed \u2014 live + listed in the directory.");
33340
+ printKeyValue("Wraps", opts.upstream);
33341
+ printKeyValue("Price", `$${opts.price} USDC`);
33342
+ printKeyValue("Tx", String(digest));
33343
+ printInfo(`Buyers: t2 agent pay ${truncateAddress(address)}`);
33344
+ printBlank();
33345
+ } catch (error) {
33346
+ handleError(error);
33347
+ }
33348
+ }
33349
+ );
33248
33350
  group.command("pay").argument("<seller>", "The seller agent's Sui address").description(
33249
33351
  "Pay a seller agent for a service (gateway-mediated, USDC). t2000 collects, keeps a small fee, and forwards the rest to the seller \u2014 with a receipt. [Agent Commerce]"
33250
33352
  ).option("--amount <usdc>", "Override the price (default: the seller's declared price)").option("--data <json>", "Service input forwarded to the seller's endpoint").option("--max-price <usdc>", "Max USDC to auto-approve (default 1.00, or --amount)").option(