@lucid-agents/taskmarket 1.20.1 → 1.20.3

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "taskmarket": "1.20.1",
2
+ "taskmarket": "1.20.3",
3
3
  "manifestVersion": 1,
4
4
  "pi": {
5
5
  "package": "@earendil-works/pi-coding-agent",
@@ -10,9 +10,9 @@ import {
10
10
  selectRail,
11
11
  uncertainPurchases,
12
12
  withdrawalHatch
13
- } from "./chunk-OIQZWRMS.js";
14
- import "./chunk-RHDWF7BZ.js";
15
- import "./chunk-OQ6PFG36.js";
13
+ } from "./chunk-VEZ72QNL.js";
14
+ import "./chunk-EMIVR2MT.js";
15
+ import "./chunk-4SG3R5IH.js";
16
16
  import "./chunk-XJOB4NMV.js";
17
17
  import "./chunk-YM4S6IE4.js";
18
18
  import "./chunk-S7SJMJ2I.js";
@@ -16,7 +16,7 @@ import {
16
16
  readMppTempoChallenge,
17
17
  reconcileX402Payment,
18
18
  withX402FileLock
19
- } from "./chunk-RHDWF7BZ.js";
19
+ } from "./chunk-EMIVR2MT.js";
20
20
  import {
21
21
  ApiError,
22
22
  ComputeCreditBuyOutputSchema,
@@ -37,8 +37,9 @@ import {
37
37
  readFailureBody,
38
38
  resolveIdempotencyKey,
39
39
  selectedNetwork,
40
+ withChainId,
40
41
  withIdempotentWrite
41
- } from "./chunk-OQ6PFG36.js";
42
+ } from "./chunk-4SG3R5IH.js";
42
43
 
43
44
  // src/lib/x402-fee.ts
44
45
  import { randomUUID as randomUUID3 } from "crypto";
@@ -600,7 +601,9 @@ function atomicToUsd(atomic) {
600
601
  return fraction ? `${value / scale}.${fraction}` : `${value / scale}`;
601
602
  }
602
603
  async function fetchComputePricing() {
603
- const parsed = ComputeCreditPricingSchema.safeParse(await apiGet(COMPUTE_PRICING_PATH));
604
+ const parsed = ComputeCreditPricingSchema.safeParse(
605
+ await apiGet(withChainId(COMPUTE_PRICING_PATH))
606
+ );
604
607
  if (!parsed.success) {
605
608
  throw new ComputeCreditError("invalid_response", "The compute pricing response is malformed");
606
609
  }
@@ -825,7 +828,12 @@ async function purchaseLocked(input, seams) {
825
828
  try {
826
829
  const outcome = await x402FeePost(
827
830
  COMPUTE_CREDIT_PATH,
828
- { deviceId: keystore.deviceId, apiToken: keystore.apiToken, amountUsd: input.amountUsd },
831
+ {
832
+ chainId: selectedNetwork().chainId,
833
+ deviceId: keystore.deviceId,
834
+ apiToken: keystore.apiToken,
835
+ amountUsd: input.amountUsd
836
+ },
829
837
  {
830
838
  idempotencyKey: pending.idempotencyKey,
831
839
  invocationId: pending.invocationId,
@@ -882,7 +890,12 @@ async function resolvePendingLocked(seams) {
882
890
  try {
883
891
  const replay = await apiPost(
884
892
  COMPUTE_CREDIT_PATH,
885
- { deviceId: keystore.deviceId, apiToken: keystore.apiToken, amountUsd: record.amountUsd },
893
+ {
894
+ chainId: selectedNetwork().chainId,
895
+ deviceId: keystore.deviceId,
896
+ apiToken: keystore.apiToken,
897
+ amountUsd: record.amountUsd
898
+ },
886
899
  { idempotencyKey: key }
887
900
  );
888
901
  const parsed = ComputeCreditBuyOutputSchema.safeParse(replay.data);
@@ -934,6 +947,7 @@ async function readComputeCreditBalance() {
934
947
  async function readStatus() {
935
948
  const keystore = await loadKeystore();
936
949
  const outcome = await apiPost(COMPUTE_CREDIT_STATUS_PATH, {
950
+ chainId: selectedNetwork().chainId,
937
951
  deviceId: keystore.deviceId,
938
952
  apiToken: keystore.apiToken
939
953
  });
@@ -703,7 +703,9 @@ var SponsoredTaskFundingPreviewFailureSchema = z7.enum([
703
703
  var PreviewFundingInputSchema = z7.object({
704
704
  vaultId: VaultIdInputSchema,
705
705
  managerAddress: VaultAddressSchema,
706
- grossAmount: z7.string().regex(/^[1-9]\d*$/, "Must be a positive integer amount in base units")
706
+ grossAmount: z7.string().regex(/^[1-9]\d*$/, "Must be a positive integer amount in base units"),
707
+ // Optional: the call runs on the vault's own chain. Naming another chain is refused.
708
+ chainId: z7.coerce.number().int().positive().optional()
707
709
  });
708
710
  var PreviewFundingOutputSchema = z7.object({
709
711
  ok: z7.boolean(),
@@ -711,6 +713,8 @@ var PreviewFundingOutputSchema = z7.object({
711
713
  });
712
714
  var BuildFundingHookDataInputSchema = z7.object({
713
715
  vaultId: VaultIdInputSchema,
716
+ // Optional: the call runs on the vault's own chain. Naming another chain is refused.
717
+ chainId: z7.number().int().positive().optional(),
714
718
  managerAddress: VaultAddressSchema,
715
719
  grossAmount: z7.string(),
716
720
  reward: z7.string(),
@@ -1453,15 +1457,15 @@ var AgentStatsSchema = z10.object({
1453
1457
  address: z10.string(),
1454
1458
  agentId: z10.string().nullable().optional(),
1455
1459
  actorType: ActorType.optional(),
1456
- completedTasks: z10.number(),
1457
- ratedTasks: z10.number(),
1458
- totalStars: z10.number(),
1459
- averageRating: z10.number(),
1460
+ completedTasks: z10.number().nullable(),
1461
+ ratedTasks: z10.number().nullable(),
1462
+ totalStars: z10.number().nullable(),
1463
+ averageRating: z10.number().nullable(),
1460
1464
  /**
1461
1465
  * Net USDC base units paid to this address as a worker, summed from settlement records
1462
1466
  * across every Taskmarket contract generation.
1463
1467
  */
1464
- totalEarnings: z10.string(),
1468
+ totalEarnings: z10.string().nullable(),
1465
1469
  skills: z10.array(z10.string()).optional(),
1466
1470
  emailAddress: z10.string().nullable().optional(),
1467
1471
  credibility: z10.number().int().min(0).max(1e3).optional(),
@@ -1598,13 +1602,13 @@ var HealthResponseSchema = z12.object({
1598
1602
  staleNonTerminal: z12.number().int().nonnegative()
1599
1603
  })).optional()
1600
1604
  }).optional(),
1601
- /** The chain this process's contract configuration targets (CHAIN_ID after its default). */
1602
- chainId: z12.number().int().optional(),
1605
+ /** Every chain this process serves, in SERVED_CHAIN_IDS order (ADR-0327: no default chain). */
1606
+ servedChainIds: z12.array(z12.number().int()).optional(),
1603
1607
  /**
1604
1608
  * The chain this process's swarm wallets run on (ADR-0176). An operator compares it with the
1605
1609
  * consumer's `/health` after a deploy: the two must match, and in production both refuse to
1606
- * boot unless CHAIN_ID names it explicitly. Absent when the configured CHAIN_ID names no swarm
1607
- * chain outside production.
1610
+ * boot unless SWARM_CHAIN_ID names it explicitly. Absent when the configured SWARM_CHAIN_ID
1611
+ * names no swarm chain outside production.
1608
1612
  */
1609
1613
  swarmChainId: z12.number().int().optional(),
1610
1614
  /**
@@ -2208,6 +2212,9 @@ var EmailInboundHeadersSchema = z21.object({
2208
2212
  "x-email-to": z21.string().email()
2209
2213
  });
2210
2214
  var BroadcastInputSchema = z21.object({
2215
+ // The chain whose completed-task counts `filters.minTasks` reads. Required with minTasks
2216
+ // (refused as chain_required without it, ADR-0327); the other filters are chain-neutral.
2217
+ chainId: z21.number().int().positive().optional(),
2211
2218
  subject: z21.string().min(1).max(200),
2212
2219
  body: z21.string().min(1).max(5e4),
2213
2220
  filters: z21.object({
@@ -3399,7 +3406,12 @@ var HostedAllowanceViewSchema = z24.object({
3399
3406
  var COMPUTE_CREDIT_PURCHASE_STATUSES = ["pending", "granted", "void"];
3400
3407
  var DeviceCredentialsShape = {
3401
3408
  deviceId: z25.string().min(1).max(200),
3402
- apiToken: z25.string().min(1).max(500)
3409
+ apiToken: z25.string().min(1).max(500),
3410
+ /**
3411
+ * The chain the purchase is paid and recorded on. The backend has no default chain (ADR-0327):
3412
+ * a request that names none, and whose payment names no network, is refused `chain_required`.
3413
+ */
3414
+ chainId: z25.number().int().positive().optional()
3403
3415
  };
3404
3416
  var ComputeCreditBuyInputSchema = z25.object({
3405
3417
  ...DeviceCredentialsShape,
@@ -4042,6 +4054,11 @@ var API_ERROR_REASONS = [
4042
4054
  "payment_payer_mismatch",
4043
4055
  /** The request named a chain this backend does not serve. Nothing was read or charged. */
4044
4056
  "chain_not_served",
4057
+ /**
4058
+ * The request named no chain (no `chainId` input, no payment network) and is not about a task
4059
+ * whose chain could be used. Name a chain with `chainId`. Nothing was read or charged.
4060
+ */
4061
+ "chain_required",
4045
4062
  /**
4046
4063
  * The request named two different chains, for example a `chainId` input and a payment for
4047
4064
  * another network. Refused before any payment was verified, so nothing was charged.
@@ -4949,7 +4966,7 @@ var WALLET_BRIDGE_QUOTE_TTL_SECONDS = 10 * 60;
4949
4966
  var WalletBridgeDestinationSchema = z39.enum(["tempo"]);
4950
4967
  var BaseUnits = z39.string().regex(/^\d+$/, "Must be an integer amount in base units");
4951
4968
  var WalletBridgeQuoteInputSchema = z39.object({
4952
- /** The served chain; must be Base mainnet (8453). Omitted, the default chain. */
4969
+ /** Must be Base mainnet (8453), the bridge's only origin. Omitted, the call runs on Base. */
4953
4970
  chainId: z39.number().int().positive().optional(),
4954
4971
  from: EthAddressSchema,
4955
4972
  to: WalletBridgeDestinationSchema.default("tempo"),
@@ -4998,6 +5015,7 @@ var WalletBridgeQuoteOutputSchema = z39.object({
4998
5015
  })
4999
5016
  });
5000
5017
  var WalletBridgeInputSchema = z39.object({
5018
+ /** Must be Base mainnet (8453), the bridge's only origin. Omitted, the call runs on Base. */
5001
5019
  chainId: z39.number().int().positive().optional(),
5002
5020
  from: EthAddressSchema,
5003
5021
  amountBaseUnits: BaseUnits,
@@ -10256,6 +10274,9 @@ function setSelectedNetwork(network) {
10256
10274
  function selectedNetwork() {
10257
10275
  return selected ?? resolveNetwork({ env: process.env.TASKMARKET_NETWORK });
10258
10276
  }
10277
+ function withChainId(path3, chainId = selectedNetwork().chainId) {
10278
+ return `${path3}${path3.includes("?") ? "&" : "?"}chainId=${chainId}`;
10279
+ }
10259
10280
  function apiUrl() {
10260
10281
  return process.env.TASKMARKET_API_URL || selectedNetwork().apiUrl;
10261
10282
  }
@@ -10270,11 +10291,15 @@ function networkToStamp() {
10270
10291
  }
10271
10292
  function chainInfoFor(raw, chainId) {
10272
10293
  const full = NetworkInfoSchema.safeParse(raw);
10273
- if (full.success) {
10274
- const info = full.data;
10275
- return info.chains.find((chain) => chain.chainId === chainId) ?? info.chains.find((chain) => chain.chainId === info.chainId) ?? info.chains[0];
10276
- }
10277
- return void 0;
10294
+ if (!full.success) return void 0;
10295
+ const chain = full.data.chains.find((entry) => entry.chainId === chainId);
10296
+ if (chain) return chain;
10297
+ const selected2 = selectedNetwork();
10298
+ const subject = selected2.chainId === chainId ? `network "${selected2.name}" (chain ${chainId})` : `chain ${chainId}`;
10299
+ const served = full.data.chains.map((entry) => entry.chainId).join(", ");
10300
+ throw new Error(
10301
+ `The selected ${subject} is not available: the API at ${apiUrl()} does not serve it (it serves chain ${served}). Choose a network it serves with --network, or point TASKMARKET_API_URL at an API that serves this one.`
10302
+ );
10278
10303
  }
10279
10304
 
10280
10305
  // src/lib/idempotency.ts
@@ -10592,6 +10617,7 @@ export {
10592
10617
  resolveNetwork,
10593
10618
  setSelectedNetwork,
10594
10619
  selectedNetwork,
10620
+ withChainId,
10595
10621
  apiUrl,
10596
10622
  paymentProtocolOf,
10597
10623
  apiOrigin,
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __tmCreateRequire } from 'node:module'; import { fileURLToPath as __tmFileURLToPath } from 'node:url'; import { dirname as __tmDirname } from 'node:path'; const require = __tmCreateRequire(import.meta.url); const __tmFilename = __tmFileURLToPath(import.meta.url); const __tmDirnameValue = __tmDirname(__tmFilename);
2
2
  import {
3
3
  getTaskmarketHome
4
- } from "./chunk-OQ6PFG36.js";
4
+ } from "./chunk-4SG3R5IH.js";
5
5
  import {
6
6
  AgentLaunchError
7
7
  } from "./chunk-YM4S6IE4.js";
@@ -22,7 +22,7 @@ import {
22
22
  unresolvedCount,
23
23
  updateSyncState,
24
24
  uploadWorkspace
25
- } from "./chunk-GAESVHWN.js";
25
+ } from "./chunk-6VM3O3RZ.js";
26
26
  import {
27
27
  AgentLaunchError
28
28
  } from "./chunk-YM4S6IE4.js";
@@ -6,14 +6,14 @@ import {
6
6
  loadDeliverableRecord,
7
7
  readComputeView,
8
8
  taskStage
9
- } from "./chunk-7NH3EVI7.js";
9
+ } from "./chunk-NLVNUGBO.js";
10
10
  import {
11
11
  activeClaim,
12
12
  captureProblem,
13
13
  killedSession,
14
14
  loadSyncState,
15
15
  orphanOf
16
- } from "./chunk-GAESVHWN.js";
16
+ } from "./chunk-6VM3O3RZ.js";
17
17
  import {
18
18
  allocationViews,
19
19
  channelView,
@@ -21,12 +21,12 @@ import {
21
21
  openAgentChannels,
22
22
  uncertainPurchases,
23
23
  withdrawalHatch
24
- } from "./chunk-OIQZWRMS.js";
24
+ } from "./chunk-VEZ72QNL.js";
25
25
  import {
26
26
  SandboxListOutputSchema,
27
27
  apiUrl,
28
28
  selectedNetwork
29
- } from "./chunk-OQ6PFG36.js";
29
+ } from "./chunk-4SG3R5IH.js";
30
30
  import {
31
31
  AGENT_VIEW_VERSION,
32
32
  blockingPurchases,
@@ -11,7 +11,7 @@ import {
11
11
  loadKeystore,
12
12
  mppAttributionMemo,
13
13
  parseMppChallenge
14
- } from "./chunk-OQ6PFG36.js";
14
+ } from "./chunk-4SG3R5IH.js";
15
15
 
16
16
  // ../../packages/x402-payer/dist/api.js
17
17
  var X402_PAYER_API_VERSION = 1;
@@ -1,11 +1,11 @@
1
1
  import { createRequire as __tmCreateRequire } from 'node:module'; import { fileURLToPath as __tmFileURLToPath } from 'node:url'; import { dirname as __tmDirname } from 'node:path'; const require = __tmCreateRequire(import.meta.url); const __tmFilename = __tmFileURLToPath(import.meta.url); const __tmDirnameValue = __tmDirname(__tmFilename);
2
2
  import {
3
3
  x402FeePost
4
- } from "./chunk-GG3D4M74.js";
4
+ } from "./chunk-4EN2RUZ3.js";
5
5
  import {
6
6
  createWalletAccountFromKeystore,
7
7
  signMessage
8
- } from "./chunk-RHDWF7BZ.js";
8
+ } from "./chunk-EMIVR2MT.js";
9
9
  import {
10
10
  READ_AUTH_ADDRESS_HEADER,
11
11
  READ_AUTH_SIGNATURE_HEADER,
@@ -19,7 +19,7 @@ import {
19
19
  getTaskmarketHome,
20
20
  isRecordingPendingResponse,
21
21
  loadKeystore
22
- } from "./chunk-OQ6PFG36.js";
22
+ } from "./chunk-4SG3R5IH.js";
23
23
 
24
24
  // src/lib/read-auth.ts
25
25
  async function signReadAuth() {
@@ -8,7 +8,7 @@ import {
8
8
  unsafeHostPath,
9
9
  withFileLock,
10
10
  writeAtomic
11
- } from "./chunk-GAESVHWN.js";
11
+ } from "./chunk-6VM3O3RZ.js";
12
12
  import {
13
13
  buyComputeCredit,
14
14
  fetchComputePricing,
@@ -16,10 +16,10 @@ import {
16
16
  loadComputeCreditConfig,
17
17
  onComputeBalanceObserved,
18
18
  readComputeCreditStatus
19
- } from "./chunk-GG3D4M74.js";
19
+ } from "./chunk-4EN2RUZ3.js";
20
20
  import {
21
21
  getTaskmarketHome
22
- } from "./chunk-OQ6PFG36.js";
22
+ } from "./chunk-4SG3R5IH.js";
23
23
  import {
24
24
  burnRate,
25
25
  computeLow
@@ -11,12 +11,12 @@ import {
11
11
  listX402Payments,
12
12
  loadX402Policy,
13
13
  rpcUrlForNetwork
14
- } from "./chunk-RHDWF7BZ.js";
14
+ } from "./chunk-EMIVR2MT.js";
15
15
  import {
16
16
  getTaskmarketHome,
17
17
  keystoreExists,
18
18
  loadKeystore
19
- } from "./chunk-OQ6PFG36.js";
19
+ } from "./chunk-4SG3R5IH.js";
20
20
  import {
21
21
  failureDetail,
22
22
  failureDetailOf,
@@ -6,25 +6,26 @@ import {
6
6
  } from "./chunk-4ZC6SH7H.js";
7
7
  import {
8
8
  listSandboxes
9
- } from "./chunk-YLNOLUYO.js";
10
- import "./chunk-7NH3EVI7.js";
11
- import "./chunk-GAESVHWN.js";
12
- import "./chunk-GG3D4M74.js";
9
+ } from "./chunk-AJ5V4H2H.js";
10
+ import "./chunk-NLVNUGBO.js";
11
+ import "./chunk-6VM3O3RZ.js";
12
+ import "./chunk-4EN2RUZ3.js";
13
13
  import {
14
14
  channelView,
15
15
  loadAgentPolicy,
16
16
  openAgentChannels
17
- } from "./chunk-OIQZWRMS.js";
17
+ } from "./chunk-VEZ72QNL.js";
18
18
  import {
19
19
  getX402PolicyPath,
20
20
  loadX402Policy,
21
21
  rpcUrlForNetwork
22
- } from "./chunk-RHDWF7BZ.js";
22
+ } from "./chunk-EMIVR2MT.js";
23
23
  import {
24
24
  apiUrl,
25
25
  keystoreExists,
26
- loadKeystore
27
- } from "./chunk-OQ6PFG36.js";
26
+ loadKeystore,
27
+ withChainId
28
+ } from "./chunk-4SG3R5IH.js";
28
29
  import {
29
30
  AGENT_VIEW_VERSION
30
31
  } from "./chunk-XJOB4NMV.js";
@@ -124,7 +125,7 @@ async function runDoctor(deps = {}) {
124
125
  add("channels", "skip", "Needs a wallet and a usable spending policy");
125
126
  }
126
127
  try {
127
- const response = await get(`${apiBase.replace(/\/+$/, "")}/api/compute/pricing`);
128
+ const response = await get(withChainId(`${apiBase.replace(/\/+$/, "")}/api/compute/pricing`));
128
129
  await response.body?.cancel().catch(() => void 0);
129
130
  add(
130
131
  "api",
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  signReadAuth,
15
15
  submitTaskFiles,
16
16
  taskAccessGrantHeaders
17
- } from "./chunk-GE7B3DNP.js";
17
+ } from "./chunk-H2XTB3NF.js";
18
18
  import {
19
19
  ComputeCreditError,
20
20
  applyComputeCreditSetup,
@@ -36,7 +36,7 @@ import {
36
36
  refusedPaidWrite,
37
37
  releasePendingComputePurchase,
38
38
  resolvePendingComputePurchases
39
- } from "./chunk-GG3D4M74.js";
39
+ } from "./chunk-4EN2RUZ3.js";
40
40
  import {
41
41
  MPP_TEMPO_DEFAULT_VALIDITY_SECONDS,
42
42
  X402PayError,
@@ -58,7 +58,7 @@ import {
58
58
  signSponsoredTempoTransfer,
59
59
  signTaskmarketFeePayment,
60
60
  signTypedData
61
- } from "./chunk-RHDWF7BZ.js";
61
+ } from "./chunk-EMIVR2MT.js";
62
62
  import {
63
63
  AgentMessageEnvelopeSchema,
64
64
  ApiError,
@@ -164,9 +164,10 @@ import {
164
164
  taskmarketChain,
165
165
  taskmarketCommandFor,
166
166
  usdcToBaseUnits,
167
+ withChainId,
167
168
  withErrorContext,
168
169
  withIdempotentWrite
169
- } from "./chunk-OQ6PFG36.js";
170
+ } from "./chunk-4SG3R5IH.js";
170
171
  import {
171
172
  channelLines
172
173
  } from "./chunk-XJOB4NMV.js";
@@ -636,7 +637,7 @@ var initCommand = new Command2("init").description("Create and register a new ag
636
637
  } catch {
637
638
  }
638
639
  if (!emailAddress2) {
639
- const username2 = opts.email ?? (agentId2 && networkInfo2 ? sanitizeEmailUsername(agentId2, String(networkInfo2.chainId)) : null);
640
+ const username2 = opts.email ?? (agentId2 && networkInfo2 ? sanitizeEmailUsername(agentId2, String(selectedNetwork().chainId)) : null);
640
641
  if (username2) {
641
642
  emailAddress2 = await tryRegisterEmail(
642
643
  keystore.deviceId,
@@ -646,7 +647,13 @@ var initCommand = new Command2("init").description("Create and register a new ag
646
647
  );
647
648
  }
648
649
  }
649
- const chain2 = chainInfoFor(networkInfo2, selectedNetwork().chainId);
650
+ let chain2;
651
+ try {
652
+ chain2 = chainInfoFor(networkInfo2, selectedNetwork().chainId);
653
+ } catch (err) {
654
+ renderFailure(err);
655
+ return;
656
+ }
650
657
  printResult({
651
658
  address: keystore.walletAddress,
652
659
  agentId: agentId2,
@@ -710,9 +717,15 @@ var initCommand = new Command2("init").description("Create and register a new ag
710
717
  networkInfo = response.result.data;
711
718
  } catch {
712
719
  }
713
- const username = opts.email ?? (agentId && networkInfo ? sanitizeEmailUsername(agentId, String(networkInfo.chainId)) : null);
720
+ const username = opts.email ?? (agentId && networkInfo ? sanitizeEmailUsername(agentId, String(selectedNetwork().chainId)) : null);
714
721
  const emailAddress = username ? await tryRegisterEmail(deviceId, apiToken, username, !!opts.email) : null;
715
- const chain = chainInfoFor(networkInfo, selectedNetwork().chainId);
722
+ let chain;
723
+ try {
724
+ chain = chainInfoFor(networkInfo, selectedNetwork().chainId);
725
+ } catch (err) {
726
+ renderFailure(err);
727
+ return;
728
+ }
716
729
  printResult({
717
730
  address,
718
731
  agentId,
@@ -797,7 +810,7 @@ async function x402Post(path3, body, options) {
797
810
  // src/commands/identity.ts
798
811
  var identityCommand = new Command4("identity").description("Manage agent identity");
799
812
  identityCommand.command("register").description("Register ERC-8004 agent identity (costs 0.001 in the payment token)").action(async () => {
800
- const { data: result, idempotencyKey } = await x402Post("/api/identity/register", {});
813
+ const { data: result, idempotencyKey } = await x402Post("/api/identity/register", { chainId: selectedNetwork().chainId });
801
814
  printResult({ agentId: result.agentId }, { idempotencyKey });
802
815
  });
803
816
  identityCommand.command("status").description("Check identity registration status").action(async () => {
@@ -863,14 +876,16 @@ var statsCommand = new Command6("stats").description("View agent statistics").op
863
876
  const keystore = await loadKeystore();
864
877
  address = keystore.walletAddress;
865
878
  }
866
- const statsQuery = opts.agent ? `/api/agents/stats?agentId=${opts.agent}` : `/api/agents/stats?address=${address}`;
879
+ const statsQuery = withChainId(
880
+ opts.agent ? `/api/agents/stats?agentId=${opts.agent}` : `/api/agents/stats?address=${address}`
881
+ );
867
882
  const [result, balanceResult, dreamsResult, exchangeRateResult] = await Promise.all([
868
883
  apiGet(statsQuery),
869
884
  apiGet(
870
885
  `/api/wallet/balance?address=${address}&chainId=${selectedNetwork().chainId}`
871
886
  ),
872
- apiGet(`/api/wallet/dreams-balance?address=${address}`).then((r) => r).catch(() => null),
873
- apiGet("/api/wallet/exchange-rate").then((r) => r).catch(() => null)
887
+ apiGet(withChainId(`/api/wallet/dreams-balance?address=${address}`)).then((r) => r).catch(() => null),
888
+ apiGet(withChainId("/api/wallet/exchange-rate")).then((r) => r).catch(() => null)
874
889
  ]);
875
890
  let pendingDreamsRewards = null;
876
891
  let pendingDreamsUsd = null;
@@ -1415,7 +1430,7 @@ function parseTermsFlags(opts) {
1415
1430
  }
1416
1431
  async function fetchTermsBoundsInfo() {
1417
1432
  try {
1418
- const response = await apiGet("/api/tasks/terms-bounds");
1433
+ const response = await apiGet(withChainId("/api/tasks/terms-bounds"));
1419
1434
  return {
1420
1435
  // Spread over the defaults so a server that predates a field still yields a full record.
1421
1436
  bounds: { ...DEFAULT_TERMS_BOUNDS, ...response?.bounds ?? {} },
@@ -1668,6 +1683,7 @@ var createCmd = new Command8("create").description("Create a new task (costs the
1668
1683
  return void printError(`Each tag must be at most ${TAG_MAX_BYTES} bytes: "${longTag}"`);
1669
1684
  }
1670
1685
  const body = {
1686
+ chainId: selectedNetwork().chainId,
1671
1687
  description: opts.description,
1672
1688
  reward: rewardBaseUnits,
1673
1689
  duration,
@@ -1800,7 +1816,7 @@ var createCmd = new Command8("create").description("Create a new task (costs the
1800
1816
  return;
1801
1817
  }
1802
1818
  const preview = await apiGet(
1803
- `/api/sponsored-task-vaults/${opts.sponsoredTask}/preview-funding?managerAddress=${managerAddress}&grossAmount=${grossAmount}`
1819
+ `/api/sponsored-task-vaults/${opts.sponsoredTask}/preview-funding?managerAddress=${managerAddress}&grossAmount=${grossAmount}&chainId=${selectedNetwork().chainId}`
1804
1820
  );
1805
1821
  if (!preview.ok) {
1806
1822
  return void printError(
@@ -1836,7 +1852,7 @@ var createCmd = new Command8("create").description("Create a new task (costs the
1836
1852
  }
1837
1853
  let taskLimits;
1838
1854
  try {
1839
- const limits = await apiGet("/api/tasks/limits");
1855
+ const limits = await apiGet(withChainId("/api/tasks/limits"));
1840
1856
  const { maxTags, maxHooks: maxHooks2 } = limits ?? {};
1841
1857
  if (typeof maxTags === "number" && Number.isInteger(maxTags) && maxTags > 0 && typeof maxHooks2 === "number" && Number.isInteger(maxHooks2) && maxHooks2 > 0) {
1842
1858
  taskLimits = { maxTags, maxHooks: maxHooks2 };
@@ -1855,7 +1871,7 @@ var createCmd = new Command8("create").description("Create a new task (costs the
1855
1871
  if (hooks.length > 0) {
1856
1872
  try {
1857
1873
  const attachmentConfiguration = await apiGet(
1858
- "/api/hooks/attachment-configuration"
1874
+ withChainId("/api/hooks/attachment-configuration")
1859
1875
  );
1860
1876
  if (attachmentConfiguration !== null && typeof attachmentConfiguration === "object" && !Array.isArray(attachmentConfiguration)) {
1861
1877
  const { defaultHooks, maxHooks: maxHooks2 } = attachmentConfiguration;
@@ -3441,7 +3457,7 @@ async function runAgentCommand(options) {
3441
3457
  try {
3442
3458
  const { assertAgentCompatibility } = await import("./compatibility-636WJOEX.js");
3443
3459
  const pi = assertAgentCompatibility();
3444
- const { runAgent } = await import("./launch-ZUPYNI5D.js");
3460
+ const { runAgent } = await import("./launch-MX3RJWL7.js");
3445
3461
  result = await runAgent({
3446
3462
  model: options.model,
3447
3463
  pi,
@@ -3500,13 +3516,13 @@ function agentManagementCommands() {
3500
3516
  const status = new Command48("status").description(
3501
3517
  "Show the agent channels (locked, charged, refundable), purchases with an unknown outcome, the sandbox and compute credit. Reads only."
3502
3518
  ).option("--json", "Print the versioned JSON envelope").action(async (options) => {
3503
- const { collectAgentStatus, statusLines } = await import("./status-3TADKQEQ.js");
3519
+ const { collectAgentStatus, statusLines } = await import("./status-JCOPIQ7O.js");
3504
3520
  await run(options, () => collectAgentStatus(), statusLines);
3505
3521
  });
3506
3522
  const doctor = new Command48("doctor").description(
3507
3523
  "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."
3508
3524
  ).option("--json", "Print the versioned JSON envelope").action(async (options) => {
3509
- const { runDoctor, doctorLines } = await import("./doctor-7OCOVNPS.js");
3525
+ const { runDoctor, doctorLines } = await import("./doctor-Z5O2VY62.js");
3510
3526
  const report = await run(options, () => runDoctor(), doctorLines);
3511
3527
  if (report && !report.ok) process.exitCode = 1;
3512
3528
  });
@@ -3517,7 +3533,7 @@ function agentManagementCommands() {
3517
3533
  "Reconcile the open purchases of this channel, as status lists it; also reaches retired channels"
3518
3534
  ).option("--json", "Print the versioned JSON envelope").action(
3519
3535
  async (invocationId, options) => {
3520
- const { reconcileChannelPurchases, reconcileInvocation } = await import("./reconcile-7B4X22S3.js");
3536
+ const { reconcileChannelPurchases, reconcileInvocation } = await import("./reconcile-OAT32H4B.js");
3521
3537
  const choice = { rail: options.rail, channel: options.channel };
3522
3538
  if (invocationId !== void 0) {
3523
3539
  await run(
@@ -3575,7 +3591,7 @@ function agentManagementCommands() {
3575
3591
  `Not a USDC amount: ${options.amount} (digits, at most 6 decimals)`
3576
3592
  );
3577
3593
  }
3578
- const { openAgentChannels, requestTopUp, selectRail, withdrawalHatch } = await import("./channels-3SW6DR33.js");
3594
+ const { openAgentChannels, requestTopUp, selectRail, withdrawalHatch } = await import("./channels-B4HKYLKV.js");
3579
3595
  const { rails } = await openAgentChannels();
3580
3596
  const result = await requestTopUp(selectRail(rails, options.rail), amount);
3581
3597
  return {
@@ -3599,8 +3615,8 @@ function agentManagementCommands() {
3599
3615
  async () => {
3600
3616
  await requireExperimental();
3601
3617
  const { AGENT_VIEW_VERSION } = await import("./budget-view-J6L7X6EY.js");
3602
- const { closeChannel, openAgentChannels, selectChannel } = await import("./channels-3SW6DR33.js");
3603
- const { reconcileLeasedPurchase } = await import("./reconcile-7B4X22S3.js");
3618
+ const { closeChannel, openAgentChannels, selectChannel } = await import("./channels-B4HKYLKV.js");
3619
+ const { reconcileLeasedPurchase } = await import("./reconcile-OAT32H4B.js");
3604
3620
  const opened = await openAgentChannels();
3605
3621
  const { rail, retired } = selectChannel(opened, options);
3606
3622
  const result = await closeChannel(
@@ -3671,7 +3687,7 @@ function agentManagementCommands() {
3671
3687
  options,
3672
3688
  async () => {
3673
3689
  await requireExperimental();
3674
- const { runPull } = await import("./sync-pull-WVUJF4J4.js");
3690
+ const { runPull } = await import("./sync-pull-D4DZ2LYX.js");
3675
3691
  const { terminalPrompter } = await import("./prompter-LSICEYSQ.js");
3676
3692
  return runPull(options, {
3677
3693
  interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY) && !options.json,
@@ -3740,6 +3756,7 @@ var agentsCommand = new Command50("agents").description("Browse the agent direct
3740
3756
  if (opts.skill) params.set("skill", opts.skill);
3741
3757
  if (opts.search) params.set("search", opts.search);
3742
3758
  if (opts.limit) params.set("limit", opts.limit);
3759
+ params.set("chainId", String(selectedNetwork().chainId));
3743
3760
  const result = await apiGet(`/api/agents/leaderboard?${params.toString()}`);
3744
3761
  printResult(result);
3745
3762
  });
@@ -3799,12 +3816,24 @@ var depositCommand = new Command53("deposit").description("Show wallet address a
3799
3816
  renderFailure(err, { fallback: "Failed to fetch network info from backend." });
3800
3817
  return;
3801
3818
  }
3802
- const chain = chainInfoFor(networkInfo, selectedNetwork().chainId);
3803
- const chainId = chain?.chainId ?? networkInfo.chainId;
3804
- const tokenAddress = chain?.tokenAddress ?? networkInfo.usdcAddress;
3819
+ let chain;
3820
+ try {
3821
+ chain = chainInfoFor(networkInfo, selectedNetwork().chainId);
3822
+ } catch (err) {
3823
+ renderFailure(err);
3824
+ return;
3825
+ }
3826
+ if (!chain) {
3827
+ renderFailure(
3828
+ new Error("The API returned network info this CLI cannot read; upgrade the CLI or the API.")
3829
+ );
3830
+ return;
3831
+ }
3832
+ const chainId = chain.chainId;
3833
+ const tokenAddress = chain.tokenAddress;
3805
3834
  const data = {
3806
3835
  address,
3807
- network: chain?.networkName ?? networkInfo.networkName,
3836
+ network: chain.networkName,
3808
3837
  chainId,
3809
3838
  currency: paymentTokenSymbol(chainId),
3810
3839
  tokenAddress,
@@ -4250,7 +4279,7 @@ var withdrawDreamsCommand = new Command62("withdraw-dreams").description("Withdr
4250
4279
  return;
4251
4280
  }
4252
4281
  const balance = await apiGet(
4253
- `/api/wallet/dreams-balance?address=${workerAddress}`
4282
+ withChainId(`/api/wallet/dreams-balance?address=${workerAddress}`)
4254
4283
  );
4255
4284
  if (!balance.hookAddress || balance.chainId === void 0) {
4256
4285
  printError("DREAMS rewards are not configured on this server");
@@ -4299,6 +4328,7 @@ var withdrawDreamsCommand = new Command62("withdraw-dreams").description("Withdr
4299
4328
  const { data: result, idempotencyKey } = await apiPost(
4300
4329
  "/api/wallet/withdraw-dreams",
4301
4330
  {
4331
+ chainId: balance.chainId,
4302
4332
  workerAddress,
4303
4333
  destination,
4304
4334
  nonce,
@@ -4635,6 +4665,7 @@ var withdrawCommand = new Command65("withdraw").description(
4635
4665
  const { data: result, idempotencyKey } = await apiPost(
4636
4666
  "/api/wallet/withdraw",
4637
4667
  {
4668
+ chainId,
4638
4669
  from,
4639
4670
  amountBaseUnits,
4640
4671
  authorization,
@@ -5481,7 +5512,7 @@ async function resolveInboxId(to) {
5481
5512
  if (!isAddress(to) && to.length === 64 && /^[0-9a-f]+$/.test(to)) {
5482
5513
  return to;
5483
5514
  }
5484
- const param = isAddress(to) ? `address=${encodeURIComponent(to)}` : `agentId=${encodeURIComponent(to)}`;
5515
+ const param = isAddress(to) ? `address=${encodeURIComponent(to)}` : `agentId=${encodeURIComponent(to)}&chainId=${selectedNetwork().chainId}`;
5485
5516
  const result = await apiGet(`/api/xmtp/resolve?${param}`);
5486
5517
  if (!result.inboxId) {
5487
5518
  const label = isAddress(to) ? `address ${to}` : `agent "${to}"`;
@@ -7,7 +7,7 @@ import {
7
7
  recordSessionEnd,
8
8
  recordSessionStart,
9
9
  uploadPlan
10
- } from "./chunk-ZPZHYEPM.js";
10
+ } from "./chunk-77XBHT43.js";
11
11
  import {
12
12
  TaskOperationError,
13
13
  authorizeUploads,
@@ -28,7 +28,7 @@ import {
28
28
  submitUploadedArtifacts,
29
29
  taskAccessGrantHeaders,
30
30
  taskAwardsOf
31
- } from "./chunk-GE7B3DNP.js";
31
+ } from "./chunk-H2XTB3NF.js";
32
32
  import {
33
33
  terminalPrompter
34
34
  } from "./chunk-ZIC2YCLV.js";
@@ -68,7 +68,7 @@ import {
68
68
  sha256Hex,
69
69
  specHash,
70
70
  taskStage
71
- } from "./chunk-7NH3EVI7.js";
71
+ } from "./chunk-NLVNUGBO.js";
72
72
  import {
73
73
  BrokerConnector,
74
74
  OutputLimitError,
@@ -80,7 +80,7 @@ import {
80
80
  serveSandboxChannel,
81
81
  withFileLock,
82
82
  writeAtomic
83
- } from "./chunk-GAESVHWN.js";
83
+ } from "./chunk-6VM3O3RZ.js";
84
84
  import {
85
85
  applyComputeCreditSetup,
86
86
  atomicToUsd,
@@ -90,7 +90,7 @@ import {
90
90
  planComputeCreditSetup,
91
91
  readComputeCreditBalance,
92
92
  usdToAtomic
93
- } from "./chunk-GG3D4M74.js";
93
+ } from "./chunk-4EN2RUZ3.js";
94
94
  import {
95
95
  MAX_RETIRED_RAILS,
96
96
  WORKSPACE_CONSENT_VERSION,
@@ -110,7 +110,7 @@ import {
110
110
  routeOfCatalogRow,
111
111
  saveAgentPolicy,
112
112
  settledRetiredRails
113
- } from "./chunk-OIQZWRMS.js";
113
+ } from "./chunk-VEZ72QNL.js";
114
114
  import {
115
115
  BASE_CHANNEL_RAIL_ID,
116
116
  createBaseChannelPayer,
@@ -124,7 +124,7 @@ import {
124
124
  rpcUrlForNetwork,
125
125
  saveX402Policy,
126
126
  x402SpendWindowAvailability
127
- } from "./chunk-RHDWF7BZ.js";
127
+ } from "./chunk-EMIVR2MT.js";
128
128
  import {
129
129
  IntentStatusResponseSchema,
130
130
  NetworkChainInfoSchema,
@@ -136,7 +136,7 @@ import {
136
136
  loadKeystore,
137
137
  selectedNetwork,
138
138
  taskmarketChain
139
- } from "./chunk-OQ6PFG36.js";
139
+ } from "./chunk-4SG3R5IH.js";
140
140
  import {
141
141
  AGENT_VIEW_VERSION,
142
142
  describeFailureDetail,
@@ -3,14 +3,14 @@ import {
3
3
  channelView,
4
4
  openAgentChannels,
5
5
  selectChannel
6
- } from "./chunk-OIQZWRMS.js";
6
+ } from "./chunk-VEZ72QNL.js";
7
7
  import {
8
8
  BASE_CHANNEL_RAIL_ID,
9
9
  X402_INVOCATION_ID_PATTERN,
10
10
  getX402JournalPath,
11
11
  listX402Payments
12
- } from "./chunk-RHDWF7BZ.js";
13
- import "./chunk-OQ6PFG36.js";
12
+ } from "./chunk-EMIVR2MT.js";
13
+ import "./chunk-4SG3R5IH.js";
14
14
  import {
15
15
  AGENT_VIEW_VERSION,
16
16
  LOST_RESPONSE_TEXT,
@@ -7,13 +7,13 @@ import {
7
7
  statusLines,
8
8
  syncLines,
9
9
  taskLines
10
- } from "./chunk-YLNOLUYO.js";
11
- import "./chunk-7NH3EVI7.js";
12
- import "./chunk-GAESVHWN.js";
13
- import "./chunk-GG3D4M74.js";
14
- import "./chunk-OIQZWRMS.js";
15
- import "./chunk-RHDWF7BZ.js";
16
- import "./chunk-OQ6PFG36.js";
10
+ } from "./chunk-AJ5V4H2H.js";
11
+ import "./chunk-NLVNUGBO.js";
12
+ import "./chunk-6VM3O3RZ.js";
13
+ import "./chunk-4EN2RUZ3.js";
14
+ import "./chunk-VEZ72QNL.js";
15
+ import "./chunk-EMIVR2MT.js";
16
+ import "./chunk-4SG3R5IH.js";
17
17
  import "./chunk-XJOB4NMV.js";
18
18
  import "./chunk-YM4S6IE4.js";
19
19
  import "./chunk-S7SJMJ2I.js";
@@ -11,7 +11,7 @@ import {
11
11
  savedWorkspace,
12
12
  summarize,
13
13
  unsavedPaths
14
- } from "./chunk-ZPZHYEPM.js";
14
+ } from "./chunk-77XBHT43.js";
15
15
  import {
16
16
  BrokerConnector,
17
17
  SandboxUnavailableError,
@@ -27,11 +27,11 @@ import {
27
27
  releaseClaim,
28
28
  unresolvedCount,
29
29
  updateSyncState
30
- } from "./chunk-GAESVHWN.js";
30
+ } from "./chunk-6VM3O3RZ.js";
31
31
  import {
32
32
  apiUrl,
33
33
  loadKeystore
34
- } from "./chunk-OQ6PFG36.js";
34
+ } from "./chunk-4SG3R5IH.js";
35
35
  import {
36
36
  AgentLaunchError
37
37
  } from "./chunk-YM4S6IE4.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-agents/taskmarket",
3
- "version": "1.20.1",
3
+ "version": "1.20.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "taskmarket": "./dist/index.js"
@@ -30,11 +30,11 @@
30
30
  "vitest": "^2.0.0",
31
31
  "@taskmarket/agent-host": "0.0.1",
32
32
  "@taskmarket/contracts": "0.0.0",
33
+ "@taskmarket/remote-tools": "0.0.1",
34
+ "@taskmarket/shared": "2.0.0",
33
35
  "@taskmarket/prettier-config": "0.0.0",
34
36
  "@taskmarket/eslint-config": "0.0.0",
35
- "@taskmarket/remote-tools": "0.0.1",
36
- "@taskmarket/x402-payer": "0.1.0",
37
- "@taskmarket/shared": "2.0.0"
37
+ "@taskmarket/x402-payer": "0.1.0"
38
38
  },
39
39
  "files": [
40
40
  "dist",