@t2000/cli 9.11.0 → 9.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.
- package/README.md +4 -1
- package/dist/{chunk-KHOU3HJU.js → chunk-XPCTSCTS.js} +91 -1
- package/dist/chunk-XPCTSCTS.js.map +1 -0
- package/dist/{dist-LRBJUCHL.js → dist-WU4EKM5J.js} +590 -24
- package/dist/{dist-LRBJUCHL.js.map → dist-WU4EKM5J.js.map} +1 -1
- package/dist/{dist-24ZYDGZH.js → dist-ZIRF2Q6M.js} +12 -2
- package/dist/index.js +58 -53
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-KHOU3HJU.js.map +0 -1
- /package/dist/{dist-24ZYDGZH.js.map → dist-ZIRF2Q6M.js.map} +0 -0
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
CLOCK_ID,
|
|
13
13
|
COIN_REGISTRY,
|
|
14
14
|
DEFAULT_API_BASE,
|
|
15
|
+
DEFAULT_COMMERCE_API_BASE,
|
|
15
16
|
DEFAULT_GRPC_URL,
|
|
16
17
|
DEFAULT_NETWORK,
|
|
17
18
|
ETH_TYPE,
|
|
@@ -96,6 +97,7 @@ import {
|
|
|
96
97
|
extractTxSender,
|
|
97
98
|
fallbackLabel,
|
|
98
99
|
fetchAllCoins,
|
|
100
|
+
fetchOffering,
|
|
99
101
|
findSwapRoute,
|
|
100
102
|
formatAssetAmount,
|
|
101
103
|
formatSui,
|
|
@@ -107,6 +109,7 @@ import {
|
|
|
107
109
|
getDecimals,
|
|
108
110
|
getDecimalsForCoinType,
|
|
109
111
|
getJob,
|
|
112
|
+
getJobSpec,
|
|
110
113
|
getLimits,
|
|
111
114
|
getSponsoredSwapProviders,
|
|
112
115
|
getSuiClient,
|
|
@@ -119,6 +122,7 @@ import {
|
|
|
119
122
|
jobActionsFor,
|
|
120
123
|
keypairFromPrivateKey,
|
|
121
124
|
listModels,
|
|
125
|
+
listOfferings,
|
|
122
126
|
loadKey,
|
|
123
127
|
looksLikeSuiNs,
|
|
124
128
|
mapMoveAbortCode,
|
|
@@ -135,6 +139,7 @@ import {
|
|
|
135
139
|
preflightPay,
|
|
136
140
|
preflightSend,
|
|
137
141
|
preflightSwap,
|
|
142
|
+
putJobSpec,
|
|
138
143
|
queryBalance,
|
|
139
144
|
queryHistory,
|
|
140
145
|
queryTransaction,
|
|
@@ -166,7 +171,7 @@ import {
|
|
|
166
171
|
verifyReceipt,
|
|
167
172
|
walletExists,
|
|
168
173
|
writeLimitsFile
|
|
169
|
-
} from "./chunk-
|
|
174
|
+
} from "./chunk-XPCTSCTS.js";
|
|
170
175
|
import "./chunk-634W6JCI.js";
|
|
171
176
|
import "./chunk-BHQGGFE6.js";
|
|
172
177
|
import "./chunk-GCC33SG5.js";
|
|
@@ -192,6 +197,7 @@ export {
|
|
|
192
197
|
CLOCK_ID,
|
|
193
198
|
COIN_REGISTRY,
|
|
194
199
|
DEFAULT_API_BASE,
|
|
200
|
+
DEFAULT_COMMERCE_API_BASE,
|
|
195
201
|
DEFAULT_GRPC_URL,
|
|
196
202
|
DEFAULT_NETWORK,
|
|
197
203
|
ETH_TYPE,
|
|
@@ -276,6 +282,7 @@ export {
|
|
|
276
282
|
extractTxSender,
|
|
277
283
|
fallbackLabel,
|
|
278
284
|
fetchAllCoins,
|
|
285
|
+
fetchOffering,
|
|
279
286
|
findSwapRoute,
|
|
280
287
|
formatAssetAmount,
|
|
281
288
|
formatSui,
|
|
@@ -287,6 +294,7 @@ export {
|
|
|
287
294
|
getDecimals,
|
|
288
295
|
getDecimalsForCoinType,
|
|
289
296
|
getJob,
|
|
297
|
+
getJobSpec,
|
|
290
298
|
getLimits,
|
|
291
299
|
getSponsoredSwapProviders,
|
|
292
300
|
getSuiClient,
|
|
@@ -299,6 +307,7 @@ export {
|
|
|
299
307
|
jobActionsFor,
|
|
300
308
|
keypairFromPrivateKey,
|
|
301
309
|
listModels,
|
|
310
|
+
listOfferings,
|
|
302
311
|
loadKey,
|
|
303
312
|
looksLikeSuiNs,
|
|
304
313
|
mapMoveAbortCode,
|
|
@@ -315,6 +324,7 @@ export {
|
|
|
315
324
|
preflightPay,
|
|
316
325
|
preflightSend,
|
|
317
326
|
preflightSwap,
|
|
327
|
+
putJobSpec,
|
|
318
328
|
queryBalance,
|
|
319
329
|
queryHistory,
|
|
320
330
|
queryTransaction,
|
|
@@ -347,4 +357,4 @@ export {
|
|
|
347
357
|
walletExists,
|
|
348
358
|
writeLimitsFile
|
|
349
359
|
};
|
|
350
|
-
//# sourceMappingURL=dist-
|
|
360
|
+
//# sourceMappingURL=dist-ZIRF2Q6M.js.map
|
package/dist/index.js
CHANGED
|
@@ -7,16 +7,19 @@ import {
|
|
|
7
7
|
MAX_JOB_USDC,
|
|
8
8
|
T2000,
|
|
9
9
|
clearLimits,
|
|
10
|
+
fetchOffering,
|
|
10
11
|
formatUsd,
|
|
11
12
|
generateKeypair,
|
|
12
13
|
getAddress,
|
|
13
14
|
getJob,
|
|
15
|
+
getJobSpec,
|
|
14
16
|
getLimits,
|
|
15
17
|
getSuiClient,
|
|
16
18
|
hasLimits,
|
|
17
19
|
jobActionsFor,
|
|
18
20
|
keypairFromPrivateKey,
|
|
19
21
|
listModels,
|
|
22
|
+
putJobSpec,
|
|
20
23
|
saveBech32,
|
|
21
24
|
saveKey,
|
|
22
25
|
setLimits,
|
|
@@ -25,7 +28,7 @@ import {
|
|
|
25
28
|
verifyJobForSeller,
|
|
26
29
|
verifyReceipt,
|
|
27
30
|
walletExists
|
|
28
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-XPCTSCTS.js";
|
|
29
32
|
import "./chunk-634W6JCI.js";
|
|
30
33
|
import "./chunk-BHQGGFE6.js";
|
|
31
34
|
import "./chunk-GCC33SG5.js";
|
|
@@ -22278,7 +22281,7 @@ async function runEstimate(url, opts) {
|
|
|
22278
22281
|
let req = accepts.find((a) => a.scheme === "exact" && a.network?.startsWith("sui:")) ?? accepts[0];
|
|
22279
22282
|
let dialect = "x402";
|
|
22280
22283
|
if (!req) {
|
|
22281
|
-
const { parseMppSuiChallenge } = await import("./dist-
|
|
22284
|
+
const { parseMppSuiChallenge } = await import("./dist-ZIRF2Q6M.js");
|
|
22282
22285
|
const challenge = await parseMppSuiChallenge(response);
|
|
22283
22286
|
if (!challenge) {
|
|
22284
22287
|
throw new Error(
|
|
@@ -23370,7 +23373,7 @@ function registerMcpStart(parent) {
|
|
|
23370
23373
|
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) => {
|
|
23371
23374
|
let mod;
|
|
23372
23375
|
try {
|
|
23373
|
-
mod = await import("./dist-
|
|
23376
|
+
mod = await import("./dist-WU4EKM5J.js");
|
|
23374
23377
|
} catch {
|
|
23375
23378
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
23376
23379
|
process.exit(1);
|
|
@@ -24512,11 +24515,10 @@ function registerCheck(program3) {
|
|
|
24512
24515
|
|
|
24513
24516
|
// src/commands/job.ts
|
|
24514
24517
|
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
24515
|
-
import { createHash
|
|
24518
|
+
import { createHash } from "crypto";
|
|
24516
24519
|
import { readFile as readFile3 } from "fs/promises";
|
|
24517
24520
|
|
|
24518
24521
|
// src/lib/offerings.ts
|
|
24519
|
-
import { createHash } from "crypto";
|
|
24520
24522
|
async function fetchJson3(url, init) {
|
|
24521
24523
|
const res = await fetch(url, {
|
|
24522
24524
|
method: init?.method ?? "GET",
|
|
@@ -24531,51 +24533,6 @@ async function fetchJson3(url, init) {
|
|
|
24531
24533
|
}
|
|
24532
24534
|
return json;
|
|
24533
24535
|
}
|
|
24534
|
-
async function fetchOffering(base, agent, slug) {
|
|
24535
|
-
const json = await fetchJson3(
|
|
24536
|
-
`${base}/offerings?agent=${encodeURIComponent(agent)}`
|
|
24537
|
-
);
|
|
24538
|
-
const rows = json.offerings ?? [];
|
|
24539
|
-
const match = rows.find((o) => o.slug === slug.trim().toLowerCase());
|
|
24540
|
-
if (!match) {
|
|
24541
|
-
const live = rows.filter((o) => !o.retired).map((o) => o.slug);
|
|
24542
|
-
throw new Error(
|
|
24543
|
-
`Agent ${truncateAddress(agent)} has no offering "${slug}".` + (live.length > 0 ? ` Live offerings: ${live.join(", ")}` : "")
|
|
24544
|
-
);
|
|
24545
|
-
}
|
|
24546
|
-
if (match.retired) {
|
|
24547
|
-
throw new Error(
|
|
24548
|
-
`Offering "${slug}" is retired \u2014 the seller no longer sells it.`
|
|
24549
|
-
);
|
|
24550
|
-
}
|
|
24551
|
-
return match;
|
|
24552
|
-
}
|
|
24553
|
-
async function putJobSpec(base, content) {
|
|
24554
|
-
const json = await fetchJson3(`${base}/job/spec`, {
|
|
24555
|
-
method: "POST",
|
|
24556
|
-
body: { content }
|
|
24557
|
-
});
|
|
24558
|
-
const hash = json.hash;
|
|
24559
|
-
if (!hash) {
|
|
24560
|
-
throw new Error("Failed to store the job spec.");
|
|
24561
|
-
}
|
|
24562
|
-
return hash;
|
|
24563
|
-
}
|
|
24564
|
-
async function getJobSpec(base, hash) {
|
|
24565
|
-
const clean = hash.trim().toLowerCase().replace(/^0x/, "");
|
|
24566
|
-
const json = await fetchJson3(`${base}/job/spec/${clean}`);
|
|
24567
|
-
const content = json.content;
|
|
24568
|
-
if (content === void 0) {
|
|
24569
|
-
throw new Error("No spec stored for this hash.");
|
|
24570
|
-
}
|
|
24571
|
-
const actual = createHash("sha256").update(content, "utf8").digest("hex");
|
|
24572
|
-
if (actual !== clean) {
|
|
24573
|
-
throw new Error(
|
|
24574
|
-
"Spec content does NOT match its hash \u2014 the store returned tampered data. Do not trust it."
|
|
24575
|
-
);
|
|
24576
|
-
}
|
|
24577
|
-
return content;
|
|
24578
|
-
}
|
|
24579
24536
|
|
|
24580
24537
|
// src/commands/job.ts
|
|
24581
24538
|
var DEFAULT_API_BASE5 = process.env.T2000_API_URL ?? "https://api.t2000.ai/v1";
|
|
@@ -24600,7 +24557,7 @@ async function resolveCommitment(input) {
|
|
|
24600
24557
|
} catch {
|
|
24601
24558
|
bytes = Buffer.from(input, "utf8");
|
|
24602
24559
|
}
|
|
24603
|
-
return `0x${
|
|
24560
|
+
return `0x${createHash("sha256").update(bytes).digest("hex")}`;
|
|
24604
24561
|
}
|
|
24605
24562
|
function stateColor(state) {
|
|
24606
24563
|
if (state === "released") return import_picocolors15.default.green(state);
|
|
@@ -24898,12 +24855,60 @@ Buying an OFFERING (t2 ACP) \u2014 price + terms come from the listing:
|
|
|
24898
24855
|
printBlank();
|
|
24899
24856
|
printSuccess(note);
|
|
24900
24857
|
if (digest) printKeyValue("Tx", digest);
|
|
24858
|
+
if (verb === "release") {
|
|
24859
|
+
printInfo(`Rate the work (builds the seller's on-chain-backed reputation): t2 job review ${truncateAddress(jobId)} --stars 5`);
|
|
24860
|
+
}
|
|
24901
24861
|
printBlank();
|
|
24902
24862
|
} catch (error) {
|
|
24903
24863
|
handleError(error);
|
|
24904
24864
|
}
|
|
24905
24865
|
});
|
|
24906
24866
|
}
|
|
24867
|
+
group.command("review").argument("<jobId>", "The Job object id (0x\u2026) of a RELEASED job you paid for").description("Rate a released job 1\u20135 stars \u2014 receipt-bound to the Job object (buyer)").requiredOption("--stars <1-5>", "Star rating, 1 (poor) to 5 (excellent)").option("--text <text>", "Optional short review (max 400 chars)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE5})`).action(async (jobId, opts) => {
|
|
24868
|
+
try {
|
|
24869
|
+
const stars = Number.parseInt(opts.stars, 10);
|
|
24870
|
+
if (!Number.isInteger(stars) || stars < 1 || stars > 5) {
|
|
24871
|
+
throw new Error(`--stars must be an integer 1\u20135 (got "${opts.stars}").`);
|
|
24872
|
+
}
|
|
24873
|
+
const base = opts.api ?? DEFAULT_API_BASE5;
|
|
24874
|
+
const agent = await withAgent({ keyPath: opts.key });
|
|
24875
|
+
const address = agent.address();
|
|
24876
|
+
const challenge = await fetchJson3(`${base}/agent/challenge`, {
|
|
24877
|
+
method: "POST",
|
|
24878
|
+
body: { address }
|
|
24879
|
+
});
|
|
24880
|
+
const nonce = challenge.nonce;
|
|
24881
|
+
if (!nonce) throw new Error("Failed to get a challenge nonce.");
|
|
24882
|
+
const payload = {
|
|
24883
|
+
jobId: validateAddress(jobId),
|
|
24884
|
+
stars,
|
|
24885
|
+
text: opts.text?.trim() || null
|
|
24886
|
+
};
|
|
24887
|
+
const payloadHash = createHash("sha256").update(JSON.stringify(payload), "utf8").digest("hex");
|
|
24888
|
+
const message = new TextEncoder().encode(
|
|
24889
|
+
`t2000-job-review:${nonce}:${payloadHash}`
|
|
24890
|
+
);
|
|
24891
|
+
const { signature } = await agent.keypair.signPersonalMessage(message);
|
|
24892
|
+
const response = await fetchJson3(`${base}/job/review`, {
|
|
24893
|
+
method: "POST",
|
|
24894
|
+
body: { address, nonce, signature, payload }
|
|
24895
|
+
});
|
|
24896
|
+
if (isJsonMode()) {
|
|
24897
|
+
printJson(response);
|
|
24898
|
+
return;
|
|
24899
|
+
}
|
|
24900
|
+
printBlank();
|
|
24901
|
+
printSuccess(`Review saved \u2014 ${"\u2605".repeat(stars)}${"\u2606".repeat(5 - stars)} on job ${truncateAddress(payload.jobId)}.`);
|
|
24902
|
+
const review = response.review;
|
|
24903
|
+
if (review?.seller) {
|
|
24904
|
+
printKeyValue("Seller page", `https://agents.t2000.ai/${review.seller}`);
|
|
24905
|
+
}
|
|
24906
|
+
printInfo("Re-run with different --stars/--text to edit your review.");
|
|
24907
|
+
printBlank();
|
|
24908
|
+
} catch (error) {
|
|
24909
|
+
handleError(error);
|
|
24910
|
+
}
|
|
24911
|
+
});
|
|
24907
24912
|
group.command("spec").argument("<jobId>", "The Job object id (0x\u2026)").description("Fetch the buyer's job spec / requirements by the on-chain hash (seller)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE5})`).action(async (jobId, opts) => {
|
|
24908
24913
|
try {
|
|
24909
24914
|
const client = getSuiClient();
|
|
@@ -25010,7 +25015,7 @@ Buying an OFFERING (t2 ACP) \u2014 price + terms come from the listing:
|
|
|
25010
25015
|
|
|
25011
25016
|
// src/commands/offering.ts
|
|
25012
25017
|
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
25013
|
-
import { createHash as
|
|
25018
|
+
import { createHash as createHash2 } from "crypto";
|
|
25014
25019
|
import { readFile as readFile4 } from "fs/promises";
|
|
25015
25020
|
var DEFAULT_API_BASE6 = process.env.T2000_API_URL ?? "https://api.t2000.ai/v1";
|
|
25016
25021
|
async function signedOfferingAction(opts) {
|
|
@@ -25024,7 +25029,7 @@ async function signedOfferingAction(opts) {
|
|
|
25024
25029
|
if (!nonce) {
|
|
25025
25030
|
throw new Error("Failed to get a challenge nonce.");
|
|
25026
25031
|
}
|
|
25027
|
-
const payloadHash =
|
|
25032
|
+
const payloadHash = createHash2("sha256").update(JSON.stringify(opts.payload), "utf8").digest("hex");
|
|
25028
25033
|
const message = new TextEncoder().encode(
|
|
25029
25034
|
`t2000-agent-offering:${nonce}:${payloadHash}`
|
|
25030
25035
|
);
|