@lucid-agents/taskmarket 1.25.1 → 1.27.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/THIRD_PARTY_NOTICES.md +224 -122
- package/dist/agent-compatibility.json +1 -1
- package/dist/api-EKGAP2TK.js +35 -0
- package/dist/{channels-LEYAANE5.js → channels-5V4244GL.js} +5 -4
- package/dist/{chunk-RFRSTYDB.js → chunk-6T24AGBE.js} +5 -5
- package/dist/chunk-7KBQDZWR.js +933 -0
- package/dist/{chunk-6KBTN3WM.js → chunk-CS36JL4J.js} +1 -45
- package/dist/{chunk-ULPTFH3G.js → chunk-D26Z36NX.js} +1 -1
- package/dist/chunk-DTSONVE3.js +39 -0
- package/dist/{chunk-CGUYPUG3.js → chunk-EDW4XCAY.js} +6 -6
- package/dist/chunk-HVI5YS47.js +46 -0
- package/dist/{chunk-XBTNZTXE.js → chunk-MAIB4J42.js} +9 -7
- package/dist/{chunk-PE72DL5T.js → chunk-PCDHSI5Y.js} +90 -84
- package/dist/{chunk-4E76UNBE.js → chunk-QF2AWW7O.js} +11 -127
- package/dist/{chunk-73SUBS7U.js → chunk-RA3GGK5G.js} +42 -18
- package/dist/chunk-ZW6MI2F6.js +17019 -0
- package/dist/{doctor-K2JOWQF4.js → doctor-3VKAO7ZW.js} +11 -19
- package/dist/index.js +19303 -7978
- package/dist/{launch-O72WIBHY.js → launch-YVKAONR5.js} +73 -46
- package/dist/pi-extensions/remote-tools.cjs +4 -4
- package/dist/pi-extensions/xgate.cjs +4248 -308
- package/dist/read-auth-XZOWQ45P.js +10 -0
- package/dist/{reconcile-FZTOX3PZ.js → reconcile-YBEASFA3.js} +7 -6
- package/dist/{status-CC5L5YUU.js → status-NCA4MCIV.js} +11 -16
- package/dist/{sync-pull-DZGTSKZU.js → sync-pull-WOKOY65R.js} +4 -3
- package/dist/task-access-grants-7JUAFFYG.js +13 -0
- package/package.json +9 -5
- package/dist/chunk-L3A7JOO5.js +0 -11727
|
@@ -2,16 +2,13 @@ import { createRequire as __tmCreateRequire } from 'node:module'; import { fileU
|
|
|
2
2
|
import {
|
|
3
3
|
MppTempoChargeRequestSchema,
|
|
4
4
|
TEMPO_MAX_VALIDITY_WINDOW_SECONDS,
|
|
5
|
-
apiUrl,
|
|
6
5
|
clampValidityWindowSeconds,
|
|
7
6
|
decodeMppJson,
|
|
8
|
-
decryptPrivateKey,
|
|
9
7
|
formatMppCredential,
|
|
10
8
|
getTaskmarketHome,
|
|
11
|
-
loadKeystore,
|
|
12
9
|
mppAttributionMemo,
|
|
13
10
|
parseMppChallenge
|
|
14
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ZW6MI2F6.js";
|
|
15
12
|
|
|
16
13
|
// ../../packages/x402-payer/dist/api.js
|
|
17
14
|
var X402_PAYER_API_VERSION = 1;
|
|
@@ -7470,42 +7467,6 @@ async function createMppTempoCredential(input) {
|
|
|
7470
7467
|
return { authorization, request, transaction, memo, validBefore };
|
|
7471
7468
|
}
|
|
7472
7469
|
|
|
7473
|
-
// src/lib/signer.ts
|
|
7474
|
-
import { privateKeyToAccount } from "viem/accounts";
|
|
7475
|
-
async function fetchDeviceKey(deviceId, apiToken, keyServerUrl) {
|
|
7476
|
-
const base2 = keyServerUrl ?? apiUrl();
|
|
7477
|
-
const res = await fetch(`${base2}/api/devices/${deviceId}/key`, {
|
|
7478
|
-
method: "POST",
|
|
7479
|
-
headers: { "Content-Type": "application/json" },
|
|
7480
|
-
body: JSON.stringify({ deviceId, apiToken })
|
|
7481
|
-
});
|
|
7482
|
-
if (!res.ok) {
|
|
7483
|
-
const text = await res.text().catch(() => "");
|
|
7484
|
-
throw new Error(`Failed to fetch device key (${res.status}): ${text}`);
|
|
7485
|
-
}
|
|
7486
|
-
const data = await res.json();
|
|
7487
|
-
return data.deviceEncryptionKey;
|
|
7488
|
-
}
|
|
7489
|
-
async function signTypedData(typedData, keystore) {
|
|
7490
|
-
const account = await createWalletAccountFromKeystore(keystore);
|
|
7491
|
-
const sig = await account.signTypedData(typedData);
|
|
7492
|
-
return sig;
|
|
7493
|
-
}
|
|
7494
|
-
async function signMessage(message, keystore) {
|
|
7495
|
-
const account = await createWalletAccountFromKeystore(keystore);
|
|
7496
|
-
const sig = await account.signMessage({ message });
|
|
7497
|
-
return sig;
|
|
7498
|
-
}
|
|
7499
|
-
async function createWalletAccountFromKeystore(keystore) {
|
|
7500
|
-
const dek = await fetchDeviceKey(keystore.deviceId, keystore.apiToken, keystore.keyServerUrl);
|
|
7501
|
-
const privateKey = decryptPrivateKey(dek, keystore.encryptedKey);
|
|
7502
|
-
return privateKeyToAccount(privateKey);
|
|
7503
|
-
}
|
|
7504
|
-
async function getWalletAddress() {
|
|
7505
|
-
const keystore = await loadKeystore();
|
|
7506
|
-
return keystore.walletAddress;
|
|
7507
|
-
}
|
|
7508
|
-
|
|
7509
7470
|
// src/lib/x402-paths.ts
|
|
7510
7471
|
import path5 from "path";
|
|
7511
7472
|
function getX402JournalPath() {
|
|
@@ -7549,11 +7510,6 @@ export {
|
|
|
7549
7510
|
signSponsoredTempoTransfer,
|
|
7550
7511
|
readMppTempoChallenge,
|
|
7551
7512
|
createMppTempoCredential,
|
|
7552
|
-
fetchDeviceKey,
|
|
7553
|
-
signTypedData,
|
|
7554
|
-
signMessage,
|
|
7555
|
-
createWalletAccountFromKeystore,
|
|
7556
|
-
getWalletAddress,
|
|
7557
7513
|
getX402JournalPath,
|
|
7558
7514
|
getX402PolicyPath
|
|
7559
7515
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createRequire as __tmCreateRequire } from 'node:module'; import { fileURLToPath as __tmFileURLToPath } from 'node:url'; import { dirname as __tmDirname } from 'node:path'; const require = __tmCreateRequire(import.meta.url); const __tmFilename = __tmFileURLToPath(import.meta.url); const __tmDirnameValue = __tmDirname(__tmFilename);
|
|
2
|
+
import {
|
|
3
|
+
createWalletAccountFromKeystore,
|
|
4
|
+
loadKeystore
|
|
5
|
+
} from "./chunk-7KBQDZWR.js";
|
|
6
|
+
import {
|
|
7
|
+
READ_AUTH_ADDRESS_HEADER,
|
|
8
|
+
READ_AUTH_SIGNATURE_HEADER,
|
|
9
|
+
buildReadAuthMessage
|
|
10
|
+
} from "./chunk-ZW6MI2F6.js";
|
|
11
|
+
|
|
12
|
+
// src/lib/read-auth.ts
|
|
13
|
+
async function signReadAuth() {
|
|
14
|
+
let keystore;
|
|
15
|
+
try {
|
|
16
|
+
keystore = await loadKeystore();
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const account = await createWalletAccountFromKeystore(keystore);
|
|
22
|
+
const signature = await account.signMessage({
|
|
23
|
+
message: buildReadAuthMessage(keystore.walletAddress)
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
walletAddress: keystore.walletAddress,
|
|
27
|
+
headers: {
|
|
28
|
+
[READ_AUTH_ADDRESS_HEADER]: keystore.walletAddress,
|
|
29
|
+
[READ_AUTH_SIGNATURE_HEADER]: signature
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
} catch {
|
|
33
|
+
return { walletAddress: keystore.walletAddress, headers: {} };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
signReadAuth
|
|
39
|
+
};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
unsafeHostPath,
|
|
9
9
|
withFileLock,
|
|
10
10
|
writeAtomic
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6T24AGBE.js";
|
|
12
12
|
import {
|
|
13
13
|
buyComputeCredit,
|
|
14
14
|
fetchComputePricing,
|
|
@@ -16,17 +16,17 @@ import {
|
|
|
16
16
|
loadComputeCreditConfig,
|
|
17
17
|
onComputeBalanceObserved,
|
|
18
18
|
readComputeCreditStatus
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RA3GGK5G.js";
|
|
20
20
|
import {
|
|
21
21
|
getTaskmarketHome
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ZW6MI2F6.js";
|
|
23
|
+
import {
|
|
24
|
+
AgentLaunchError
|
|
25
|
+
} from "./chunk-YM4S6IE4.js";
|
|
23
26
|
import {
|
|
24
27
|
burnRate,
|
|
25
28
|
computeLow
|
|
26
29
|
} from "./chunk-XJOB4NMV.js";
|
|
27
|
-
import {
|
|
28
|
-
AgentLaunchError
|
|
29
|
-
} from "./chunk-YM4S6IE4.js";
|
|
30
30
|
|
|
31
31
|
// src/lib/agent/active-task.ts
|
|
32
32
|
import { createHash } from "crypto";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createRequire as __tmCreateRequire } from 'node:module'; import { fileURLToPath as __tmFileURLToPath } from 'node:url'; import { dirname as __tmDirname } from 'node:path'; const require = __tmCreateRequire(import.meta.url); const __tmFilename = __tmFileURLToPath(import.meta.url); const __tmDirnameValue = __tmDirname(__tmFilename);
|
|
2
|
+
import {
|
|
3
|
+
TASK_ACCESS_GRANT_HEADER,
|
|
4
|
+
getTaskmarketHome
|
|
5
|
+
} from "./chunk-ZW6MI2F6.js";
|
|
6
|
+
|
|
7
|
+
// src/lib/task-access-grants.ts
|
|
8
|
+
import { promises as fs } from "fs";
|
|
9
|
+
import path from "path";
|
|
10
|
+
function getGrantsPath() {
|
|
11
|
+
return path.join(getTaskmarketHome(), "task-access-grants.json");
|
|
12
|
+
}
|
|
13
|
+
async function readGrantsFile() {
|
|
14
|
+
try {
|
|
15
|
+
const raw = await fs.readFile(getGrantsPath(), "utf-8");
|
|
16
|
+
return JSON.parse(raw);
|
|
17
|
+
} catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function loadTaskAccessGrant(taskId) {
|
|
22
|
+
const grants = await readGrantsFile();
|
|
23
|
+
const record = grants[taskId];
|
|
24
|
+
if (!record) return null;
|
|
25
|
+
if (new Date(record.expiresAt).getTime() <= Date.now()) return null;
|
|
26
|
+
return record.grant;
|
|
27
|
+
}
|
|
28
|
+
async function taskAccessGrantHeaders(taskId) {
|
|
29
|
+
const grant = await loadTaskAccessGrant(taskId);
|
|
30
|
+
return grant ? { [TASK_ACCESS_GRANT_HEADER]: grant } : {};
|
|
31
|
+
}
|
|
32
|
+
async function saveTaskAccessGrant(taskId, grant, expiresAt) {
|
|
33
|
+
const grants = await readGrantsFile();
|
|
34
|
+
grants[taskId] = { grant, expiresAt };
|
|
35
|
+
const dir = path.dirname(getGrantsPath());
|
|
36
|
+
await fs.mkdir(dir, { recursive: true });
|
|
37
|
+
await fs.writeFile(getGrantsPath(), JSON.stringify(grants, null, 2), {
|
|
38
|
+
mode: 384
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
loadTaskAccessGrant,
|
|
44
|
+
taskAccessGrantHeaders,
|
|
45
|
+
saveTaskAccessGrant
|
|
46
|
+
};
|
|
@@ -4,19 +4,24 @@ import {
|
|
|
4
4
|
WITHDRAW_DELAY_SECONDS,
|
|
5
5
|
createBaseChannelPayer,
|
|
6
6
|
createBaseChannelRpcReader,
|
|
7
|
-
createWalletAccountFromKeystore,
|
|
8
7
|
createX402Allocations,
|
|
9
8
|
getX402JournalPath,
|
|
10
9
|
getX402PolicyPath,
|
|
11
10
|
listX402Payments,
|
|
12
11
|
loadX402Policy,
|
|
13
12
|
rpcUrlForNetwork
|
|
14
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-CS36JL4J.js";
|
|
15
14
|
import {
|
|
16
|
-
|
|
15
|
+
createWalletAccountFromKeystore,
|
|
17
16
|
keystoreExists,
|
|
18
17
|
loadKeystore
|
|
19
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-7KBQDZWR.js";
|
|
19
|
+
import {
|
|
20
|
+
getTaskmarketHome
|
|
21
|
+
} from "./chunk-ZW6MI2F6.js";
|
|
22
|
+
import {
|
|
23
|
+
AgentLaunchError
|
|
24
|
+
} from "./chunk-YM4S6IE4.js";
|
|
20
25
|
import {
|
|
21
26
|
failureDetail,
|
|
22
27
|
failureDetailOf,
|
|
@@ -24,9 +29,6 @@ import {
|
|
|
24
29
|
responseFailureReason,
|
|
25
30
|
withFailureDetail
|
|
26
31
|
} from "./chunk-XJOB4NMV.js";
|
|
27
|
-
import {
|
|
28
|
-
AgentLaunchError
|
|
29
|
-
} from "./chunk-YM4S6IE4.js";
|
|
30
32
|
|
|
31
33
|
// src/lib/agent/channels.ts
|
|
32
34
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -1,85 +1,27 @@
|
|
|
1
1
|
import { createRequire as __tmCreateRequire } from 'node:module'; import { fileURLToPath as __tmFileURLToPath } from 'node:url'; import { dirname as __tmDirname } from 'node:path'; const require = __tmCreateRequire(import.meta.url); const __tmFilename = __tmFileURLToPath(import.meta.url); const __tmDirnameValue = __tmDirname(__tmFilename);
|
|
2
2
|
import {
|
|
3
3
|
x402FeePost
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RA3GGK5G.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
signReadAuth
|
|
7
|
+
} from "./chunk-DTSONVE3.js";
|
|
8
|
+
import {
|
|
9
|
+
taskAccessGrantHeaders
|
|
10
|
+
} from "./chunk-HVI5YS47.js";
|
|
9
11
|
import {
|
|
10
|
-
READ_AUTH_ADDRESS_HEADER,
|
|
11
|
-
READ_AUTH_SIGNATURE_HEADER,
|
|
12
|
-
TASK_ACCESS_GRANT_HEADER,
|
|
13
|
-
TaskAwardSchema,
|
|
14
12
|
apiGet,
|
|
15
13
|
apiPost,
|
|
14
|
+
loadKeystore,
|
|
15
|
+
runWorkerAction,
|
|
16
|
+
signMessage,
|
|
17
|
+
taskRequiresTap
|
|
18
|
+
} from "./chunk-7KBQDZWR.js";
|
|
19
|
+
import {
|
|
20
|
+
TaskAwardSchema,
|
|
16
21
|
buildClaimMessage,
|
|
17
|
-
buildReadAuthMessage,
|
|
18
22
|
buildSubmitMessage,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
loadKeystore
|
|
22
|
-
} from "./chunk-L3A7JOO5.js";
|
|
23
|
-
|
|
24
|
-
// src/lib/read-auth.ts
|
|
25
|
-
async function signReadAuth() {
|
|
26
|
-
let keystore;
|
|
27
|
-
try {
|
|
28
|
-
keystore = await loadKeystore();
|
|
29
|
-
} catch {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
const account = await createWalletAccountFromKeystore(keystore);
|
|
34
|
-
const signature = await account.signMessage({
|
|
35
|
-
message: buildReadAuthMessage(keystore.walletAddress)
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
walletAddress: keystore.walletAddress,
|
|
39
|
-
headers: {
|
|
40
|
-
[READ_AUTH_ADDRESS_HEADER]: keystore.walletAddress,
|
|
41
|
-
[READ_AUTH_SIGNATURE_HEADER]: signature
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
} catch {
|
|
45
|
-
return { walletAddress: keystore.walletAddress, headers: {} };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/lib/task-access-grants.ts
|
|
50
|
-
import { promises as fs } from "fs";
|
|
51
|
-
import path from "path";
|
|
52
|
-
function getGrantsPath() {
|
|
53
|
-
return path.join(getTaskmarketHome(), "task-access-grants.json");
|
|
54
|
-
}
|
|
55
|
-
async function readGrantsFile() {
|
|
56
|
-
try {
|
|
57
|
-
const raw = await fs.readFile(getGrantsPath(), "utf-8");
|
|
58
|
-
return JSON.parse(raw);
|
|
59
|
-
} catch {
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async function loadTaskAccessGrant(taskId) {
|
|
64
|
-
const grants = await readGrantsFile();
|
|
65
|
-
const record = grants[taskId];
|
|
66
|
-
if (!record) return null;
|
|
67
|
-
if (new Date(record.expiresAt).getTime() <= Date.now()) return null;
|
|
68
|
-
return record.grant;
|
|
69
|
-
}
|
|
70
|
-
async function taskAccessGrantHeaders(taskId) {
|
|
71
|
-
const grant = await loadTaskAccessGrant(taskId);
|
|
72
|
-
return grant ? { [TASK_ACCESS_GRANT_HEADER]: grant } : {};
|
|
73
|
-
}
|
|
74
|
-
async function saveTaskAccessGrant(taskId, grant, expiresAt) {
|
|
75
|
-
const grants = await readGrantsFile();
|
|
76
|
-
grants[taskId] = { grant, expiresAt };
|
|
77
|
-
const dir = path.dirname(getGrantsPath());
|
|
78
|
-
await fs.mkdir(dir, { recursive: true });
|
|
79
|
-
await fs.writeFile(getGrantsPath(), JSON.stringify(grants, null, 2), {
|
|
80
|
-
mode: 384
|
|
81
|
-
});
|
|
82
|
-
}
|
|
23
|
+
isRecordingPendingResponse
|
|
24
|
+
} from "./chunk-ZW6MI2F6.js";
|
|
83
25
|
|
|
84
26
|
// src/sdk/artifact-upload.ts
|
|
85
27
|
import { extname } from "path";
|
|
@@ -163,6 +105,57 @@ function putArtifactBytes(uploadUrl, data, mimeType, onProgress) {
|
|
|
163
105
|
});
|
|
164
106
|
}
|
|
165
107
|
|
|
108
|
+
// src/lib/worker-attestation.ts
|
|
109
|
+
var requirementCache = /* @__PURE__ */ new Map();
|
|
110
|
+
async function defaultGet(path) {
|
|
111
|
+
const { apiGet: apiGet2 } = await import("./api-EKGAP2TK.js");
|
|
112
|
+
const { signReadAuth: signReadAuth2 } = await import("./read-auth-XZOWQ45P.js");
|
|
113
|
+
const { taskAccessGrantHeaders: taskAccessGrantHeaders2 } = await import("./task-access-grants-7JUAFFYG.js");
|
|
114
|
+
const taskId = /^\/api\/tasks\/([^/?]+)/.exec(path)?.[1] ?? "";
|
|
115
|
+
return apiGet2(path, {
|
|
116
|
+
headers: {
|
|
117
|
+
...(await signReadAuth2())?.headers ?? {},
|
|
118
|
+
...await taskAccessGrantHeaders2(taskId) ?? {}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
var REQUIREMENT_CACHE_MS = 6e4;
|
|
123
|
+
function taskRequirementsOf(taskId, get = defaultGet, now = Date.now) {
|
|
124
|
+
const key = taskId.toLowerCase();
|
|
125
|
+
const cached = requirementCache.get(key);
|
|
126
|
+
if (cached && cached.until > now()) return cached.pending;
|
|
127
|
+
const entry = { pending: Promise.resolve(null), until: 0 };
|
|
128
|
+
entry.pending = get(`/api/tasks/${taskId}`).then((task) => task ?? null).catch(() => {
|
|
129
|
+
if (requirementCache.get(key) === entry) requirementCache.delete(key);
|
|
130
|
+
return null;
|
|
131
|
+
});
|
|
132
|
+
entry.until = now() + REQUIREMENT_CACHE_MS;
|
|
133
|
+
requirementCache.set(key, entry);
|
|
134
|
+
return entry.pending;
|
|
135
|
+
}
|
|
136
|
+
async function attestedWorkerAction(taskId, keystore, run, task) {
|
|
137
|
+
if (!keystore.tapKey) return run(void 0);
|
|
138
|
+
return runWorkerAction({
|
|
139
|
+
taskId,
|
|
140
|
+
task: task === void 0 ? await taskRequirementsOf(taskId) : task,
|
|
141
|
+
keystore,
|
|
142
|
+
run
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
var GATED_WRITE_PATH = /^\/api\/tasks\/([^/?]+)\/(?:claim|pitches|bids|proofs|submissions|submissions\/from-keys)(?:\?.*)?$/;
|
|
146
|
+
function gatedWriteTaskId(path) {
|
|
147
|
+
return GATED_WRITE_PATH.exec(path)?.[1];
|
|
148
|
+
}
|
|
149
|
+
async function maybeAttestedWrite(path, send, get) {
|
|
150
|
+
const taskId = gatedWriteTaskId(path);
|
|
151
|
+
if (!taskId) return send(void 0);
|
|
152
|
+
const keystore = await loadKeystore().catch(() => void 0);
|
|
153
|
+
if (!keystore?.tapKey) return send(void 0);
|
|
154
|
+
const task = await taskRequirementsOf(taskId, get);
|
|
155
|
+
if (!taskRequiresTap(task)) return send(void 0);
|
|
156
|
+
return runWorkerAction({ taskId, task, keystore, run: send });
|
|
157
|
+
}
|
|
158
|
+
|
|
166
159
|
// src/lib/task-sdk.ts
|
|
167
160
|
async function putWithProgress(upload) {
|
|
168
161
|
process.stderr.write(` Uploading ${upload.fileName}...
|
|
@@ -173,11 +166,15 @@ async function putWithProgress(upload) {
|
|
|
173
166
|
process.stderr.write("\n");
|
|
174
167
|
}
|
|
175
168
|
var cliTaskTransport = {
|
|
176
|
-
get: (
|
|
169
|
+
get: (path, headers) => apiGet(path, { headers }),
|
|
177
170
|
// A write the caller gave no key is sent exactly as before the SDK existed, with no options,
|
|
178
171
|
// so `apiPost` resolves its key itself (explicit, then TASKMARKET_IDEMPOTENCY_KEY, then fresh).
|
|
179
|
-
|
|
180
|
-
|
|
172
|
+
// A gated worker action on a task that requires `tap` is TAP-signed (lib/worker-attestation.ts).
|
|
173
|
+
post: (path, body, options) => maybeAttestedWrite(
|
|
174
|
+
path,
|
|
175
|
+
(tap) => tap ? apiPost(path, body, { ...options, tap }) : options === void 0 ? apiPost(path, body) : apiPost(path, body, options)
|
|
176
|
+
),
|
|
177
|
+
feePost: (path, body, options) => maybeAttestedWrite(path, (tap) => x402FeePost(path, body, tap ? { ...options, tap } : options)),
|
|
181
178
|
put: putWithProgress
|
|
182
179
|
};
|
|
183
180
|
function keystoreTaskSigner(keystore) {
|
|
@@ -210,9 +207,9 @@ var TaskOperationError = class extends Error {
|
|
|
210
207
|
this.code = code;
|
|
211
208
|
}
|
|
212
209
|
};
|
|
213
|
-
function withChainQuery(
|
|
214
|
-
if (chainId === void 0) return
|
|
215
|
-
return `${
|
|
210
|
+
function withChainQuery(path, chainId) {
|
|
211
|
+
if (chainId === void 0) return path;
|
|
212
|
+
return `${path}${path.includes("?") ? "&" : "?"}chainId=${chainId}`;
|
|
216
213
|
}
|
|
217
214
|
function withChainBody(body, chainId) {
|
|
218
215
|
return chainId === void 0 ? body : { ...body, chainId };
|
|
@@ -257,8 +254,17 @@ async function listTasks(ctx, filter = {}) {
|
|
|
257
254
|
if (filter.tags) params.set("tags", filter.tags);
|
|
258
255
|
if (filter.minReward) params.set("minReward", filter.minReward);
|
|
259
256
|
if (filter.maxReward) params.set("maxReward", filter.maxReward);
|
|
257
|
+
if (filter.minTotalReward) params.set("minTotalReward", filter.minTotalReward);
|
|
260
258
|
if (filter.deadlineHours) params.set("deadlineHours", filter.deadlineHours);
|
|
261
259
|
if (filter.sponsored) params.set("sponsored", "true");
|
|
260
|
+
if (filter.identity) params.set("identity", filter.identity);
|
|
261
|
+
if (filter.verifiedBy) params.set("verifiedBy", filter.verifiedBy);
|
|
262
|
+
if (filter.requester) params.set("requester", filter.requester);
|
|
263
|
+
if (filter.hire !== void 0) params.set("hire", String(filter.hire));
|
|
264
|
+
if (filter.hireKind) params.set("hireKind", filter.hireKind);
|
|
265
|
+
if (filter.hireState) params.set("hireState", filter.hireState);
|
|
266
|
+
if (filter.hireServiceId) params.set("hireServiceId", filter.hireServiceId);
|
|
267
|
+
if (filter.reservedWorker) params.set("reservedWorker", filter.reservedWorker);
|
|
262
268
|
if (filter.limit) params.set("limit", filter.limit);
|
|
263
269
|
if (filter.cursor) params.set("cursor", filter.cursor);
|
|
264
270
|
const result = await ctx.transport.get(
|
|
@@ -267,10 +273,11 @@ async function listTasks(ctx, filter = {}) {
|
|
|
267
273
|
);
|
|
268
274
|
return { tasks: result.tasks, hasMore: result.hasMore, nextCursor: result.nextCursor };
|
|
269
275
|
}
|
|
270
|
-
async function listTaskSubmissions(ctx, ref) {
|
|
276
|
+
async function listTaskSubmissions(ctx, ref, filter = {}) {
|
|
271
277
|
const headers = await readAuthHeaders(ctx);
|
|
278
|
+
const query = filter.passedCheck ? `?${new URLSearchParams({ passedCheck: filter.passedCheck }).toString()}` : "";
|
|
272
279
|
return await ctx.transport.get(
|
|
273
|
-
withChainQuery(`/api/tasks/${ref.taskId}/submissions`, ref.chainId),
|
|
280
|
+
withChainQuery(`/api/tasks/${ref.taskId}/submissions${query}`, ref.chainId),
|
|
274
281
|
headers
|
|
275
282
|
);
|
|
276
283
|
}
|
|
@@ -433,9 +440,8 @@ async function submitTaskFiles(ctx, ref, files, options = {}) {
|
|
|
433
440
|
}
|
|
434
441
|
|
|
435
442
|
export {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
saveTaskAccessGrant,
|
|
443
|
+
taskRequirementsOf,
|
|
444
|
+
attestedWorkerAction,
|
|
439
445
|
mimeTypeForPath,
|
|
440
446
|
putArtifactBytes,
|
|
441
447
|
cliTaskTransport,
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
loadDeliverableRecord,
|
|
7
7
|
readComputeView,
|
|
8
8
|
taskStage
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EDW4XCAY.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-6T24AGBE.js";
|
|
17
17
|
import {
|
|
18
18
|
allocationViews,
|
|
19
19
|
channelView,
|
|
@@ -21,22 +21,21 @@ import {
|
|
|
21
21
|
openAgentChannels,
|
|
22
22
|
uncertainPurchases,
|
|
23
23
|
withdrawalHatch
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-MAIB4J42.js";
|
|
25
25
|
import {
|
|
26
|
-
SandboxListOutputSchema,
|
|
27
26
|
apiUrl,
|
|
28
27
|
selectedNetwork
|
|
29
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-7KBQDZWR.js";
|
|
30
29
|
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
channelLines,
|
|
34
|
-
computeLines,
|
|
35
|
-
formatUsdc
|
|
36
|
-
} from "./chunk-XJOB4NMV.js";
|
|
30
|
+
SandboxListOutputSchema
|
|
31
|
+
} from "./chunk-ZW6MI2F6.js";
|
|
37
32
|
import {
|
|
38
33
|
AgentLaunchError
|
|
39
34
|
} from "./chunk-YM4S6IE4.js";
|
|
35
|
+
import {
|
|
36
|
+
AGENT_VIEW_VERSION,
|
|
37
|
+
blockingPurchases
|
|
38
|
+
} from "./chunk-XJOB4NMV.js";
|
|
40
39
|
|
|
41
40
|
// src/lib/agent/status.ts
|
|
42
41
|
import { promises as fs } from "fs";
|
|
@@ -244,125 +243,10 @@ async function collectAgentStatus(deps = {}) {
|
|
|
244
243
|
view.inference.blocked = reasons.length > 0;
|
|
245
244
|
return view;
|
|
246
245
|
}
|
|
247
|
-
function statusLines(view) {
|
|
248
|
-
const lines = [
|
|
249
|
-
`taskmarket agent status (view v${view.version}, ${view.generatedAt})`,
|
|
250
|
-
view.wallet ? `Wallet: ${view.wallet.address}` : "Wallet: none",
|
|
251
|
-
`Spending policy: ${view.policy.state}${view.policy.models.length ? ` (${view.policy.models.join(", ")})` : ""}${view.policy.error ? `: ${view.policy.error}` : ""}`
|
|
252
|
-
];
|
|
253
|
-
for (const channel of view.channels) {
|
|
254
|
-
lines.push(...channelLines(channel));
|
|
255
|
-
if (channel.state === "blocked" || channel.state === "withdrawal_pending") {
|
|
256
|
-
lines.push(` ${channel.withdrawal.note}`);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (view.purchases.uncertain.length === 0) {
|
|
260
|
-
lines.push("Purchases with an unknown outcome: none");
|
|
261
|
-
} else {
|
|
262
|
-
lines.push("Purchases with an unknown outcome (never resent; reconcile them):");
|
|
263
|
-
for (const purchase of view.purchases.uncertain) {
|
|
264
|
-
lines.push(
|
|
265
|
-
` ${purchase.invocationId} on ${purchase.rail}: ${purchase.state}, at most ${formatUsdc(purchase.authorizedAtomic)}${purchase.blocking ? ", blocks new turns" : ""}`
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
lines.push(
|
|
270
|
-
view.inference.blocked ? `New inference: blocked (${view.inference.reasons.join("; ")})` : "New inference: ready"
|
|
271
|
-
);
|
|
272
|
-
if (view.sandbox.state === "ok") {
|
|
273
|
-
lines.push(
|
|
274
|
-
view.sandbox.sandboxes.length === 0 ? "Sandbox: none" : `Sandbox: ${view.sandbox.sandboxes.map(
|
|
275
|
-
(s) => `${s.sandboxId} ${s.purpose} ${s.state}${s.creditWarning ? ` (${s.creditWarning})` : ""}`
|
|
276
|
-
).join("; ")}`
|
|
277
|
-
);
|
|
278
|
-
} else if (view.sandbox.state === "unavailable") {
|
|
279
|
-
lines.push(`Sandbox: unavailable (${view.sandbox.error})`);
|
|
280
|
-
}
|
|
281
|
-
lines.push(...computeLines(view.compute));
|
|
282
|
-
lines.push(...syncLines(view.sync));
|
|
283
|
-
lines.push(...taskLines(view.task, view.taskError));
|
|
284
|
-
return lines;
|
|
285
|
-
}
|
|
286
|
-
var STAGES = {
|
|
287
|
-
claiming: "claiming (a claim may have been sent; the next session confirms it before anything else)",
|
|
288
|
-
claimed: "claimed (the task workspace is not set up yet)",
|
|
289
|
-
working: "working (workspace ready, not validated yet)",
|
|
290
|
-
frozen: "frozen (validated, waiting for your approval to submit)",
|
|
291
|
-
submitting: "submitting (sent; the next session looks it up before anything is sent again)",
|
|
292
|
-
submitted: "submitted (not yet accepted or paid)",
|
|
293
|
-
awaiting_acceptance: "awaiting acceptance (submitted; the requester or evaluator decides)",
|
|
294
|
-
reward_pending: "reward pending (awarded; the payout is not verified on the chain yet)",
|
|
295
|
-
paid: "paid (the payout is verified on the chain)",
|
|
296
|
-
rejected: "rejected (no reward)",
|
|
297
|
-
expired: "expired (ended without an award; no reward)",
|
|
298
|
-
stopped: "stopped"
|
|
299
|
-
};
|
|
300
|
-
function taskLines(task, error) {
|
|
301
|
-
if (error) return [`Marketplace task: the run state cannot be read (${error})`];
|
|
302
|
-
if (!task) return ["Marketplace task: none"];
|
|
303
|
-
const lines = [`Marketplace task ${task.taskId} on ${task.network}: ${STAGES[task.stage]}`];
|
|
304
|
-
if (task.claimId) lines.push(` Claim: ${task.claimId}`);
|
|
305
|
-
if (task.workspace) lines.push(` Workspace (in the sandbox): ${task.workspace}`);
|
|
306
|
-
if (task.validation) {
|
|
307
|
-
lines.push(
|
|
308
|
-
` Validation: ${task.validation.attemptsUsed} of ${task.validation.maxAttempts} attempt(s) used, until ${task.validation.deadline}`
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
if (task.deliverableId) lines.push(` Deliverable: ${task.deliverableId}`);
|
|
312
|
-
if (task.submissionId) lines.push(` Submission: ${task.submissionId}`);
|
|
313
|
-
const outcome = task.outcome;
|
|
314
|
-
if (outcome?.payout) {
|
|
315
|
-
lines.push(
|
|
316
|
-
` Paid: ${outcome.payout.amount} atomic units of ${outcome.payout.asset} in ${outcome.payout.settlementTxHash}`
|
|
317
|
-
);
|
|
318
|
-
} else if (outcome?.award) {
|
|
319
|
-
lines.push(
|
|
320
|
-
` Award: ${outcome.award.workerPayment} atomic units of ${outcome.award.asset}, not verified (${outcome.unverified?.reason ?? "unverified"})`
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
if (outcome) lines.push(` Outcome observed ${outcome.observedAt}`);
|
|
324
|
-
lines.push(` As recorded ${task.updatedAt}`);
|
|
325
|
-
return lines;
|
|
326
|
-
}
|
|
327
|
-
function syncLines(sync) {
|
|
328
|
-
if (!sync.project) return ["Workspace sync: this directory cannot be read"];
|
|
329
|
-
const lines = [
|
|
330
|
-
`Workspace sync (${sync.project}): ${sync.approved ? `upload approved ${sync.approvedAt}` : "upload not approved yet"}${sync.sessionRunning ? "; a session is running here" : ""}`
|
|
331
|
-
];
|
|
332
|
-
if (sync.lastUploadAt) {
|
|
333
|
-
lines.push(` Last upload: ${sync.lastUploadAt} (${sync.uploadedFiles ?? 0} file(s))`);
|
|
334
|
-
}
|
|
335
|
-
if (sync.lastPullAt) lines.push(` Last pull: ${sync.lastPullAt}`);
|
|
336
|
-
if (sync.pending) {
|
|
337
|
-
const { clean, conflict, blocked } = sync.pending;
|
|
338
|
-
const notSaved = sync.pending.notSaved ?? 0;
|
|
339
|
-
const tooDeep = sync.pending.tooDeep ?? 0;
|
|
340
|
-
const waiting = `${clean + conflict} change(s) to pull${conflict ? ` (${conflict} in conflict)` : ""}${notSaved ? `, ${notSaved} too large to have been saved` : ""}${tooDeep ? `, ${tooDeep} director(ies) nested too deep to have been saved (taskmarket agent pull --keep-local <dir> acknowledges one, --discard all)` : ""}${blocked ? `, ${blocked} blocked` : ""}`;
|
|
341
|
-
lines.push(
|
|
342
|
-
sync.pending.saved ? ` Saved from the last session: ${waiting}; review them with taskmarket agent pull` : ` In the sandbox: ${waiting}, as counted ${sync.pending.checkedAt} (not checked live, which would resume the sandbox)`
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
if (sync.orphanSandboxId) {
|
|
346
|
-
lines.push(
|
|
347
|
-
` A killed --no-sync session left sandbox ${sync.orphanSandboxId}: taskmarket agent pull --recover brings back what the agent made there, until it stops once idle.`
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
if (sync.captureFailed) {
|
|
351
|
-
const failed = sync.captureFailed;
|
|
352
|
-
const where = failed.sandboxId ? ` (sandbox ${failed.sandboxId})` : "";
|
|
353
|
-
lines.push(
|
|
354
|
-
failed.kind === "interrupted" ? ` The last session ended at ${failed.at} before its changes were saved${where}: recover them with taskmarket agent pull --recover, or drop them with taskmarket agent pull --discard. New sessions wait until then.` : ` The last session's changes could not be saved${where}: ${failed.reason}. Recover them with taskmarket agent pull --recover, or drop them with taskmarket agent pull --discard. New sessions wait until then.`
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
return lines;
|
|
358
|
-
}
|
|
359
246
|
|
|
360
247
|
export {
|
|
361
248
|
readTaskStatus,
|
|
362
249
|
readSyncStatus,
|
|
363
250
|
listSandboxes,
|
|
364
|
-
collectAgentStatus
|
|
365
|
-
statusLines,
|
|
366
|
-
taskLines,
|
|
367
|
-
syncLines
|
|
251
|
+
collectAgentStatus
|
|
368
252
|
};
|