@lucid-agents/taskmarket 1.28.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.
- package/dist/agent-compatibility.json +1 -1
- package/dist/{api-IV2LK5CF.js → api-JLEPMDTE.js} +2 -2
- package/dist/{channels-GM4PE3LJ.js → channels-BUVR2LSZ.js} +4 -4
- package/dist/{chunk-MWLJU6TX.js → chunk-5YR4AZAD.js} +3 -3
- package/dist/{chunk-UTVPFCAV.js → chunk-6C63PTFL.js} +9 -8
- package/dist/{chunk-MOKEWGED.js → chunk-CJS2PHFX.js} +225 -43
- package/dist/{chunk-OFZJJRJG.js → chunk-CPYULZB3.js} +3 -3
- package/dist/{chunk-QUYCPKAV.js → chunk-E7HXLN2A.js} +2 -2
- package/dist/{chunk-6XSCWMWF.js → chunk-HET5ZDJT.js} +1 -1
- package/dist/{chunk-YRAEI25P.js → chunk-J27HWZ7Y.js} +1 -1
- package/dist/{chunk-GL3YWOBS.js → chunk-MSTGI2YG.js} +1 -1
- package/dist/{chunk-ZUJOFDF5.js → chunk-QS4JQF6W.js} +5 -5
- package/dist/{chunk-5UCQ4CTG.js → chunk-RY4U7U45.js} +4793 -3978
- package/dist/{chunk-JU7EXT2K.js → chunk-S52R3ZY5.js} +1 -1
- package/dist/{chunk-JG7RZOLG.js → chunk-VE4GYPEZ.js} +1 -1
- package/dist/{doctor-L22YVTB2.js → doctor-RYO3E7UL.js} +15 -11
- package/dist/index.js +625 -174
- package/dist/{launch-QG6GW2RQ.js → launch-5NLS7GTY.js} +20 -155
- package/dist/pi-extensions/xgate.cjs +3009 -2282
- package/dist/{read-auth-YA3TQYY6.js → read-auth-GIBB7BSS.js} +3 -3
- package/dist/{reconcile-TPFGJNMP.js → reconcile-YEIABUC6.js} +4 -4
- package/dist/{status-GSCNQCSX.js → status-K3CANP2J.js} +8 -8
- package/dist/{sync-pull-NCOPVSGZ.js → sync-pull-JK2V7ZZF.js} +4 -4
- package/dist/{task-access-grants-6TS6JMKK.js → task-access-grants-FS7OSOE2.js} +2 -2
- package/package.json +2 -2
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
parseFailureBody,
|
|
15
15
|
readFailureBody,
|
|
16
16
|
withErrorContext
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-HET5ZDJT.js";
|
|
18
|
+
import "./chunk-RY4U7U45.js";
|
|
19
19
|
import "./chunk-S7SJMJ2I.js";
|
|
20
20
|
export {
|
|
21
21
|
ApiError,
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
selectRail,
|
|
11
11
|
uncertainPurchases,
|
|
12
12
|
withdrawalHatch
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-CJS2PHFX.js";
|
|
14
|
+
import "./chunk-VE4GYPEZ.js";
|
|
15
|
+
import "./chunk-HET5ZDJT.js";
|
|
16
|
+
import "./chunk-RY4U7U45.js";
|
|
17
17
|
import "./chunk-YM4S6IE4.js";
|
|
18
18
|
import "./chunk-XJOB4NMV.js";
|
|
19
19
|
import "./chunk-S7SJMJ2I.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
readMppTempoChallenge,
|
|
16
16
|
reconcileX402Payment,
|
|
17
17
|
withX402FileLock
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-VE4GYPEZ.js";
|
|
19
19
|
import {
|
|
20
20
|
ApiError,
|
|
21
21
|
apiGet,
|
|
@@ -36,14 +36,14 @@ import {
|
|
|
36
36
|
withChainId,
|
|
37
37
|
withIdempotentWrite,
|
|
38
38
|
withTapSignature
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-HET5ZDJT.js";
|
|
40
40
|
import {
|
|
41
41
|
ComputeCreditBuyOutputSchema,
|
|
42
42
|
ComputeCreditPricingSchema,
|
|
43
43
|
ComputeCreditStatusOutputSchema,
|
|
44
44
|
apiErrorEnvelopeOf,
|
|
45
45
|
getTaskmarketHome
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-RY4U7U45.js";
|
|
47
47
|
|
|
48
48
|
// src/lib/x402-fee.ts
|
|
49
49
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -1,13 +1,13 @@
|
|
|
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-
|
|
4
|
+
} from "./chunk-5YR4AZAD.js";
|
|
5
5
|
import {
|
|
6
6
|
signReadAuth
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-E7HXLN2A.js";
|
|
8
8
|
import {
|
|
9
9
|
taskAccessGrantHeaders
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MSTGI2YG.js";
|
|
11
11
|
import {
|
|
12
12
|
apiGet,
|
|
13
13
|
apiPost,
|
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
runWorkerAction,
|
|
16
16
|
signMessage,
|
|
17
17
|
taskRequiresTap
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HET5ZDJT.js";
|
|
19
19
|
import {
|
|
20
20
|
TaskAwardSchema,
|
|
21
21
|
buildClaimMessage,
|
|
22
22
|
buildSubmitMessage,
|
|
23
23
|
isRecordingPendingResponse
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-RY4U7U45.js";
|
|
25
25
|
|
|
26
26
|
// src/sdk/artifact-upload.ts
|
|
27
27
|
import { extname } from "path";
|
|
@@ -108,9 +108,9 @@ function putArtifactBytes(uploadUrl, data, mimeType, onProgress) {
|
|
|
108
108
|
// src/lib/worker-attestation.ts
|
|
109
109
|
var requirementCache = /* @__PURE__ */ new Map();
|
|
110
110
|
async function defaultGet(path) {
|
|
111
|
-
const { apiGet: apiGet2 } = await import("./api-
|
|
112
|
-
const { signReadAuth: signReadAuth2 } = await import("./read-auth-
|
|
113
|
-
const { taskAccessGrantHeaders: taskAccessGrantHeaders2 } = await import("./task-access-grants-
|
|
111
|
+
const { apiGet: apiGet2 } = await import("./api-JLEPMDTE.js");
|
|
112
|
+
const { signReadAuth: signReadAuth2 } = await import("./read-auth-GIBB7BSS.js");
|
|
113
|
+
const { taskAccessGrantHeaders: taskAccessGrantHeaders2 } = await import("./task-access-grants-FS7OSOE2.js");
|
|
114
114
|
const taskId = /^\/api\/tasks\/([^/?]+)/.exec(path)?.[1] ?? "";
|
|
115
115
|
return apiGet2(path, {
|
|
116
116
|
headers: {
|
|
@@ -252,6 +252,7 @@ async function listTasks(ctx, filter = {}) {
|
|
|
252
252
|
if (filter.mode) params.set("mode", filter.mode);
|
|
253
253
|
if (filter.auctionType) params.set("auctionType", filter.auctionType);
|
|
254
254
|
if (filter.tags) params.set("tags", filter.tags);
|
|
255
|
+
if (filter.capabilities) params.set("capabilities", filter.capabilities);
|
|
255
256
|
if (filter.minReward) params.set("minReward", filter.minReward);
|
|
256
257
|
if (filter.maxReward) params.set("maxReward", filter.maxReward);
|
|
257
258
|
if (filter.minTotalReward) params.set("minTotalReward", filter.minTotalReward);
|
|
@@ -10,15 +10,16 @@ import {
|
|
|
10
10
|
listX402Payments,
|
|
11
11
|
loadX402Policy,
|
|
12
12
|
rpcUrlForNetwork
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VE4GYPEZ.js";
|
|
14
14
|
import {
|
|
15
15
|
createWalletAccountFromKeystore,
|
|
16
16
|
keystoreExists,
|
|
17
17
|
loadKeystore
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HET5ZDJT.js";
|
|
19
19
|
import {
|
|
20
|
-
getTaskmarketHome
|
|
21
|
-
|
|
20
|
+
getTaskmarketHome,
|
|
21
|
+
taskmarketChain
|
|
22
|
+
} from "./chunk-RY4U7U45.js";
|
|
22
23
|
import {
|
|
23
24
|
AgentLaunchError
|
|
24
25
|
} from "./chunk-YM4S6IE4.js";
|
|
@@ -301,6 +302,180 @@ function parse(bytes) {
|
|
|
301
302
|
}
|
|
302
303
|
}
|
|
303
304
|
|
|
305
|
+
// src/lib/agent/rail-profile.ts
|
|
306
|
+
import { promises as fs } from "fs";
|
|
307
|
+
import { z } from "zod";
|
|
308
|
+
var AGENT_RAIL_PROFILE_ENV = "TASKMARKET_AGENT_RAIL_PROFILE";
|
|
309
|
+
var AGENT_RAIL_PROFILE_FILE_ENV = "TASKMARKET_AGENT_RAIL_PROFILE_FILE";
|
|
310
|
+
var AGENT_DEVELOPER_ENV = "TASKMARKET_AGENT_DEVELOPER";
|
|
311
|
+
var AGENT_RAIL_NETWORKS = [
|
|
312
|
+
"eip155:8453",
|
|
313
|
+
"eip155:84532",
|
|
314
|
+
"eip155:4217",
|
|
315
|
+
"eip155:42431"
|
|
316
|
+
];
|
|
317
|
+
var CHANNEL_PAYER_NETWORKS = ["eip155:8453", "eip155:84532"];
|
|
318
|
+
function railChain(network) {
|
|
319
|
+
return taskmarketChain(Number(network.slice("eip155:".length)));
|
|
320
|
+
}
|
|
321
|
+
function railChainIdHex(network) {
|
|
322
|
+
return `0x${railChain(network).chainId.toString(16)}`;
|
|
323
|
+
}
|
|
324
|
+
function railAssetSymbol(network) {
|
|
325
|
+
return railChain(network).payment.symbol;
|
|
326
|
+
}
|
|
327
|
+
function channelPayerSupports(network) {
|
|
328
|
+
return CHANNEL_PAYER_NETWORKS.includes(network);
|
|
329
|
+
}
|
|
330
|
+
function assertChannelNetworkSupported(network) {
|
|
331
|
+
if (channelPayerSupports(network)) return;
|
|
332
|
+
throw new AgentLaunchError(
|
|
333
|
+
"rail_network_unsupported",
|
|
334
|
+
`The batch-settlement inference channel is not available on ${NETWORK_NAMES[network]} (${network}); it runs on ${CHANNEL_PAYER_NETWORKS.map((n) => NETWORK_NAMES[n]).join(" and ")}. Nothing was written.`,
|
|
335
|
+
{ network }
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
var BASE_MAINNET = "eip155:8453";
|
|
339
|
+
var address = z.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x-prefixed 20-byte address");
|
|
340
|
+
var InferenceRailProfileSchema = z.object({
|
|
341
|
+
/** Shown to the user, e.g. `base-mainnet`. */
|
|
342
|
+
name: z.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/),
|
|
343
|
+
kind: z.literal("base-batch-channel"),
|
|
344
|
+
origin: z.string().url(),
|
|
345
|
+
network: z.enum(AGENT_RAIL_NETWORKS),
|
|
346
|
+
scheme: z.literal("batch-settlement"),
|
|
347
|
+
asset: address,
|
|
348
|
+
/** The registry's payment token for `network`: USDC on Base, OUSD on Tempo. */
|
|
349
|
+
assetSymbol: z.enum(["USDC", "OUSD"]),
|
|
350
|
+
assetDecimals: z.literal(6),
|
|
351
|
+
receiver: address,
|
|
352
|
+
receiverAuthorizer: address,
|
|
353
|
+
withdrawDelaySeconds: z.number().int().positive().max(31536e3),
|
|
354
|
+
/** The environment variable the x402 policy names for this network's RPC URL. */
|
|
355
|
+
rpcUrlEnv: z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),
|
|
356
|
+
/** Local devnet only: let the payer reach a loopback origin. */
|
|
357
|
+
allowPrivateNetwork: z.boolean().default(false)
|
|
358
|
+
}).strict().superRefine((profile, ctx) => {
|
|
359
|
+
const expected = railAssetSymbol(profile.network);
|
|
360
|
+
if (profile.assetSymbol !== expected) {
|
|
361
|
+
ctx.addIssue({
|
|
362
|
+
code: "custom",
|
|
363
|
+
path: ["assetSymbol"],
|
|
364
|
+
message: `${profile.network} settles in ${expected}, not ${profile.assetSymbol}`
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
var BASE_MAINNET_PROFILE = {
|
|
369
|
+
name: "base-mainnet",
|
|
370
|
+
kind: "base-batch-channel",
|
|
371
|
+
origin: "https://api.xgate.run",
|
|
372
|
+
network: BASE_MAINNET,
|
|
373
|
+
scheme: "batch-settlement",
|
|
374
|
+
asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
375
|
+
assetSymbol: "USDC",
|
|
376
|
+
assetDecimals: 6,
|
|
377
|
+
withdrawDelaySeconds: 900,
|
|
378
|
+
rpcUrlEnv: "BASE_RPC_URL",
|
|
379
|
+
allowPrivateNetwork: false
|
|
380
|
+
};
|
|
381
|
+
var STAGING_PROFILE = {
|
|
382
|
+
name: "staging",
|
|
383
|
+
kind: "base-batch-channel",
|
|
384
|
+
origin: "https://devnet-api.xgate.run",
|
|
385
|
+
network: "eip155:84532",
|
|
386
|
+
scheme: "batch-settlement",
|
|
387
|
+
asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
388
|
+
assetSymbol: "USDC",
|
|
389
|
+
assetDecimals: 6,
|
|
390
|
+
receiver: "0x11E5BA3a2593c44d6d180054A4c8aa839202B8dd",
|
|
391
|
+
receiverAuthorizer: "0x3721824a31197dcDD2984cF43b92B6cc8A87c0Fb",
|
|
392
|
+
withdrawDelaySeconds: 3600,
|
|
393
|
+
rpcUrlEnv: "BASE_SEPOLIA_RPC_URL",
|
|
394
|
+
allowPrivateNetwork: false
|
|
395
|
+
};
|
|
396
|
+
var RAIL_PROFILES = {
|
|
397
|
+
[BASE_MAINNET_PROFILE.name]: BASE_MAINNET_PROFILE,
|
|
398
|
+
[STAGING_PROFILE.name]: STAGING_PROFILE
|
|
399
|
+
};
|
|
400
|
+
var NETWORK_NAMES = Object.fromEntries(
|
|
401
|
+
AGENT_RAIL_NETWORKS.map((network) => {
|
|
402
|
+
const { name, testnet } = railChain(network);
|
|
403
|
+
return [network, testnet ? `${name} (testnet)` : name];
|
|
404
|
+
})
|
|
405
|
+
);
|
|
406
|
+
function unavailable(message) {
|
|
407
|
+
return new AgentLaunchError("inference_rail_unavailable", `${message}. Nothing was written.`);
|
|
408
|
+
}
|
|
409
|
+
function isLoopbackOrigin(origin3) {
|
|
410
|
+
const host = new URL(origin3).hostname;
|
|
411
|
+
return host === "localhost" || host === "[::1]" || /^127(\.\d{1,3}){3}$/.test(host);
|
|
412
|
+
}
|
|
413
|
+
function pinnedProfile(name) {
|
|
414
|
+
const pinned = Object.hasOwn(RAIL_PROFILES, name) ? RAIL_PROFILES[name] : void 0;
|
|
415
|
+
if (!pinned) {
|
|
416
|
+
throw unavailable(
|
|
417
|
+
`${AGENT_RAIL_PROFILE_ENV} names ${JSON.stringify(name)}, which is not a rail profile this CLI ships (${Object.keys(RAIL_PROFILES).join(", ")})`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
const parsed = InferenceRailProfileSchema.safeParse(pinned);
|
|
421
|
+
if (!parsed.success) {
|
|
422
|
+
throw unavailable(
|
|
423
|
+
`The ${name} inference channel for taskmarket agent is not published yet, so there is nothing to approve`
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
return parsed.data;
|
|
427
|
+
}
|
|
428
|
+
async function customProfile(file) {
|
|
429
|
+
let raw;
|
|
430
|
+
try {
|
|
431
|
+
raw = JSON.parse(await fs.readFile(file, "utf8"));
|
|
432
|
+
} catch (error) {
|
|
433
|
+
throw unavailable(
|
|
434
|
+
`${AGENT_RAIL_PROFILE_FILE_ENV} names ${file}, which could not be read as JSON: ${error.message}`
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
const parsed = InferenceRailProfileSchema.safeParse(raw);
|
|
438
|
+
if (!parsed.success) {
|
|
439
|
+
const issue = parsed.error.issues[0];
|
|
440
|
+
throw unavailable(`${file}: ${issue.path.join(".") || "(root)"}: ${issue.message}`);
|
|
441
|
+
}
|
|
442
|
+
const profile = parsed.data;
|
|
443
|
+
if (!railChain(profile.network).testnet) {
|
|
444
|
+
throw unavailable(
|
|
445
|
+
`${file}: a custom rail profile cannot use ${NETWORK_NAMES[profile.network]} mainnet (${profile.network}); mainnet terms are pinned in the CLI`
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
if (Object.hasOwn(RAIL_PROFILES, profile.name)) {
|
|
449
|
+
throw unavailable(`${file}: the name ${profile.name} belongs to a pinned rail profile`);
|
|
450
|
+
}
|
|
451
|
+
const url = new URL(profile.origin);
|
|
452
|
+
if (url.protocol !== "https:" || url.origin !== profile.origin) {
|
|
453
|
+
throw unavailable(`${file}: origin must be an HTTPS origin with nothing after it`);
|
|
454
|
+
}
|
|
455
|
+
if (profile.allowPrivateNetwork && !isLoopbackOrigin(profile.origin)) {
|
|
456
|
+
throw unavailable(
|
|
457
|
+
`${file}: allowPrivateNetwork is only for a local devnet, whose origin is a loopback address`
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
return profile;
|
|
461
|
+
}
|
|
462
|
+
async function loadInferenceRailProfile(env = process.env) {
|
|
463
|
+
const name = env[AGENT_RAIL_PROFILE_ENV]?.trim();
|
|
464
|
+
const file = env[AGENT_RAIL_PROFILE_FILE_ENV]?.trim();
|
|
465
|
+
if (!file) return pinnedProfile(name || BASE_MAINNET_PROFILE.name);
|
|
466
|
+
if (name) {
|
|
467
|
+
throw unavailable(
|
|
468
|
+
`Set either ${AGENT_RAIL_PROFILE_ENV} (a pinned profile) or ${AGENT_RAIL_PROFILE_FILE_ENV} (a development profile), not both`
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
if (env[AGENT_DEVELOPER_ENV]?.trim() !== "1") {
|
|
472
|
+
throw unavailable(
|
|
473
|
+
`${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`
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
return customProfile(file);
|
|
477
|
+
}
|
|
478
|
+
|
|
304
479
|
// src/lib/agent/payer.ts
|
|
305
480
|
function routeOfCatalogRow(row) {
|
|
306
481
|
return row?.owned_by === "anthropic" ? "/providers/anthropic/v1/messages" : "/providers/openai/v1/responses";
|
|
@@ -375,6 +550,7 @@ async function createAgentRails(options) {
|
|
|
375
550
|
`Rail ${rail.id} pays from ${rail.wallet}, but the wallet is ${options.walletAddress}`
|
|
376
551
|
);
|
|
377
552
|
}
|
|
553
|
+
assertChannelNetworkSupported(rail.network);
|
|
378
554
|
let rpcUrl;
|
|
379
555
|
try {
|
|
380
556
|
rpcUrl = rpcUrlForNetwork(x402Policy, rail.network);
|
|
@@ -547,47 +723,47 @@ async function reconcileLeftoverOperations(rails, log = () => void 0) {
|
|
|
547
723
|
|
|
548
724
|
// src/lib/agent/policy.ts
|
|
549
725
|
import { randomUUID } from "crypto";
|
|
550
|
-
import { promises as
|
|
726
|
+
import { promises as fs2 } from "fs";
|
|
551
727
|
import path from "path";
|
|
552
|
-
import { z } from "zod";
|
|
728
|
+
import { z as z2 } from "zod";
|
|
553
729
|
var XGATE_ROUTES = [
|
|
554
730
|
"/providers/anthropic/v1/messages",
|
|
555
731
|
"/providers/openai/v1/responses"
|
|
556
732
|
];
|
|
557
733
|
var WORKSPACE_CONSENT_VERSION = "boat-eu-2026-10-sync";
|
|
558
|
-
var
|
|
559
|
-
var atomic2 =
|
|
734
|
+
var address2 = z2.string().regex(/^0x[0-9a-fA-F]{40}$/, "expected a 0x-prefixed 20-byte address");
|
|
735
|
+
var atomic2 = z2.string().regex(/^(0|[1-9][0-9]{0,30})$/, "expected an integer amount string");
|
|
560
736
|
var positiveAtomic = atomic2.refine((value) => BigInt(value) > 0n, "expected an amount above 0");
|
|
561
|
-
var ruleId =
|
|
562
|
-
var allocationId =
|
|
563
|
-
var origin2 =
|
|
737
|
+
var ruleId = z2.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/, "invalid id");
|
|
738
|
+
var allocationId = z2.string().regex(/^[A-Za-z0-9._:-]{1,128}$/, "invalid allocation id");
|
|
739
|
+
var origin2 = z2.string().url().refine((value) => {
|
|
564
740
|
const url = new URL(value);
|
|
565
741
|
return url.protocol === "https:" && !url.username && !url.password && url.pathname === "/" && !url.search && !url.hash && !value.endsWith("/");
|
|
566
742
|
}, "expected an HTTPS origin such as https://api.xgate.run");
|
|
567
|
-
var RailLimitsSchema =
|
|
743
|
+
var RailLimitsSchema = z2.object({
|
|
568
744
|
perRequest: positiveAtomic,
|
|
569
745
|
deposit: positiveAtomic,
|
|
570
746
|
total: positiveAtomic,
|
|
571
|
-
expiresAt:
|
|
747
|
+
expiresAt: z2.string().datetime()
|
|
572
748
|
}).strict();
|
|
573
|
-
var BaseBatchChannelRailSchema =
|
|
749
|
+
var BaseBatchChannelRailSchema = z2.object({
|
|
574
750
|
id: ruleId,
|
|
575
|
-
kind:
|
|
751
|
+
kind: z2.literal("base-batch-channel"),
|
|
576
752
|
/** The wallet that funds deposits and signs vouchers; must be the keystore's wallet. */
|
|
577
|
-
wallet:
|
|
578
|
-
network:
|
|
579
|
-
scheme:
|
|
580
|
-
/**
|
|
581
|
-
asset:
|
|
753
|
+
wallet: address2,
|
|
754
|
+
network: z2.enum(AGENT_RAIL_NETWORKS),
|
|
755
|
+
scheme: z2.literal("batch-settlement"),
|
|
756
|
+
/** The payment token on `network`: USDC on Base, OUSD on Tempo. */
|
|
757
|
+
asset: address2,
|
|
582
758
|
origin: origin2,
|
|
583
|
-
route:
|
|
584
|
-
receiver:
|
|
585
|
-
receiverAuthorizer:
|
|
586
|
-
salt:
|
|
759
|
+
route: z2.enum(XGATE_ROUTES),
|
|
760
|
+
receiver: address2,
|
|
761
|
+
receiverAuthorizer: address2,
|
|
762
|
+
salt: z2.string().regex(/^0x[0-9a-fA-F]{64}$/, "expected a 32-byte hex salt"),
|
|
587
763
|
/** A block at or before the channel's first deposit; return scans start here. */
|
|
588
|
-
fromBlock:
|
|
764
|
+
fromBlock: z2.string().regex(/^(0|[1-9][0-9]{0,19})$/),
|
|
589
765
|
/** The channel's withdraw delay, as onboarding showed it. */
|
|
590
|
-
withdrawDelaySeconds:
|
|
766
|
+
withdrawDelaySeconds: z2.number().int().nonnegative(),
|
|
591
767
|
/**
|
|
592
768
|
* The durable root allocation, shared by every rail of the policy: all routes and every
|
|
593
769
|
* renewal's history count against its one `total`.
|
|
@@ -599,14 +775,14 @@ var BaseBatchChannelRailSchema = z.object({
|
|
|
599
775
|
policyRuleId: ruleId,
|
|
600
776
|
limits: RailLimitsSchema
|
|
601
777
|
}).strict();
|
|
602
|
-
var AgentRailSchema =
|
|
778
|
+
var AgentRailSchema = z2.discriminatedUnion("kind", [BaseBatchChannelRailSchema]);
|
|
603
779
|
var MAX_RETIRED_RAILS = 64;
|
|
604
|
-
var AgentPolicySchema =
|
|
605
|
-
version:
|
|
606
|
-
approvedAt:
|
|
780
|
+
var AgentPolicySchema = z2.object({
|
|
781
|
+
version: z2.literal(1),
|
|
782
|
+
approvedAt: z2.string().datetime(),
|
|
607
783
|
/** xgate model ids the user approved. Only those the router also qualifies are offered. */
|
|
608
|
-
models:
|
|
609
|
-
rails:
|
|
784
|
+
models: z2.array(z2.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/, "invalid model id")).min(1).max(64),
|
|
785
|
+
rails: z2.array(AgentRailSchema).min(1).max(XGATE_ROUTES.length),
|
|
610
786
|
/**
|
|
611
787
|
* Channels that buy nothing more but may still hold a refundable deposit: those a renewal
|
|
612
788
|
* replaced (a channel's budget and allocation are fixed for its life, ADR-0243, so a larger
|
|
@@ -617,10 +793,10 @@ var AgentPolicySchema = z.object({
|
|
|
617
793
|
* the journal shows nothing deposited, pending or refundable on its channel; onboarding never
|
|
618
794
|
* drops one to make room, and refuses to retire more than `MAX_RETIRED_RAILS`.
|
|
619
795
|
*/
|
|
620
|
-
retiredRails:
|
|
621
|
-
workspace:
|
|
622
|
-
consentVersion:
|
|
623
|
-
approvedAt:
|
|
796
|
+
retiredRails: z2.array(AgentRailSchema).max(MAX_RETIRED_RAILS).default([]),
|
|
797
|
+
workspace: z2.object({
|
|
798
|
+
consentVersion: z2.string().min(1).max(64),
|
|
799
|
+
approvedAt: z2.string().datetime()
|
|
624
800
|
}).strict()
|
|
625
801
|
}).strict().superRefine((policy, ctx) => {
|
|
626
802
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -668,7 +844,7 @@ function getAgentPolicyPath() {
|
|
|
668
844
|
async function readAgentPolicy(policyPath = getAgentPolicyPath()) {
|
|
669
845
|
let raw;
|
|
670
846
|
try {
|
|
671
|
-
raw = await
|
|
847
|
+
raw = await fs2.readFile(policyPath, "utf8");
|
|
672
848
|
} catch (error) {
|
|
673
849
|
if (error.code === "ENOENT") return void 0;
|
|
674
850
|
throw error;
|
|
@@ -702,17 +878,17 @@ async function loadAgentPolicy(policyPath = getAgentPolicyPath()) {
|
|
|
702
878
|
}
|
|
703
879
|
async function saveAgentPolicy(policy, policyPath = getAgentPolicyPath()) {
|
|
704
880
|
const validated = AgentPolicySchema.parse(policy);
|
|
705
|
-
await
|
|
881
|
+
await fs2.mkdir(path.dirname(policyPath), { recursive: true, mode: 448 });
|
|
706
882
|
const temporary = `${policyPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
707
883
|
try {
|
|
708
|
-
await
|
|
884
|
+
await fs2.writeFile(temporary, `${JSON.stringify(validated, null, 2)}
|
|
709
885
|
`, {
|
|
710
886
|
mode: 384,
|
|
711
887
|
flag: "wx"
|
|
712
888
|
});
|
|
713
|
-
await
|
|
889
|
+
await fs2.rename(temporary, policyPath);
|
|
714
890
|
} finally {
|
|
715
|
-
await
|
|
891
|
+
await fs2.rm(temporary, { force: true }).catch(() => void 0);
|
|
716
892
|
}
|
|
717
893
|
}
|
|
718
894
|
async function assessAgentPolicy(policy, options) {
|
|
@@ -764,7 +940,7 @@ function requireApprovedModel(policy, requested) {
|
|
|
764
940
|
}
|
|
765
941
|
function planSessionModels(options) {
|
|
766
942
|
const { approved, offered, requested, previous } = options;
|
|
767
|
-
const
|
|
943
|
+
const unavailable2 = approved.filter((model) => !offered.includes(model));
|
|
768
944
|
if (offered.length === 0) {
|
|
769
945
|
throw new AgentLaunchError(
|
|
770
946
|
"no_qualified_models",
|
|
@@ -778,7 +954,7 @@ function planSessionModels(options) {
|
|
|
778
954
|
);
|
|
779
955
|
}
|
|
780
956
|
const start = requested ?? (previous !== void 0 && offered.includes(previous) ? previous : offered[0]);
|
|
781
|
-
return { start, unavailable };
|
|
957
|
+
return { start, unavailable: unavailable2 };
|
|
782
958
|
}
|
|
783
959
|
|
|
784
960
|
// src/lib/agent/retired.ts
|
|
@@ -1180,6 +1356,12 @@ async function closeChannel(rail, confirm, options = {}) {
|
|
|
1180
1356
|
export {
|
|
1181
1357
|
XgateError,
|
|
1182
1358
|
XgatePurchaseError,
|
|
1359
|
+
AGENT_RAIL_NETWORKS,
|
|
1360
|
+
railChain,
|
|
1361
|
+
railChainIdHex,
|
|
1362
|
+
assertChannelNetworkSupported,
|
|
1363
|
+
NETWORK_NAMES,
|
|
1364
|
+
loadInferenceRailProfile,
|
|
1183
1365
|
routeOfCatalogRow,
|
|
1184
1366
|
createAgentTransport,
|
|
1185
1367
|
reconcileLeftoverOperations,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
unsafeHostPath,
|
|
9
9
|
withFileLock,
|
|
10
10
|
writeAtomic
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-S52R3ZY5.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-
|
|
19
|
+
} from "./chunk-5YR4AZAD.js";
|
|
20
20
|
import {
|
|
21
21
|
getTaskmarketHome
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-RY4U7U45.js";
|
|
23
23
|
import {
|
|
24
24
|
AgentLaunchError
|
|
25
25
|
} from "./chunk-YM4S6IE4.js";
|
|
@@ -2,12 +2,12 @@ import { createRequire as __tmCreateRequire } from 'node:module'; import { fileU
|
|
|
2
2
|
import {
|
|
3
3
|
createWalletAccountFromKeystore,
|
|
4
4
|
loadKeystore
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HET5ZDJT.js";
|
|
6
6
|
import {
|
|
7
7
|
READ_AUTH_ADDRESS_HEADER,
|
|
8
8
|
READ_AUTH_SIGNATURE_HEADER,
|
|
9
9
|
buildReadAuthMessage
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RY4U7U45.js";
|
|
11
11
|
|
|
12
12
|
// src/lib/read-auth.ts
|
|
13
13
|
async function signReadAuth() {
|
|
@@ -2,7 +2,7 @@ import { createRequire as __tmCreateRequire } from 'node:module'; import { fileU
|
|
|
2
2
|
import {
|
|
3
3
|
TASK_ACCESS_GRANT_HEADER,
|
|
4
4
|
getTaskmarketHome
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-RY4U7U45.js";
|
|
6
6
|
|
|
7
7
|
// src/lib/task-access-grants.ts
|
|
8
8
|
import { promises as fs } from "fs";
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
loadDeliverableRecord,
|
|
7
7
|
readComputeView,
|
|
8
8
|
taskStage
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CPYULZB3.js";
|
|
10
10
|
import {
|
|
11
11
|
activeClaim,
|
|
12
12
|
captureProblem,
|
|
13
13
|
killedSession,
|
|
14
14
|
loadSyncState,
|
|
15
15
|
orphanOf
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-S52R3ZY5.js";
|
|
17
17
|
import {
|
|
18
18
|
allocationViews,
|
|
19
19
|
channelView,
|
|
@@ -21,14 +21,14 @@ import {
|
|
|
21
21
|
openAgentChannels,
|
|
22
22
|
uncertainPurchases,
|
|
23
23
|
withdrawalHatch
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-CJS2PHFX.js";
|
|
25
25
|
import {
|
|
26
26
|
apiUrl,
|
|
27
27
|
selectedNetwork
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-HET5ZDJT.js";
|
|
29
29
|
import {
|
|
30
30
|
SandboxListOutputSchema
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-RY4U7U45.js";
|
|
32
32
|
import {
|
|
33
33
|
AgentLaunchError
|
|
34
34
|
} from "./chunk-YM4S6IE4.js";
|