@lucid-agents/taskmarket 1.29.0 → 1.30.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-4UFXNF3X.js → api-JLEPMDTE.js} +2 -2
  3. package/dist/{channels-UJ32F6KT.js → channels-BUVR2LSZ.js} +4 -4
  4. package/dist/{chunk-6QD7LE3R.js → chunk-5YR4AZAD.js} +3 -3
  5. package/dist/{chunk-VABTHZFQ.js → chunk-6C63PTFL.js} +8 -8
  6. package/dist/{chunk-BXZHXNZZ.js → chunk-CJS2PHFX.js} +225 -43
  7. package/dist/{chunk-LLDTXUHC.js → chunk-CPYULZB3.js} +3 -3
  8. package/dist/{chunk-LRCJQWAT.js → chunk-E7HXLN2A.js} +2 -2
  9. package/dist/{chunk-44AGKANB.js → chunk-HET5ZDJT.js} +1 -1
  10. package/dist/{chunk-A4M344DT.js → chunk-J27HWZ7Y.js} +1 -1
  11. package/dist/{chunk-XUBYHJMJ.js → chunk-MSTGI2YG.js} +1 -1
  12. package/dist/{chunk-CLFA6AAX.js → chunk-QS4JQF6W.js} +5 -5
  13. package/dist/{chunk-FQIK5KSR.js → chunk-RY4U7U45.js} +2538 -2110
  14. package/dist/{chunk-R7FABEN6.js → chunk-S52R3ZY5.js} +1 -1
  15. package/dist/{chunk-6QUNPM4S.js → chunk-VE4GYPEZ.js} +1 -1
  16. package/dist/{doctor-HRIWE4JV.js → doctor-RYO3E7UL.js} +15 -11
  17. package/dist/index.js +583 -164
  18. package/dist/{launch-ZER5DDN3.js → launch-5NLS7GTY.js} +20 -155
  19. package/dist/pi-extensions/xgate.cjs +473 -130
  20. package/dist/{read-auth-D5OASV5M.js → read-auth-GIBB7BSS.js} +3 -3
  21. package/dist/{reconcile-VEEAEVG7.js → reconcile-YEIABUC6.js} +4 -4
  22. package/dist/{status-BDVDZCU2.js → status-K3CANP2J.js} +8 -8
  23. package/dist/{sync-pull-QXN3V4MI.js → sync-pull-JK2V7ZZF.js} +4 -4
  24. package/dist/{task-access-grants-RS4O6LUB.js → task-access-grants-FS7OSOE2.js} +2 -2
  25. package/package.json +2 -2
@@ -38,7 +38,7 @@ import {
38
38
  sha256Hex,
39
39
  specHash,
40
40
  taskStage
41
- } from "./chunk-LLDTXUHC.js";
41
+ } from "./chunk-CPYULZB3.js";
42
42
  import {
43
43
  SessionSync,
44
44
  emptyBase,
@@ -47,7 +47,7 @@ import {
47
47
  recordSessionEnd,
48
48
  recordSessionStart,
49
49
  uploadPlan
50
- } from "./chunk-A4M344DT.js";
50
+ } from "./chunk-J27HWZ7Y.js";
51
51
  import {
52
52
  BrokerConnector,
53
53
  OutputLimitError,
@@ -59,7 +59,7 @@ import {
59
59
  serveSandboxChannel,
60
60
  withFileLock,
61
61
  writeAtomic
62
- } from "./chunk-R7FABEN6.js";
62
+ } from "./chunk-S52R3ZY5.js";
63
63
  import {
64
64
  TaskOperationError,
65
65
  authorizeUploads,
@@ -78,7 +78,7 @@ import {
78
78
  requestArtifactUpload,
79
79
  submitUploadedArtifacts,
80
80
  taskAwardsOf
81
- } from "./chunk-VABTHZFQ.js";
81
+ } from "./chunk-6C63PTFL.js";
82
82
  import {
83
83
  applyComputeCreditSetup,
84
84
  atomicToUsd,
@@ -88,33 +88,37 @@ import {
88
88
  planComputeCreditSetup,
89
89
  readComputeCreditBalance,
90
90
  usdToAtomic
91
- } from "./chunk-6QD7LE3R.js";
91
+ } from "./chunk-5YR4AZAD.js";
92
92
  import {
93
93
  signReadAuth
94
- } from "./chunk-LRCJQWAT.js";
94
+ } from "./chunk-E7HXLN2A.js";
95
95
  import {
96
96
  taskAccessGrantHeaders
97
- } from "./chunk-XUBYHJMJ.js";
97
+ } from "./chunk-MSTGI2YG.js";
98
98
  import {
99
99
  MAX_RETIRED_RAILS,
100
+ NETWORK_NAMES,
100
101
  WORKSPACE_CONSENT_VERSION,
101
102
  XGATE_ROUTES,
102
103
  XgateError,
103
104
  XgatePurchaseError,
104
105
  allocationViews,
106
+ assertChannelNetworkSupported,
105
107
  assessAgentPolicy,
106
108
  channelView,
107
109
  createAgentTransport,
108
110
  getAgentPolicyPath,
111
+ loadInferenceRailProfile,
109
112
  openAgentChannels,
110
113
  planSessionModels,
114
+ railChain,
111
115
  readAgentPolicy,
112
116
  reconcileLeftoverOperations,
113
117
  requireApprovedModel,
114
118
  routeOfCatalogRow,
115
119
  saveAgentPolicy,
116
120
  settledRetiredRails
117
- } from "./chunk-BXZHXNZZ.js";
121
+ } from "./chunk-CJS2PHFX.js";
118
122
  import {
119
123
  BASE_CHANNEL_RAIL_ID,
120
124
  createBaseChannelPayer,
@@ -128,13 +132,13 @@ import {
128
132
  rpcUrlForNetwork,
129
133
  saveX402Policy,
130
134
  x402SpendWindowAvailability
131
- } from "./chunk-6QUNPM4S.js";
135
+ } from "./chunk-VE4GYPEZ.js";
132
136
  import {
133
137
  apiUrl,
134
138
  keystoreExists,
135
139
  loadKeystore,
136
140
  selectedNetwork
137
- } from "./chunk-44AGKANB.js";
141
+ } from "./chunk-HET5ZDJT.js";
138
142
  import {
139
143
  IntentStatusResponseSchema,
140
144
  NetworkChainInfoSchema,
@@ -143,7 +147,7 @@ import {
143
147
  isRecordingPendingResponse,
144
148
  piCodingAgentTools,
145
149
  taskmarketChain
146
- } from "./chunk-FQIK5KSR.js";
150
+ } from "./chunk-RY4U7U45.js";
147
151
  import {
148
152
  AgentLaunchError
149
153
  } from "./chunk-YM4S6IE4.js";
@@ -3351,7 +3355,7 @@ function hostOutcomeReads(input) {
3351
3355
  return {
3352
3356
  async payout(taskId) {
3353
3357
  marketplace ??= (input.marketplace ?? marketplaceFromNetworkInfo)(context, chainId);
3354
- const address3 = await marketplace.catch((error) => {
3358
+ const address2 = await marketplace.catch((error) => {
3355
3359
  marketplace = void 0;
3356
3360
  throw error;
3357
3361
  });
@@ -3359,7 +3363,7 @@ function hostOutcomeReads(input) {
3359
3363
  return observePayout(
3360
3364
  context,
3361
3365
  { taskId, chainId },
3362
- { worker: input.wallet, marketplace: address3, ...reader ? { reader } : {} }
3366
+ { worker: input.wallet, marketplace: address2, ...reader ? { reader } : {} }
3363
3367
  );
3364
3368
  },
3365
3369
  submissions: (taskId) => listTaskSubmissions(context, { taskId, chainId })
@@ -5341,143 +5345,6 @@ async function checkDepositWindows(input) {
5341
5345
  // src/lib/agent/onboarding.ts
5342
5346
  import { randomBytes as randomBytes3, randomUUID as randomUUID4 } from "crypto";
5343
5347
  import { createPublicClient as createPublicClient2, erc20Abi, http as http2 } from "viem";
5344
-
5345
- // src/lib/agent/rail-profile.ts
5346
- import { promises as fs5 } from "fs";
5347
- import { z } from "zod";
5348
- var AGENT_RAIL_PROFILE_ENV = "TASKMARKET_AGENT_RAIL_PROFILE";
5349
- var AGENT_RAIL_PROFILE_FILE_ENV = "TASKMARKET_AGENT_RAIL_PROFILE_FILE";
5350
- var AGENT_DEVELOPER_ENV = "TASKMARKET_AGENT_DEVELOPER";
5351
- var BASE_MAINNET = "eip155:8453";
5352
- var address2 = z.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x-prefixed 20-byte address");
5353
- var InferenceRailProfileSchema = z.object({
5354
- /** Shown to the user, e.g. `base-mainnet`. */
5355
- name: z.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/),
5356
- kind: z.literal("base-batch-channel"),
5357
- origin: z.string().url(),
5358
- network: z.enum(["eip155:8453", "eip155:84532"]),
5359
- scheme: z.literal("batch-settlement"),
5360
- asset: address2,
5361
- assetSymbol: z.literal("USDC"),
5362
- assetDecimals: z.literal(6),
5363
- receiver: address2,
5364
- receiverAuthorizer: address2,
5365
- withdrawDelaySeconds: z.number().int().positive().max(31536e3),
5366
- /** The environment variable the x402 policy names for this network's RPC URL. */
5367
- rpcUrlEnv: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),
5368
- /** Local devnet only: let the payer reach a loopback origin. */
5369
- allowPrivateNetwork: z.boolean().default(false)
5370
- }).strict();
5371
- var BASE_MAINNET_PROFILE = {
5372
- name: "base-mainnet",
5373
- kind: "base-batch-channel",
5374
- origin: "https://api.xgate.run",
5375
- network: BASE_MAINNET,
5376
- scheme: "batch-settlement",
5377
- asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
5378
- assetSymbol: "USDC",
5379
- assetDecimals: 6,
5380
- withdrawDelaySeconds: 900,
5381
- rpcUrlEnv: "BASE_RPC_URL",
5382
- allowPrivateNetwork: false
5383
- };
5384
- var STAGING_PROFILE = {
5385
- name: "staging",
5386
- kind: "base-batch-channel",
5387
- origin: "https://devnet-api.xgate.run",
5388
- network: "eip155:84532",
5389
- scheme: "batch-settlement",
5390
- asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
5391
- assetSymbol: "USDC",
5392
- assetDecimals: 6,
5393
- receiver: "0x11E5BA3a2593c44d6d180054A4c8aa839202B8dd",
5394
- receiverAuthorizer: "0x3721824a31197dcDD2984cF43b92B6cc8A87c0Fb",
5395
- withdrawDelaySeconds: 3600,
5396
- rpcUrlEnv: "BASE_SEPOLIA_RPC_URL",
5397
- allowPrivateNetwork: false
5398
- };
5399
- var RAIL_PROFILES = {
5400
- [BASE_MAINNET_PROFILE.name]: BASE_MAINNET_PROFILE,
5401
- [STAGING_PROFILE.name]: STAGING_PROFILE
5402
- };
5403
- var NETWORK_NAMES = {
5404
- "eip155:8453": "Base",
5405
- "eip155:84532": "Base Sepolia (testnet)"
5406
- };
5407
- function unavailable(message) {
5408
- return new AgentLaunchError("inference_rail_unavailable", `${message}. Nothing was written.`);
5409
- }
5410
- function isLoopbackOrigin(origin) {
5411
- const host = new URL(origin).hostname;
5412
- return host === "localhost" || host === "[::1]" || /^127(\.\d{1,3}){3}$/.test(host);
5413
- }
5414
- function pinnedProfile(name) {
5415
- const pinned = Object.hasOwn(RAIL_PROFILES, name) ? RAIL_PROFILES[name] : void 0;
5416
- if (!pinned) {
5417
- throw unavailable(
5418
- `${AGENT_RAIL_PROFILE_ENV} names ${JSON.stringify(name)}, which is not a rail profile this CLI ships (${Object.keys(RAIL_PROFILES).join(", ")})`
5419
- );
5420
- }
5421
- const parsed = InferenceRailProfileSchema.safeParse(pinned);
5422
- if (!parsed.success) {
5423
- throw unavailable(
5424
- `The ${name} inference channel for taskmarket agent is not published yet, so there is nothing to approve`
5425
- );
5426
- }
5427
- return parsed.data;
5428
- }
5429
- async function customProfile(file) {
5430
- let raw;
5431
- try {
5432
- raw = JSON.parse(await fs5.readFile(file, "utf8"));
5433
- } catch (error) {
5434
- throw unavailable(
5435
- `${AGENT_RAIL_PROFILE_FILE_ENV} names ${file}, which could not be read as JSON: ${error.message}`
5436
- );
5437
- }
5438
- const parsed = InferenceRailProfileSchema.safeParse(raw);
5439
- if (!parsed.success) {
5440
- const issue = parsed.error.issues[0];
5441
- throw unavailable(`${file}: ${issue.path.join(".") || "(root)"}: ${issue.message}`);
5442
- }
5443
- const profile = parsed.data;
5444
- if (profile.network === BASE_MAINNET) {
5445
- throw unavailable(
5446
- `${file}: a custom rail profile cannot use Base mainnet (${BASE_MAINNET}); mainnet terms are pinned in the CLI`
5447
- );
5448
- }
5449
- if (Object.hasOwn(RAIL_PROFILES, profile.name)) {
5450
- throw unavailable(`${file}: the name ${profile.name} belongs to a pinned rail profile`);
5451
- }
5452
- const url = new URL(profile.origin);
5453
- if (url.protocol !== "https:" || url.origin !== profile.origin) {
5454
- throw unavailable(`${file}: origin must be an HTTPS origin with nothing after it`);
5455
- }
5456
- if (profile.allowPrivateNetwork && !isLoopbackOrigin(profile.origin)) {
5457
- throw unavailable(
5458
- `${file}: allowPrivateNetwork is only for a local devnet, whose origin is a loopback address`
5459
- );
5460
- }
5461
- return profile;
5462
- }
5463
- async function loadInferenceRailProfile(env = process.env) {
5464
- const name = env[AGENT_RAIL_PROFILE_ENV]?.trim();
5465
- const file = env[AGENT_RAIL_PROFILE_FILE_ENV]?.trim();
5466
- if (!file) return pinnedProfile(name || BASE_MAINNET_PROFILE.name);
5467
- if (name) {
5468
- throw unavailable(
5469
- `Set either ${AGENT_RAIL_PROFILE_ENV} (a pinned profile) or ${AGENT_RAIL_PROFILE_FILE_ENV} (a development profile), not both`
5470
- );
5471
- }
5472
- if (env[AGENT_DEVELOPER_ENV]?.trim() !== "1") {
5473
- throw unavailable(
5474
- `${AGENT_RAIL_PROFILE_FILE_ENV} is a development setting and is read only with ${AGENT_DEVELOPER_ENV}=1; set ${AGENT_RAIL_PROFILE_ENV} to a pinned profile (${Object.keys(RAIL_PROFILES).join(", ")}) instead`
5475
- );
5476
- }
5477
- return customProfile(file);
5478
- }
5479
-
5480
- // src/lib/agent/onboarding.ts
5481
5348
  var ONBOARDING_DEFAULTS = {
5482
5349
  depositUsd: "5",
5483
5350
  perRequestUsd: "1",
@@ -5521,16 +5388,12 @@ async function readXgateCatalog(origin, fetchImpl = fetch) {
5521
5388
  }
5522
5389
  return models;
5523
5390
  }
5524
- var CHAIN_IDS = {
5525
- "eip155:8453": 8453,
5526
- "eip155:84532": 84532
5527
- };
5528
5391
  async function readBaseChain(profile, rpcUrl, wallet) {
5529
5392
  const client = createPublicClient2({
5530
5393
  transport: http2(rpcUrl, { timeout: 15e3, retryCount: 1 })
5531
5394
  });
5532
5395
  const chainId = await client.getChainId();
5533
- if (chainId !== CHAIN_IDS[profile.network]) {
5396
+ if (chainId !== railChain(profile.network).chainId) {
5534
5397
  throw new Error(`the RPC serves chain ${chainId}, not ${profile.network}`);
5535
5398
  }
5536
5399
  const blockNumber = await client.getBlockNumber();
@@ -5720,6 +5583,7 @@ function shortId() {
5720
5583
  return randomUUID4().replace(/-/g, "").slice(0, 12);
5721
5584
  }
5722
5585
  async function preflight(deps, profile, wallet, prompter) {
5586
+ assertChannelNetworkSupported(profile.network);
5723
5587
  prompter.say(["", "Checking the inference terms, the chain and compute (read-only)..."]);
5724
5588
  const step = async (name, read) => {
5725
5589
  try {
@@ -5829,6 +5693,7 @@ function sameTerms(rail, profile, wallet) {
5829
5693
  return rail.origin === profile.origin && rail.network === profile.network && same(rail.asset, profile.asset) && same(rail.receiver, profile.receiver) && same(rail.receiverAuthorizer, profile.receiverAuthorizer) && same(rail.wallet, wallet);
5830
5694
  }
5831
5695
  function channelSessionKey(rail, rpcUrl, journalPath) {
5696
+ assertChannelNetworkSupported(rail.network);
5832
5697
  const channel = {
5833
5698
  network: rail.network,
5834
5699
  payer: rail.wallet,