@t2000/sdk 10.13.4 → 10.14.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/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/{commerce-Cj8Zh9Tm.d.cts → commerce-C4D3VxBu.d.cts} +1 -1
- package/dist/{commerce-Cj8Zh9Tm.d.ts → commerce-C4D3VxBu.d.ts} +1 -1
- package/dist/index.cjs +107 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -3
- package/dist/index.d.ts +71 -3
- package/dist/index.js +101 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1517,7 +1517,7 @@ declare function listServices(base: string, filter?: {
|
|
|
1517
1517
|
declare function fetchService(base: string, agent: string, slug: string): Promise<ServiceListing>;
|
|
1518
1518
|
/**
|
|
1519
1519
|
* The buyer-requirements gate (SPEC_ACP_JOB_SPEC_V1 §4.1) — ONE implementation
|
|
1520
|
-
* shared by `t2 job
|
|
1520
|
+
* shared by `t2 job hire`, MCP `t2000_job_hire`, and the console's
|
|
1521
1521
|
* hire-prepare, so a hire can never fund with an unusable brief.
|
|
1522
1522
|
*
|
|
1523
1523
|
* 1. Listing has no `requirements` → the buyer may omit (anything passes).
|
|
@@ -1517,7 +1517,7 @@ declare function listServices(base: string, filter?: {
|
|
|
1517
1517
|
declare function fetchService(base: string, agent: string, slug: string): Promise<ServiceListing>;
|
|
1518
1518
|
/**
|
|
1519
1519
|
* The buyer-requirements gate (SPEC_ACP_JOB_SPEC_V1 §4.1) — ONE implementation
|
|
1520
|
-
* shared by `t2 job
|
|
1520
|
+
* shared by `t2 job hire`, MCP `t2000_job_hire`, and the console's
|
|
1521
1521
|
* hire-prepare, so a hire can never fund with an unusable brief.
|
|
1522
1522
|
*
|
|
1523
1523
|
* 1. Listing has no `requirements` → the buyer may omit (anything passes).
|
package/dist/index.cjs
CHANGED
|
@@ -3546,6 +3546,106 @@ async function getJobSpec(base, hash) {
|
|
|
3546
3546
|
}
|
|
3547
3547
|
return content;
|
|
3548
3548
|
}
|
|
3549
|
+
async function fetchJson(url, init) {
|
|
3550
|
+
const res = await fetch(url, {
|
|
3551
|
+
method: init?.method ?? "GET",
|
|
3552
|
+
headers: init?.body ? { "Content-Type": "application/json" } : void 0,
|
|
3553
|
+
body: init?.body ? JSON.stringify(init.body) : void 0
|
|
3554
|
+
});
|
|
3555
|
+
const json = await res.json().catch(() => ({}));
|
|
3556
|
+
if (!res.ok) {
|
|
3557
|
+
const err = json.error;
|
|
3558
|
+
const msg = typeof err === "string" ? err : err?.message ?? `HTTP ${res.status}`;
|
|
3559
|
+
throw new Error(msg);
|
|
3560
|
+
}
|
|
3561
|
+
return json;
|
|
3562
|
+
}
|
|
3563
|
+
async function listOpenJobs(base, filter = {}) {
|
|
3564
|
+
const params = new URLSearchParams();
|
|
3565
|
+
if (filter.status) params.set("status", filter.status);
|
|
3566
|
+
if (filter.query) params.set("q", filter.query);
|
|
3567
|
+
if (filter.buyer) params.set("buyer", filter.buyer);
|
|
3568
|
+
if (filter.seller) params.set("seller", filter.seller);
|
|
3569
|
+
if (filter.limit) params.set("limit", String(filter.limit));
|
|
3570
|
+
const qs = params.size > 0 ? `?${params.toString()}` : "";
|
|
3571
|
+
const json = await fetchJson(`${base}/open-jobs${qs}`);
|
|
3572
|
+
return json.openJobs ?? [];
|
|
3573
|
+
}
|
|
3574
|
+
async function getOpenJob(base, id) {
|
|
3575
|
+
const json = await fetchJson(
|
|
3576
|
+
`${base}/open-jobs/${encodeURIComponent(id.trim())}`
|
|
3577
|
+
);
|
|
3578
|
+
return json.openJob;
|
|
3579
|
+
}
|
|
3580
|
+
async function signedChallenge(base, signer, action, id) {
|
|
3581
|
+
const address = signer.getAddress();
|
|
3582
|
+
const challenge = await fetchJson(`${base}/agent/challenge`, {
|
|
3583
|
+
method: "POST",
|
|
3584
|
+
body: { address }
|
|
3585
|
+
});
|
|
3586
|
+
const nonce = challenge.nonce;
|
|
3587
|
+
if (!nonce) {
|
|
3588
|
+
throw new Error("Failed to get a challenge nonce.");
|
|
3589
|
+
}
|
|
3590
|
+
const message = new TextEncoder().encode(
|
|
3591
|
+
id ? `t2000-open-${action}:${nonce}:${id}` : `t2000-open-${action}:${nonce}`
|
|
3592
|
+
);
|
|
3593
|
+
const { signature } = await signer.signPersonalMessage(message);
|
|
3594
|
+
return { address, nonce, signature };
|
|
3595
|
+
}
|
|
3596
|
+
async function createOpenJob(base, signer, input) {
|
|
3597
|
+
const auth = await signedChallenge(base, signer, "create");
|
|
3598
|
+
const json = await fetchJson(`${base}/open-jobs`, {
|
|
3599
|
+
method: "POST",
|
|
3600
|
+
body: { ...auth, ...input }
|
|
3601
|
+
});
|
|
3602
|
+
return json.openJob;
|
|
3603
|
+
}
|
|
3604
|
+
async function claimOpenJob(base, signer, id) {
|
|
3605
|
+
const auth = await signedChallenge(base, signer, "claim", id);
|
|
3606
|
+
const json = await fetchJson(
|
|
3607
|
+
`${base}/open-jobs/${encodeURIComponent(id)}/claim`,
|
|
3608
|
+
{ method: "POST", body: auth }
|
|
3609
|
+
);
|
|
3610
|
+
return json.openJob ?? null;
|
|
3611
|
+
}
|
|
3612
|
+
async function unclaimOpenJob(base, signer, id) {
|
|
3613
|
+
const auth = await signedChallenge(base, signer, "unclaim", id);
|
|
3614
|
+
await fetchJson(`${base}/open-jobs/${encodeURIComponent(id)}/unclaim`, {
|
|
3615
|
+
method: "POST",
|
|
3616
|
+
body: auth
|
|
3617
|
+
});
|
|
3618
|
+
}
|
|
3619
|
+
async function cancelOpenJob(base, signer, id) {
|
|
3620
|
+
const auth = await signedChallenge(base, signer, "cancel", id);
|
|
3621
|
+
await fetchJson(`${base}/open-jobs/${encodeURIComponent(id)}/cancel`, {
|
|
3622
|
+
method: "POST",
|
|
3623
|
+
body: auth
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
async function fundOpenJob(base, signer, id) {
|
|
3627
|
+
const address = signer.getAddress();
|
|
3628
|
+
const encoded = encodeURIComponent(id.trim());
|
|
3629
|
+
const prep = await fetchJson(`${base}/open-jobs/${encoded}/fund-prepare`, {
|
|
3630
|
+
method: "POST",
|
|
3631
|
+
body: { address }
|
|
3632
|
+
});
|
|
3633
|
+
const nonce = prep.nonce;
|
|
3634
|
+
const txBytes = prep.txBytes;
|
|
3635
|
+
if (!(nonce && txBytes)) {
|
|
3636
|
+
throw new Error("Failed to prepare the funding transaction.");
|
|
3637
|
+
}
|
|
3638
|
+
const { signature } = await signer.signTransaction(utils.fromBase64(txBytes));
|
|
3639
|
+
const json = await fetchJson(`${base}/open-jobs/${encoded}/fund-submit`, {
|
|
3640
|
+
method: "POST",
|
|
3641
|
+
body: { nonce, address, signature }
|
|
3642
|
+
});
|
|
3643
|
+
const digest = json.digest;
|
|
3644
|
+
if (!digest) {
|
|
3645
|
+
throw new Error("The funding transaction did not go through.");
|
|
3646
|
+
}
|
|
3647
|
+
return { digest, jobId: json.jobId ?? null };
|
|
3648
|
+
}
|
|
3549
3649
|
|
|
3550
3650
|
// src/index.ts
|
|
3551
3651
|
init_coinSelection();
|
|
@@ -4430,15 +4530,18 @@ exports.buildRevokeLeafTx = buildRevokeLeafTx;
|
|
|
4430
4530
|
exports.buildSendTx = buildSendTx;
|
|
4431
4531
|
exports.buildSwapTx = buildSwapTx;
|
|
4432
4532
|
exports.buildTokenizeTx = buildTokenizeTx;
|
|
4533
|
+
exports.cancelOpenJob = cancelOpenJob;
|
|
4433
4534
|
exports.chatCompletion = chatCompletion;
|
|
4434
4535
|
exports.chatCompletionStream = chatCompletionStream;
|
|
4435
4536
|
exports.checkPositiveAmount = checkPositiveAmount;
|
|
4436
4537
|
exports.checkSuiAddress = checkSuiAddress;
|
|
4538
|
+
exports.claimOpenJob = claimOpenJob;
|
|
4437
4539
|
exports.classifyAction = classifyAction;
|
|
4438
4540
|
exports.classifyLabel = classifyLabel;
|
|
4439
4541
|
exports.classifyTransaction = classifyTransaction;
|
|
4440
4542
|
exports.clearLimits = clearLimits;
|
|
4441
4543
|
exports.composeTx = composeTx;
|
|
4544
|
+
exports.createOpenJob = createOpenJob;
|
|
4442
4545
|
exports.dailySpentToday = dailySpentToday;
|
|
4443
4546
|
exports.deriveAllowedAddressesFromPtb = deriveAllowedAddressesFromPtb;
|
|
4444
4547
|
exports.deserializeCetusRoute = deserializeCetusRoute;
|
|
@@ -4457,6 +4560,7 @@ exports.formatAssetAmount = formatAssetAmount;
|
|
|
4457
4560
|
exports.formatSui = formatSui;
|
|
4458
4561
|
exports.formatUsd = formatUsd;
|
|
4459
4562
|
exports.fullHandle = fullHandle;
|
|
4563
|
+
exports.fundOpenJob = fundOpenJob;
|
|
4460
4564
|
exports.generateKeypair = generateKeypair;
|
|
4461
4565
|
exports.getAddress = getAddress;
|
|
4462
4566
|
exports.getCoinMeta = getCoinMeta;
|
|
@@ -4465,6 +4569,7 @@ exports.getDecimalsForCoinType = getDecimalsForCoinType;
|
|
|
4465
4569
|
exports.getJob = getJob;
|
|
4466
4570
|
exports.getJobSpec = getJobSpec;
|
|
4467
4571
|
exports.getLimits = getLimits;
|
|
4572
|
+
exports.getOpenJob = getOpenJob;
|
|
4468
4573
|
exports.getSponsoredSwapProviders = getSponsoredSwapProviders;
|
|
4469
4574
|
exports.getSuiClient = getSuiClient;
|
|
4470
4575
|
exports.getSuiGrpcClient = getSuiGrpcClient;
|
|
@@ -4476,6 +4581,7 @@ exports.isInRegistry = isInRegistry;
|
|
|
4476
4581
|
exports.jobActionsFor = jobActionsFor;
|
|
4477
4582
|
exports.keypairFromPrivateKey = keypairFromPrivateKey;
|
|
4478
4583
|
exports.listModels = listModels;
|
|
4584
|
+
exports.listOpenJobs = listOpenJobs;
|
|
4479
4585
|
exports.listServices = listServices;
|
|
4480
4586
|
exports.loadKey = loadKey;
|
|
4481
4587
|
exports.looksLikeSuiNs = looksLikeSuiNs;
|
|
@@ -4517,6 +4623,7 @@ exports.stableToRaw = stableToRaw;
|
|
|
4517
4623
|
exports.suiToMist = suiToMist;
|
|
4518
4624
|
exports.throwIfSimulationFailed = throwIfSimulationFailed;
|
|
4519
4625
|
exports.truncateAddress = truncateAddress;
|
|
4626
|
+
exports.unclaimOpenJob = unclaimOpenJob;
|
|
4520
4627
|
exports.usdcToRaw = usdcToRaw;
|
|
4521
4628
|
exports.validateAddress = validateAddress;
|
|
4522
4629
|
exports.validateAgentCoinParams = validateAgentCoinParams;
|