@lucid-agents/taskmarket 1.46.0 → 1.47.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/agent-compatibility.json +1 -1
- package/dist/{api-56KWZFR4.js → api-ENHCGR7K.js} +2 -2
- package/dist/{channels-YKCZU2Q7.js → channels-LX2DTMKZ.js} +4 -4
- package/dist/{chunk-MMODVSSS.js → chunk-4MAQWPJ2.js} +1 -1
- package/dist/{chunk-O5C2CWWL.js → chunk-54J54BK7.js} +5 -5
- package/dist/{chunk-3MITXF2F.js → chunk-AMT2L4BR.js} +3 -3
- package/dist/{chunk-MUFEOBRQ.js → chunk-AS6EFS2V.js} +2 -1
- package/dist/{chunk-HFG7TSVD.js → chunk-O53R76N3.js} +109 -18
- package/dist/{chunk-AS3N5L25.js → chunk-PDVDVVVF.js} +2 -2
- package/dist/{chunk-66HELSIU.js → chunk-PPJNXEWM.js} +3 -3
- package/dist/{chunk-64NUUQBC.js → chunk-RO5AHGHC.js} +1 -1
- package/dist/{chunk-DPJIDICA.js → chunk-TUP4MTW6.js} +3 -3
- package/dist/{chunk-E3J2J3PZ.js → chunk-V2BCPGOB.js} +8 -8
- package/dist/{chunk-7KZOHF7R.js → chunk-WOPSQ2GZ.js} +1 -1
- package/dist/{chunk-Y3B7POF2.js → chunk-XRM455ZG.js} +41 -5
- package/dist/{doctor-TA3AZMPJ.js → doctor-PEAKIDKS.js} +8 -8
- package/dist/index.js +287 -47
- package/dist/{launch-2RINYQTU.js → launch-CEJWCOQA.js} +11 -11
- package/dist/pi-extensions/xgate.cjs +7 -1
- package/dist/{read-auth-FFCZKAFN.js → read-auth-524RVF3G.js} +3 -3
- package/dist/{reconcile-O6LVP2Z3.js → reconcile-GMYKLZTG.js} +4 -4
- package/dist/{status-FRMTSDIG.js → status-Y6JAL4DR.js} +8 -8
- package/dist/{sync-pull-OUXRL6A2.js → sync-pull-YFIWHI4H.js} +4 -4
- package/dist/{task-access-grants-WV3HVN5V.js → task-access-grants-GXJ6WOQK.js} +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
listWorkerSubmissions,
|
|
15
15
|
submitTaskFiles,
|
|
16
16
|
taskRequirementsOf
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-V2BCPGOB.js";
|
|
18
18
|
import {
|
|
19
19
|
ComputeCreditError,
|
|
20
20
|
applyComputeCreditSetup,
|
|
@@ -39,14 +39,14 @@ import {
|
|
|
39
39
|
withPaymentProtocol,
|
|
40
40
|
x402FeePost,
|
|
41
41
|
x402PaymentProtocol
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-TUP4MTW6.js";
|
|
43
43
|
import {
|
|
44
44
|
signReadAuth
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-PDVDVVVF.js";
|
|
46
46
|
import {
|
|
47
47
|
saveTaskAccessGrant,
|
|
48
48
|
taskAccessGrantHeaders
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-WOPSQ2GZ.js";
|
|
50
50
|
import {
|
|
51
51
|
MPP_TEMPO_DEFAULT_VALIDITY_SECONDS,
|
|
52
52
|
X402PayError,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
setX402PolicyRuleEnabled,
|
|
66
66
|
signSponsoredTempoTransfer,
|
|
67
67
|
signTaskmarketFeePayment
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-XRM455ZG.js";
|
|
69
69
|
import {
|
|
70
70
|
ALL_NETWORKS,
|
|
71
71
|
ApiError,
|
|
@@ -105,6 +105,7 @@ import {
|
|
|
105
105
|
loadKeystore,
|
|
106
106
|
networkNameForChain,
|
|
107
107
|
networkToStamp,
|
|
108
|
+
newIdempotencyKey,
|
|
108
109
|
parseTapPrivateKey,
|
|
109
110
|
paymentProtocolOf,
|
|
110
111
|
readFailureBody,
|
|
@@ -129,7 +130,7 @@ import {
|
|
|
129
130
|
withErrorContext,
|
|
130
131
|
withIdempotentWrite,
|
|
131
132
|
withTapSignature
|
|
132
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-AS6EFS2V.js";
|
|
133
134
|
import {
|
|
134
135
|
AGENT_AVATAR_MAX_BYTES,
|
|
135
136
|
AGENT_HIRES_ROLES,
|
|
@@ -174,6 +175,7 @@ import {
|
|
|
174
175
|
GRANT_MODE_NAMES,
|
|
175
176
|
HIRE_AGENT_AT_CAPACITY,
|
|
176
177
|
HIRE_AGENT_UNAVAILABLE,
|
|
178
|
+
HIRE_LISTING_HIDDEN,
|
|
177
179
|
HIRE_MAX_ACCEPT_WINDOW_SECS,
|
|
178
180
|
HIRE_MIN_ACCEPT_WINDOW_SECS,
|
|
179
181
|
HIRE_SERVICE_ID_MAX_LENGTH,
|
|
@@ -338,6 +340,7 @@ import {
|
|
|
338
340
|
hiddenChecksResult,
|
|
339
341
|
hireAcceptAtCapacity,
|
|
340
342
|
hireAcceptAtCapacityMessage,
|
|
343
|
+
hireListingHiddenMessage,
|
|
341
344
|
hireSelectAtCapacityMessage,
|
|
342
345
|
hireUnavailableAcknowledgeable,
|
|
343
346
|
hireUnavailableMessage,
|
|
@@ -402,7 +405,7 @@ import {
|
|
|
402
405
|
verifierProviderId,
|
|
403
406
|
verifiersUnsupportedOnChain,
|
|
404
407
|
viemChainFor
|
|
405
|
-
} from "./chunk-
|
|
408
|
+
} from "./chunk-O53R76N3.js";
|
|
406
409
|
import "./chunk-S7SJMJ2I.js";
|
|
407
410
|
|
|
408
411
|
// src/index.ts
|
|
@@ -10040,11 +10043,13 @@ function parseMetricAndDropOptions(opts) {
|
|
|
10040
10043
|
}
|
|
10041
10044
|
return { fields };
|
|
10042
10045
|
}
|
|
10043
|
-
async function hireAvailabilityError(hire) {
|
|
10046
|
+
async function hireAvailabilityError(hire, requester) {
|
|
10044
10047
|
let availability;
|
|
10045
10048
|
try {
|
|
10049
|
+
const query4 = new URLSearchParams({ worker: hire.worker });
|
|
10050
|
+
if (requester) query4.set("requester", requester);
|
|
10046
10051
|
availability = await apiGet(
|
|
10047
|
-
`/api/tasks/hire-availability
|
|
10052
|
+
`/api/tasks/hire-availability?${query4.toString()}`
|
|
10048
10053
|
);
|
|
10049
10054
|
} catch (err) {
|
|
10050
10055
|
if (err instanceof ApiError && err.status === 404) return null;
|
|
@@ -10464,7 +10469,8 @@ async function runCreateTask(input, extra = {}) {
|
|
|
10464
10469
|
if ("error" in hire) return void printError(hire.error);
|
|
10465
10470
|
if (hire.hire) body.hire = hire.hire;
|
|
10466
10471
|
if (hire.hire) {
|
|
10467
|
-
const
|
|
10472
|
+
const requesterAddress = await loadKeystore().then((keystore) => keystore.walletAddress).catch(() => void 0);
|
|
10473
|
+
const refusal = await hireAvailabilityError(hire.hire, requesterAddress);
|
|
10468
10474
|
if (refusal) {
|
|
10469
10475
|
return void renderFailure(new Error(refusal.message), { details: { code: refusal.code } });
|
|
10470
10476
|
}
|
|
@@ -13547,7 +13553,7 @@ async function runAgentCommand(options) {
|
|
|
13547
13553
|
try {
|
|
13548
13554
|
const { assertAgentCompatibility } = await import("./compatibility-636WJOEX.js");
|
|
13549
13555
|
const pi = assertAgentCompatibility();
|
|
13550
|
-
const { runAgent } = await import("./launch-
|
|
13556
|
+
const { runAgent } = await import("./launch-CEJWCOQA.js");
|
|
13551
13557
|
result = await runAgent({
|
|
13552
13558
|
model: options.model,
|
|
13553
13559
|
pi,
|
|
@@ -13981,13 +13987,13 @@ function agentManagementCommands() {
|
|
|
13981
13987
|
const status = new Command58("status").description(
|
|
13982
13988
|
"Show the agent channels (locked, charged, refundable), purchases with an unknown outcome, the sandbox and compute credit. Reads only."
|
|
13983
13989
|
).action(async () => {
|
|
13984
|
-
const { collectAgentStatus } = await import("./status-
|
|
13990
|
+
const { collectAgentStatus } = await import("./status-Y6JAL4DR.js");
|
|
13985
13991
|
await run(() => collectAgentStatus());
|
|
13986
13992
|
});
|
|
13987
13993
|
const doctor = new Command58("doctor").description(
|
|
13988
13994
|
"Check that the agent can start: Node and the bundled runtime, wallet and policy, channels, API, sandbox broker, host keys, xgate and RPC. Reads only."
|
|
13989
13995
|
).action(async () => {
|
|
13990
|
-
const { runDoctor } = await import("./doctor-
|
|
13996
|
+
const { runDoctor } = await import("./doctor-PEAKIDKS.js");
|
|
13991
13997
|
const report = await run(() => runDoctor());
|
|
13992
13998
|
if (report && !report.ok) process.exitCode = 1;
|
|
13993
13999
|
});
|
|
@@ -13998,7 +14004,7 @@ function agentManagementCommands() {
|
|
|
13998
14004
|
"Reconcile the open purchases of this channel, as status lists it; also reaches retired channels"
|
|
13999
14005
|
).action(
|
|
14000
14006
|
async (invocationId, options) => {
|
|
14001
|
-
const { reconcileChannelPurchases, reconcileInvocation } = await import("./reconcile-
|
|
14007
|
+
const { reconcileChannelPurchases, reconcileInvocation } = await import("./reconcile-GMYKLZTG.js");
|
|
14002
14008
|
const choice = { rail: options.rail, channel: options.channel };
|
|
14003
14009
|
if (invocationId !== void 0) {
|
|
14004
14010
|
await run(() => reconcileInvocation(invocationId, { choice }));
|
|
@@ -14030,7 +14036,7 @@ function agentManagementCommands() {
|
|
|
14030
14036
|
`Not a USDC amount: ${options.amount} (digits, at most 6 decimals)`
|
|
14031
14037
|
);
|
|
14032
14038
|
}
|
|
14033
|
-
const { openAgentChannels, requestTopUp, selectRail, withdrawalHatch } = await import("./channels-
|
|
14039
|
+
const { openAgentChannels, requestTopUp, selectRail, withdrawalHatch } = await import("./channels-LX2DTMKZ.js");
|
|
14034
14040
|
const { rails } = await openAgentChannels();
|
|
14035
14041
|
const result = await requestTopUp(selectRail(rails, options.rail), amount);
|
|
14036
14042
|
return {
|
|
@@ -14050,8 +14056,8 @@ function agentManagementCommands() {
|
|
|
14050
14056
|
await run(async () => {
|
|
14051
14057
|
await requireExperimental();
|
|
14052
14058
|
const { AGENT_VIEW_VERSION } = await import("./budget-view-J6L7X6EY.js");
|
|
14053
|
-
const { closeChannel, openAgentChannels, selectChannel } = await import("./channels-
|
|
14054
|
-
const { reconcileLeasedPurchase } = await import("./reconcile-
|
|
14059
|
+
const { closeChannel, openAgentChannels, selectChannel } = await import("./channels-LX2DTMKZ.js");
|
|
14060
|
+
const { reconcileLeasedPurchase } = await import("./reconcile-GMYKLZTG.js");
|
|
14055
14061
|
const opened = await openAgentChannels();
|
|
14056
14062
|
const { rail, retired } = selectChannel(opened, options);
|
|
14057
14063
|
const result = await closeChannel(
|
|
@@ -14105,7 +14111,7 @@ function agentManagementCommands() {
|
|
|
14105
14111
|
async (options) => {
|
|
14106
14112
|
await run(async () => {
|
|
14107
14113
|
await requireExperimental();
|
|
14108
|
-
const { runPull } = await import("./sync-pull-
|
|
14114
|
+
const { runPull } = await import("./sync-pull-YFIWHI4H.js");
|
|
14109
14115
|
const { terminalPrompter } = await import("./prompter-LSICEYSQ.js");
|
|
14110
14116
|
return runPull(options, {
|
|
14111
14117
|
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
@@ -16407,7 +16413,9 @@ function cachedInboxLookup(lookup, options = {}) {
|
|
|
16407
16413
|
// src/lib/xmtp-cursor.ts
|
|
16408
16414
|
import fs4 from "fs";
|
|
16409
16415
|
import path2 from "path";
|
|
16410
|
-
var MAX_RECENT_IDS_PER_CONVERSATION =
|
|
16416
|
+
var MAX_RECENT_IDS_PER_CONVERSATION = 5e3;
|
|
16417
|
+
var MAX_CURSOR_RECENT_IDS = 2e4;
|
|
16418
|
+
var MAX_CURSOR_CONVERSATIONS = 1e3;
|
|
16411
16419
|
var CURSOR_OVERLAP_NS = 10n * 60n * 1000000000n;
|
|
16412
16420
|
var CURSOR_FLUSH_DELAY_MS = 1e3;
|
|
16413
16421
|
function xmtpCursorPath(dbDir, walletAddress) {
|
|
@@ -16415,40 +16423,95 @@ function xmtpCursorPath(dbDir, walletAddress) {
|
|
|
16415
16423
|
}
|
|
16416
16424
|
function readCursorFile(filePath) {
|
|
16417
16425
|
const conversations = /* @__PURE__ */ new Map();
|
|
16426
|
+
let prunedBeforeNs = 0n;
|
|
16418
16427
|
try {
|
|
16419
16428
|
const parsed = JSON.parse(fs4.readFileSync(filePath, "utf8"));
|
|
16420
16429
|
if (parsed?.version === 2 && parsed.conversations && typeof parsed.conversations === "object") {
|
|
16430
|
+
if (typeof parsed.prunedBeforeNs === "string" && /^\d+$/.test(parsed.prunedBeforeNs)) {
|
|
16431
|
+
prunedBeforeNs = BigInt(parsed.prunedBeforeNs);
|
|
16432
|
+
}
|
|
16421
16433
|
for (const [conversationId, entry] of Object.entries(parsed.conversations)) {
|
|
16422
16434
|
if (!entry || typeof entry.lastSentAtNs !== "string" || !/^\d+$/.test(entry.lastSentAtNs) || !Array.isArray(entry.recentIds)) {
|
|
16423
16435
|
continue;
|
|
16424
16436
|
}
|
|
16425
|
-
const
|
|
16437
|
+
const lastSentAtNs = BigInt(entry.lastSentAtNs);
|
|
16438
|
+
const recentIds = [];
|
|
16439
|
+
const recentAtNs = [];
|
|
16440
|
+
entry.recentIds.forEach((id, index) => {
|
|
16441
|
+
if (typeof id !== "string") return;
|
|
16442
|
+
const at = entry.recentAtNs?.[index];
|
|
16443
|
+
recentIds.push(id);
|
|
16444
|
+
recentAtNs.push(typeof at === "string" && /^\d+$/.test(at) ? BigInt(at) : lastSentAtNs);
|
|
16445
|
+
});
|
|
16446
|
+
const start = Math.max(0, recentIds.length - MAX_RECENT_IDS_PER_CONVERSATION);
|
|
16447
|
+
const ids = recentIds.slice(start);
|
|
16426
16448
|
conversations.set(conversationId, {
|
|
16427
|
-
lastSentAtNs
|
|
16428
|
-
recentIds,
|
|
16429
|
-
|
|
16449
|
+
lastSentAtNs,
|
|
16450
|
+
recentIds: ids,
|
|
16451
|
+
recentAtNs: recentAtNs.slice(start),
|
|
16452
|
+
known: new Set(ids)
|
|
16430
16453
|
});
|
|
16431
16454
|
}
|
|
16432
16455
|
}
|
|
16433
16456
|
} catch {
|
|
16434
16457
|
}
|
|
16435
|
-
return conversations;
|
|
16458
|
+
return { conversations, prunedBeforeNs };
|
|
16436
16459
|
}
|
|
16437
|
-
function
|
|
16438
|
-
const
|
|
16439
|
-
|
|
16460
|
+
function pruneConversations(state) {
|
|
16461
|
+
const { conversations } = state;
|
|
16462
|
+
if (conversations.size <= MAX_CURSOR_CONVERSATIONS) return;
|
|
16463
|
+
const oldestFirst = [...conversations.entries()].sort(
|
|
16464
|
+
(a, b) => a[1].lastSentAtNs < b[1].lastSentAtNs ? -1 : a[1].lastSentAtNs > b[1].lastSentAtNs ? 1 : 0
|
|
16465
|
+
);
|
|
16466
|
+
for (const [conversationId, entry] of oldestFirst.slice(
|
|
16467
|
+
0,
|
|
16468
|
+
conversations.size - MAX_CURSOR_CONVERSATIONS
|
|
16469
|
+
)) {
|
|
16470
|
+
if (entry.lastSentAtNs > state.prunedBeforeNs) state.prunedBeforeNs = entry.lastSentAtNs;
|
|
16471
|
+
conversations.delete(conversationId);
|
|
16472
|
+
}
|
|
16473
|
+
}
|
|
16474
|
+
function writeCursorFile(filePath, state) {
|
|
16475
|
+
pruneConversations(state);
|
|
16476
|
+
const value = {
|
|
16477
|
+
version: 2,
|
|
16478
|
+
prunedBeforeNs: state.prunedBeforeNs.toString(),
|
|
16479
|
+
conversations: {}
|
|
16480
|
+
};
|
|
16481
|
+
const kept = [];
|
|
16482
|
+
for (const [conversationId, entry] of state.conversations) {
|
|
16483
|
+
const floor = entry.lastSentAtNs - CURSOR_OVERLAP_NS;
|
|
16484
|
+
entry.recentIds.forEach((id, index) => {
|
|
16485
|
+
if (entry.recentAtNs[index] >= floor) {
|
|
16486
|
+
kept.push({ conversationId, id, at: entry.recentAtNs[index] });
|
|
16487
|
+
}
|
|
16488
|
+
});
|
|
16489
|
+
}
|
|
16490
|
+
if (kept.length > MAX_CURSOR_RECENT_IDS) {
|
|
16491
|
+
kept.sort((a, b) => a.at < b.at ? 1 : a.at > b.at ? -1 : 0);
|
|
16492
|
+
kept.length = MAX_CURSOR_RECENT_IDS;
|
|
16493
|
+
}
|
|
16494
|
+
for (const [conversationId, entry] of state.conversations) {
|
|
16440
16495
|
value.conversations[conversationId] = {
|
|
16441
16496
|
lastSentAtNs: entry.lastSentAtNs.toString(),
|
|
16442
|
-
recentIds:
|
|
16497
|
+
recentIds: [],
|
|
16498
|
+
recentAtNs: []
|
|
16443
16499
|
};
|
|
16444
16500
|
}
|
|
16501
|
+
for (const { conversationId, id, at } of kept) {
|
|
16502
|
+
const target = value.conversations[conversationId];
|
|
16503
|
+
target.recentIds.push(id);
|
|
16504
|
+
target.recentAtNs?.push(at.toString());
|
|
16505
|
+
}
|
|
16445
16506
|
fs4.mkdirSync(path2.dirname(filePath), { recursive: true });
|
|
16446
16507
|
const tmpPath = `${filePath}.${process.pid}.tmp`;
|
|
16447
16508
|
fs4.writeFileSync(tmpPath, JSON.stringify(value), { mode: 384 });
|
|
16448
16509
|
fs4.renameSync(tmpPath, filePath);
|
|
16449
16510
|
}
|
|
16450
16511
|
function loadXmtpCursor(filePath, options = {}) {
|
|
16451
|
-
const
|
|
16512
|
+
const state = readCursorFile(filePath);
|
|
16513
|
+
const { conversations } = state;
|
|
16514
|
+
pruneConversations(state);
|
|
16452
16515
|
const flushDelayMs = options.flushDelayMs ?? CURSOR_FLUSH_DELAY_MS;
|
|
16453
16516
|
let dirty = false;
|
|
16454
16517
|
let timer;
|
|
@@ -16462,7 +16525,7 @@ function loadXmtpCursor(filePath, options = {}) {
|
|
|
16462
16525
|
}
|
|
16463
16526
|
dirty = false;
|
|
16464
16527
|
try {
|
|
16465
|
-
writeCursorFile(filePath,
|
|
16528
|
+
writeCursorFile(filePath, state);
|
|
16466
16529
|
} catch (error) {
|
|
16467
16530
|
process.stderr.write(
|
|
16468
16531
|
`xmtp: could not save the listener cursor: ${error instanceof Error ? error.message : String(error)}
|
|
@@ -16474,7 +16537,7 @@ function loadXmtpCursor(filePath, options = {}) {
|
|
|
16474
16537
|
floorFor: (conversationId) => {
|
|
16475
16538
|
const entry = conversations.get(conversationId);
|
|
16476
16539
|
if (!entry) {
|
|
16477
|
-
return void 0;
|
|
16540
|
+
return state.prunedBeforeNs > 0n ? state.prunedBeforeNs : void 0;
|
|
16478
16541
|
}
|
|
16479
16542
|
return entry.lastSentAtNs > CURSOR_OVERLAP_NS ? entry.lastSentAtNs - CURSOR_OVERLAP_NS : 0n;
|
|
16480
16543
|
},
|
|
@@ -16482,7 +16545,7 @@ function loadXmtpCursor(filePath, options = {}) {
|
|
|
16482
16545
|
advance: (message) => {
|
|
16483
16546
|
let entry = conversations.get(message.conversationId);
|
|
16484
16547
|
if (!entry) {
|
|
16485
|
-
entry = { lastSentAtNs: 0n, recentIds: [], known: /* @__PURE__ */ new Set() };
|
|
16548
|
+
entry = { lastSentAtNs: 0n, recentIds: [], recentAtNs: [], known: /* @__PURE__ */ new Set() };
|
|
16486
16549
|
conversations.set(message.conversationId, entry);
|
|
16487
16550
|
}
|
|
16488
16551
|
if (message.sentAtNs > entry.lastSentAtNs) {
|
|
@@ -16491,8 +16554,10 @@ function loadXmtpCursor(filePath, options = {}) {
|
|
|
16491
16554
|
if (!entry.known.has(message.id)) {
|
|
16492
16555
|
entry.known.add(message.id);
|
|
16493
16556
|
entry.recentIds.push(message.id);
|
|
16557
|
+
entry.recentAtNs.push(message.sentAtNs);
|
|
16494
16558
|
while (entry.recentIds.length > MAX_RECENT_IDS_PER_CONVERSATION) {
|
|
16495
16559
|
const dropped = entry.recentIds.shift();
|
|
16560
|
+
entry.recentAtNs.shift();
|
|
16496
16561
|
if (dropped !== void 0) {
|
|
16497
16562
|
entry.known.delete(dropped);
|
|
16498
16563
|
}
|
|
@@ -17316,6 +17381,16 @@ async function createProductionClient(input, env) {
|
|
|
17316
17381
|
return revocable;
|
|
17317
17382
|
},
|
|
17318
17383
|
inboxIdForAddress,
|
|
17384
|
+
signWithInstallationKey(text) {
|
|
17385
|
+
const sign = asObject(client)?.signWithInstallationKey;
|
|
17386
|
+
if (typeof sign !== "function") {
|
|
17387
|
+
throw new XmtpTransportError(
|
|
17388
|
+
"XMTP SDK client cannot sign with its installation key",
|
|
17389
|
+
"non-retryable"
|
|
17390
|
+
);
|
|
17391
|
+
}
|
|
17392
|
+
return Buffer.from(sign.call(client, text)).toString("hex");
|
|
17393
|
+
},
|
|
17319
17394
|
async setConsentState(targetInboxId, state) {
|
|
17320
17395
|
const clientObject = asObject(client);
|
|
17321
17396
|
if (!clientObject) return;
|
|
@@ -17405,6 +17480,59 @@ async function createXmtpClient(input) {
|
|
|
17405
17480
|
}
|
|
17406
17481
|
return createProductionClient(input, env);
|
|
17407
17482
|
}
|
|
17483
|
+
var networkInboxLookups = /* @__PURE__ */ new Map();
|
|
17484
|
+
async function lookupInboxIdOnNetwork(address3) {
|
|
17485
|
+
const env = resolveXmtpEnv();
|
|
17486
|
+
let lookup = networkInboxLookups.get(env);
|
|
17487
|
+
if (!lookup) {
|
|
17488
|
+
lookup = env === "memory" ? memoryInboxLookup() : sdkNetworkInboxLookup(env);
|
|
17489
|
+
networkInboxLookups.set(env, lookup);
|
|
17490
|
+
}
|
|
17491
|
+
return lookup(address3);
|
|
17492
|
+
}
|
|
17493
|
+
function memoryInboxLookup() {
|
|
17494
|
+
return async (address3) => {
|
|
17495
|
+
const busDir = process.env.TASKMARKET_XMTP_MEMORY_DIR?.trim();
|
|
17496
|
+
return devInboxByAddress.get(address3.toLowerCase()) ?? (busDir ? createFileBus(busDir).lookup(address3) : null);
|
|
17497
|
+
};
|
|
17498
|
+
}
|
|
17499
|
+
function sdkNetworkInboxLookup(env) {
|
|
17500
|
+
let backend;
|
|
17501
|
+
return cachedInboxLookup(async (address3) => {
|
|
17502
|
+
assertXmtpSupported();
|
|
17503
|
+
const sdkModule = asObject(
|
|
17504
|
+
await import("@xmtp/node-sdk").catch((error) => {
|
|
17505
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
17506
|
+
throw new XmtpTransportError(
|
|
17507
|
+
`Could not load @xmtp/node-sdk on ${process.platform}-${process.arch}: ${reason}`,
|
|
17508
|
+
"non-retryable",
|
|
17509
|
+
error
|
|
17510
|
+
);
|
|
17511
|
+
})
|
|
17512
|
+
);
|
|
17513
|
+
const createBackend = sdkModule?.createBackend;
|
|
17514
|
+
const getInboxIdForIdentifier = sdkModule?.getInboxIdForIdentifier;
|
|
17515
|
+
if (typeof createBackend !== "function" || typeof getInboxIdForIdentifier !== "function") {
|
|
17516
|
+
throw new XmtpTransportError(
|
|
17517
|
+
"XMTP SDK cannot resolve an address to an inbox without a client",
|
|
17518
|
+
"non-retryable"
|
|
17519
|
+
);
|
|
17520
|
+
}
|
|
17521
|
+
const resolved = await withRetry(async () => {
|
|
17522
|
+
backend ??= createBackend({ env });
|
|
17523
|
+
try {
|
|
17524
|
+
return await getInboxIdForIdentifier(await backend, {
|
|
17525
|
+
identifier: address3,
|
|
17526
|
+
identifierKind: 0
|
|
17527
|
+
});
|
|
17528
|
+
} catch (error) {
|
|
17529
|
+
backend = void 0;
|
|
17530
|
+
throw error;
|
|
17531
|
+
}
|
|
17532
|
+
}, parseRetryAttempts());
|
|
17533
|
+
return resolved ?? null;
|
|
17534
|
+
});
|
|
17535
|
+
}
|
|
17408
17536
|
function sentRequestStoreFor(client) {
|
|
17409
17537
|
return createSentRequestStore(sentRequestsPath(client.dbPath));
|
|
17410
17538
|
}
|
|
@@ -17673,7 +17801,7 @@ function parseJsonPayload(value) {
|
|
|
17673
17801
|
return parsed;
|
|
17674
17802
|
}
|
|
17675
17803
|
async function resolveInboxId(to) {
|
|
17676
|
-
if (
|
|
17804
|
+
if (isRawInboxId(to)) {
|
|
17677
17805
|
return to;
|
|
17678
17806
|
}
|
|
17679
17807
|
const param = isAddress3(to) ? `address=${encodeURIComponent(to)}` : `agentId=${encodeURIComponent(to)}&chainId=${selectedNetwork().chainId}`;
|
|
@@ -17684,6 +17812,29 @@ async function resolveInboxId(to) {
|
|
|
17684
17812
|
}
|
|
17685
17813
|
return result.inboxId;
|
|
17686
17814
|
}
|
|
17815
|
+
function isRawInboxId(value) {
|
|
17816
|
+
return !isAddress3(value) && value.length === 64 && /^[0-9a-f]+$/.test(value);
|
|
17817
|
+
}
|
|
17818
|
+
async function resolvePeerRuleInboxId(to, inboxIdOnNetwork = lookupInboxIdOnNetwork) {
|
|
17819
|
+
if (isRawInboxId(to)) {
|
|
17820
|
+
return to;
|
|
17821
|
+
}
|
|
17822
|
+
let address3 = to;
|
|
17823
|
+
if (!isAddress3(to)) {
|
|
17824
|
+
const result = await apiGet(
|
|
17825
|
+
`/api/xmtp/resolve?agentId=${encodeURIComponent(to)}&chainId=${selectedNetwork().chainId}`
|
|
17826
|
+
);
|
|
17827
|
+
if (!result.address) {
|
|
17828
|
+
throw new Error(`No XMTP inbox found for agent "${to}"`);
|
|
17829
|
+
}
|
|
17830
|
+
address3 = result.address;
|
|
17831
|
+
}
|
|
17832
|
+
const inboxId = await inboxIdOnNetwork(address3);
|
|
17833
|
+
if (!inboxId) {
|
|
17834
|
+
throw new Error(`No XMTP inbox found on the XMTP network for address ${address3}`);
|
|
17835
|
+
}
|
|
17836
|
+
return inboxId;
|
|
17837
|
+
}
|
|
17687
17838
|
function getDefaultQueryTimeoutMs() {
|
|
17688
17839
|
const raw = process.env.TASKMARKET_XMTP_QUERY_TIMEOUT_MS;
|
|
17689
17840
|
if (!raw) {
|
|
@@ -17703,6 +17854,33 @@ function senderInboxIdFor(keystore, client) {
|
|
|
17703
17854
|
}
|
|
17704
17855
|
return client.inboxId;
|
|
17705
17856
|
}
|
|
17857
|
+
async function proveInstallation(keystore, client) {
|
|
17858
|
+
if (!client.signWithInstallationKey || !/^[0-9a-f]{64}$/.test(client.installationId)) {
|
|
17859
|
+
return void 0;
|
|
17860
|
+
}
|
|
17861
|
+
let issued;
|
|
17862
|
+
try {
|
|
17863
|
+
({ data: issued } = await apiPost(
|
|
17864
|
+
"/api/xmtp/challenge",
|
|
17865
|
+
{
|
|
17866
|
+
deviceId: keystore.deviceId,
|
|
17867
|
+
apiToken: keystore.apiToken,
|
|
17868
|
+
installationId: client.installationId
|
|
17869
|
+
},
|
|
17870
|
+
{ idempotencyKey: newIdempotencyKey() }
|
|
17871
|
+
));
|
|
17872
|
+
} catch (error) {
|
|
17873
|
+
if (error?.status !== 404) throw error;
|
|
17874
|
+
process.stderr.write(
|
|
17875
|
+
"XMTP: this backend does not issue installation challenges yet; registering without a proof.\n"
|
|
17876
|
+
);
|
|
17877
|
+
return void 0;
|
|
17878
|
+
}
|
|
17879
|
+
return {
|
|
17880
|
+
challengeId: issued.challengeId,
|
|
17881
|
+
signature: client.signWithInstallationKey(issued.challenge)
|
|
17882
|
+
};
|
|
17883
|
+
}
|
|
17706
17884
|
var xmtpCommand = new Command78("xmtp").description("Manage XMTP messaging for this agent");
|
|
17707
17885
|
xmtpCommand.hook("preAction", () => {
|
|
17708
17886
|
if (resolveXmtpEnv() !== "memory") assertXmtpSupported();
|
|
@@ -17716,13 +17894,15 @@ xmtpCommand.command("init").description("Initialize XMTP client and register ins
|
|
|
17716
17894
|
existingDbPath: keystore.xmtpDbPath,
|
|
17717
17895
|
keystore
|
|
17718
17896
|
});
|
|
17897
|
+
const installationProof = await proveInstallation(keystore, client);
|
|
17719
17898
|
const { data: status, idempotencyKey } = await apiPost("/api/xmtp/bootstrap", {
|
|
17720
17899
|
deviceId: keystore.deviceId,
|
|
17721
17900
|
apiToken: keystore.apiToken,
|
|
17722
17901
|
inboxId: client.inboxId,
|
|
17723
17902
|
installationId: client.installationId,
|
|
17724
17903
|
dbPath: client.dbPath,
|
|
17725
|
-
clientVersion: process.env.npm_package_version ?? "unknown"
|
|
17904
|
+
clientVersion: process.env.npm_package_version ?? "unknown",
|
|
17905
|
+
...installationProof ? { installationProof } : {}
|
|
17726
17906
|
});
|
|
17727
17907
|
await saveKeystore({
|
|
17728
17908
|
...keystore,
|
|
@@ -17871,7 +18051,7 @@ peersCommand.command("set").description("Set messaging policy for a specific pee
|
|
|
17871
18051
|
throw new Error(`--policy must be one of: ${validPolicies.join(", ")}`);
|
|
17872
18052
|
}
|
|
17873
18053
|
const keystore = await loadKeystore();
|
|
17874
|
-
const peerInboxId = await
|
|
18054
|
+
const peerInboxId = await resolvePeerRuleInboxId(options.to);
|
|
17875
18055
|
const { data: result, idempotencyKey } = await apiPost(
|
|
17876
18056
|
"/api/xmtp/peers",
|
|
17877
18057
|
{
|
|
@@ -17894,7 +18074,7 @@ allowlistCommand.command("add").description("Allow messages from a peer inbox (X
|
|
|
17894
18074
|
existingDbPath: keystore.xmtpDbPath,
|
|
17895
18075
|
keystore
|
|
17896
18076
|
});
|
|
17897
|
-
const targetInboxId = await
|
|
18077
|
+
const targetInboxId = await resolvePeerRuleInboxId(options.to);
|
|
17898
18078
|
if (!client.setConsentState) {
|
|
17899
18079
|
throw new Error("setConsentState not available in this XMTP client mode");
|
|
17900
18080
|
}
|
|
@@ -17910,7 +18090,7 @@ allowlistCommand.command("remove").description("Deny messages from a peer inbox
|
|
|
17910
18090
|
existingDbPath: keystore.xmtpDbPath,
|
|
17911
18091
|
keystore
|
|
17912
18092
|
});
|
|
17913
|
-
const targetInboxId = await
|
|
18093
|
+
const targetInboxId = await resolvePeerRuleInboxId(options.to);
|
|
17914
18094
|
if (!client.setConsentState) {
|
|
17915
18095
|
throw new Error("setConsentState not available in this XMTP client mode");
|
|
17916
18096
|
}
|
|
@@ -17926,7 +18106,7 @@ allowlistCommand.command("check").description("Check the XMTP SDK consent state
|
|
|
17926
18106
|
existingDbPath: keystore.xmtpDbPath,
|
|
17927
18107
|
keystore
|
|
17928
18108
|
});
|
|
17929
|
-
const targetInboxId = await
|
|
18109
|
+
const targetInboxId = await resolvePeerRuleInboxId(options.to);
|
|
17930
18110
|
if (!client.getConsentState) {
|
|
17931
18111
|
throw new Error("getConsentState not available in this XMTP client mode");
|
|
17932
18112
|
}
|
|
@@ -18420,7 +18600,7 @@ function emailReceivedLine(email) {
|
|
|
18420
18600
|
to: email.toAddress,
|
|
18421
18601
|
subject: email.subject,
|
|
18422
18602
|
receivedAt: email.receivedAt,
|
|
18423
|
-
verified: senderVerification === "pass",
|
|
18603
|
+
verified: senderVerification === "pass" || senderVerification === "platform",
|
|
18424
18604
|
senderVerification,
|
|
18425
18605
|
isRead: email.isRead,
|
|
18426
18606
|
command: `taskmarket email read ${email.id}`
|
|
@@ -19128,11 +19308,17 @@ var registerCommand = new Command83("register").description(
|
|
|
19128
19308
|
|
|
19129
19309
|
// src/commands/email/inbox.ts
|
|
19130
19310
|
import { Command as Command84 } from "commander";
|
|
19131
|
-
var inboxCommand2 = new Command84("inbox").description("List emails in your inbox").option("--limit <n>", "Number of emails to return", "20").option("--unread", "Show only unread emails").action(async (opts) => {
|
|
19311
|
+
var inboxCommand2 = new Command84("inbox").description("List emails in your inbox, each with a bodyPreview (use read for the full body)").option("--limit <n>", "Number of emails to return", "20").option("--offset <n>", "Skip this many emails, to page past --limit", "0").option("--unread", "Show only unread emails").action(async (opts) => {
|
|
19312
|
+
const offset = Number(opts.offset);
|
|
19313
|
+
if (!Number.isInteger(offset) || offset < 0) {
|
|
19314
|
+
printError("--offset must be a whole number");
|
|
19315
|
+
return;
|
|
19316
|
+
}
|
|
19132
19317
|
const keystore = await loadKeystore();
|
|
19133
19318
|
const params = new URLSearchParams({
|
|
19134
19319
|
deviceId: keystore.deviceId,
|
|
19135
|
-
limit: opts.limit
|
|
19320
|
+
limit: opts.limit,
|
|
19321
|
+
offset: String(offset)
|
|
19136
19322
|
});
|
|
19137
19323
|
if (opts.unread) {
|
|
19138
19324
|
params.set("unread", "true");
|
|
@@ -19145,7 +19331,25 @@ var inboxCommand2 = new Command84("inbox").description("List emails in your inbo
|
|
|
19145
19331
|
|
|
19146
19332
|
// src/commands/email/read.ts
|
|
19147
19333
|
import { Command as Command85 } from "commander";
|
|
19148
|
-
var
|
|
19334
|
+
var EMAIL_READ_BODY_MAX_CHARS = 32768;
|
|
19335
|
+
function capEmailBodies(email, max) {
|
|
19336
|
+
let truncated = false;
|
|
19337
|
+
const capped = {};
|
|
19338
|
+
for (const key of ["bodyText", "bodyHtml"]) {
|
|
19339
|
+
const value = email[key];
|
|
19340
|
+
if (typeof value === "string" && value.length > max) {
|
|
19341
|
+
let end = max;
|
|
19342
|
+
const last = value.charCodeAt(end - 1);
|
|
19343
|
+
if (last >= 55296 && last <= 56319) end -= 1;
|
|
19344
|
+
capped[key] = value.slice(0, end);
|
|
19345
|
+
truncated = true;
|
|
19346
|
+
}
|
|
19347
|
+
}
|
|
19348
|
+
return { ...email, ...capped, truncated };
|
|
19349
|
+
}
|
|
19350
|
+
var readCommand = new Command85("read").description(
|
|
19351
|
+
`Read an email by ID (marks it as read). Each body is cut at ${EMAIL_READ_BODY_MAX_CHARS} characters unless --full`
|
|
19352
|
+
).argument("<id>", "Email ID").option("--full", "Return the whole stored body instead of the first 32768 characters").action(async (id, opts) => {
|
|
19149
19353
|
const keystore = await loadKeystore();
|
|
19150
19354
|
const params = new URLSearchParams({
|
|
19151
19355
|
deviceId: keystore.deviceId,
|
|
@@ -19154,7 +19358,9 @@ var readCommand = new Command85("read").description("Read an email by ID (marks
|
|
|
19154
19358
|
const result = await apiGet(`/api/emails/get?${params.toString()}`, {
|
|
19155
19359
|
headers: { "x-taskmarket-api-token": keystore.apiToken }
|
|
19156
19360
|
});
|
|
19157
|
-
printResult(
|
|
19361
|
+
printResult(
|
|
19362
|
+
opts.full ? { ...result, truncated: false } : capEmailBodies(result, EMAIL_READ_BODY_MAX_CHARS)
|
|
19363
|
+
);
|
|
19158
19364
|
});
|
|
19159
19365
|
|
|
19160
19366
|
// src/commands/email/send.ts
|
|
@@ -19179,7 +19385,22 @@ var sendCommand = new Command86("send").description("Send an email").requiredOpt
|
|
|
19179
19385
|
|
|
19180
19386
|
// src/commands/email/reply.ts
|
|
19181
19387
|
import { Command as Command87 } from "commander";
|
|
19182
|
-
var
|
|
19388
|
+
var VERIFIED_SENDER_VALUES = ["pass", "platform"];
|
|
19389
|
+
function isVerifiedSender(senderVerification) {
|
|
19390
|
+
return senderVerification != null && VERIFIED_SENDER_VALUES.includes(senderVerification);
|
|
19391
|
+
}
|
|
19392
|
+
function domainOf(address3) {
|
|
19393
|
+
return address3.slice(address3.lastIndexOf("@") + 1).trim().toLowerCase();
|
|
19394
|
+
}
|
|
19395
|
+
function replyNeedsVerifiedSender(original) {
|
|
19396
|
+
if (isVerifiedSender(original.senderVerification)) return false;
|
|
19397
|
+
const platformDomain = original.toAddress ? domainOf(original.toAddress) : "";
|
|
19398
|
+
return platformDomain === "" || domainOf(original.fromAddress) !== platformDomain;
|
|
19399
|
+
}
|
|
19400
|
+
var replyCommand = new Command87("reply").description("Reply to an email").argument("<id>", "Email ID to reply to").requiredOption("--body <text>", "Reply body text").option(
|
|
19401
|
+
"--allow-unverified-sender",
|
|
19402
|
+
"Reply even though the sender's address is not verified (it may be forged)"
|
|
19403
|
+
).action(async (id, opts) => {
|
|
19183
19404
|
const keystore = await loadKeystore();
|
|
19184
19405
|
const params = new URLSearchParams({
|
|
19185
19406
|
deviceId: keystore.deviceId,
|
|
@@ -19188,6 +19409,14 @@ var replyCommand = new Command87("reply").description("Reply to an email").argum
|
|
|
19188
19409
|
const original = await apiGet(`/api/emails/get?${params.toString()}`, {
|
|
19189
19410
|
headers: { "x-taskmarket-api-token": keystore.apiToken }
|
|
19190
19411
|
});
|
|
19412
|
+
if (!opts.allowUnverifiedSender && replyNeedsVerifiedSender(original)) {
|
|
19413
|
+
return void renderFailure(
|
|
19414
|
+
new Error(
|
|
19415
|
+
`The sender of this email is not verified (senderVerification: ${original.senderVerification ?? "missing"}) and its From address is outside Taskmarket, so it may be forged and a reply would pay to mail a third party. Nothing was sent. Pass --allow-unverified-sender to reply anyway.`
|
|
19416
|
+
),
|
|
19417
|
+
{ details: { code: "unverified_sender" } }
|
|
19418
|
+
);
|
|
19419
|
+
}
|
|
19191
19420
|
const to = original.fromAddress;
|
|
19192
19421
|
const rawSubject = original.subject ?? "";
|
|
19193
19422
|
const subject = (rawSubject.startsWith("Re: ") ? rawSubject : `Re: ${rawSubject}`).slice(
|
|
@@ -29079,7 +29308,7 @@ function prepareListingFile(kind, text) {
|
|
|
29079
29308
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
29080
29309
|
return { valid: false, reason: "The file must hold one JSON object" };
|
|
29081
29310
|
}
|
|
29082
|
-
const hidden = findHiddenCharacters(kind === "
|
|
29311
|
+
const hidden = findHiddenCharacters(parsed) ?? (kind === "hook" ? findHiddenCharacters(text) : null);
|
|
29083
29312
|
if (hidden) {
|
|
29084
29313
|
return {
|
|
29085
29314
|
valid: false,
|
|
@@ -29678,7 +29907,13 @@ async function lookupListedService(worker, serviceId) {
|
|
|
29678
29907
|
if (err instanceof ApiError && err.status === 404) return { service: null };
|
|
29679
29908
|
throw err;
|
|
29680
29909
|
}
|
|
29681
|
-
if (listing?.hidden)
|
|
29910
|
+
if (listing?.hidden) {
|
|
29911
|
+
return {
|
|
29912
|
+
service: null,
|
|
29913
|
+
error: `${HIRE_LISTING_HIDDEN}: ${hireListingHiddenMessage()}`,
|
|
29914
|
+
code: HIRE_LISTING_HIDDEN
|
|
29915
|
+
};
|
|
29916
|
+
}
|
|
29682
29917
|
if (!serviceId) return { service: null };
|
|
29683
29918
|
const service = listing?.services?.find((s2) => s2.id === serviceId);
|
|
29684
29919
|
if (!service || service.hidden) {
|
|
@@ -29717,7 +29952,12 @@ hireCommand.action(async (worker, opts) => {
|
|
|
29717
29952
|
let serviceTitle = null;
|
|
29718
29953
|
if (/^0x[0-9a-fA-F]{40}$/.test(worker)) {
|
|
29719
29954
|
const lookup = await lookupListedService(worker, opts.service);
|
|
29720
|
-
if (lookup.error)
|
|
29955
|
+
if (lookup.error) {
|
|
29956
|
+
if (lookup.code) {
|
|
29957
|
+
return void renderFailure(new Error(lookup.error), { details: { code: lookup.code } });
|
|
29958
|
+
}
|
|
29959
|
+
return void printError(lookup.error);
|
|
29960
|
+
}
|
|
29721
29961
|
if (opts.service) {
|
|
29722
29962
|
if (lookup.service) {
|
|
29723
29963
|
requiresEvaluator ||= Boolean(lookup.service.requiresEvaluator);
|