@lucid-agents/taskmarket 1.2.2 → 1.2.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.
- package/dist/index.js +35 -22
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -819,10 +819,12 @@ var acceptCmd = new Command9("accept").description("Accept a submission (costs 0
|
|
|
819
819
|
import { Command as Command10 } from "commander";
|
|
820
820
|
function parseWinner(spec) {
|
|
821
821
|
const parts = spec.split(":");
|
|
822
|
-
if (parts.length
|
|
823
|
-
throw new Error(
|
|
822
|
+
if (parts.length < 2 || parts.length > 3) {
|
|
823
|
+
throw new Error(
|
|
824
|
+
`Invalid --winner value "${spec}". Expected <addr>:<share> or <addr>:<share>:<submissionId>`
|
|
825
|
+
);
|
|
824
826
|
}
|
|
825
|
-
const [worker, shareStr] = parts;
|
|
827
|
+
const [worker, shareStr, submissionIdStr] = parts;
|
|
826
828
|
if (!/^0x[0-9a-fA-F]{40}$/.test(worker)) {
|
|
827
829
|
throw new Error(`Invalid worker address in "${spec}"`);
|
|
828
830
|
}
|
|
@@ -830,28 +832,29 @@ function parseWinner(spec) {
|
|
|
830
832
|
if (Number.isNaN(share) || share < 1 || share > 1e4) {
|
|
831
833
|
throw new Error(`Invalid share in "${spec}" \u2014 must be integer 1..10000 (basis points)`);
|
|
832
834
|
}
|
|
833
|
-
|
|
835
|
+
const submissionId = submissionIdStr ? submissionIdStr : void 0;
|
|
836
|
+
return { worker, share, ...submissionId !== void 0 && { submissionId } };
|
|
834
837
|
}
|
|
835
838
|
var acceptSubmissionsCmd = new Command10("accept-submissions").description(
|
|
836
|
-
"Accept N submissions for a Bounty/Benchmark task with explicit share basis points (costs 0.001 USDC).\nShares must sum to 10000. The contract resolves each deliverable from on-chain submission history.\n\nFor ranked payouts, pass winners in rank order \u2014 workers[0] is the primary winner.\n\
|
|
837
|
-
).argument("<taskId>", "Task ID (0x-prefixed hex)").requiredOption(
|
|
838
|
-
|
|
839
|
+
"Accept N submissions for a Bounty/Benchmark task with explicit share basis points (costs 0.001 USDC).\nShares must sum to 10000. The contract resolves each deliverable from on-chain submission history.\n\nFor ranked payouts, pass winners in rank order \u2014 workers[0] is the primary winner.\n\nTo pin a specific submission version, append the submission ID as a third field.\n\nExamples:\n task accept-submissions 0x\u2026 --winner 0xAlice:5000 --winner 0xBob:3000 --winner 0xCarol:2000\n task accept-submissions 0x\u2026 --winner 0xAlice:5000:sub_abc123 --winner 0xBob:5000:sub_def456"
|
|
840
|
+
).argument("<taskId>", "Task ID (0x-prefixed hex)").requiredOption(
|
|
841
|
+
"--winner <spec...>",
|
|
842
|
+
"Winner spec <addr>:<share> or <addr>:<share>:<submissionId>. Pass multiple times."
|
|
843
|
+
).action(async (taskId, opts) => {
|
|
839
844
|
try {
|
|
840
|
-
winners = opts.winner.map(parseWinner);
|
|
845
|
+
const winners = opts.winner.map(parseWinner);
|
|
846
|
+
const sum = winners.reduce((a, w) => a + w.share, 0);
|
|
847
|
+
if (sum !== 1e4) {
|
|
848
|
+
throw new Error(`Winner shares must sum to 10000 basis points (got ${sum})`);
|
|
849
|
+
}
|
|
850
|
+
const result = await x402Post(`/api/tasks/${taskId}/accept-submissions`, {
|
|
851
|
+
taskId,
|
|
852
|
+
winners
|
|
853
|
+
});
|
|
854
|
+
printResult({ accepted: result.success, winners: winners.length });
|
|
841
855
|
} catch (err) {
|
|
842
856
|
printError(err instanceof Error ? err.message : String(err));
|
|
843
|
-
return;
|
|
844
|
-
}
|
|
845
|
-
const sum = winners.reduce((a, w) => a + w.share, 0);
|
|
846
|
-
if (sum !== 1e4) {
|
|
847
|
-
printError(`Winner shares must sum to 10000 basis points (got ${sum})`);
|
|
848
|
-
return;
|
|
849
857
|
}
|
|
850
|
-
const result = await x402Post(`/api/tasks/${taskId}/accept-submissions`, {
|
|
851
|
-
taskId,
|
|
852
|
-
winners
|
|
853
|
-
});
|
|
854
|
-
printResult({ accepted: result.success, winners: winners.length });
|
|
855
858
|
});
|
|
856
859
|
|
|
857
860
|
// src/commands/task/rate.ts
|
|
@@ -1162,15 +1165,25 @@ var updateCmd = new Command26("update").description("Update an open task (costs
|
|
|
1162
1165
|
}
|
|
1163
1166
|
if (opts.extendExpiry !== void 0) {
|
|
1164
1167
|
const delta = parseInt(opts.extendExpiry, 10);
|
|
1165
|
-
if (!Number.isFinite(delta) || delta <
|
|
1166
|
-
printError(
|
|
1168
|
+
if (!Number.isFinite(delta) || delta < 1) {
|
|
1169
|
+
printError(
|
|
1170
|
+
`--extend-expiry must be a positive integer (seconds), got: ${opts.extendExpiry}`
|
|
1171
|
+
);
|
|
1167
1172
|
}
|
|
1168
1173
|
const task = await apiGet(`/api/tasks/${taskId}`);
|
|
1169
1174
|
if (!task) {
|
|
1170
1175
|
printError(`Task not found: ${taskId}`);
|
|
1171
1176
|
}
|
|
1172
1177
|
const currentExpiry = Math.floor(new Date(task.expiryTime).getTime() / 1e3);
|
|
1173
|
-
|
|
1178
|
+
const newExpiry = currentExpiry + delta;
|
|
1179
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
1180
|
+
if (newExpiry <= now) {
|
|
1181
|
+
const expiredAgo = now - currentExpiry;
|
|
1182
|
+
printError(
|
|
1183
|
+
`--extend-expiry would set expiry in the past. Task expired ${expiredAgo}s ago; pass at least ${expiredAgo + 1} seconds to extend beyond now.`
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
body.expiryTime = newExpiry;
|
|
1174
1187
|
}
|
|
1175
1188
|
if (opts.bidDeadline !== void 0) {
|
|
1176
1189
|
const ts = Math.floor(new Date(opts.bidDeadline).getTime() / 1e3);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucid-agents/taskmarket",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"taskmarket": "./dist/index.js"
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"typescript": "^5.3.3",
|
|
19
19
|
"vitest": "^2.0.0",
|
|
20
20
|
"@taskmarket/prettier-config": "0.0.0",
|
|
21
|
-
"@taskmarket/
|
|
22
|
-
"@taskmarket/
|
|
21
|
+
"@taskmarket/eslint-config": "0.0.0",
|
|
22
|
+
"@taskmarket/shared": "2.0.0"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|