@lucid-agents/taskmarket 1.43.0 → 1.45.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 (25) hide show
  1. package/dist/agent-compatibility.json +1 -1
  2. package/dist/{api-HZEK636T.js → api-PZVGK3VQ.js} +2 -2
  3. package/dist/{channels-FWGJII6Y.js → channels-LDMZ3OEM.js} +4 -4
  4. package/dist/{chunk-XZZKUMHQ.js → chunk-5NILW5UT.js} +22 -7
  5. package/dist/{chunk-MGDBSENK.js → chunk-6YFLKQ4Q.js} +4646 -4006
  6. package/dist/{chunk-FKQBRXQS.js → chunk-FHDTYW6C.js} +1 -1
  7. package/dist/{chunk-F532X4HL.js → chunk-GIVPCMJ3.js} +1 -1
  8. package/dist/{chunk-FN5FZ4RL.js → chunk-JPVBWX3Q.js} +3 -3
  9. package/dist/{chunk-YS3YH7U3.js → chunk-KY4JM6NG.js} +3 -3
  10. package/dist/{chunk-XEGCIN3K.js → chunk-PRYNO5S7.js} +1 -1
  11. package/dist/{chunk-FNSX2KLZ.js → chunk-QUY6764O.js} +2 -2
  12. package/dist/{chunk-ZMPMQTQQ.js → chunk-QYXBVFVX.js} +5 -5
  13. package/dist/{chunk-Z7MFEW73.js → chunk-THIC75V5.js} +3 -3
  14. package/dist/{chunk-B2PINQHQ.js → chunk-TPCXOWSC.js} +8 -8
  15. package/dist/{chunk-IRKICJEV.js → chunk-XLJRCGOJ.js} +1 -1
  16. package/dist/{doctor-NTQ3ZJRU.js → doctor-HV5QQDGU.js} +8 -8
  17. package/dist/index.js +621 -237
  18. package/dist/{launch-FOCL5JOR.js → launch-56RHQCWT.js} +11 -11
  19. package/dist/pi-extensions/xgate.cjs +32 -1
  20. package/dist/{read-auth-UAZUJEEQ.js → read-auth-ZJBQQVGO.js} +3 -3
  21. package/dist/{reconcile-IKPAKGH3.js → reconcile-PQXSATCK.js} +4 -4
  22. package/dist/{status-A636ECTT.js → status-EBMZGDFS.js} +8 -8
  23. package/dist/{sync-pull-DVC4R6BN.js → sync-pull-423LBSPO.js} +4 -4
  24. package/dist/{task-access-grants-5I7QQXZV.js → task-access-grants-KWTKM3NP.js} +2 -2
  25. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  listWorkerSubmissions,
15
15
  submitTaskFiles,
16
16
  taskRequirementsOf
17
- } from "./chunk-B2PINQHQ.js";
17
+ } from "./chunk-TPCXOWSC.js";
18
18
  import {
19
19
  ComputeCreditError,
20
20
  applyComputeCreditSetup,
@@ -37,14 +37,14 @@ import {
37
37
  releasePendingComputePurchase,
38
38
  resolvePendingComputePurchases,
39
39
  x402FeePost
40
- } from "./chunk-YS3YH7U3.js";
40
+ } from "./chunk-KY4JM6NG.js";
41
41
  import {
42
42
  signReadAuth
43
- } from "./chunk-FNSX2KLZ.js";
43
+ } from "./chunk-QUY6764O.js";
44
44
  import {
45
45
  saveTaskAccessGrant,
46
46
  taskAccessGrantHeaders
47
- } from "./chunk-FKQBRXQS.js";
47
+ } from "./chunk-FHDTYW6C.js";
48
48
  import {
49
49
  MPP_TEMPO_DEFAULT_VALIDITY_SECONDS,
50
50
  X402PayError,
@@ -62,7 +62,7 @@ import {
62
62
  setX402PolicyRuleEnabled,
63
63
  signSponsoredTempoTransfer,
64
64
  signTaskmarketFeePayment
65
- } from "./chunk-F532X4HL.js";
65
+ } from "./chunk-GIVPCMJ3.js";
66
66
  import {
67
67
  ALL_NETWORKS,
68
68
  ApiError,
@@ -71,6 +71,7 @@ import {
71
71
  NETWORK_NAMES,
72
72
  NetworkRequiredError,
73
73
  TAP_ALGORITHMS,
74
+ TAP_CREATE_ALGORITHMS,
74
75
  allNetworksSelected,
75
76
  apiDelete,
76
77
  apiGet,
@@ -125,7 +126,7 @@ import {
125
126
  withErrorContext,
126
127
  withIdempotentWrite,
127
128
  withTapSignature
128
- } from "./chunk-XZZKUMHQ.js";
129
+ } from "./chunk-5NILW5UT.js";
129
130
  import {
130
131
  AGENT_AVATAR_MAX_BYTES,
131
132
  AGENT_HIRES_ROLES,
@@ -173,6 +174,9 @@ import {
173
174
  HIRE_MAX_ACCEPT_WINDOW_SECS,
174
175
  HIRE_MIN_ACCEPT_WINDOW_SECS,
175
176
  HIRE_SERVICE_ID_MAX_LENGTH,
177
+ HOOK_BIT_FEE,
178
+ HOOK_BIT_ON_CALL,
179
+ HOOK_BIT_REALLOCATE,
176
180
  HireAvailabilitySchema,
177
181
  HireKind,
178
182
  HireState,
@@ -293,6 +297,8 @@ import {
293
297
  buildAgentListingWriteMessage,
294
298
  buildDeviceRegisterMessage,
295
299
  buildForfeitMessage,
300
+ buildHookManifest,
301
+ buildHookSolidity,
296
302
  buildLegalReceiptHeaders,
297
303
  buildPitchMessage,
298
304
  buildProofMessage,
@@ -312,8 +318,10 @@ import {
312
318
  clientValidityWindowSeconds,
313
319
  compareSubmissionVersionsNewestFirst,
314
320
  composeBrief,
321
+ contractName,
315
322
  coreChains,
316
323
  dreamsToUsd,
324
+ effectiveCapabilities,
317
325
  evaluationWindowError,
318
326
  extractLiterals,
319
327
  extractTaskChecks,
@@ -323,7 +331,6 @@ import {
323
331
  formatPaymentAmount,
324
332
  formatTaskChecksErrors,
325
333
  formatUsdcBaseUnits,
326
- getAgentName,
327
334
  getTaskmarketHome,
328
335
  hiddenChecksResult,
329
336
  hireAcceptAtCapacity,
@@ -331,8 +338,13 @@ import {
331
338
  hireSelectAtCapacityMessage,
332
339
  hireUnavailableAcknowledgeable,
333
340
  hireUnavailableMessage,
341
+ hookCallRoleChoices,
334
342
  hookListingSubject,
343
+ hookModes,
344
+ hookObserveChoices,
345
+ hookVetoChoices,
335
346
  humanListingChangeError,
347
+ initialHookBuilderInput,
336
348
  isCapabilitySlug,
337
349
  isInFlightApiError,
338
350
  isInitialBriefTurnMessage,
@@ -342,6 +354,7 @@ import {
342
354
  isTaskmarketChainId,
343
355
  isTerminalWalletBridgeStatus,
344
356
  listingSubmissionWriteChange,
357
+ manifestReadiness,
345
358
  marketEventPreferenceChange,
346
359
  matchesAnyGlob,
347
360
  needsYouKindForIntent,
@@ -360,6 +373,7 @@ import {
360
373
  resolveTaskTerms,
361
374
  runDataChecks,
362
375
  runPatchChecks,
376
+ selectedCallbacks,
363
377
  settlementActionExpiresAt,
364
378
  settlementActionRequiresExpiry,
365
379
  settlerModeContracts,
@@ -385,7 +399,7 @@ import {
385
399
  verifierProviderId,
386
400
  verifiersUnsupportedOnChain,
387
401
  viemChainFor
388
- } from "./chunk-MGDBSENK.js";
402
+ } from "./chunk-6YFLKQ4Q.js";
389
403
  import "./chunk-S7SJMJ2I.js";
390
404
 
391
405
  // src/index.ts
@@ -2532,6 +2546,12 @@ function numberDecoderFactory(input) {
2532
2546
  }
2533
2547
  });
2534
2548
  }
2549
+ var getI64Decoder = (config = {}) => numberDecoderFactory({
2550
+ config,
2551
+ get: (view, le) => view.getBigInt64(0, le),
2552
+ name: "i64",
2553
+ size: 8
2554
+ });
2535
2555
  var getShortU16Encoder = () => createEncoder({
2536
2556
  getSizeFromValue: (value) => {
2537
2557
  if (value <= 127) return 1;
@@ -2564,6 +2584,12 @@ var getU16Encoder = (config = {}) => numberEncoderFactory({
2564
2584
  set: (view, value, le) => view.setUint16(0, Number(value), le),
2565
2585
  size: 2
2566
2586
  });
2587
+ var getU16Decoder = (config = {}) => numberDecoderFactory({
2588
+ config,
2589
+ get: (view, le) => view.getUint16(0, le),
2590
+ name: "u16",
2591
+ size: 2
2592
+ });
2567
2593
  var getU32Encoder = (config = {}) => numberEncoderFactory({
2568
2594
  config,
2569
2595
  name: "u32",
@@ -3126,7 +3152,7 @@ function getLifetimeTokenEncoder() {
3126
3152
  noneValue: "zeroes",
3127
3153
  prefix: null
3128
3154
  }),
3129
- (token) => token ?? null
3155
+ (token2) => token2 ?? null
3130
3156
  );
3131
3157
  }
3132
3158
  function getMessageEncoder() {
@@ -3928,8 +3954,8 @@ function addRaceContender(contender) {
3928
3954
  const record = { deferreds, settled: false };
3929
3955
  Promise.resolve(contender).then(
3930
3956
  (value) => {
3931
- for (const { resolve: resolve2 } of deferreds) {
3932
- resolve2(value);
3957
+ for (const { resolve: resolve3 } of deferreds) {
3958
+ resolve3(value);
3933
3959
  }
3934
3960
  deferreds.clear();
3935
3961
  record.settled = true;
@@ -3947,11 +3973,11 @@ function addRaceContender(contender) {
3947
3973
  var wm = /* @__PURE__ */ new WeakMap();
3948
3974
  async function safeRace(contenders) {
3949
3975
  let deferred;
3950
- const result = new Promise((resolve2, reject) => {
3951
- deferred = { reject, resolve: resolve2 };
3976
+ const result = new Promise((resolve3, reject) => {
3977
+ deferred = { reject, resolve: resolve3 };
3952
3978
  for (const contender of contenders) {
3953
3979
  if (!isObject(contender)) {
3954
- Promise.resolve(contender).then(resolve2, reject);
3980
+ Promise.resolve(contender).then(resolve3, reject);
3955
3981
  continue;
3956
3982
  }
3957
3983
  let record = wm.get(contender);
@@ -3960,7 +3986,7 @@ async function safeRace(contenders) {
3960
3986
  record.deferreds.add(deferred);
3961
3987
  wm.set(contender, record);
3962
3988
  } else if (record.settled) {
3963
- Promise.resolve(contender).then(resolve2, reject);
3989
+ Promise.resolve(contender).then(resolve3, reject);
3964
3990
  } else {
3965
3991
  record.deferreds.add(deferred);
3966
3992
  }
@@ -5298,14 +5324,14 @@ function createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value) {
5298
5324
  } else {
5299
5325
  argumentLabel = `\`${keyPath[0].toString()}\``;
5300
5326
  }
5301
- const path9 = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
5327
+ const path10 = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
5302
5328
  const error = new SolanaError(SOLANA_ERROR__RPC__INTEGER_OVERFLOW, {
5303
5329
  argumentLabel,
5304
5330
  keyPath,
5305
5331
  methodName,
5306
- optionalPathLabel: path9 ? ` at path \`${path9}\`` : "",
5332
+ optionalPathLabel: path10 ? ` at path \`${path10}\`` : "",
5307
5333
  value,
5308
- ...path9 !== void 0 ? { path: path9 } : void 0
5334
+ ...path10 !== void 0 ? { path: path10 } : void 0
5309
5335
  });
5310
5336
  safeCaptureStackTrace(error, createSolanaJsonRpcIntegerOverflowError);
5311
5337
  return error;
@@ -5366,7 +5392,7 @@ function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
5366
5392
  coalescedRequest.numConsumers++;
5367
5393
  if (signal) {
5368
5394
  const responsePromise = coalescedRequest.responsePromise;
5369
- return await new Promise((resolve2, reject) => {
5395
+ return await new Promise((resolve3, reject) => {
5370
5396
  const handleAbort = () => {
5371
5397
  signal.removeEventListener("abort", handleAbort);
5372
5398
  coalescedRequest.numConsumers -= 1;
@@ -5379,7 +5405,7 @@ function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
5379
5405
  reject(signal.reason);
5380
5406
  };
5381
5407
  signal.addEventListener("abort", handleAbort);
5382
- responsePromise.then(resolve2).catch(reject).finally(() => {
5408
+ responsePromise.then(resolve3).catch(reject).finally(() => {
5383
5409
  signal.removeEventListener("abort", handleAbort);
5384
5410
  });
5385
5411
  });
@@ -7412,9 +7438,9 @@ function explainEnrolFailure(error, chainId) {
7412
7438
  return error;
7413
7439
  }
7414
7440
  async function enrolTapKey(stored, chainId) {
7415
- if (stored.alg !== "ed25519") {
7441
+ if (stored.alg !== "ed25519" && stored.alg !== "ecdsa-p256-sha256") {
7416
7442
  throw new Error(
7417
- `Only an ed25519 TAP key can be enrolled with the simulated directory, not ${stored.alg}.`
7443
+ `Only an ed25519 or ECDSA P-256 TAP key can be enrolled with the simulated directory, not ${stored.alg}.`
7418
7444
  );
7419
7445
  }
7420
7446
  const auth = await signReadAuth();
@@ -7466,44 +7492,33 @@ async function readTapKeyStatus(stored, chainId) {
7466
7492
  }
7467
7493
 
7468
7494
  // src/commands/init.ts
7469
- function sanitizeEmailUsername(agentId, suffix) {
7470
- const maxBase = 30 - 1 - suffix.length;
7471
- if (maxBase < 2) return null;
7472
- const base = agentId.toLowerCase().replace(/[^a-z0-9]/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "").slice(0, maxBase).replace(/-+$/, "");
7473
- if (base.length < 2) return null;
7474
- const candidate = `${base}-${suffix}`;
7475
- return /^[a-z0-9][a-z0-9-]{1,28}[a-z0-9]$/.test(candidate) ? candidate : null;
7476
- }
7477
- async function tryRegisterEmail(deviceId, apiToken, username, explicit, warnings) {
7495
+ async function tryRegisterEmail(deviceId, apiToken, warnings) {
7478
7496
  try {
7479
7497
  const { data: reg } = await apiPost("/api/emails/register", {
7480
7498
  deviceId,
7481
- apiToken,
7482
- username
7499
+ apiToken
7483
7500
  });
7484
7501
  return reg.emailAddress;
7485
7502
  } catch (err) {
7486
- if (explicit) {
7487
- const msg = err instanceof Error ? err.message : String(err);
7488
- warnings.push(
7489
- cliWarning(
7490
- "email_registration_failed",
7491
- `Email registration failed: ${msg}. Run: taskmarket email register --username ${username}`,
7492
- { username, retryCommand: `taskmarket email register --username ${username}` }
7493
- )
7494
- );
7495
- }
7503
+ const msg = err instanceof Error ? err.message : String(err);
7504
+ warnings.push(
7505
+ cliWarning(
7506
+ "email_registration_failed",
7507
+ `Email registration failed: ${msg}. Run: taskmarket email register`,
7508
+ { retryCommand: "taskmarket email register" }
7509
+ )
7510
+ );
7496
7511
  return null;
7497
7512
  }
7498
7513
  }
7499
7514
  function terminalIo() {
7500
7515
  return {
7501
7516
  interactive: Boolean(process.stdin.isTTY && process.stderr.isTTY),
7502
- ask: (question) => new Promise((resolve2) => {
7517
+ ask: (question) => new Promise((resolve3) => {
7503
7518
  const rl = createInterface2({ input: process.stdin, output: process.stderr });
7504
7519
  rl.question(question, (answer) => {
7505
7520
  rl.close();
7506
- resolve2(answer);
7521
+ resolve3(answer);
7507
7522
  });
7508
7523
  })
7509
7524
  };
@@ -7582,9 +7597,6 @@ async function addTapKey() {
7582
7597
  }
7583
7598
  var initCommand = new Command2("init").description(
7584
7599
  "Create and register this machine's agent wallet (one-time; refuses when a wallet exists)"
7585
- ).option(
7586
- "--email <username>",
7587
- "Claim a custom email username (default: auto-generated from agent ID)"
7588
7600
  ).option(
7589
7601
  "--yes",
7590
7602
  "Confirm legal acceptance non-interactively after reviewing every current policy"
@@ -7593,7 +7605,7 @@ var initCommand = new Command2("init").description(
7593
7605
  "On a machine that already has a wallet, add its Solana wallet (new wallets get one anyway)"
7594
7606
  ).option(
7595
7607
  "--tap",
7596
- "Also create a TAP signing key (ed25519) and enrol it with the simulated directory where the network's chain uses it; on a machine that already has a wallet, add one. Off unless given."
7608
+ "Also create a TAP signing key (ECDSA P-256) and enrol it with the simulated directory where the network's chain uses it; on a machine that already has a wallet, add one. Off unless given."
7597
7609
  ).action(async (opts) => {
7598
7610
  if ((opts.solana || opts.tap) && await keystoreExists()) {
7599
7611
  if (opts.solana && opts.tap) {
@@ -7608,15 +7620,6 @@ var initCommand = new Command2("init").description(
7608
7620
  return;
7609
7621
  }
7610
7622
  await ensureInitNetwork();
7611
- if (opts.email) {
7612
- const check = await apiGet(
7613
- `/api/emails/check-username?username=${encodeURIComponent(opts.email)}`
7614
- );
7615
- if (!check.available) {
7616
- printError(`Email username "${opts.email}" is not available.`);
7617
- return;
7618
- }
7619
- }
7620
7623
  const { privateKey, address: address3 } = generateKeypair();
7621
7624
  const solanaWallet = await generateSolanaKeypair();
7622
7625
  const publicKey = deriveCompressedPublicKey(privateKey);
@@ -7687,9 +7690,8 @@ var initCommand = new Command2("init").description(
7687
7690
  networkInfo = response.result.data;
7688
7691
  } catch {
7689
7692
  }
7690
- const username = opts.email ?? (agentId && networkInfo ? sanitizeEmailUsername(agentId, String(selectedNetwork().chainId)) : null);
7691
7693
  const warnings = [];
7692
- const emailAddress = username ? await tryRegisterEmail(deviceId, apiToken, username, !!opts.email, warnings) : null;
7694
+ const emailAddress = await tryRegisterEmail(deviceId, apiToken, warnings);
7693
7695
  let chain;
7694
7696
  try {
7695
7697
  chain = chainInfoFor(networkInfo, selectedNetwork().chainId);
@@ -7961,7 +7963,7 @@ async function approveSponsoredTaskSpend(input) {
7961
7963
  `Approval confirmed but the RPC endpoint still reports an allowance of ${allowance}; retry once the endpoint catches up`
7962
7964
  );
7963
7965
  }
7964
- await new Promise((resolve2) => setTimeout(resolve2, pollIntervalMs));
7966
+ await new Promise((resolve3) => setTimeout(resolve3, pollIntervalMs));
7965
7967
  }
7966
7968
  }
7967
7969
 
@@ -8371,7 +8373,8 @@ var addressCommand2 = new Command7("address").description("One wallet on the sel
8371
8373
  chainId: selectedNetwork().chainId,
8372
8374
  address: wanted,
8373
8375
  windowDays,
8374
- name: node?.agentId ? getAgentName(node.agentId) : null,
8376
+ // ADR-0541: the name Taskmarket stores for the wallet, never computed here.
8377
+ displayName: node?.displayName ?? null,
8375
8378
  node,
8376
8379
  events: page.items
8377
8380
  });
@@ -8482,7 +8485,7 @@ var taskPath = (taskId) => `/api/tasks/${encodeURIComponent(taskId)}`;
8482
8485
  var runPath = (runId) => `/api/submission-reviews/${encodeURIComponent(runId)}`;
8483
8486
  function createSubmissionReviewClient(options) {
8484
8487
  const now = options.now ?? Date.now;
8485
- const sleep4 = options.sleep ?? ((ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2)));
8488
+ const sleep4 = options.sleep ?? ((ms2) => new Promise((resolve3) => setTimeout(resolve3, ms2)));
8486
8489
  let headersPromise;
8487
8490
  const headers = () => headersPromise ??= (async () => {
8488
8491
  const signer = await options.signer();
@@ -8493,10 +8496,10 @@ function createSubmissionReviewClient(options) {
8493
8496
  )
8494
8497
  };
8495
8498
  })();
8496
- async function get(path9, schema) {
8497
- return schema.parse(await options.transport.get(path9, await headers()));
8499
+ async function get(path10, schema) {
8500
+ return schema.parse(await options.transport.get(path10, await headers()));
8498
8501
  }
8499
- async function write(action, payload, chainId, path9, schema, key) {
8502
+ async function write(action, payload, chainId, path10, schema, key) {
8500
8503
  const idempotencyKey = z.string().uuid().parse(resolveIdempotencyKey(key)).toLowerCase();
8501
8504
  return withIdempotentWrite(idempotencyKey, async () => {
8502
8505
  const signer = await options.signer();
@@ -8520,7 +8523,7 @@ function createSubmissionReviewClient(options) {
8520
8523
  signature,
8521
8524
  ...["pause", "cancel", "delete"].includes(action) ? { action } : {}
8522
8525
  };
8523
- const result = await options.transport.post(path9, body, idempotencyKey);
8526
+ const result = await options.transport.post(path10, body, idempotencyKey);
8524
8527
  if (result.idempotencyKey !== idempotencyKey)
8525
8528
  throw new Error(
8526
8529
  "Review response has a different request key; recover the original request before retrying."
@@ -8733,9 +8736,9 @@ function cliSubmissionReviewClient() {
8733
8736
  };
8734
8737
  },
8735
8738
  transport: {
8736
- get: (path9, headers) => apiGet(path9, { headers }),
8737
- preview: (path9, body, headers) => apiReadPost(path9, body, { headers }),
8738
- post: (path9, body, idempotencyKey, headers) => apiPost(path9, body, { idempotencyKey, headers })
8739
+ get: (path10, headers) => apiGet(path10, { headers }),
8740
+ preview: (path10, body, headers) => apiReadPost(path10, body, { headers }),
8741
+ post: (path10, body, idempotencyKey, headers) => apiPost(path10, body, { idempotencyKey, headers })
8739
8742
  }
8740
8743
  });
8741
8744
  }
@@ -9018,13 +9021,13 @@ function retryAfterMs(res) {
9018
9021
  const wait = Number.isFinite(seconds) && seconds >= 0 ? seconds : DEFAULT_RETRY_AFTER_SECONDS;
9019
9022
  return Math.min(wait, MAX_RETRY_AFTER_SECONDS) * 1e3;
9020
9023
  }
9021
- async function x402Post(path9, body, options) {
9022
- const sleep4 = options?.sleep ?? ((ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2)));
9024
+ async function x402Post(path10, body, options) {
9025
+ const sleep4 = options?.sleep ?? ((ms2) => new Promise((resolve3) => setTimeout(resolve3, ms2)));
9023
9026
  if (paymentProtocolOf(selectedNetwork().chainId) === "mpp")
9024
- return mppPost(path9, body, options);
9027
+ return mppPost(path10, body, options);
9025
9028
  const keystore = await loadKeystore();
9026
9029
  const idempotencyKey = resolveIdempotencyKey(options?.idempotencyKey);
9027
- const request = paidWriteRequest(keystore, path9, body, idempotencyKey);
9030
+ const request = paidWriteRequest(keystore, path10, body, idempotencyKey);
9028
9031
  Object.assign(request.headers, options?.headers ?? {});
9029
9032
  return withIdempotentWrite(idempotencyKey, async () => {
9030
9033
  const r1 = await fetch(request.url, {
@@ -9041,7 +9044,7 @@ async function x402Post(path9, body, options) {
9041
9044
  if (r1.ok) {
9042
9045
  return { data: await r1.json(), idempotencyKey };
9043
9046
  }
9044
- throw refusedPaidWrite(path9, r1.status, await readFailureBody(r1), idempotencyKey);
9047
+ throw refusedPaidWrite(path10, r1.status, await readFailureBody(r1), idempotencyKey);
9045
9048
  }
9046
9049
  const requirements = await r1.json();
9047
9050
  const chain = taskmarketChain(selectedNetwork().chainId);
@@ -9078,7 +9081,7 @@ async function x402Post(path9, body, options) {
9078
9081
  await sleep4(retryAfterMs(r2));
9079
9082
  continue;
9080
9083
  }
9081
- throw failedAfterPayment(path9, r2.status, read4, idempotencyKey);
9084
+ throw failedAfterPayment(path10, r2.status, read4, idempotencyKey);
9082
9085
  }
9083
9086
  });
9084
9087
  }
@@ -9155,7 +9158,7 @@ function parseRequirementFilter(value, schema, flag) {
9155
9158
  return { value: trimmed };
9156
9159
  }
9157
9160
  function tapSimulatedMessage(chainId) {
9158
- return `TAP on chain ${chainId} is simulated: a TAP check there proves only that the worker holds a key it enrolled with Taskmarket, not that the verifier knows it. Passed checks are recorded as tap-simulated, and a tap:identity:known requirement there behaves as tap:identity:verified: the simulated directory enrols only verified keys.`;
9161
+ return `TAP on chain ${chainId} is simulated: a TAP check there proves only that the worker holds a key it enrolled with Taskmarket, not that the verifier knows it. Passed checks are recorded as tap-simulated. Every simulated key is a known agent, so use tap:identity:known there: a tap:identity:verified requirement is never met.`;
9159
9162
  }
9160
9163
  async function tapSimulatedWarnings(verifiedBy, chainId) {
9161
9164
  if (chainId === void 0 || !verifiedBy?.some((id) => verifierProviderId(id) === "tap"))
@@ -9462,7 +9465,7 @@ function taskGateCandidates(task) {
9462
9465
  // src/lib/recording.ts
9463
9466
  var RECORDING_POLL_INTERVAL_MS = 3e3;
9464
9467
  var RECORDING_POLL_TIMEOUT_MS = 75e3;
9465
- var sleepFor = (ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2));
9468
+ var sleepFor = (ms2) => new Promise((resolve3) => setTimeout(resolve3, ms2));
9466
9469
  async function settleRecording(data, idempotencyKey, options = {}) {
9467
9470
  if (!isRecordingPendingResponse(data)) return {};
9468
9471
  const { txHash, intentId } = data;
@@ -9476,13 +9479,13 @@ async function settleRecording(data, idempotencyKey, options = {}) {
9476
9479
  `Transaction ${txHash ?? "(unknown)"} is confirmed on chain; recording it is pending. Waiting up to ${Math.round(timeoutMs / 1e3)}s for the backend to record it...`
9477
9480
  );
9478
9481
  const headers = (await signReadAuth())?.headers ?? {};
9479
- const path9 = `/api/intents?idempotencyKey=${encodeURIComponent(idempotencyKey)}`;
9482
+ const path10 = `/api/intents?idempotencyKey=${encodeURIComponent(idempotencyKey)}`;
9480
9483
  const deadline = now() + timeoutMs;
9481
9484
  while (now() < deadline) {
9482
9485
  await sleep4(intervalMs);
9483
9486
  let intent;
9484
9487
  try {
9485
- intent = IntentStatusResponseSchema.safeParse(await apiGet(path9, { headers }));
9488
+ intent = IntentStatusResponseSchema.safeParse(await apiGet(path10, { headers }));
9486
9489
  } catch {
9487
9490
  continue;
9488
9491
  }
@@ -10111,7 +10114,7 @@ var createCmd = new Command11("create").description("Create a new task (costs th
10111
10114
  "Only workers with one of these identities may claim, pitch, bid, submit proofs or submit work (comma-separated; any one is enough): erc8004:identity:registered, erc8004:reputation:reputable"
10112
10115
  ).option(
10113
10116
  "--require-verified <verifiers>",
10114
- "Only workers one of these verifiers passes may work on the task (comma-separated; any one is enough): tap:identity:verified (verified agents) or tap:identity:known (known or verified agents). With --require-identity too, both must be met."
10117
+ "Only workers one of these verifiers passes may work on the task (comma-separated; any one is enough): tap:identity:known (any agent registered with TAP; the level to use) or tap:identity:verified (agents the verifier reviewed by hand; the verifier does not use this level yet). With --require-identity too, both must be met."
10115
10118
  ).option("--tags <tags>", "Comma-separated tags").option(
10116
10119
  "--capabilities <slugs>",
10117
10120
  "Comma-separated capability slugs the task needs, from `taskmarket capabilities` (active entries only; capped like a listing)"
@@ -10668,7 +10671,15 @@ async function runCreateTask(input, extra = {}) {
10668
10671
  stakeRequired: stake.stakeRequired,
10669
10672
  stakeBps: stake.stakeBps,
10670
10673
  tags: opts.tags ? opts.tags.split(",").map((t) => t.trim()) : [],
10671
- hookContracts: hooks,
10674
+ // The requester's own hooks only. The server attaches the payout gate after them and
10675
+ // before the sponsored hook, and the funding hash lists the hooks in that order.
10676
+ hookContracts: hooks.filter((hook) => !gateHook || hook.toLowerCase() !== gateHook),
10677
+ ...gatesTasks.length > 0 ? { payoutGate: { gatesTaskIds: gatesTasks } } : payoutGate ? {
10678
+ payoutGate: {
10679
+ ...payoutGate.gatingTaskId ? { gatingTaskId: payoutGate.gatingTaskId } : {},
10680
+ deadline: payoutGate.deadline
10681
+ }
10682
+ } : {},
10672
10683
  evaluator: opts.evaluator,
10673
10684
  evaluatorFeeBps: opts.evaluatorFeeBps ? Number(opts.evaluatorFeeBps) : void 0,
10674
10685
  evaluationWindowHours: opts.evaluationWindow ? Number(opts.evaluationWindow) : void 0,
@@ -10877,7 +10888,7 @@ var listCmd = new Command12("list").alias("search").description("List available
10877
10888
  "Only tasks that require this worker identity: erc8004:identity:registered or erc8004:reputation:reputable"
10878
10889
  ).option(
10879
10890
  "--verified-by <verifier>",
10880
- "Only tasks that require this verifier: tap:identity:verified or tap:identity:known"
10891
+ "Only tasks that require this verifier: tap:identity:known or tap:identity:verified"
10881
10892
  ).option("--limit <n>", "Maximum results to return", "20").option(
10882
10893
  "--cursor <cursor>",
10883
10894
  "Cursor from previous page (nextCursor in JSON output); pass it with the same --sort and filters"
@@ -11246,9 +11257,9 @@ function runCliChecks(spec, engineResults, target, options) {
11246
11257
  }
11247
11258
  return engineResults.map((r) => byId.get(r.id) ?? r);
11248
11259
  }
11249
- function isDirectory(path9) {
11260
+ function isDirectory(path10) {
11250
11261
  try {
11251
- return statSync(path9).isDirectory();
11262
+ return statSync(path10).isDirectory();
11252
11263
  } catch {
11253
11264
  return false;
11254
11265
  }
@@ -11315,11 +11326,11 @@ function deliverablePatch(files, patch) {
11315
11326
  return patch ?? taskCheckedPatch(files);
11316
11327
  }
11317
11328
  function runTaskChecks(spec, input) {
11318
- const read4 = (path9, encoding) => {
11329
+ const read4 = (path10, encoding) => {
11319
11330
  try {
11320
- return encoding ? readFileSync(path9, encoding) : readFileSync(path9);
11331
+ return encoding ? readFileSync(path10, encoding) : readFileSync(path10);
11321
11332
  } catch (error) {
11322
- throw new Error(`Cannot read ${path9}: ${error.message}`);
11333
+ throw new Error(`Cannot read ${path10}: ${error.message}`);
11323
11334
  }
11324
11335
  };
11325
11336
  const results = [];
@@ -11410,6 +11421,59 @@ async function confirmTaskOnSelectedNetwork(taskId, task) {
11410
11421
  return false;
11411
11422
  }
11412
11423
 
11424
+ // src/lib/worker-visibility.ts
11425
+ var APPEAL_REASON_TEXT = {
11426
+ no_evaluator: "the task has no evaluator",
11427
+ no_dispute_resolver: "the task names no dispute resolver",
11428
+ hook_can_veto_appeal: "a hook on the task can refuse an appeal",
11429
+ hook_powers_unknown: "a hook on the task has powers that are not known yet, so it may refuse an appeal"
11430
+ };
11431
+ function workerVisibilityWarnings(task) {
11432
+ const visibility = task?.workerVisibility;
11433
+ if (!visibility) return [];
11434
+ const warnings = [];
11435
+ const reducing = visibility.hooks.filter((hook) => hook.transforming === true);
11436
+ if (visibility.payoutCanBeReduced) {
11437
+ warnings.push(
11438
+ cliWarning(
11439
+ "payout_can_be_reduced",
11440
+ `A hook on this task can reduce your payout below what the evaluator or requester approves (${reducing.map((hook) => hook.name ?? hook.address).join(", ")}). ` + (visibility.appealPossible ? "You can appeal a verdict to the dispute resolver." : "You cannot appeal a reduction on this task.") + " Run `taskmarket task get` for each hook's powers.",
11441
+ {
11442
+ hooks: reducing.map((hook) => ({
11443
+ address: hook.address,
11444
+ name: hook.name,
11445
+ canReducePayout: hook.canReducePayout,
11446
+ canTakeFee: hook.canTakeFee
11447
+ })),
11448
+ appealPossible: visibility.appealPossible
11449
+ }
11450
+ )
11451
+ );
11452
+ }
11453
+ if (task?.evaluator && !visibility.appealPossible && visibility.appealUnavailableReason) {
11454
+ warnings.push(
11455
+ cliWarning(
11456
+ "appeal_unavailable",
11457
+ `You cannot appeal the evaluator's verdict: ${APPEAL_REASON_TEXT[visibility.appealUnavailableReason]}.`,
11458
+ { reason: visibility.appealUnavailableReason }
11459
+ )
11460
+ );
11461
+ }
11462
+ return warnings;
11463
+ }
11464
+ async function workerVisibilityWarningsFor(taskId, task) {
11465
+ if (task !== void 0) return workerVisibilityWarnings(task);
11466
+ try {
11467
+ return workerVisibilityWarnings(await getTask(cliTaskReadContext(), { taskId }));
11468
+ } catch {
11469
+ return [];
11470
+ }
11471
+ }
11472
+ async function workerVisibilityWarningOptions(taskId, task) {
11473
+ const warnings = await workerVisibilityWarningsFor(taskId, task);
11474
+ return warnings.length > 0 ? { warnings } : {};
11475
+ }
11476
+
11413
11477
  // src/commands/task/submit.ts
11414
11478
  function checksSummary(run2) {
11415
11479
  return { passed: run2.passed, failed: run2.failed, skipped: run2.skipped, warnings: run2.warnings };
@@ -11437,8 +11501,10 @@ var submitCmd = new Command14("submit").description("Submit work for a task").ar
11437
11501
  return;
11438
11502
  }
11439
11503
  let checks = null;
11504
+ let readTask = null;
11440
11505
  if (!opts.skipChecks) {
11441
11506
  const task = await getTask(cliTaskReadContext(), { taskId });
11507
+ readTask = task;
11442
11508
  if (!task) {
11443
11509
  printError(
11444
11510
  `Task not found: ${taskId} (or this is a private task you don't have access to)`
@@ -11497,7 +11563,7 @@ var submitCmd = new Command14("submit").description("Submit work for a task").ar
11497
11563
  const { submissionId, idempotencyKey } = await submitTaskFiles(
11498
11564
  cliTaskWriteContext(keystore),
11499
11565
  { taskId },
11500
- opts.file.map((path9) => ({ path: path9, role: opts.role })),
11566
+ opts.file.map((path10) => ({ path: path10, role: opts.role })),
11501
11567
  { idempotencyKey: submissionKey }
11502
11568
  );
11503
11569
  printResult(
@@ -11505,7 +11571,7 @@ var submitCmd = new Command14("submit").description("Submit work for a task").ar
11505
11571
  submissionId,
11506
11572
  ...opts.skipChecks ? { checks: { skipped: true } } : checks ? { checks: checksSummary(checks) } : {}
11507
11573
  },
11508
- { idempotencyKey }
11574
+ { idempotencyKey, ...await workerVisibilityWarningOptions(taskId, readTask) }
11509
11575
  );
11510
11576
  } finally {
11511
11577
  submitCmd.setOptionValue("file", []);
@@ -11949,7 +12015,7 @@ var claimCmd = new Command20("claim").description("Claim a task as a worker").ar
11949
12015
  const { claimId, idempotencyKey } = await claimTask(cliTaskWriteContext(keystore), { taskId });
11950
12016
  printResult(
11951
12017
  { claimId, ...stake > 0n ? { stake: stake.toString() } : {} },
11952
- { idempotencyKey }
12018
+ { idempotencyKey, ...await workerVisibilityWarningOptions(taskId, task) }
11953
12019
  );
11954
12020
  });
11955
12021
 
@@ -11980,7 +12046,10 @@ var pitchCmd = new Command21("pitch").description("Submit a pitch for a task (co
11980
12046
  { maxAmount: ACTION_FEE_MAX_AMOUNT, ...tap ? { tap } : {} }
11981
12047
  )
11982
12048
  );
11983
- printResult({ pitchId: result.pitchId }, { idempotencyKey });
12049
+ printResult(
12050
+ { pitchId: result.pitchId },
12051
+ { idempotencyKey, ...await workerVisibilityWarningOptions(taskId) }
12052
+ );
11984
12053
  }
11985
12054
  );
11986
12055
 
@@ -12085,21 +12154,24 @@ var bidCmd = new Command26("bid").description("Submit a bid on an auction task")
12085
12154
  }
12086
12155
  if (!await confirmUnverifiedHooks("bid", taskId, opts.acceptUnverifiedHooks)) return;
12087
12156
  if (!await confirmStakeTerms("bid", taskId, opts.yes)) return;
12088
- const path9 = `/api/tasks/${taskId}/bids`;
12157
+ const path10 = `/api/tasks/${taskId}/bids`;
12089
12158
  const body = { taskId, price: priceBaseUnits };
12090
12159
  const task = await taskRequirementsOf(taskId);
12091
12160
  const gated = (task?.identity?.length ?? 0) > 0 || taskRequiresTap(task);
12092
12161
  const { data: result, idempotencyKey } = gated ? await attestedWorkerAction(
12093
12162
  taskId,
12094
12163
  await loadKeystore(),
12095
- async (tap) => x402Post(path9, body, {
12164
+ async (tap) => x402Post(path10, body, {
12096
12165
  maxAmount: ACTION_FEE_MAX_AMOUNT,
12097
12166
  headers: (await signReadAuth())?.headers ?? {},
12098
12167
  ...tap ? { tap } : {}
12099
12168
  }),
12100
12169
  task
12101
- ) : await x402Post(path9, body, { maxAmount: ACTION_FEE_MAX_AMOUNT });
12102
- printResult({ bidId: result.bidId }, { idempotencyKey });
12170
+ ) : await x402Post(path10, body, { maxAmount: ACTION_FEE_MAX_AMOUNT });
12171
+ printResult(
12172
+ { bidId: result.bidId },
12173
+ { idempotencyKey, ...await workerVisibilityWarningOptions(taskId) }
12174
+ );
12103
12175
  }
12104
12176
  );
12105
12177
 
@@ -12118,19 +12190,19 @@ var auctionAcceptCmd = new Command27("auction-accept").description("Accept curre
12118
12190
  return;
12119
12191
  }
12120
12192
  }
12121
- const path9 = `/api/tasks/${taskId}/bids/accept`;
12193
+ const path10 = `/api/tasks/${taskId}/bids/accept`;
12122
12194
  const task = await taskRequirementsOf(taskId);
12123
12195
  const gated = (task?.identity?.length ?? 0) > 0 || taskRequiresTap(task);
12124
12196
  const { data: result, idempotencyKey } = gated ? await attestedWorkerAction(
12125
12197
  taskId,
12126
12198
  await loadKeystore(),
12127
- async (tap) => x402Post(path9, body, {
12199
+ async (tap) => x402Post(path10, body, {
12128
12200
  maxAmount: ACTION_FEE_MAX_AMOUNT,
12129
12201
  headers: (await signReadAuth())?.headers ?? {},
12130
12202
  ...tap ? { tap } : {}
12131
12203
  }),
12132
12204
  task
12133
- ) : await x402Post(path9, body, { maxAmount: ACTION_FEE_MAX_AMOUNT });
12205
+ ) : await x402Post(path10, body, { maxAmount: ACTION_FEE_MAX_AMOUNT });
12134
12206
  const { chainId } = selectedNetwork();
12135
12207
  printResult(
12136
12208
  {
@@ -12157,7 +12229,7 @@ var SubmissionPageSchema = TaskChildListSchema.pick({ cursor: true }).extend({
12157
12229
  });
12158
12230
  var submissionsCmd = new Command28("submissions").description("List submissions for a task").argument("<taskId>", "Task ID (0x-prefixed hex)").option(
12159
12231
  "--passed-check <provider>",
12160
- "Only submissions whose worker passed this check when submitting: erc8004:identity:registered, erc8004:reputation:reputable, tap:identity:verified or tap:identity:known"
12232
+ "Only submissions whose worker passed this check when submitting: erc8004:identity:registered, erc8004:reputation:reputable, tap:identity:known or tap:identity:verified"
12161
12233
  ).option("--limit <n>", "Page size (1-500); without it every submission is listed").option("--cursor <id>", "Last returned id; read the following page").option("--ids <ids>", "Only these submissions: comma-separated ids (at most 50)").action(
12162
12234
  async (taskId, opts) => {
12163
12235
  const passedCheck = parseRequirementFilter(opts.passedCheck, CHECK_FILTER, "--passed-check");
@@ -12594,7 +12666,7 @@ var updateCmd = new Command40("update").description(
12594
12666
  "Replace the identity requirement (comma-separated, any one is enough: erc8004:identity:registered, erc8004:reputation:reputable; none clears it). Refused once a worker has committed."
12595
12667
  ).option(
12596
12668
  "--require-verified <verifiers>",
12597
- "Replace the verifier requirement (comma-separated, any one is enough: tap:identity:verified, tap:identity:known; none clears it). tap:identity:known also accepts known agents; tap:identity:verified needs verified ones. Refused once a worker has committed."
12669
+ "Replace the verifier requirement (comma-separated, any one is enough: tap:identity:known, tap:identity:verified; none clears it). tap:identity:known accepts any agent registered with TAP; tap:identity:verified needs one the verifier reviewed by hand, a level it does not use yet. Refused once a worker has committed."
12598
12670
  ).action(
12599
12671
  async (taskId, opts) => {
12600
12672
  const body = { taskId };
@@ -12923,7 +12995,9 @@ var appealCmd = new Command44("appeal").description("Appeal an evaluator verdict
12923
12995
 
12924
12996
  // src/commands/task/evaluator-timeout.ts
12925
12997
  import { Command as Command45 } from "commander";
12926
- var evaluatorTimeoutCmd = new Command45("evaluator-timeout").description("Trigger evaluator timeout after the evaluation window expires (anyone)").argument("<taskId>", "Task ID (0x-prefixed hex)").action(async (taskId) => {
12998
+ var evaluatorTimeoutCmd = new Command45("evaluator-timeout").description(
12999
+ "Trigger evaluator timeout after the evaluation window expires (anyone); also bounty and benchmark tasks with an evaluator and a live submission"
13000
+ ).argument("<taskId>", "Task ID (0x-prefixed hex)").action(async (taskId) => {
12927
13001
  const { data: result, idempotencyKey } = await x402Post(`/api/tasks/${taskId}/evaluator-timeout`, { taskId }, { maxAmount: ACTION_FEE_MAX_AMOUNT });
12928
13002
  printResult(
12929
13003
  { txHash: result.txHash, ...await settleRecording(result, idempotencyKey) },
@@ -13138,11 +13212,11 @@ function isCommitment(value) {
13138
13212
  }
13139
13213
 
13140
13214
  // src/commands/task/checks.ts
13141
- function readBytes(path9) {
13215
+ function readBytes(path10) {
13142
13216
  try {
13143
- return readFileSync2(path9);
13217
+ return readFileSync2(path10);
13144
13218
  } catch (error) {
13145
- return `Cannot read ${path9}: ${error.message}`;
13219
+ return `Cannot read ${path10}: ${error.message}`;
13146
13220
  }
13147
13221
  }
13148
13222
  var commitCmd = new Command54("commit").description(
@@ -13266,7 +13340,7 @@ async function confirmAtTerminal(lines, unattended) {
13266
13340
  `);
13267
13341
  const readline = createInterface3({ input: process.stdin, output: process.stderr });
13268
13342
  const answer = await new Promise(
13269
- (resolve2) => readline.question("Type yes to approve: ", resolve2)
13343
+ (resolve3) => readline.question("Type yes to approve: ", resolve3)
13270
13344
  );
13271
13345
  readline.close();
13272
13346
  return answer.trim().toLowerCase() === "yes";
@@ -13456,7 +13530,7 @@ async function runAgentCommand(options) {
13456
13530
  try {
13457
13531
  const { assertAgentCompatibility } = await import("./compatibility-636WJOEX.js");
13458
13532
  const pi = assertAgentCompatibility();
13459
- const { runAgent } = await import("./launch-FOCL5JOR.js");
13533
+ const { runAgent } = await import("./launch-56RHQCWT.js");
13460
13534
  result = await runAgent({
13461
13535
  model: options.model,
13462
13536
  pi,
@@ -13890,13 +13964,13 @@ function agentManagementCommands() {
13890
13964
  const status = new Command58("status").description(
13891
13965
  "Show the agent channels (locked, charged, refundable), purchases with an unknown outcome, the sandbox and compute credit. Reads only."
13892
13966
  ).action(async () => {
13893
- const { collectAgentStatus } = await import("./status-A636ECTT.js");
13967
+ const { collectAgentStatus } = await import("./status-EBMZGDFS.js");
13894
13968
  await run(() => collectAgentStatus());
13895
13969
  });
13896
13970
  const doctor = new Command58("doctor").description(
13897
13971
  "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."
13898
13972
  ).action(async () => {
13899
- const { runDoctor } = await import("./doctor-NTQ3ZJRU.js");
13973
+ const { runDoctor } = await import("./doctor-HV5QQDGU.js");
13900
13974
  const report = await run(() => runDoctor());
13901
13975
  if (report && !report.ok) process.exitCode = 1;
13902
13976
  });
@@ -13907,7 +13981,7 @@ function agentManagementCommands() {
13907
13981
  "Reconcile the open purchases of this channel, as status lists it; also reaches retired channels"
13908
13982
  ).action(
13909
13983
  async (invocationId, options) => {
13910
- const { reconcileChannelPurchases, reconcileInvocation } = await import("./reconcile-IKPAKGH3.js");
13984
+ const { reconcileChannelPurchases, reconcileInvocation } = await import("./reconcile-PQXSATCK.js");
13911
13985
  const choice = { rail: options.rail, channel: options.channel };
13912
13986
  if (invocationId !== void 0) {
13913
13987
  await run(() => reconcileInvocation(invocationId, { choice }));
@@ -13939,7 +14013,7 @@ function agentManagementCommands() {
13939
14013
  `Not a USDC amount: ${options.amount} (digits, at most 6 decimals)`
13940
14014
  );
13941
14015
  }
13942
- const { openAgentChannels, requestTopUp, selectRail, withdrawalHatch } = await import("./channels-FWGJII6Y.js");
14016
+ const { openAgentChannels, requestTopUp, selectRail, withdrawalHatch } = await import("./channels-LDMZ3OEM.js");
13943
14017
  const { rails } = await openAgentChannels();
13944
14018
  const result = await requestTopUp(selectRail(rails, options.rail), amount);
13945
14019
  return {
@@ -13959,8 +14033,8 @@ function agentManagementCommands() {
13959
14033
  await run(async () => {
13960
14034
  await requireExperimental();
13961
14035
  const { AGENT_VIEW_VERSION } = await import("./budget-view-J6L7X6EY.js");
13962
- const { closeChannel, openAgentChannels, selectChannel } = await import("./channels-FWGJII6Y.js");
13963
- const { reconcileLeasedPurchase } = await import("./reconcile-IKPAKGH3.js");
14036
+ const { closeChannel, openAgentChannels, selectChannel } = await import("./channels-LDMZ3OEM.js");
14037
+ const { reconcileLeasedPurchase } = await import("./reconcile-PQXSATCK.js");
13964
14038
  const opened = await openAgentChannels();
13965
14039
  const { rail, retired } = selectChannel(opened, options);
13966
14040
  const result = await closeChannel(
@@ -14014,7 +14088,7 @@ function agentManagementCommands() {
14014
14088
  async (options) => {
14015
14089
  await run(async () => {
14016
14090
  await requireExperimental();
14017
- const { runPull } = await import("./sync-pull-DVC4R6BN.js");
14091
+ const { runPull } = await import("./sync-pull-423LBSPO.js");
14018
14092
  const { terminalPrompter } = await import("./prompter-LSICEYSQ.js");
14019
14093
  return runPull(options, {
14020
14094
  interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
@@ -14094,7 +14168,7 @@ var agentsCommand = new Command60("agents").description("Browse the worker direc
14094
14168
  "Filter by actor kind: agent, human (the web directory filtered to humans) or hosted"
14095
14169
  ).option(
14096
14170
  "--verified-by <verifier>",
14097
- "Only agents this verifier passed within the last 30 days: tap:identity:verified or tap:identity:known (also matches known agents)"
14171
+ "Only agents this verifier passed within the last 30 days: tap:identity:known (any agent registered with TAP) or tap:identity:verified (reviewed by hand; not yet used by the verifier)"
14098
14172
  ).option(
14099
14173
  "--availability <availability>",
14100
14174
  "available (open and under capacity), unavailable (paused or fully booked) or any",
@@ -15036,7 +15110,7 @@ function normalizePrivateKey(raw) {
15036
15110
  return `0x${hex3}`;
15037
15111
  }
15038
15112
  function promptHiddenInput(prompt) {
15039
- return new Promise((resolve2) => {
15113
+ return new Promise((resolve3) => {
15040
15114
  const rl = createInterface4({
15041
15115
  input: process.stdin,
15042
15116
  output: process.stderr,
@@ -15056,7 +15130,7 @@ function promptHiddenInput(prompt) {
15056
15130
  muted.muted = false;
15057
15131
  process.stderr.write("\n");
15058
15132
  rl.close();
15059
- resolve2(answer);
15133
+ resolve3(answer);
15060
15134
  });
15061
15135
  });
15062
15136
  }
@@ -15660,7 +15734,7 @@ function progress(message) {
15660
15734
  `);
15661
15735
  }
15662
15736
  function sleep(ms2) {
15663
- return new Promise((resolve2) => setTimeout(resolve2, ms2));
15737
+ return new Promise((resolve3) => setTimeout(resolve3, ms2));
15664
15738
  }
15665
15739
  function sameAddress2(a, b) {
15666
15740
  return a.toLowerCase() === b.toLowerCase();
@@ -15896,7 +15970,7 @@ async function waitForSolanaSignature(rpc, signature, { timeoutMs = CONFIRM_TIME
15896
15970
  if (status?.confirmationStatus === "confirmed" || status?.confirmationStatus === "finalized")
15897
15971
  return true;
15898
15972
  if (Date.now() >= deadline) return false;
15899
- await new Promise((resolve2) => setTimeout(resolve2, pollMs));
15973
+ await new Promise((resolve3) => setTimeout(resolve3, pollMs));
15900
15974
  }
15901
15975
  }
15902
15976
  async function relaySolanaInstructions(input) {
@@ -15966,13 +16040,13 @@ async function withdrawOnSolana(amount, opts) {
15966
16040
  var RECEIVE_POLICY_BLOCKED = "recipient_receive_policy_blocked";
15967
16041
  async function withdrawOnTempo(input) {
15968
16042
  const { keystore, chainId, withdrawalAddress, amountBaseUnits } = input;
15969
- const token = taskmarketChain(chainId).payment.token;
15970
- if (!token) throw new Error(`Chain ${chainId} has no known payment token`);
16043
+ const token2 = taskmarketChain(chainId).payment.token;
16044
+ if (!token2) throw new Error(`Chain ${chainId} has no known payment token`);
15971
16045
  const account = await createWalletAccountFromKeystore(keystore);
15972
16046
  const transaction = await signSponsoredTempoTransfer({
15973
16047
  signer: { address: account.address, sign: (args) => account.sign(args) },
15974
16048
  chainId,
15975
- token,
16049
+ token: token2,
15976
16050
  to: withdrawalAddress,
15977
16051
  amount: BigInt(amountBaseUnits),
15978
16052
  validBefore: Math.floor(Date.now() / 1e3) + clientValidityWindowSeconds(chainId, MPP_TEMPO_DEFAULT_VALIDITY_SECONDS),
@@ -16236,12 +16310,12 @@ function decodeEnvelope(raw) {
16236
16310
  var XmtpQueryManager = class {
16237
16311
  pending = /* @__PURE__ */ new Map();
16238
16312
  waitForResponse(requestId, timeoutMs) {
16239
- return new Promise((resolve2, reject) => {
16313
+ return new Promise((resolve3, reject) => {
16240
16314
  const timeout = setTimeout(() => {
16241
16315
  this.pending.delete(requestId);
16242
16316
  reject(new Error(`XMTP query timed out after ${timeoutMs}ms`));
16243
16317
  }, timeoutMs);
16244
- this.pending.set(requestId, { resolve: resolve2, reject, timeout });
16318
+ this.pending.set(requestId, { resolve: resolve3, reject, timeout });
16245
16319
  });
16246
16320
  }
16247
16321
  resolveResponse(envelope) {
@@ -16507,7 +16581,7 @@ function shouldHandleEnvelope(envelope, options) {
16507
16581
  return true;
16508
16582
  }
16509
16583
  function sleep2(ms2) {
16510
- return new Promise((resolve2) => setTimeout(resolve2, ms2));
16584
+ return new Promise((resolve3) => setTimeout(resolve3, ms2));
16511
16585
  }
16512
16586
  async function runStreamWithReconnect(options) {
16513
16587
  const maxReconnectAttempts = options.maxReconnectAttempts ?? Number.POSITIVE_INFINITY;
@@ -16661,7 +16735,7 @@ async function createDevClient(input) {
16661
16735
  live = true;
16662
16736
  options?.onLive?.();
16663
16737
  }
16664
- await new Promise((resolve2) => setTimeout(resolve2, 100));
16738
+ await new Promise((resolve3) => setTimeout(resolve3, 100));
16665
16739
  }
16666
16740
  return;
16667
16741
  }
@@ -16676,7 +16750,7 @@ async function createDevClient(input) {
16676
16750
  }
16677
16751
  continue;
16678
16752
  }
16679
- await new Promise((resolve2) => setTimeout(resolve2, 250));
16753
+ await new Promise((resolve3) => setTimeout(resolve3, 250));
16680
16754
  }
16681
16755
  },
16682
16756
  async setConsentState(_inboxId, _state) {
@@ -16807,7 +16881,7 @@ function toTransportError(error, fallbackMessage) {
16807
16881
  return new XmtpTransportError(message, category, error);
16808
16882
  }
16809
16883
  function sleep3(ms2) {
16810
- return new Promise((resolve2) => setTimeout(resolve2, ms2));
16884
+ return new Promise((resolve3) => setTimeout(resolve3, ms2));
16811
16885
  }
16812
16886
  function parseRetryAttempts() {
16813
16887
  const raw = process.env.TASKMARKET_XMTP_SEND_MAX_ATTEMPTS;
@@ -16906,7 +16980,7 @@ async function sendViaConversation(client, toInboxId, body) {
16906
16980
  );
16907
16981
  }
16908
16982
  function callAsync(operation) {
16909
- return new Promise((resolve2) => resolve2(operation()));
16983
+ return new Promise((resolve3) => resolve3(operation()));
16910
16984
  }
16911
16985
  async function sendWithSdkClient(client, toInboxId, body) {
16912
16986
  const clientObject = asObject(client);
@@ -17987,23 +18061,23 @@ async function readHistory(options) {
17987
18061
  return;
17988
18062
  }
17989
18063
  const headers = options.task ? (await signReadAuth())?.headers ?? {} : (await readAuthHeaders()).headers;
17990
- const path9 = options.task ? `/api/market-events/tasks/${encodeURIComponent(options.task)}${query3({ since, limit })}` : `/api/market-events${query3({ since, limit })}`;
17991
- printResult(await apiGet(path9, { headers }));
18064
+ const path10 = options.task ? `/api/market-events/tasks/${encodeURIComponent(options.task)}${query3({ since, limit })}` : `/api/market-events${query3({ since, limit })}`;
18065
+ printResult(await apiGet(path10, { headers }));
17992
18066
  }
17993
18067
  function warn(message) {
17994
18068
  process.stderr.write(`${JSON.stringify({ ok: true, warning: message })}
17995
18069
  `);
17996
18070
  }
17997
18071
  function abortableSleep(ms2, signal) {
17998
- return new Promise((resolve2) => {
18072
+ return new Promise((resolve3) => {
17999
18073
  if (signal?.aborted) {
18000
- resolve2();
18074
+ resolve3();
18001
18075
  return;
18002
18076
  }
18003
18077
  const done = () => {
18004
18078
  clearTimeout(timer);
18005
18079
  signal?.removeEventListener("abort", done);
18006
- resolve2();
18080
+ resolve3();
18007
18081
  };
18008
18082
  const timer = setTimeout(done, ms2);
18009
18083
  signal?.addEventListener("abort", done, { once: true });
@@ -18161,7 +18235,7 @@ async function assertTaskVisible(taskId, auth, options) {
18161
18235
  readAuth: async () => auth,
18162
18236
  transport: {
18163
18237
  ...cliTaskTransport,
18164
- get: (path9, headers) => apiGet(path9, { headers, signal })
18238
+ get: (path10, headers) => apiGet(path10, { headers, signal })
18165
18239
  }
18166
18240
  };
18167
18241
  let task;
@@ -18382,15 +18456,15 @@ var EMAIL_POLL_INTERVAL_MS = 6e4;
18382
18456
  var EMAIL_RETRY_MAX_MS = 15 * 6e4;
18383
18457
  var MAX_CURSOR_IDS = 100;
18384
18458
  function abortableSleep2(ms2, signal) {
18385
- return new Promise((resolve2) => {
18459
+ return new Promise((resolve3) => {
18386
18460
  if (signal?.aborted) {
18387
- resolve2();
18461
+ resolve3();
18388
18462
  return;
18389
18463
  }
18390
18464
  const done = () => {
18391
18465
  clearTimeout(timer);
18392
18466
  signal?.removeEventListener("abort", done);
18393
- resolve2();
18467
+ resolve3();
18394
18468
  };
18395
18469
  const timer = setTimeout(done, ms2);
18396
18470
  signal?.addEventListener("abort", done, { once: true });
@@ -18654,13 +18728,13 @@ async function storeTaskFilters(json) {
18654
18728
  printResult({ source: "market", type: "discovery.filter", ...data }, { idempotencyKey });
18655
18729
  }
18656
18730
  function sleepOrAbort(ms2, signal) {
18657
- return new Promise((resolve2) => {
18658
- const id = setTimeout(resolve2, ms2);
18731
+ return new Promise((resolve3) => {
18732
+ const id = setTimeout(resolve3, ms2);
18659
18733
  signal.addEventListener(
18660
18734
  "abort",
18661
18735
  () => {
18662
18736
  clearTimeout(id);
18663
- resolve2();
18737
+ resolve3();
18664
18738
  },
18665
18739
  { once: true }
18666
18740
  );
@@ -18726,7 +18800,7 @@ function createDaemonCommand(seams = {}) {
18726
18800
  );
18727
18801
  }
18728
18802
  if (emailRequested && !emailAvailable) {
18729
- const hint = `${emailMissing} Run \`taskmarket email register --username <name>\` to get one.`;
18803
+ const hint = `${emailMissing} Run \`taskmarket email register\` to get one.`;
18730
18804
  if (!othersRun("email")) throw new Error(hint);
18731
18805
  if (explicitSources || emailLookupFailed) {
18732
18806
  process.stderr.write(`${hint} Following the other sources.
@@ -18874,8 +18948,8 @@ var listCommand = new Command81("list").description(
18874
18948
  const channel = parseChannel(options.channel);
18875
18949
  const headers = await walletHeaders();
18876
18950
  if (!headers) return;
18877
- const path9 = channel === "email" ? PREFERENCES_PATH : `${PREFERENCES_PATH}?channel=${channel}`;
18878
- printResult(await apiGet(path9, { headers }));
18951
+ const path10 = channel === "email" ? PREFERENCES_PATH : `${PREFERENCES_PATH}?channel=${channel}`;
18952
+ printResult(await apiGet(path10, { headers }));
18879
18953
  } catch (err) {
18880
18954
  renderFailure(err);
18881
18955
  }
@@ -19021,21 +19095,15 @@ import { Command as Command91 } from "commander";
19021
19095
 
19022
19096
  // src/commands/email/register.ts
19023
19097
  import { Command as Command83 } from "commander";
19024
- var registerCommand = new Command83("register").description("Register an email address for this agent").requiredOption("--username <name>", "Desired username (e.g. myagent)").action(async (opts) => {
19025
- const check = await apiGet(
19026
- `/api/emails/check-username?username=${encodeURIComponent(opts.username)}`
19027
- );
19028
- if (!check.available) {
19029
- printError(`Username "${opts.username}" is not available.`);
19030
- return;
19031
- }
19098
+ var registerCommand = new Command83("register").description(
19099
+ "Register this agent email address, agent-<id>@taskmarket.dev (the backend assigns the id)"
19100
+ ).action(async () => {
19032
19101
  const keystore = await loadKeystore();
19033
19102
  const { data: result, idempotencyKey } = await apiPost(
19034
19103
  "/api/emails/register",
19035
19104
  {
19036
19105
  deviceId: keystore.deviceId,
19037
- apiToken: keystore.apiToken,
19038
- username: opts.username
19106
+ apiToken: keystore.apiToken
19039
19107
  }
19040
19108
  );
19041
19109
  printResult({ emailAddress: result.emailAddress }, { idempotencyKey });
@@ -19076,13 +19144,19 @@ var readCommand = new Command85("read").description("Read an email by ID (marks
19076
19144
  import { Command as Command86 } from "commander";
19077
19145
  var sendCommand = new Command86("send").description("Send an email").requiredOption("--to <address>", "Recipient email address").requiredOption("--subject <subject>", "Email subject").requiredOption("--body <text>", "Email body text").action(async (opts) => {
19078
19146
  const keystore = await loadKeystore();
19079
- const { data: result, idempotencyKey } = await apiPost("/api/emails/send", {
19080
- deviceId: keystore.deviceId,
19081
- apiToken: keystore.apiToken,
19082
- to: opts.to,
19083
- subject: opts.subject,
19084
- bodyText: opts.body
19085
- });
19147
+ const { data: result, idempotencyKey } = await x402Post(
19148
+ "/api/emails/send",
19149
+ {
19150
+ chainId: selectedNetwork().chainId,
19151
+ deviceId: keystore.deviceId,
19152
+ apiToken: keystore.apiToken,
19153
+ to: opts.to,
19154
+ subject: opts.subject,
19155
+ bodyText: opts.body
19156
+ },
19157
+ // Mail to an outside address pays the standard action fee; internal mail is never charged.
19158
+ { maxAmount: STANDARD_X402_ACTION_AMOUNT }
19159
+ );
19086
19160
  printResult({ sent: result.sent }, { idempotencyKey });
19087
19161
  });
19088
19162
 
@@ -19103,13 +19177,19 @@ var replyCommand = new Command87("reply").description("Reply to an email").argum
19103
19177
  0,
19104
19178
  EMAIL_SEND_SUBJECT_MAX_LENGTH
19105
19179
  );
19106
- const { data: result, idempotencyKey } = await apiPost("/api/emails/send", {
19107
- deviceId: keystore.deviceId,
19108
- apiToken: keystore.apiToken,
19109
- to,
19110
- subject,
19111
- bodyText: opts.body
19112
- });
19180
+ const { data: result, idempotencyKey } = await x402Post(
19181
+ "/api/emails/send",
19182
+ {
19183
+ chainId: selectedNetwork().chainId,
19184
+ deviceId: keystore.deviceId,
19185
+ apiToken: keystore.apiToken,
19186
+ to,
19187
+ subject,
19188
+ bodyText: opts.body
19189
+ },
19190
+ // Mail to an outside address pays the standard action fee; internal mail is never charged.
19191
+ { maxAmount: STANDARD_X402_ACTION_AMOUNT }
19192
+ );
19113
19193
  printResult({ sent: result.sent }, { idempotencyKey });
19114
19194
  });
19115
19195
 
@@ -19240,7 +19320,7 @@ async function readStdin(firstByteMs) {
19240
19320
  let timer;
19241
19321
  const first = await Promise.race([
19242
19322
  iterator.next(),
19243
- ...firstByteMs === void 0 ? [] : [new Promise((resolve2) => timer = setTimeout(() => resolve2(null), firstByteMs))]
19323
+ ...firstByteMs === void 0 ? [] : [new Promise((resolve3) => timer = setTimeout(() => resolve3(null), firstByteMs))]
19244
19324
  ]);
19245
19325
  clearTimeout(timer);
19246
19326
  if (first === null) {
@@ -19816,7 +19896,7 @@ async function walk(root) {
19816
19896
  const names = (await readdir(dir)).sort();
19817
19897
  for (const name of names) {
19818
19898
  const full = join2(dir, name);
19819
- const path9 = relative(root, full).split(sep).join("/");
19899
+ const path10 = relative(root, full).split(sep).join("/");
19820
19900
  const info = await lstat(full);
19821
19901
  if (info.isDirectory()) {
19822
19902
  await visit(full);
@@ -19825,7 +19905,7 @@ async function walk(root) {
19825
19905
  if (entries.length >= MAX_ENTRIES)
19826
19906
  throw new Error(`The skill directory has more than ${MAX_ENTRIES} files`);
19827
19907
  const mode = info.isSymbolicLink() ? USER_SKILL_GIT_MODES.symlink : !info.isFile() ? "other" : info.mode & 73 ? USER_SKILL_GIT_MODES.executable : USER_SKILL_GIT_MODES.file;
19828
- entries.push({ path: path9, mode, full });
19908
+ entries.push({ path: path10, mode, full });
19829
19909
  }
19830
19910
  };
19831
19911
  await visit(root);
@@ -20228,9 +20308,9 @@ async function confirmManualResolution() {
20228
20308
  if (!process.stdin.isTTY) throw new Error("Manual resolution requires an interactive TTY");
20229
20309
  const readline = createInterface5({ input: process.stdin, output: process.stderr });
20230
20310
  const answer = await new Promise(
20231
- (resolve2) => readline.question(
20311
+ (resolve3) => readline.question(
20232
20312
  "Manual resolution changes local spending accounting. Type resolve to continue: ",
20233
- resolve2
20313
+ resolve3
20234
20314
  )
20235
20315
  );
20236
20316
  readline.close();
@@ -20286,7 +20366,7 @@ async function confirmUnattendedRule(rule) {
20286
20366
  );
20287
20367
  const readline = createInterface6({ input: process.stdin, output: process.stderr });
20288
20368
  const answer = await new Promise(
20289
- (resolve2) => readline.question("Type authorize to grant unattended spending: ", resolve2)
20369
+ (resolve3) => readline.question("Type authorize to grant unattended spending: ", resolve3)
20290
20370
  );
20291
20371
  readline.close();
20292
20372
  return answer.trim().toLowerCase() === "authorize";
@@ -23550,6 +23630,28 @@ var CONFIG_DISCRIMINATOR = new Uint8Array([
23550
23630
  204,
23551
23631
  130
23552
23632
  ]);
23633
+ function getConfigDecoder() {
23634
+ return getStructDecoder([
23635
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
23636
+ ["admin", getAddressDecoder()],
23637
+ ["settlers", getArrayDecoder(getAddressDecoder())],
23638
+ ["threshold", getU8Decoder()],
23639
+ ["paused", getBooleanDecoder()],
23640
+ ["feeBps", getU16Decoder()],
23641
+ ["feeRecipient", getAddressDecoder()],
23642
+ ["bump", getU8Decoder()],
23643
+ ["claimDelaySeconds", getU64Decoder()],
23644
+ ["pendingAdmin", getAddressDecoder()],
23645
+ ["clusterId", fixDecoderSize(getBytesDecoder(), 32)]
23646
+ ]);
23647
+ }
23648
+ function decodeConfig(encodedAccount) {
23649
+ return decodeAccount(encodedAccount, getConfigDecoder());
23650
+ }
23651
+ async function fetchMaybeConfig(rpc, address3, config) {
23652
+ const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
23653
+ return decodeConfig(maybeAccount);
23654
+ }
23553
23655
 
23554
23656
  // ../../packages/solana-sponsored-client/dist/generated/accounts/payoutBinding.js
23555
23657
  var PAYOUT_BINDING_DISCRIMINATOR = new Uint8Array([
@@ -23569,7 +23671,9 @@ function getPayoutBindingDecoder() {
23569
23671
  ["agent", fixDecoderSize(getBytesDecoder(), 20)],
23570
23672
  ["payout", getAddressDecoder()],
23571
23673
  ["nonce", getU64Decoder()],
23572
- ["bump", getU8Decoder()]
23674
+ ["bump", getU8Decoder()],
23675
+ ["pendingPayout", getAddressDecoder()],
23676
+ ["pendingEffectiveAt", getI64Decoder()]
23573
23677
  ]);
23574
23678
  }
23575
23679
 
@@ -23798,6 +23902,7 @@ function getBindPayoutInstructionDataEncoder() {
23798
23902
  ["agent", fixEncoderSize(getBytesEncoder(), 20)],
23799
23903
  ["payout", getAddressEncoder()],
23800
23904
  ["nonce", getU64Encoder()],
23905
+ ["deadline", getU64Encoder()],
23801
23906
  ["signature", fixEncoderSize(getBytesEncoder(), 65)]
23802
23907
  ]), (value) => ({ ...value, discriminator: BIND_PAYOUT_DISCRIMINATOR }));
23803
23908
  }
@@ -23805,6 +23910,7 @@ async function getBindPayoutInstructionAsync(input, config) {
23805
23910
  const programAddress = config?.programAddress ?? SPONSORED_TASKS_PROGRAM_ADDRESS;
23806
23911
  const getAccountMeta = getAccountMetaFactory2(programAddress, "programId");
23807
23912
  const originalAccounts = {
23913
+ config: { value: input.config ?? null, isSigner: false, isWritable: false },
23808
23914
  binding: { value: input.binding ?? null, isSigner: false, isWritable: true },
23809
23915
  payer: { value: input.payer ?? null, isSigner: true, isWritable: true },
23810
23916
  systemProgram: { value: input.systemProgram ?? null, isSigner: false, isWritable: false },
@@ -23813,6 +23919,9 @@ async function getBindPayoutInstructionAsync(input, config) {
23813
23919
  };
23814
23920
  const accounts = originalAccounts;
23815
23921
  const args = { ...input };
23922
+ if (!accounts.config.value) {
23923
+ accounts.config.value = await findConfigPda({ programAddress });
23924
+ }
23816
23925
  if (!accounts.binding.value) {
23817
23926
  accounts.binding.value = await findBindingPda({
23818
23927
  taskChainId: getNonNullResolvedInstructionInput2("taskChainId", args.taskChainId),
@@ -23824,6 +23933,7 @@ async function getBindPayoutInstructionAsync(input, config) {
23824
23933
  }
23825
23934
  return Object.freeze({
23826
23935
  accounts: [
23936
+ getAccountMeta("config", accounts.config),
23827
23937
  getAccountMeta("binding", accounts.binding),
23828
23938
  getAccountMeta("payer", accounts.payer),
23829
23939
  getAccountMeta("systemProgram", accounts.systemProgram),
@@ -24090,6 +24200,18 @@ var RELEASE_DISCRIMINATOR = new Uint8Array([
24090
24200
  241
24091
24201
  ]);
24092
24202
 
24203
+ // ../../packages/solana-sponsored-client/dist/generated/instructions/releaseExpired.js
24204
+ var RELEASE_EXPIRED_DISCRIMINATOR = new Uint8Array([
24205
+ 150,
24206
+ 199,
24207
+ 225,
24208
+ 10,
24209
+ 15,
24210
+ 244,
24211
+ 46,
24212
+ 47
24213
+ ]);
24214
+
24093
24215
  // ../../packages/solana-sponsored-client/dist/generated/instructions/reserve.js
24094
24216
  var RESERVE_DISCRIMINATOR = new Uint8Array([
24095
24217
  92,
@@ -24235,16 +24357,17 @@ var SponsoredTasksEvent;
24235
24357
  SponsoredTasksEvent2[SponsoredTasksEvent2["ManagerConfigured"] = 6] = "ManagerConfigured";
24236
24358
  SponsoredTasksEvent2[SponsoredTasksEvent2["ManagerRemoved"] = 7] = "ManagerRemoved";
24237
24359
  SponsoredTasksEvent2[SponsoredTasksEvent2["PauseSet"] = 8] = "PauseSet";
24238
- SponsoredTasksEvent2[SponsoredTasksEvent2["PayoutBound"] = 9] = "PayoutBound";
24239
- SponsoredTasksEvent2[SponsoredTasksEvent2["SettlementInstalled"] = 10] = "SettlementInstalled";
24240
- SponsoredTasksEvent2[SponsoredTasksEvent2["SettlementRevoked"] = 11] = "SettlementRevoked";
24241
- SponsoredTasksEvent2[SponsoredTasksEvent2["SettlersChanged"] = 12] = "SettlersChanged";
24242
- SponsoredTasksEvent2[SponsoredTasksEvent2["SponsoredTaskClaimed"] = 13] = "SponsoredTaskClaimed";
24243
- SponsoredTasksEvent2[SponsoredTasksEvent2["TaskReleased"] = 14] = "TaskReleased";
24244
- SponsoredTasksEvent2[SponsoredTasksEvent2["TaskReserved"] = 15] = "TaskReserved";
24245
- SponsoredTasksEvent2[SponsoredTasksEvent2["VaultCreated"] = 16] = "VaultCreated";
24246
- SponsoredTasksEvent2[SponsoredTasksEvent2["VaultEmergencyExited"] = 17] = "VaultEmergencyExited";
24247
- SponsoredTasksEvent2[SponsoredTasksEvent2["VaultFunded"] = 18] = "VaultFunded";
24360
+ SponsoredTasksEvent2[SponsoredTasksEvent2["PayoutBindingPending"] = 9] = "PayoutBindingPending";
24361
+ SponsoredTasksEvent2[SponsoredTasksEvent2["PayoutBound"] = 10] = "PayoutBound";
24362
+ SponsoredTasksEvent2[SponsoredTasksEvent2["SettlementInstalled"] = 11] = "SettlementInstalled";
24363
+ SponsoredTasksEvent2[SponsoredTasksEvent2["SettlementRevoked"] = 12] = "SettlementRevoked";
24364
+ SponsoredTasksEvent2[SponsoredTasksEvent2["SettlersChanged"] = 13] = "SettlersChanged";
24365
+ SponsoredTasksEvent2[SponsoredTasksEvent2["SponsoredTaskClaimed"] = 14] = "SponsoredTaskClaimed";
24366
+ SponsoredTasksEvent2[SponsoredTasksEvent2["TaskReleased"] = 15] = "TaskReleased";
24367
+ SponsoredTasksEvent2[SponsoredTasksEvent2["TaskReserved"] = 16] = "TaskReserved";
24368
+ SponsoredTasksEvent2[SponsoredTasksEvent2["VaultCreated"] = 17] = "VaultCreated";
24369
+ SponsoredTasksEvent2[SponsoredTasksEvent2["VaultEmergencyExited"] = 18] = "VaultEmergencyExited";
24370
+ SponsoredTasksEvent2[SponsoredTasksEvent2["VaultFunded"] = 19] = "VaultFunded";
24248
24371
  })(SponsoredTasksEvent || (SponsoredTasksEvent = {}));
24249
24372
  var SponsoredTasksInstruction;
24250
24373
  (function(SponsoredTasksInstruction2) {
@@ -24259,14 +24382,15 @@ var SponsoredTasksInstruction;
24259
24382
  SponsoredTasksInstruction2[SponsoredTasksInstruction2["InitConfig"] = 8] = "InitConfig";
24260
24383
  SponsoredTasksInstruction2[SponsoredTasksInstruction2["Pause"] = 9] = "Pause";
24261
24384
  SponsoredTasksInstruction2[SponsoredTasksInstruction2["Release"] = 10] = "Release";
24262
- SponsoredTasksInstruction2[SponsoredTasksInstruction2["Reserve"] = 11] = "Reserve";
24263
- SponsoredTasksInstruction2[SponsoredTasksInstruction2["RevokeSettlement"] = 12] = "RevokeSettlement";
24264
- SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetAdmin"] = 13] = "SetAdmin";
24265
- SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetClaimDelay"] = 14] = "SetClaimDelay";
24266
- SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetFee"] = 15] = "SetFee";
24267
- SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetManagers"] = 16] = "SetManagers";
24268
- SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetSettlers"] = 17] = "SetSettlers";
24269
- SponsoredTasksInstruction2[SponsoredTasksInstruction2["Settle"] = 18] = "Settle";
24385
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["ReleaseExpired"] = 11] = "ReleaseExpired";
24386
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["Reserve"] = 12] = "Reserve";
24387
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["RevokeSettlement"] = 13] = "RevokeSettlement";
24388
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetAdmin"] = 14] = "SetAdmin";
24389
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetClaimDelay"] = 15] = "SetClaimDelay";
24390
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetFee"] = 16] = "SetFee";
24391
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetManagers"] = 17] = "SetManagers";
24392
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["SetSettlers"] = 18] = "SetSettlers";
24393
+ SponsoredTasksInstruction2[SponsoredTasksInstruction2["Settle"] = 19] = "Settle";
24270
24394
  })(SponsoredTasksInstruction || (SponsoredTasksInstruction = {}));
24271
24395
 
24272
24396
  // ../../packages/solana-sponsored-client/dist/generated/errors/sponsoredTasks.js
@@ -24307,6 +24431,11 @@ var SPONSORED_TASKS_ERROR__PAYOUT_NOT_BOUND = 6033;
24307
24431
  var SPONSORED_TASKS_ERROR__CLAIM_DELAY_NOT_ELAPSED = 6034;
24308
24432
  var SPONSORED_TASKS_ERROR__NOT_PENDING_ADMIN = 6035;
24309
24433
  var SPONSORED_TASKS_ERROR__INVALID_ATTESTED_NONCE = 6036;
24434
+ var SPONSORED_TASKS_ERROR__INVALID_ADMIN = 6037;
24435
+ var SPONSORED_TASKS_ERROR__INVALID_CLUSTER_ID = 6038;
24436
+ var SPONSORED_TASKS_ERROR__PAYOUT_SIGNATURE_EXPIRED = 6039;
24437
+ var SPONSORED_TASKS_ERROR__INVALID_PAYOUT_NONCE = 6040;
24438
+ var SPONSORED_TASKS_ERROR__RESERVATION_NOT_EXPIRED = 6041;
24310
24439
  var sponsoredTasksErrorMessages;
24311
24440
  if (process.env["NODE_ENV"] !== "production") {
24312
24441
  sponsoredTasksErrorMessages = {
@@ -24316,11 +24445,14 @@ if (process.env["NODE_ENV"] !== "production") {
24316
24445
  [SPONSORED_TASKS_ERROR__DEADLINE_IN_PAST]: `Reservation deadline is in the past`,
24317
24446
  [SPONSORED_TASKS_ERROR__EPOCH_MISMATCH]: `Reservation belongs to an earlier vault epoch`,
24318
24447
  [SPONSORED_TASKS_ERROR__INSUFFICIENT_AVAILABLE]: `Reservation exceeds the vault's available balance`,
24448
+ [SPONSORED_TASKS_ERROR__INVALID_ADMIN]: `Admin must not be the zero key`,
24319
24449
  [SPONSORED_TASKS_ERROR__INVALID_ATTESTED_NONCE]: `Attested payout nonce must be the current nonce plus one and below u64::MAX`,
24320
24450
  [SPONSORED_TASKS_ERROR__INVALID_CLAIM_DELAY]: `Claim delay must be between 1 second and i64::MAX`,
24321
24451
  [SPONSORED_TASKS_ERROR__INVALID_CLAIM_PROOF]: `Award proof does not match the settlement root`,
24452
+ [SPONSORED_TASKS_ERROR__INVALID_CLUSTER_ID]: `Cluster id must not be zero`,
24322
24453
  [SPONSORED_TASKS_ERROR__INVALID_FEE_BPS]: `Fee basis points above 10000`,
24323
24454
  [SPONSORED_TASKS_ERROR__INVALID_MANAGER_CAP]: `Manager cap is below its reserved plus spent amount`,
24455
+ [SPONSORED_TASKS_ERROR__INVALID_PAYOUT_NONCE]: `Payout binding nonce must be below u64::MAX`,
24324
24456
  [SPONSORED_TASKS_ERROR__INVALID_PAYOUT_SIGNATURE]: `Payout binding signature is not from the agent`,
24325
24457
  [SPONSORED_TASKS_ERROR__INVALID_SETTLEMENT_TOTALS]: `Settlement totals do not add up or do not match the root`,
24326
24458
  [SPONSORED_TASKS_ERROR__INVALID_SETTLERS]: `Settler set is empty, too large or has duplicates`,
@@ -24337,6 +24469,8 @@ if (process.env["NODE_ENV"] !== "production") {
24337
24469
  [SPONSORED_TASKS_ERROR__OVERFLOW]: `Arithmetic overflow`,
24338
24470
  [SPONSORED_TASKS_ERROR__PAUSED]: `Program is paused`,
24339
24471
  [SPONSORED_TASKS_ERROR__PAYOUT_NOT_BOUND]: `Worker has no payout binding`,
24472
+ [SPONSORED_TASKS_ERROR__PAYOUT_SIGNATURE_EXPIRED]: `Payout binding signature has expired`,
24473
+ [SPONSORED_TASKS_ERROR__RESERVATION_NOT_EXPIRED]: `Reservation deadline has not passed`,
24340
24474
  [SPONSORED_TASKS_ERROR__RESERVATION_WRONG_STATE]: `Reservation is not in the reserved state`,
24341
24475
  [SPONSORED_TASKS_ERROR__SETTLEMENT_EXCEEDS_RESERVATION]: `Settlement awards more than the reservation holds`,
24342
24476
  [SPONSORED_TASKS_ERROR__SETTLEMENT_HAS_CLAIMS]: `Settlement already has claims against it`,
@@ -24458,6 +24592,18 @@ var PAUSE_SET_EVENT_DISCRIMINATOR = new Uint8Array([
24458
24592
  73
24459
24593
  ]);
24460
24594
 
24595
+ // ../../packages/solana-sponsored-client/dist/generated/events/payoutBindingPending.js
24596
+ var PAYOUT_BINDING_PENDING_EVENT_DISCRIMINATOR = new Uint8Array([
24597
+ 75,
24598
+ 145,
24599
+ 148,
24600
+ 254,
24601
+ 250,
24602
+ 88,
24603
+ 225,
24604
+ 107
24605
+ ]);
24606
+
24461
24607
  // ../../packages/solana-sponsored-client/dist/generated/events/payoutBound.js
24462
24608
  var PAYOUT_BOUND_EVENT_DISCRIMINATOR = new Uint8Array([
24463
24609
  36,
@@ -24755,7 +24901,7 @@ async function readVaultCreationFee(publicClient, factory) {
24755
24901
  );
24756
24902
  }
24757
24903
  if (typeof amount !== "bigint" || amount === 0n) return null;
24758
- const [token, recipient] = await Promise.all([
24904
+ const [token2, recipient] = await Promise.all([
24759
24905
  publicClient.readContract({
24760
24906
  address: factory,
24761
24907
  abi: SponsoredTaskFactoryV2ABI,
@@ -24767,7 +24913,7 @@ async function readVaultCreationFee(publicClient, factory) {
24767
24913
  functionName: "creationFeeRecipient"
24768
24914
  })
24769
24915
  ]);
24770
- return { amount, token, recipient };
24916
+ return { amount, token: token2, recipient };
24771
24917
  }
24772
24918
  function isValidAddress4(addr) {
24773
24919
  return /^0x[a-fA-F0-9]{40}$/.test(addr);
@@ -25038,14 +25184,30 @@ var sponsoredTaskFundCommand = new Command113("fund").description("Fund a Sponso
25038
25184
  import { Command as Command114 } from "commander";
25039
25185
 
25040
25186
  // src/lib/solana-payout-binding.ts
25187
+ import { concat, keccak256 } from "viem";
25041
25188
  var PROGRAM_ID_ENV = "TASKMARKET_SOLANA_SPONSORED_TASKS_PROGRAM_ID";
25042
25189
  var PAYOUT_BINDING_TYPES = {
25043
25190
  PayoutBinding: [
25044
25191
  { name: "agent", type: "address" },
25045
25192
  { name: "payout", type: "bytes32" },
25046
- { name: "nonce", type: "uint64" }
25193
+ { name: "nonce", type: "uint64" },
25194
+ { name: "deadline", type: "uint64" }
25047
25195
  ]
25048
25196
  };
25197
+ var PAYOUT_BINDING_VALIDITY_SECONDS = 3600;
25198
+ function payoutBindingDeadline(nowSeconds = Math.floor(Date.now() / 1e3)) {
25199
+ return BigInt(nowSeconds + PAYOUT_BINDING_VALIDITY_SECONDS);
25200
+ }
25201
+ async function readClusterId(rpc, programId) {
25202
+ const [configAddress] = await findConfigPda({ programAddress: programId });
25203
+ const config = await fetchMaybeConfig(rpc, configAddress);
25204
+ if (!config.exists) {
25205
+ throw new Error(
25206
+ `The Sponsored Tasks program ${programId} has no config account on this cluster`
25207
+ );
25208
+ }
25209
+ return hex(Uint8Array.from(config.data.clusterId));
25210
+ }
25049
25211
  function resolveProgramId(flag, solanaChainId, registryProgramId = (chainId) => svmChain(chainId).sponsoredTasks.programId) {
25050
25212
  const raw = flag || process.env[PROGRAM_ID_ENV] || registryProgramId(solanaChainId);
25051
25213
  if (!raw) {
@@ -25073,14 +25235,17 @@ function payoutBindingTypedData(input) {
25073
25235
  name: "Taskmarket Sponsored Tasks",
25074
25236
  version: "1",
25075
25237
  chainId: input.taskChainId,
25076
- salt: hex(getAddressEncoder().encode(input.programId))
25238
+ salt: keccak256(
25239
+ concat([hex(getAddressEncoder().encode(input.programId)), input.clusterId])
25240
+ )
25077
25241
  },
25078
25242
  types: PAYOUT_BINDING_TYPES,
25079
25243
  primaryType: "PayoutBinding",
25080
25244
  message: {
25081
25245
  agent: input.agent,
25082
25246
  payout: hex(getAddressEncoder().encode(input.payout)),
25083
- nonce: input.nonce
25247
+ nonce: input.nonce,
25248
+ deadline: input.deadline
25084
25249
  }
25085
25250
  };
25086
25251
  }
@@ -25091,16 +25256,21 @@ async function findPayoutBindingAddress(programId, taskChainId, agent) {
25091
25256
  );
25092
25257
  return pda;
25093
25258
  }
25094
- function decodePayoutBinding(data) {
25259
+ var ZERO_ADDRESS = "11111111111111111111111111111111";
25260
+ function decodePayoutBinding(data, nowSeconds = BigInt(Math.floor(Date.now() / 1e3))) {
25095
25261
  const decoder = getPayoutBindingDecoder();
25096
25262
  if (data.length < decoder.fixedSize) return null;
25097
25263
  if (!PAYOUT_BINDING_DISCRIMINATOR.every((b, i) => data[i] === b)) return null;
25098
25264
  const decoded = decoder.decode(data);
25265
+ const waiting = decoded.pendingEffectiveAt !== 0n && nowSeconds < decoded.pendingEffectiveAt;
25266
+ const pendingApplies = decoded.pendingEffectiveAt !== 0n && !waiting;
25267
+ const current = pendingApplies ? decoded.pendingPayout : decoded.payout;
25099
25268
  return {
25100
25269
  taskChainId: Number(decoded.taskChainId),
25101
25270
  agent: hex(Uint8Array.from(decoded.agent)),
25102
- payout: decoded.payout,
25103
- nonce: decoded.nonce
25271
+ payout: current === ZERO_ADDRESS && waiting ? decoded.pendingPayout : current,
25272
+ nonce: decoded.nonce,
25273
+ pending: waiting ? { payout: decoded.pendingPayout, effectiveAt: decoded.pendingEffectiveAt } : null
25104
25274
  };
25105
25275
  }
25106
25276
  async function readPayoutBinding(rpc, programId, taskChainId, agent) {
@@ -25120,8 +25290,10 @@ async function bindPayoutInstruction(input) {
25120
25290
  programAddress: input.programId,
25121
25291
  seeds: ["__event_authority"]
25122
25292
  });
25293
+ const [config] = await findConfigPda({ programAddress: input.programId });
25123
25294
  return getBindPayoutInstructionAsync(
25124
25295
  {
25296
+ config,
25125
25297
  payer: input.payer,
25126
25298
  eventAuthority,
25127
25299
  program: input.programId,
@@ -25129,6 +25301,7 @@ async function bindPayoutInstruction(input) {
25129
25301
  agent: agentBytes(input.agent),
25130
25302
  payout: input.payout,
25131
25303
  nonce: input.nonce,
25304
+ deadline: input.deadline,
25132
25305
  signature: signatureBytes(input.signature)
25133
25306
  },
25134
25307
  { programAddress: input.programId }
@@ -25748,14 +25921,14 @@ function describeSolanaAwards(awards, vaultAddress, solanaChainId, taskId) {
25748
25921
  function isRetryableClaimConflict(err) {
25749
25922
  return err instanceof ApiError && (err.status === 409 || err.status >= 500) && /retry/i.test(err.message);
25750
25923
  }
25751
- async function postClaimWithRetry(path9, body, options = {}) {
25924
+ async function postClaimWithRetry(path10, body, options = {}) {
25752
25925
  const sleep4 = options.sleep ?? ((ms2) => new Promise((r) => setTimeout(r, ms2)));
25753
25926
  const deadline = Date.now() + (options.budgetMs ?? CLAIM_RETRY_BUDGET_MS);
25754
25927
  const idempotencyKey = resolveIdempotencyKey();
25755
25928
  let delayMs = 500;
25756
25929
  for (; ; ) {
25757
25930
  try {
25758
- return await apiPost(path9, body, { idempotencyKey });
25931
+ return await apiPost(path10, body, { idempotencyKey });
25759
25932
  } catch (err) {
25760
25933
  if (!isRetryableClaimConflict(err) || Date.now() + delayMs > deadline) throw err;
25761
25934
  await sleep4(delayMs);
@@ -25995,7 +26168,16 @@ var sponsoredTaskBindPayoutCommand = new Command126("bind-payout").description(
25995
26168
  binding: await readPayoutBinding(rpc, programId, taskChainId, agent)
25996
26169
  }))
25997
26170
  );
25998
- const view = (binding) => binding ? { payout: binding.payout, nonce: binding.nonce.toString() } : null;
26171
+ const view = (binding) => binding ? {
26172
+ payout: binding.payout,
26173
+ nonce: binding.nonce.toString(),
26174
+ ...binding.pending ? {
26175
+ pending: {
26176
+ payout: binding.pending.payout,
26177
+ effectiveAt: binding.pending.effectiveAt.toString()
26178
+ }
26179
+ } : {}
26180
+ } : null;
25999
26181
  if (opts.status) {
26000
26182
  const unbound = current.some((c) => !c.binding);
26001
26183
  printResult({
@@ -26025,6 +26207,7 @@ var sponsoredTaskBindPayoutCommand = new Command126("bind-payout").description(
26025
26207
  }
26026
26208
  }
26027
26209
  let payer;
26210
+ let clusterId;
26028
26211
  const bindings = [];
26029
26212
  try {
26030
26213
  for (const { taskChainId, binding } of current) {
@@ -26033,8 +26216,18 @@ var sponsoredTaskBindPayoutCommand = new Command126("bind-payout").description(
26033
26216
  continue;
26034
26217
  }
26035
26218
  const nonce = nonceOverride ?? (binding ? binding.nonce + 1n : 1n);
26219
+ clusterId ??= await readClusterId(rpc, programId);
26220
+ const deadline = payoutBindingDeadline();
26036
26221
  const signature = await signTypedData(
26037
- payoutBindingTypedData({ taskChainId, programId, agent, payout, nonce }),
26222
+ payoutBindingTypedData({
26223
+ taskChainId,
26224
+ programId,
26225
+ clusterId,
26226
+ agent,
26227
+ payout,
26228
+ nonce,
26229
+ deadline
26230
+ }),
26038
26231
  keystore
26039
26232
  );
26040
26233
  payer ??= await createSolanaSignerFromKeystore(keystore);
@@ -26047,11 +26240,13 @@ var sponsoredTaskBindPayoutCommand = new Command126("bind-payout").description(
26047
26240
  agent,
26048
26241
  payout,
26049
26242
  nonce,
26243
+ deadline,
26050
26244
  signature
26051
26245
  });
26052
26246
  bindings.push({
26053
26247
  taskChainId,
26054
26248
  nonce: nonce.toString(),
26249
+ deadline: deadline.toString(),
26055
26250
  replaced: view(binding),
26056
26251
  signature: txSignature
26057
26252
  });
@@ -26220,9 +26415,9 @@ function evaluatorTerms(opts) {
26220
26415
  }
26221
26416
 
26222
26417
  // src/commands/project/write.ts
26223
- async function postProjectWrite(path9, body, options) {
26418
+ async function postProjectWrite(path10, body, options) {
26224
26419
  const { data: result, idempotencyKey } = await x402Post(
26225
- path9,
26420
+ path10,
26226
26421
  { chainId: selectedNetwork().chainId, ...body },
26227
26422
  { maxAmount: options.maxAmount }
26228
26423
  );
@@ -26545,10 +26740,10 @@ function proposalDecisionBody(proposalId, suggestions) {
26545
26740
  if (!parsed.success) return { error: `--suggestion: ${parsed.error.issues[0].message}` };
26546
26741
  return body;
26547
26742
  }
26548
- async function read(path9) {
26743
+ async function read(path10) {
26549
26744
  try {
26550
26745
  const headers = (await signReadAuth())?.headers ?? {};
26551
- printResult(await apiGet(withChainId(path9), { headers }));
26746
+ printResult(await apiGet(withChainId(path10), { headers }));
26552
26747
  } catch (err) {
26553
26748
  renderFailure(err);
26554
26749
  }
@@ -26702,10 +26897,10 @@ function suggestionSettingsBody(projectId, opts) {
26702
26897
  }
26703
26898
  return body;
26704
26899
  }
26705
- async function signedRead(path9) {
26900
+ async function signedRead(path10) {
26706
26901
  try {
26707
26902
  const headers = (await signReadAuth())?.headers ?? {};
26708
- printResult(await apiGet(withChainId(path9), { headers }));
26903
+ printResult(await apiGet(withChainId(path10), { headers }));
26709
26904
  } catch (err) {
26710
26905
  renderFailure(err);
26711
26906
  }
@@ -27485,22 +27680,22 @@ var UUID3 = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-
27485
27680
  var ADDRESS2 = /^0x[0-9a-fA-F]{40}$/;
27486
27681
  var FILE_MAX_BYTES = 256 * 1024;
27487
27682
  var PARAM_NAME = /^[A-Za-z][A-Za-z0-9_]{0,39}$/;
27488
- async function readJsonFile(path9, what = "template") {
27489
- if (!path9) return { error: `Pass the ${what} with --file <path> (JSON)` };
27683
+ async function readJsonFile(path10, what = "template") {
27684
+ if (!path10) return { error: `Pass the ${what} with --file <path> (JSON)` };
27490
27685
  let text;
27491
27686
  try {
27492
- const buffer = await readFile4(path9);
27687
+ const buffer = await readFile4(path10);
27493
27688
  if (buffer.length > FILE_MAX_BYTES) {
27494
- return { error: `${path9} is ${buffer.length} bytes; a ${what} is at most 64 KiB as JSON` };
27689
+ return { error: `${path10} is ${buffer.length} bytes; a ${what} is at most 64 KiB as JSON` };
27495
27690
  }
27496
27691
  text = buffer.toString("utf8");
27497
27692
  } catch (error) {
27498
- return { error: `Unable to read ${path9}: ${error.message}` };
27693
+ return { error: `Unable to read ${path10}: ${error.message}` };
27499
27694
  }
27500
27695
  try {
27501
27696
  return { document: JSON.parse(text) };
27502
27697
  } catch (error) {
27503
- return { error: `${path9} is not valid JSON: ${error.message}` };
27698
+ return { error: `${path10} is not valid JSON: ${error.message}` };
27504
27699
  }
27505
27700
  }
27506
27701
  function templateChoice(value) {
@@ -27556,8 +27751,8 @@ function updateNote(workflowId, status) {
27556
27751
  return `Update available: ${status.templateId} is at version ${status.latestVersion}, this workflow has ${status.currentVersion}. Apply it with: taskmarket workflow update-template ${workflowId}`;
27557
27752
  }
27558
27753
  var collect6 = (value, previous = []) => [...previous, value];
27559
- async function readValidTemplate(path9) {
27560
- const parsed = await readJsonFile(path9);
27754
+ async function readValidTemplate(path10) {
27755
+ const parsed = await readJsonFile(path10);
27561
27756
  if ("error" in parsed) {
27562
27757
  printError(parsed.error);
27563
27758
  return null;
@@ -27978,9 +28173,9 @@ function scheduleSettingsBody(projectId, opts) {
27978
28173
  }
27979
28174
  return body;
27980
28175
  }
27981
- async function read2(path9) {
28176
+ async function read2(path10) {
27982
28177
  try {
27983
- printResult(await apiGet(path9));
28178
+ printResult(await apiGet(path10));
27984
28179
  } catch (err) {
27985
28180
  renderFailure(err);
27986
28181
  }
@@ -28307,19 +28502,19 @@ function parseWorkflowText(text) {
28307
28502
  return { error: `The file is not valid JSON: ${error.message}` };
28308
28503
  }
28309
28504
  }
28310
- async function readDocument(path9) {
28311
- if (!path9) return { error: "Pass the workflow document with --file <path> (JSON)" };
28505
+ async function readDocument(path10) {
28506
+ if (!path10) return { error: "Pass the workflow document with --file <path> (JSON)" };
28312
28507
  let text;
28313
28508
  try {
28314
- const buffer = await readFile5(path9);
28509
+ const buffer = await readFile5(path10);
28315
28510
  if (buffer.length > FILE_MAX_BYTES2) {
28316
28511
  return {
28317
- error: `${path9} is ${buffer.length} bytes; a workflow document is at most 64 KiB as JSON`
28512
+ error: `${path10} is ${buffer.length} bytes; a workflow document is at most 64 KiB as JSON`
28318
28513
  };
28319
28514
  }
28320
28515
  text = buffer.toString("utf8");
28321
28516
  } catch (error) {
28322
- return { error: `Unable to read ${path9}: ${error.message}` };
28517
+ return { error: `Unable to read ${path10}: ${error.message}` };
28323
28518
  }
28324
28519
  return parseWorkflowText(text);
28325
28520
  }
@@ -28335,9 +28530,9 @@ function stepKey(value) {
28335
28530
  }
28336
28531
  return trimmed;
28337
28532
  }
28338
- async function read3(path9) {
28533
+ async function read3(path10) {
28339
28534
  try {
28340
- printResult(await apiGet(path9));
28535
+ printResult(await apiGet(path10));
28341
28536
  } catch (err) {
28342
28537
  renderFailure(err);
28343
28538
  }
@@ -28602,13 +28797,13 @@ var deleteCommand3 = new Command150("delete").description(
28602
28797
  { maxAmount: ACTION_FEE_MAX_AMOUNT }
28603
28798
  );
28604
28799
  });
28605
- async function ownerGet(path9) {
28800
+ async function ownerGet(path10) {
28606
28801
  const auth = await signReadAuth();
28607
- return apiGet(path9, { headers: auth?.headers ?? {} });
28802
+ return apiGet(path10, { headers: auth?.headers ?? {} });
28608
28803
  }
28609
- async function ownerRead(path9) {
28804
+ async function ownerRead(path10) {
28610
28805
  try {
28611
- printResult(await ownerGet(path9));
28806
+ printResult(await ownerGet(path10));
28612
28807
  } catch (err) {
28613
28808
  renderFailure(err);
28614
28809
  }
@@ -28816,6 +29011,8 @@ var statusCommand4 = new Command151("status").description("Check whether an emai
28816
29011
  var dropsCommand = new Command151("drops").description("Browse Task Drops and manage email subscriptions to them").addCommand(listCommand9).addCommand(showCommand7).addCommand(subscribeCommand).addCommand(statusCommand4);
28817
29012
 
28818
29013
  // src/commands/hooks.ts
29014
+ import { mkdir, readFile as readFile7, writeFile } from "fs/promises";
29015
+ import path9 from "path";
28819
29016
  import { Command as Command153 } from "commander";
28820
29017
  import { BaseError, ContractFunctionRevertedError, ContractFunctionZeroDataError } from "viem";
28821
29018
 
@@ -28941,6 +29138,84 @@ function submissionsCommandFor(kind) {
28941
29138
  });
28942
29139
  }
28943
29140
 
29141
+ // src/lib/hook-build.ts
29142
+ function token(label) {
29143
+ return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
29144
+ }
29145
+ var vetoBits = new Map(hookVetoChoices.map((item) => [token(item.label), item.bit]));
29146
+ var observeBits = new Map([
29147
+ ...hookObserveChoices.map((item) => [token(item.label), item.bit]),
29148
+ ["other", 25]
29149
+ ]);
29150
+ var roleValues = new Map(
29151
+ hookCallRoleChoices.map((item) => [token(item.role.replace(/^ROLE_/, "")), item.value])
29152
+ );
29153
+ roleValues.set("anyone", roleValues.get("stranger") ?? 0);
29154
+ var hookVetoNames = [...vetoBits.keys()];
29155
+ var hookObserveNames = [...observeBits.keys()];
29156
+ var hookCallerRoleNames = [...roleValues.keys()];
29157
+ function resolve2(kind, names, known) {
29158
+ return names.map((raw) => {
29159
+ const value = known.get(token(raw));
29160
+ if (value === void 0) {
29161
+ throw new Error(`Unknown ${kind} "${raw}". Choose from: ${[...known.keys()].join(", ")}`);
29162
+ }
29163
+ return value;
29164
+ });
29165
+ }
29166
+ function splitNames(value) {
29167
+ if (value === void 0) return void 0;
29168
+ const list2 = Array.isArray(value) ? value : value.split(",");
29169
+ return list2.map((item) => item.trim()).filter(Boolean);
29170
+ }
29171
+ function resolveHookBuilderInput(choices) {
29172
+ const input = { ...initialHookBuilderInput };
29173
+ for (const [key, value] of Object.entries(choices.fields ?? {})) {
29174
+ if (!(key in initialHookBuilderInput)) throw new Error(`Unknown field "${key}"`);
29175
+ const kind = typeof initialHookBuilderInput[key];
29176
+ input[key] = kind === "string" && typeof value === "object" && value !== null ? JSON.stringify(value) : value;
29177
+ }
29178
+ const chosen = choices.veto !== void 0 || choices.observe !== void 0 || choices.reduce || choices.fee || (choices.onCall?.length ?? 0) > 0;
29179
+ let mask = chosen ? 0 : input.capabilities;
29180
+ for (const bit of resolve2("action to veto", choices.veto ?? [], vetoBits)) mask |= 1 << bit;
29181
+ for (const bit of resolve2("action to observe", choices.observe ?? [], observeBits)) {
29182
+ mask |= 1 << bit;
29183
+ }
29184
+ if (choices.reduce) mask |= 1 << HOOK_BIT_REALLOCATE;
29185
+ if (choices.fee) mask |= 1 << HOOK_BIT_FEE;
29186
+ if (choices.onCall && choices.onCall.length > 0) {
29187
+ mask |= 1 << HOOK_BIT_ON_CALL;
29188
+ input.callRoles = resolve2("caller role", choices.onCall, roleValues).reduce(
29189
+ (roles, value) => (roles | value) >>> 0,
29190
+ 0
29191
+ );
29192
+ }
29193
+ input.capabilities = mask >>> 0;
29194
+ if (choices.configParams !== void 0) input.configParameters = choices.configParams;
29195
+ if (choices.modes !== void 0) {
29196
+ for (const mode of choices.modes) {
29197
+ if (!hookModes.some((name) => name === mode)) {
29198
+ throw new Error(`Unknown task mode "${mode}". Choose from: ${hookModes.join(", ")}`);
29199
+ }
29200
+ }
29201
+ input.modes = choices.modes;
29202
+ }
29203
+ return input;
29204
+ }
29205
+ function buildHook(choices) {
29206
+ const input = resolveHookBuilderInput(choices);
29207
+ const readiness = manifestReadiness(input);
29208
+ return {
29209
+ ready: readiness.ready,
29210
+ problems: readiness.missing,
29211
+ capabilities: effectiveCapabilities(input),
29212
+ callbacks: selectedCallbacks(input),
29213
+ contract: contractName(input.name),
29214
+ manifest: buildHookManifest(input),
29215
+ solidity: buildHookSolidity(input)
29216
+ };
29217
+ }
29218
+
28944
29219
  // src/commands/hooks.ts
28945
29220
  function withV2Declarations(entry) {
28946
29221
  const mask = capabilitiesOf(entry);
@@ -29073,7 +29348,103 @@ var attachmentConfigCommand = new Command153("attachment-config").description(
29073
29348
  renderFailure(err);
29074
29349
  }
29075
29350
  });
29076
- var hooksCommand = new Command153("hooks").description("Browse the hook registry on the selected --network").addCommand(listCommand10).addCommand(showCommand8).addCommand(encodeConfigCommand).addCommand(attachmentConfigCommand).addCommand(submitCommandFor("hook")).addCommand(submissionsCommandFor("hook"));
29351
+ var choiceKeys = /* @__PURE__ */ new Set(["veto", "observe", "reduce", "fee", "onCall", "configParams", "modes"]);
29352
+ async function readBuildFile(file) {
29353
+ let parsed;
29354
+ try {
29355
+ parsed = JSON.parse(await readFile7(file, "utf8"));
29356
+ } catch (err) {
29357
+ throw new Error(`Cannot read ${file} as JSON: ${err.message}`);
29358
+ }
29359
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
29360
+ throw new Error(`${file} must hold a JSON object`);
29361
+ }
29362
+ const record = parsed;
29363
+ const fields = Object.fromEntries(Object.entries(record).filter(([key]) => !choiceKeys.has(key)));
29364
+ const list2 = (key) => record[key] === void 0 ? void 0 : splitNames(record[key]);
29365
+ return {
29366
+ veto: list2("veto"),
29367
+ observe: list2("observe"),
29368
+ reduce: record.reduce === true,
29369
+ fee: record.fee === true,
29370
+ onCall: list2("onCall"),
29371
+ configParams: typeof record.configParams === "string" ? record.configParams : void 0,
29372
+ modes: list2("modes"),
29373
+ fields
29374
+ };
29375
+ }
29376
+ async function hookBuildChoices(opts) {
29377
+ const choices = opts.input ? await readBuildFile(opts.input) : {};
29378
+ const fields = { ...choices.fields };
29379
+ for (const key of [
29380
+ "name",
29381
+ "description",
29382
+ "author",
29383
+ "authorUrl",
29384
+ "repository",
29385
+ "commit",
29386
+ "sourcePath"
29387
+ ]) {
29388
+ if (opts[key] !== void 0) fields[key] = opts[key];
29389
+ }
29390
+ return {
29391
+ ...choices,
29392
+ veto: splitNames(opts.veto) ?? choices.veto,
29393
+ observe: splitNames(opts.observe) ?? choices.observe,
29394
+ reduce: opts.reduce || choices.reduce,
29395
+ fee: opts.fee || choices.fee,
29396
+ onCall: splitNames(opts.onCall) ?? choices.onCall,
29397
+ configParams: opts.configParams ?? choices.configParams,
29398
+ modes: splitNames(opts.mode) ?? choices.modes,
29399
+ fields
29400
+ };
29401
+ }
29402
+ var buildCommand = new Command153("build").description(
29403
+ "Build a Task Hook V2 manifest (schema 2.0.0) and a BaseTMPHookV2 Solidity scaffold from the choices the web hook builder offers (taskmarket.dev/hooks/build). Prints one JSON envelope with 'manifest', 'solidity', 'ready' and 'problems' (what the manifest still needs before it can be submitted)"
29404
+ ).option(
29405
+ "--input <file>",
29406
+ "JSON file with the choices below as keys (veto, observe, reduce, fee, onCall, configParams, modes) and any other web builder field, such as deploymentChainId or hookAddress; flags override it"
29407
+ ).option(
29408
+ "--veto <actions>",
29409
+ `Actions the hook can refuse, comma-separated: ${hookVetoNames.join(", ")}`
29410
+ ).option(
29411
+ "--observe <actions>",
29412
+ `Actions the hook observes after they run, comma-separated: ${hookObserveNames.join(", ")}`
29413
+ ).option(
29414
+ "--reduce",
29415
+ "The hook can reduce or reallocate awards (switches Accept on, forbids an Appeal veto)"
29416
+ ).option("--fee", "The hook can take a hook fee (switches Accept on, forbids an Appeal veto)").option(
29417
+ "--on-call <roles>",
29418
+ `Accept direct calls (onCall) from these roles, comma-separated: ${hookCallerRoleNames.join(", ")}`
29419
+ ).option(
29420
+ "--config-params <abi>",
29421
+ "The hook's own configuration as ABI parameters, such as 'address recipient, uint64 limit'; needs the create veto"
29422
+ ).option(
29423
+ "--mode <modes>",
29424
+ "Task modes the hook serves, comma-separated: bounty, claim, pitch, benchmark, auction (default bounty)"
29425
+ ).option("--name <name>", "Project name").option("--description <text>", "What the hook does").option("--author <name>", "Author name").option("--author-url <url>", "Author HTTPS URL").option("--repository <url>", "Source repository HTTPS URL").option("--commit <sha>", "Source commit SHA").option("--source-path <path>", "Source contract path, such as src/MyHook.sol").option(
29426
+ "--out-dir <dir>",
29427
+ "Also write <slug>.manifest.json and <Contract>.sol to this directory (the envelope still prints)"
29428
+ ).action(async (opts) => {
29429
+ try {
29430
+ const result = buildHook(await hookBuildChoices(opts));
29431
+ let files;
29432
+ if (opts.outDir) {
29433
+ await mkdir(opts.outDir, { recursive: true });
29434
+ files = {
29435
+ manifest: path9.resolve(opts.outDir, `${result.manifest.identity.slug}.manifest.json`),
29436
+ solidity: path9.resolve(opts.outDir, `${result.contract}.sol`)
29437
+ };
29438
+ await writeFile(files.manifest, `${JSON.stringify(result.manifest, null, 2)}
29439
+ `);
29440
+ await writeFile(files.solidity, result.solidity);
29441
+ }
29442
+ printResult(files ? { ...result, files } : result);
29443
+ } catch (err) {
29444
+ renderFailure(err);
29445
+ }
29446
+ });
29447
+ var hooksCommand = new Command153("hooks").description("Browse the hook registry on the selected --network").addCommand(listCommand10).addCommand(showCommand8).addCommand(encodeConfigCommand).addCommand(attachmentConfigCommand).addCommand(buildCommand).addCommand(submitCommandFor("hook")).addCommand(submissionsCommandFor("hook"));
29077
29448
 
29078
29449
  // src/commands/catalog/index.ts
29079
29450
  import { Command as Command154 } from "commander";
@@ -29089,7 +29460,7 @@ tapCommand.command("import").description(
29089
29460
  "Import a TAP private key and its key id, stored encrypted in the keystore. Gated worker actions on tasks that require tap are then signed with it automatically."
29090
29461
  ).requiredOption("--key-id <id>", "The key id the verifier issued for this key").option(
29091
29462
  "--key-file <path>",
29092
- "File holding the private key: a PEM private key, or an ed25519 seed as 64 hex characters. Use - to read it from stdin.",
29463
+ "File holding the private key: a PEM private key (PKCS#8 or SEC1), or an ed25519 seed as 64 hex characters. Use - to read it from stdin.",
29093
29464
  "-"
29094
29465
  ).option(
29095
29466
  "--alg <alg>",
@@ -29134,9 +29505,16 @@ tapCommand.command("import").description(
29134
29505
  }
29135
29506
  );
29136
29507
  tapCommand.command("create").description(
29137
- "Create an ed25519 TAP key, stored encrypted in the keystore with no key id until it is enrolled. Never replaces a key that exists."
29138
- ).action(async () => {
29508
+ "Create an ECDSA P-256 TAP key (or ed25519 with --alg ed25519), stored encrypted in the keystore with no key id until it is enrolled. Never replaces a key that exists."
29509
+ ).option(
29510
+ "--alg <alg>",
29511
+ `Key type to create: ${TAP_CREATE_ALGORITHMS.join(", ")}`,
29512
+ "ecdsa-p256-sha256"
29513
+ ).action(async (opts) => {
29139
29514
  try {
29515
+ if (!TAP_CREATE_ALGORITHMS.includes(opts.alg)) {
29516
+ throw new Error(`--alg must be one of: ${TAP_CREATE_ALGORITHMS.join(", ")}`);
29517
+ }
29140
29518
  const keystore = await loadKeystore();
29141
29519
  if (keystore.tapKey) {
29142
29520
  throw new Error(
@@ -29144,7 +29522,13 @@ tapCommand.command("create").description(
29144
29522
  );
29145
29523
  }
29146
29524
  const dek = await fetchDeviceKey(keystore.deviceId, keystore.apiToken, keystore.keyServerUrl);
29147
- const tapKey = storedTapKey(dek, null, generateTapKey(), /* @__PURE__ */ new Date(), "created");
29525
+ const tapKey = storedTapKey(
29526
+ dek,
29527
+ null,
29528
+ generateTapKey(opts.alg),
29529
+ /* @__PURE__ */ new Date(),
29530
+ "created"
29531
+ );
29148
29532
  await saveKeystore({ ...keystore, tapKey });
29149
29533
  printResult({ ...tapKeySummary(tapKey), created: true });
29150
29534
  } catch (err) {