@lucid-agents/taskmarket 1.25.1 → 1.26.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.
Files changed (28) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +224 -122
  2. package/dist/agent-compatibility.json +1 -1
  3. package/dist/api-H7VPA6C6.js +35 -0
  4. package/dist/{channels-LEYAANE5.js → channels-4IFPTRDY.js} +5 -4
  5. package/dist/{chunk-6KBTN3WM.js → chunk-2AJZDGEL.js} +1 -45
  6. package/dist/{chunk-ULPTFH3G.js → chunk-CNWA5PU3.js} +1 -1
  7. package/dist/{chunk-4E76UNBE.js → chunk-FMK32RJF.js} +11 -127
  8. package/dist/{chunk-RFRSTYDB.js → chunk-GT5TOHOY.js} +5 -5
  9. package/dist/chunk-NTLOY7SP.js +46 -0
  10. package/dist/chunk-PJAWRHHZ.js +39 -0
  11. package/dist/chunk-Q2FZSDFG.js +933 -0
  12. package/dist/{chunk-CGUYPUG3.js → chunk-RPGVVVJD.js} +6 -6
  13. package/dist/chunk-VTMYCZLT.js +17003 -0
  14. package/dist/{chunk-73SUBS7U.js → chunk-XV6DBK4C.js} +42 -18
  15. package/dist/{chunk-PE72DL5T.js → chunk-YAKNCBUK.js} +90 -84
  16. package/dist/{chunk-XBTNZTXE.js → chunk-YIOZ7W3M.js} +9 -7
  17. package/dist/{doctor-K2JOWQF4.js → doctor-HENBO5YV.js} +11 -19
  18. package/dist/index.js +19290 -7979
  19. package/dist/{launch-O72WIBHY.js → launch-DMKAPDO4.js} +73 -46
  20. package/dist/pi-extensions/remote-tools.cjs +4 -4
  21. package/dist/pi-extensions/xgate.cjs +4234 -308
  22. package/dist/read-auth-26D4BRUP.js +10 -0
  23. package/dist/{reconcile-FZTOX3PZ.js → reconcile-6A5U2Q7Q.js} +7 -6
  24. package/dist/{status-CC5L5YUU.js → status-GRLQL23D.js} +11 -16
  25. package/dist/{sync-pull-DZGTSKZU.js → sync-pull-MSYWP5WU.js} +4 -3
  26. package/dist/task-access-grants-54GQX63L.js +13 -0
  27. package/package.json +10 -6
  28. package/dist/chunk-L3A7JOO5.js +0 -11727
@@ -6,7 +6,6 @@ import {
6
6
  createEvmPerRequestRail,
7
7
  createMppTempoCredential,
8
8
  createTaskmarketFeeRail,
9
- createWalletAccountFromKeystore,
10
9
  createX402Allocations,
11
10
  createX402Payer,
12
11
  getX402JournalPath,
@@ -16,19 +15,15 @@ import {
16
15
  readMppTempoChallenge,
17
16
  reconcileX402Payment,
18
17
  withX402FileLock
19
- } from "./chunk-6KBTN3WM.js";
18
+ } from "./chunk-2AJZDGEL.js";
20
19
  import {
21
20
  ApiError,
22
- ComputeCreditBuyOutputSchema,
23
- ComputeCreditPricingSchema,
24
- ComputeCreditStatusOutputSchema,
25
- apiErrorEnvelopeOf,
26
21
  apiGet,
27
22
  apiOrigin,
28
23
  apiPost,
29
24
  apiUrl,
25
+ createWalletAccountFromKeystore,
30
26
  failureMessage,
31
- getTaskmarketHome,
32
27
  idempotencyHeaders,
33
28
  legalReceiptHeadersForKeystore,
34
29
  loadKeystore,
@@ -37,9 +32,18 @@ import {
37
32
  readFailureBody,
38
33
  resolveIdempotencyKey,
39
34
  selectedNetwork,
35
+ tapSigningFetch,
40
36
  withChainId,
41
- withIdempotentWrite
42
- } from "./chunk-L3A7JOO5.js";
37
+ withIdempotentWrite,
38
+ withTapSignature
39
+ } from "./chunk-Q2FZSDFG.js";
40
+ import {
41
+ ComputeCreditBuyOutputSchema,
42
+ ComputeCreditPricingSchema,
43
+ ComputeCreditStatusOutputSchema,
44
+ apiErrorEnvelopeOf,
45
+ getTaskmarketHome
46
+ } from "./chunk-VTMYCZLT.js";
43
47
 
44
48
  // src/lib/x402-fee.ts
45
49
  import { randomUUID as randomUUID3 } from "crypto";
@@ -64,13 +68,19 @@ function refusedPaidWrite(path3, status, read, idempotencyKey) {
64
68
  apiErrorEnvelopeOf(read.body) ?? void 0
65
69
  );
66
70
  }
71
+ var REFUSED_BEFORE_SETTLEMENT = /* @__PURE__ */ new Set([
72
+ "payment_preflight_rejected",
73
+ "recipient_receive_policy_blocked",
74
+ "payment_rejected",
75
+ "chain_not_served",
76
+ "chain_required",
77
+ "chain_conflict",
78
+ "invalid_input"
79
+ ]);
67
80
  function failedAfterPayment(path3, status, read, idempotencyKey) {
68
- return new ApiError(
69
- status,
70
- failureMessage(`POST ${path3} failed after payment`, status, read),
71
- idempotencyKey,
72
- apiErrorEnvelopeOf(read.body) ?? void 0
73
- );
81
+ const envelope = apiErrorEnvelopeOf(read.body) ?? void 0;
82
+ const prefix = envelope !== void 0 && REFUSED_BEFORE_SETTLEMENT.has(envelope.reason) ? `POST ${path3} was refused before payment; no payment was taken` : `POST ${path3} failed after payment`;
83
+ return new ApiError(status, failureMessage(prefix, status, read), idempotencyKey, envelope);
74
84
  }
75
85
 
76
86
  // src/lib/mpp.ts
@@ -91,10 +101,21 @@ async function mppPost(path3, body, options = {}) {
91
101
  const idempotencyKey = resolveIdempotencyKey(options.idempotencyKey);
92
102
  const chainId = options.chainId ?? selectedNetwork().chainId;
93
103
  const request = paidWriteRequest(keystore, path3, { chainId, ...body }, idempotencyKey);
104
+ Object.assign(request.headers, options.headers ?? {});
94
105
  const send = (headers) => fetchImpl(request.url, {
95
106
  method: "POST",
96
107
  redirect: "error",
97
- headers: { ...request.headers, ...headers },
108
+ // Every attempt, the paid retry included, is TAP-signed afresh inside a gated action, over
109
+ // the headers it is sent with, so the retry's Authorization is covered.
110
+ headers: withTapSignature(
111
+ {
112
+ method: "POST",
113
+ url: request.url,
114
+ headers: { ...request.headers, ...headers },
115
+ body: request.body
116
+ },
117
+ options.tap
118
+ ),
98
119
  body: request.body
99
120
  });
100
121
  return withIdempotentWrite(idempotencyKey, async () => {
@@ -432,7 +453,8 @@ async function x402FeePost(path3, body, options = {}) {
432
453
  idempotencyKey: options.idempotencyKey,
433
454
  expect: options.expect,
434
455
  account: options.account,
435
- fetchImpl: options.fetchImpl
456
+ fetchImpl: options.fetchImpl,
457
+ ...options.tap ? { tap: options.tap } : {}
436
458
  });
437
459
  }
438
460
  const keystore = await loadKeystore();
@@ -442,7 +464,9 @@ async function x402FeePost(path3, body, options = {}) {
442
464
  const payer = createCliX402Payer({
443
465
  firstParty: true,
444
466
  account: options.account,
445
- fetchImpl: options.fetchImpl
467
+ // The payer sends the unpaid and the paid round itself, so a gated action signs each one
468
+ // at the fetch, each with its own TAP nonce.
469
+ fetchImpl: options.tap ? tapSigningFetch(options.fetchImpl ?? globalThis.fetch, options.tap) : options.fetchImpl
446
470
  });
447
471
  let result;
448
472
  try {
@@ -1,85 +1,27 @@
1
1
  import { createRequire as __tmCreateRequire } from 'node:module'; import { fileURLToPath as __tmFileURLToPath } from 'node:url'; import { dirname as __tmDirname } from 'node:path'; const require = __tmCreateRequire(import.meta.url); const __tmFilename = __tmFileURLToPath(import.meta.url); const __tmDirnameValue = __tmDirname(__tmFilename);
2
2
  import {
3
3
  x402FeePost
4
- } from "./chunk-73SUBS7U.js";
4
+ } from "./chunk-XV6DBK4C.js";
5
5
  import {
6
- createWalletAccountFromKeystore,
7
- signMessage
8
- } from "./chunk-6KBTN3WM.js";
6
+ signReadAuth
7
+ } from "./chunk-PJAWRHHZ.js";
8
+ import {
9
+ taskAccessGrantHeaders
10
+ } from "./chunk-NTLOY7SP.js";
9
11
  import {
10
- READ_AUTH_ADDRESS_HEADER,
11
- READ_AUTH_SIGNATURE_HEADER,
12
- TASK_ACCESS_GRANT_HEADER,
13
- TaskAwardSchema,
14
12
  apiGet,
15
13
  apiPost,
14
+ loadKeystore,
15
+ runWorkerAction,
16
+ signMessage,
17
+ taskRequiresTap
18
+ } from "./chunk-Q2FZSDFG.js";
19
+ import {
20
+ TaskAwardSchema,
16
21
  buildClaimMessage,
17
- buildReadAuthMessage,
18
22
  buildSubmitMessage,
19
- getTaskmarketHome,
20
- isRecordingPendingResponse,
21
- loadKeystore
22
- } from "./chunk-L3A7JOO5.js";
23
-
24
- // src/lib/read-auth.ts
25
- async function signReadAuth() {
26
- let keystore;
27
- try {
28
- keystore = await loadKeystore();
29
- } catch {
30
- return null;
31
- }
32
- try {
33
- const account = await createWalletAccountFromKeystore(keystore);
34
- const signature = await account.signMessage({
35
- message: buildReadAuthMessage(keystore.walletAddress)
36
- });
37
- return {
38
- walletAddress: keystore.walletAddress,
39
- headers: {
40
- [READ_AUTH_ADDRESS_HEADER]: keystore.walletAddress,
41
- [READ_AUTH_SIGNATURE_HEADER]: signature
42
- }
43
- };
44
- } catch {
45
- return { walletAddress: keystore.walletAddress, headers: {} };
46
- }
47
- }
48
-
49
- // src/lib/task-access-grants.ts
50
- import { promises as fs } from "fs";
51
- import path from "path";
52
- function getGrantsPath() {
53
- return path.join(getTaskmarketHome(), "task-access-grants.json");
54
- }
55
- async function readGrantsFile() {
56
- try {
57
- const raw = await fs.readFile(getGrantsPath(), "utf-8");
58
- return JSON.parse(raw);
59
- } catch {
60
- return {};
61
- }
62
- }
63
- async function loadTaskAccessGrant(taskId) {
64
- const grants = await readGrantsFile();
65
- const record = grants[taskId];
66
- if (!record) return null;
67
- if (new Date(record.expiresAt).getTime() <= Date.now()) return null;
68
- return record.grant;
69
- }
70
- async function taskAccessGrantHeaders(taskId) {
71
- const grant = await loadTaskAccessGrant(taskId);
72
- return grant ? { [TASK_ACCESS_GRANT_HEADER]: grant } : {};
73
- }
74
- async function saveTaskAccessGrant(taskId, grant, expiresAt) {
75
- const grants = await readGrantsFile();
76
- grants[taskId] = { grant, expiresAt };
77
- const dir = path.dirname(getGrantsPath());
78
- await fs.mkdir(dir, { recursive: true });
79
- await fs.writeFile(getGrantsPath(), JSON.stringify(grants, null, 2), {
80
- mode: 384
81
- });
82
- }
23
+ isRecordingPendingResponse
24
+ } from "./chunk-VTMYCZLT.js";
83
25
 
84
26
  // src/sdk/artifact-upload.ts
85
27
  import { extname } from "path";
@@ -163,6 +105,57 @@ function putArtifactBytes(uploadUrl, data, mimeType, onProgress) {
163
105
  });
164
106
  }
165
107
 
108
+ // src/lib/worker-attestation.ts
109
+ var requirementCache = /* @__PURE__ */ new Map();
110
+ async function defaultGet(path) {
111
+ const { apiGet: apiGet2 } = await import("./api-H7VPA6C6.js");
112
+ const { signReadAuth: signReadAuth2 } = await import("./read-auth-26D4BRUP.js");
113
+ const { taskAccessGrantHeaders: taskAccessGrantHeaders2 } = await import("./task-access-grants-54GQX63L.js");
114
+ const taskId = /^\/api\/tasks\/([^/?]+)/.exec(path)?.[1] ?? "";
115
+ return apiGet2(path, {
116
+ headers: {
117
+ ...(await signReadAuth2())?.headers ?? {},
118
+ ...await taskAccessGrantHeaders2(taskId) ?? {}
119
+ }
120
+ });
121
+ }
122
+ var REQUIREMENT_CACHE_MS = 6e4;
123
+ function taskRequirementsOf(taskId, get = defaultGet, now = Date.now) {
124
+ const key = taskId.toLowerCase();
125
+ const cached = requirementCache.get(key);
126
+ if (cached && cached.until > now()) return cached.pending;
127
+ const entry = { pending: Promise.resolve(null), until: 0 };
128
+ entry.pending = get(`/api/tasks/${taskId}`).then((task) => task ?? null).catch(() => {
129
+ if (requirementCache.get(key) === entry) requirementCache.delete(key);
130
+ return null;
131
+ });
132
+ entry.until = now() + REQUIREMENT_CACHE_MS;
133
+ requirementCache.set(key, entry);
134
+ return entry.pending;
135
+ }
136
+ async function attestedWorkerAction(taskId, keystore, run, task) {
137
+ if (!keystore.tapKey) return run(void 0);
138
+ return runWorkerAction({
139
+ taskId,
140
+ task: task === void 0 ? await taskRequirementsOf(taskId) : task,
141
+ keystore,
142
+ run
143
+ });
144
+ }
145
+ var GATED_WRITE_PATH = /^\/api\/tasks\/([^/?]+)\/(?:claim|pitches|bids|proofs|submissions|submissions\/from-keys)(?:\?.*)?$/;
146
+ function gatedWriteTaskId(path) {
147
+ return GATED_WRITE_PATH.exec(path)?.[1];
148
+ }
149
+ async function maybeAttestedWrite(path, send, get) {
150
+ const taskId = gatedWriteTaskId(path);
151
+ if (!taskId) return send(void 0);
152
+ const keystore = await loadKeystore().catch(() => void 0);
153
+ if (!keystore?.tapKey) return send(void 0);
154
+ const task = await taskRequirementsOf(taskId, get);
155
+ if (!taskRequiresTap(task)) return send(void 0);
156
+ return runWorkerAction({ taskId, task, keystore, run: send });
157
+ }
158
+
166
159
  // src/lib/task-sdk.ts
167
160
  async function putWithProgress(upload) {
168
161
  process.stderr.write(` Uploading ${upload.fileName}...
@@ -173,11 +166,15 @@ async function putWithProgress(upload) {
173
166
  process.stderr.write("\n");
174
167
  }
175
168
  var cliTaskTransport = {
176
- get: (path2, headers) => apiGet(path2, { headers }),
169
+ get: (path, headers) => apiGet(path, { headers }),
177
170
  // A write the caller gave no key is sent exactly as before the SDK existed, with no options,
178
171
  // so `apiPost` resolves its key itself (explicit, then TASKMARKET_IDEMPOTENCY_KEY, then fresh).
179
- post: (path2, body, options) => options === void 0 ? apiPost(path2, body) : apiPost(path2, body, options),
180
- feePost: (path2, body, options) => x402FeePost(path2, body, options),
172
+ // A gated worker action on a task that requires `tap` is TAP-signed (lib/worker-attestation.ts).
173
+ post: (path, body, options) => maybeAttestedWrite(
174
+ path,
175
+ (tap) => tap ? apiPost(path, body, { ...options, tap }) : options === void 0 ? apiPost(path, body) : apiPost(path, body, options)
176
+ ),
177
+ feePost: (path, body, options) => maybeAttestedWrite(path, (tap) => x402FeePost(path, body, tap ? { ...options, tap } : options)),
181
178
  put: putWithProgress
182
179
  };
183
180
  function keystoreTaskSigner(keystore) {
@@ -210,9 +207,9 @@ var TaskOperationError = class extends Error {
210
207
  this.code = code;
211
208
  }
212
209
  };
213
- function withChainQuery(path2, chainId) {
214
- if (chainId === void 0) return path2;
215
- return `${path2}${path2.includes("?") ? "&" : "?"}chainId=${chainId}`;
210
+ function withChainQuery(path, chainId) {
211
+ if (chainId === void 0) return path;
212
+ return `${path}${path.includes("?") ? "&" : "?"}chainId=${chainId}`;
216
213
  }
217
214
  function withChainBody(body, chainId) {
218
215
  return chainId === void 0 ? body : { ...body, chainId };
@@ -257,8 +254,17 @@ async function listTasks(ctx, filter = {}) {
257
254
  if (filter.tags) params.set("tags", filter.tags);
258
255
  if (filter.minReward) params.set("minReward", filter.minReward);
259
256
  if (filter.maxReward) params.set("maxReward", filter.maxReward);
257
+ if (filter.minTotalReward) params.set("minTotalReward", filter.minTotalReward);
260
258
  if (filter.deadlineHours) params.set("deadlineHours", filter.deadlineHours);
261
259
  if (filter.sponsored) params.set("sponsored", "true");
260
+ if (filter.identity) params.set("identity", filter.identity);
261
+ if (filter.verifiedBy) params.set("verifiedBy", filter.verifiedBy);
262
+ if (filter.requester) params.set("requester", filter.requester);
263
+ if (filter.hire !== void 0) params.set("hire", String(filter.hire));
264
+ if (filter.hireKind) params.set("hireKind", filter.hireKind);
265
+ if (filter.hireState) params.set("hireState", filter.hireState);
266
+ if (filter.hireServiceId) params.set("hireServiceId", filter.hireServiceId);
267
+ if (filter.reservedWorker) params.set("reservedWorker", filter.reservedWorker);
262
268
  if (filter.limit) params.set("limit", filter.limit);
263
269
  if (filter.cursor) params.set("cursor", filter.cursor);
264
270
  const result = await ctx.transport.get(
@@ -267,10 +273,11 @@ async function listTasks(ctx, filter = {}) {
267
273
  );
268
274
  return { tasks: result.tasks, hasMore: result.hasMore, nextCursor: result.nextCursor };
269
275
  }
270
- async function listTaskSubmissions(ctx, ref) {
276
+ async function listTaskSubmissions(ctx, ref, filter = {}) {
271
277
  const headers = await readAuthHeaders(ctx);
278
+ const query = filter.passedCheck ? `?${new URLSearchParams({ passedCheck: filter.passedCheck }).toString()}` : "";
272
279
  return await ctx.transport.get(
273
- withChainQuery(`/api/tasks/${ref.taskId}/submissions`, ref.chainId),
280
+ withChainQuery(`/api/tasks/${ref.taskId}/submissions${query}`, ref.chainId),
274
281
  headers
275
282
  );
276
283
  }
@@ -433,9 +440,8 @@ async function submitTaskFiles(ctx, ref, files, options = {}) {
433
440
  }
434
441
 
435
442
  export {
436
- signReadAuth,
437
- taskAccessGrantHeaders,
438
- saveTaskAccessGrant,
443
+ taskRequirementsOf,
444
+ attestedWorkerAction,
439
445
  mimeTypeForPath,
440
446
  putArtifactBytes,
441
447
  cliTaskTransport,
@@ -4,19 +4,24 @@ import {
4
4
  WITHDRAW_DELAY_SECONDS,
5
5
  createBaseChannelPayer,
6
6
  createBaseChannelRpcReader,
7
- createWalletAccountFromKeystore,
8
7
  createX402Allocations,
9
8
  getX402JournalPath,
10
9
  getX402PolicyPath,
11
10
  listX402Payments,
12
11
  loadX402Policy,
13
12
  rpcUrlForNetwork
14
- } from "./chunk-6KBTN3WM.js";
13
+ } from "./chunk-2AJZDGEL.js";
15
14
  import {
16
- getTaskmarketHome,
15
+ createWalletAccountFromKeystore,
17
16
  keystoreExists,
18
17
  loadKeystore
19
- } from "./chunk-L3A7JOO5.js";
18
+ } from "./chunk-Q2FZSDFG.js";
19
+ import {
20
+ getTaskmarketHome
21
+ } from "./chunk-VTMYCZLT.js";
22
+ import {
23
+ AgentLaunchError
24
+ } from "./chunk-YM4S6IE4.js";
20
25
  import {
21
26
  failureDetail,
22
27
  failureDetailOf,
@@ -24,9 +29,6 @@ import {
24
29
  responseFailureReason,
25
30
  withFailureDetail
26
31
  } from "./chunk-XJOB4NMV.js";
27
- import {
28
- AgentLaunchError
29
- } from "./chunk-YM4S6IE4.js";
30
32
 
31
33
  // src/lib/agent/channels.ts
32
34
  import { randomUUID as randomUUID2 } from "crypto";
@@ -1,35 +1,36 @@
1
1
  import { createRequire as __tmCreateRequire } from 'node:module'; import { fileURLToPath as __tmFileURLToPath } from 'node:url'; import { dirname as __tmDirname } from 'node:path'; const require = __tmCreateRequire(import.meta.url); const __tmFilename = __tmFileURLToPath(import.meta.url); const __tmDirnameValue = __tmDirname(__tmFilename);
2
+ import {
3
+ listSandboxes
4
+ } from "./chunk-FMK32RJF.js";
5
+ import "./chunk-RPGVVVJD.js";
6
+ import "./chunk-GT5TOHOY.js";
7
+ import "./chunk-XV6DBK4C.js";
2
8
  import {
3
9
  AGENT_COMPATIBILITY,
4
10
  assertAgentCompatibility,
5
11
  nodeVersionSupported
6
12
  } from "./chunk-4ZC6SH7H.js";
7
- import {
8
- listSandboxes
9
- } from "./chunk-4E76UNBE.js";
10
- import "./chunk-CGUYPUG3.js";
11
- import "./chunk-RFRSTYDB.js";
12
- import "./chunk-73SUBS7U.js";
13
13
  import {
14
14
  channelView,
15
15
  loadAgentPolicy,
16
16
  openAgentChannels
17
- } from "./chunk-XBTNZTXE.js";
17
+ } from "./chunk-YIOZ7W3M.js";
18
18
  import {
19
19
  getX402PolicyPath,
20
20
  loadX402Policy,
21
21
  rpcUrlForNetwork
22
- } from "./chunk-6KBTN3WM.js";
22
+ } from "./chunk-2AJZDGEL.js";
23
23
  import {
24
24
  apiUrl,
25
25
  keystoreExists,
26
26
  loadKeystore,
27
27
  withChainId
28
- } from "./chunk-L3A7JOO5.js";
28
+ } from "./chunk-Q2FZSDFG.js";
29
+ import "./chunk-VTMYCZLT.js";
30
+ import "./chunk-YM4S6IE4.js";
29
31
  import {
30
32
  AGENT_VIEW_VERSION
31
33
  } from "./chunk-XJOB4NMV.js";
32
- import "./chunk-YM4S6IE4.js";
33
34
  import "./chunk-S7SJMJ2I.js";
34
35
 
35
36
  // src/lib/agent/doctor.ts
@@ -206,15 +207,6 @@ async function runDoctor(deps = {}) {
206
207
  checks
207
208
  };
208
209
  }
209
- function doctorLines(report) {
210
- return [
211
- `taskmarket agent doctor (view v${report.version}): ${report.ok ? "ready" : "problems found"}`,
212
- ...report.checks.map(
213
- (check) => `${check.status.toUpperCase().padEnd(4)} ${check.id}: ${check.summary}`
214
- )
215
- ];
216
- }
217
210
  export {
218
- doctorLines,
219
211
  runDoctor
220
212
  };