@t2000/sdk 10.28.0 → 10.29.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/index.cjs +32 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3821,6 +3821,36 @@ async function getJobSpec(base, hash) {
|
|
|
3821
3821
|
}
|
|
3822
3822
|
return content;
|
|
3823
3823
|
}
|
|
3824
|
+
|
|
3825
|
+
// src/job-spec-envelope.ts
|
|
3826
|
+
var TITLE_PREFIX_RE = /^title\s*:\s*(.+)$/i;
|
|
3827
|
+
var ENVELOPE_TITLE_MAX = 80;
|
|
3828
|
+
function customHireEnvelope(brief, title, now) {
|
|
3829
|
+
const body2 = brief.trim();
|
|
3830
|
+
let t = title?.trim() ?? "";
|
|
3831
|
+
if (!t) {
|
|
3832
|
+
const first = body2.split("\n").find((l) => l.trim())?.trim() ?? "";
|
|
3833
|
+
const prefixed = TITLE_PREFIX_RE.exec(first);
|
|
3834
|
+
t = (prefixed ? prefixed[1] : first).trim();
|
|
3835
|
+
}
|
|
3836
|
+
if (t.length > ENVELOPE_TITLE_MAX) {
|
|
3837
|
+
t = `${t.slice(0, ENVELOPE_TITLE_MAX - 1).trimEnd()}\u2026`;
|
|
3838
|
+
}
|
|
3839
|
+
return JSON.stringify({
|
|
3840
|
+
type: "t2-acp-custom@1",
|
|
3841
|
+
title: t || "Custom job",
|
|
3842
|
+
brief: body2,
|
|
3843
|
+
createdAtMs: now
|
|
3844
|
+
});
|
|
3845
|
+
}
|
|
3846
|
+
function isCustomHireEnvelope(text) {
|
|
3847
|
+
try {
|
|
3848
|
+
const parsed = JSON.parse(text);
|
|
3849
|
+
return (parsed.type === "t2-acp-custom@1" || parsed.type === "t2-acp-invite@1") && typeof parsed.brief === "string" && parsed.brief.trim().length > 0;
|
|
3850
|
+
} catch {
|
|
3851
|
+
return false;
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3824
3854
|
async function fetchJson(url, init) {
|
|
3825
3855
|
const res = await fetch(url, {
|
|
3826
3856
|
method: init?.method ?? "GET",
|
|
@@ -4423,6 +4453,7 @@ exports.classifySendAsset = classifySendAsset;
|
|
|
4423
4453
|
exports.classifyTransaction = classifyTransaction;
|
|
4424
4454
|
exports.clearLimits = clearLimits;
|
|
4425
4455
|
exports.composeTx = composeTx;
|
|
4456
|
+
exports.customHireEnvelope = customHireEnvelope;
|
|
4426
4457
|
exports.dailySpentToday = dailySpentToday;
|
|
4427
4458
|
exports.deriveAllowedAddressesFromPtb = deriveAllowedAddressesFromPtb;
|
|
4428
4459
|
exports.deserializeCetusRoute = deserializeCetusRoute;
|
|
@@ -4459,6 +4490,7 @@ exports.hasLimits = hasLimits;
|
|
|
4459
4490
|
exports.invalidSendAssetMessage = invalidSendAssetMessage;
|
|
4460
4491
|
exports.isAllowedAsset = isAllowedAsset;
|
|
4461
4492
|
exports.isCetusRouteFresh = isCetusRouteFresh;
|
|
4493
|
+
exports.isCustomHireEnvelope = isCustomHireEnvelope;
|
|
4462
4494
|
exports.isInRegistry = isInRegistry;
|
|
4463
4495
|
exports.jobActionsFor = jobActionsFor;
|
|
4464
4496
|
exports.keypairFromPrivateKey = keypairFromPrivateKey;
|