@lucid-agents/taskmarket 1.34.0 → 1.36.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-R76D244Y.js → api-BAW7ZGDD.js} +2 -2
- package/dist/{channels-SVCU2MU5.js → channels-FAOZ67V2.js} +4 -4
- package/dist/{chunk-CHX7O7EU.js → chunk-6AIEGDDI.js} +1 -1
- package/dist/{chunk-B7W4G3EY.js → chunk-7TDHFFF2.js} +1 -1
- package/dist/{chunk-YHVP2UNE.js → chunk-AZ2N4KKB.js} +1 -1
- package/dist/{chunk-BDKM5JMT.js → chunk-BQ63ZEML.js} +1 -1
- package/dist/{chunk-JRWRBSS2.js → chunk-F5ZHREXK.js} +3 -3
- package/dist/{chunk-KHDQRFHG.js → chunk-FXBA6X3I.js} +5 -5
- package/dist/{chunk-WP7GXSKE.js → chunk-NF3XHNJH.js} +3 -3
- package/dist/{chunk-45GK5BHD.js → chunk-Q2NCP72I.js} +14 -9
- package/dist/{chunk-QAGDCIMU.js → chunk-Q3IC6GTF.js} +125 -6
- package/dist/{chunk-54OR2JDT.js → chunk-TKHBDRU6.js} +2 -2
- package/dist/{chunk-YGSVDU2D.js → chunk-WGQV5OG3.js} +3 -3
- package/dist/{chunk-G3U2BQNC.js → chunk-WJHT663R.js} +1 -1
- package/dist/{doctor-IIVQFDIB.js → doctor-WFGKN5ZB.js} +8 -8
- package/dist/index.js +366 -127
- package/dist/{launch-INDP2HH3.js → launch-QWDD4WLN.js} +11 -11
- package/dist/pi-extensions/xgate.cjs +65 -2
- package/dist/{read-auth-AGP3CUMT.js → read-auth-JKSDOSKI.js} +3 -3
- package/dist/{reconcile-H3JIKN2X.js → reconcile-B33L7D3M.js} +4 -4
- package/dist/{status-SARVECVT.js → status-CBGRCJQO.js} +8 -8
- package/dist/{sync-pull-IUPV57MU.js → sync-pull-EA6TBOHC.js} +4 -4
- package/dist/{task-access-grants-HALV3NEO.js → task-access-grants-JF7LGUWX.js} +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
listWorkerSubmissions,
|
|
15
15
|
submitTaskFiles,
|
|
16
16
|
taskRequirementsOf
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-Q2NCP72I.js";
|
|
18
18
|
import {
|
|
19
19
|
ComputeCreditError,
|
|
20
20
|
applyComputeCreditSetup,
|
|
@@ -36,14 +36,14 @@ import {
|
|
|
36
36
|
refusedPaidWrite,
|
|
37
37
|
releasePendingComputePurchase,
|
|
38
38
|
resolvePendingComputePurchases
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-F5ZHREXK.js";
|
|
40
40
|
import {
|
|
41
41
|
signReadAuth
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-TKHBDRU6.js";
|
|
43
43
|
import {
|
|
44
44
|
saveTaskAccessGrant,
|
|
45
45
|
taskAccessGrantHeaders
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-6AIEGDDI.js";
|
|
47
47
|
import {
|
|
48
48
|
MPP_TEMPO_DEFAULT_VALIDITY_SECONDS,
|
|
49
49
|
X402PayError,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
setX402PolicyRuleEnabled,
|
|
62
62
|
signSponsoredTempoTransfer,
|
|
63
63
|
signTaskmarketFeePayment
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-AZ2N4KKB.js";
|
|
65
65
|
import {
|
|
66
66
|
ALL_NETWORKS,
|
|
67
67
|
ApiError,
|
|
@@ -124,7 +124,7 @@ import {
|
|
|
124
124
|
withErrorContext,
|
|
125
125
|
withIdempotentWrite,
|
|
126
126
|
withTapSignature
|
|
127
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-WJHT663R.js";
|
|
128
128
|
import {
|
|
129
129
|
AGENT_AVATAR_MAX_BYTES,
|
|
130
130
|
AGENT_HIRES_ROLES,
|
|
@@ -254,6 +254,9 @@ import {
|
|
|
254
254
|
WORKFLOW_STEP_LIMIT_MAX,
|
|
255
255
|
WORKFLOW_STEP_LIMIT_MIN,
|
|
256
256
|
WORKFLOW_TEMPLATE_PARAMETERS_MAX,
|
|
257
|
+
WORKFLOW_TEMPLATE_SEARCH_MAX_LENGTH,
|
|
258
|
+
WORKFLOW_TEMPLATE_SEARCH_SORTS,
|
|
259
|
+
WORKFLOW_TEMPLATE_SEARCH_TAGS_MAX,
|
|
257
260
|
WalletMarketEventsInputSchema,
|
|
258
261
|
apiErrorEnvelopeOf,
|
|
259
262
|
assertSelectableCapabilities,
|
|
@@ -310,6 +313,7 @@ import {
|
|
|
310
313
|
marketEventPreferenceChange,
|
|
311
314
|
needsYouKindForIntent,
|
|
312
315
|
normalizeReferenceCode,
|
|
316
|
+
normalizeWorkflowTemplateTags,
|
|
313
317
|
parseIsoDurationSeconds,
|
|
314
318
|
parseScheduleCadence,
|
|
315
319
|
paymentTokenSymbol,
|
|
@@ -341,7 +345,7 @@ import {
|
|
|
341
345
|
vaultCallGasLimit7702,
|
|
342
346
|
verifierProviderId,
|
|
343
347
|
verifiersUnsupportedOnChain
|
|
344
|
-
} from "./chunk-
|
|
348
|
+
} from "./chunk-Q3IC6GTF.js";
|
|
345
349
|
import "./chunk-S7SJMJ2I.js";
|
|
346
350
|
|
|
347
351
|
// src/index.ts
|
|
@@ -5254,14 +5258,14 @@ function createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value) {
|
|
|
5254
5258
|
} else {
|
|
5255
5259
|
argumentLabel = `\`${keyPath[0].toString()}\``;
|
|
5256
5260
|
}
|
|
5257
|
-
const
|
|
5261
|
+
const path9 = keyPath.length > 1 ? keyPath.slice(1).map((pathPart) => typeof pathPart === "number" ? `[${pathPart}]` : pathPart).join(".") : void 0;
|
|
5258
5262
|
const error = new SolanaError(SOLANA_ERROR__RPC__INTEGER_OVERFLOW, {
|
|
5259
5263
|
argumentLabel,
|
|
5260
5264
|
keyPath,
|
|
5261
5265
|
methodName,
|
|
5262
|
-
optionalPathLabel:
|
|
5266
|
+
optionalPathLabel: path9 ? ` at path \`${path9}\`` : "",
|
|
5263
5267
|
value,
|
|
5264
|
-
...
|
|
5268
|
+
...path9 !== void 0 ? { path: path9 } : void 0
|
|
5265
5269
|
});
|
|
5266
5270
|
safeCaptureStackTrace(error, createSolanaJsonRpcIntegerOverflowError);
|
|
5267
5271
|
return error;
|
|
@@ -8449,10 +8453,10 @@ function createSubmissionReviewClient(options) {
|
|
|
8449
8453
|
)
|
|
8450
8454
|
};
|
|
8451
8455
|
})();
|
|
8452
|
-
async function get(
|
|
8453
|
-
return schema.parse(await options.transport.get(
|
|
8456
|
+
async function get(path9, schema) {
|
|
8457
|
+
return schema.parse(await options.transport.get(path9, await headers()));
|
|
8454
8458
|
}
|
|
8455
|
-
async function write(action, payload, chainId,
|
|
8459
|
+
async function write(action, payload, chainId, path9, schema, key) {
|
|
8456
8460
|
const idempotencyKey = z.string().uuid().parse(resolveIdempotencyKey(key)).toLowerCase();
|
|
8457
8461
|
return withIdempotentWrite(idempotencyKey, async () => {
|
|
8458
8462
|
const signer = await options.signer();
|
|
@@ -8476,7 +8480,7 @@ function createSubmissionReviewClient(options) {
|
|
|
8476
8480
|
signature,
|
|
8477
8481
|
...["pause", "cancel", "delete"].includes(action) ? { action } : {}
|
|
8478
8482
|
};
|
|
8479
|
-
const result = await options.transport.post(
|
|
8483
|
+
const result = await options.transport.post(path9, body, idempotencyKey);
|
|
8480
8484
|
if (result.idempotencyKey !== idempotencyKey)
|
|
8481
8485
|
throw new Error(
|
|
8482
8486
|
"Review response has a different request key; recover the original request before retrying."
|
|
@@ -8689,9 +8693,9 @@ function cliSubmissionReviewClient() {
|
|
|
8689
8693
|
};
|
|
8690
8694
|
},
|
|
8691
8695
|
transport: {
|
|
8692
|
-
get: (
|
|
8693
|
-
preview: (
|
|
8694
|
-
post: (
|
|
8696
|
+
get: (path9, headers) => apiGet(path9, { headers }),
|
|
8697
|
+
preview: (path9, body, headers) => apiReadPost(path9, body, { headers }),
|
|
8698
|
+
post: (path9, body, idempotencyKey, headers) => apiPost(path9, body, { idempotencyKey, headers })
|
|
8695
8699
|
}
|
|
8696
8700
|
});
|
|
8697
8701
|
}
|
|
@@ -8974,13 +8978,13 @@ function retryAfterMs(res) {
|
|
|
8974
8978
|
const wait = Number.isFinite(seconds) && seconds >= 0 ? seconds : DEFAULT_RETRY_AFTER_SECONDS;
|
|
8975
8979
|
return Math.min(wait, MAX_RETRY_AFTER_SECONDS) * 1e3;
|
|
8976
8980
|
}
|
|
8977
|
-
async function x402Post(
|
|
8981
|
+
async function x402Post(path9, body, options) {
|
|
8978
8982
|
const sleep4 = options?.sleep ?? ((ms2) => new Promise((resolve) => setTimeout(resolve, ms2)));
|
|
8979
8983
|
if (paymentProtocolOf(selectedNetwork().chainId) === "mpp")
|
|
8980
|
-
return mppPost(
|
|
8984
|
+
return mppPost(path9, body, options);
|
|
8981
8985
|
const keystore = await loadKeystore();
|
|
8982
8986
|
const idempotencyKey = resolveIdempotencyKey(options?.idempotencyKey);
|
|
8983
|
-
const request = paidWriteRequest(keystore,
|
|
8987
|
+
const request = paidWriteRequest(keystore, path9, body, idempotencyKey);
|
|
8984
8988
|
Object.assign(request.headers, options?.headers ?? {});
|
|
8985
8989
|
return withIdempotentWrite(idempotencyKey, async () => {
|
|
8986
8990
|
const r1 = await fetch(request.url, {
|
|
@@ -8997,7 +9001,7 @@ async function x402Post(path8, body, options) {
|
|
|
8997
9001
|
if (r1.ok) {
|
|
8998
9002
|
return { data: await r1.json(), idempotencyKey };
|
|
8999
9003
|
}
|
|
9000
|
-
throw refusedPaidWrite(
|
|
9004
|
+
throw refusedPaidWrite(path9, r1.status, await readFailureBody(r1), idempotencyKey);
|
|
9001
9005
|
}
|
|
9002
9006
|
const requirements = await r1.json();
|
|
9003
9007
|
const chain = taskmarketChain(selectedNetwork().chainId);
|
|
@@ -9034,7 +9038,7 @@ async function x402Post(path8, body, options) {
|
|
|
9034
9038
|
await sleep4(retryAfterMs(r2));
|
|
9035
9039
|
continue;
|
|
9036
9040
|
}
|
|
9037
|
-
throw failedAfterPayment(
|
|
9041
|
+
throw failedAfterPayment(path9, r2.status, read3, idempotencyKey);
|
|
9038
9042
|
}
|
|
9039
9043
|
});
|
|
9040
9044
|
}
|
|
@@ -9432,13 +9436,13 @@ async function settleRecording(data, idempotencyKey, options = {}) {
|
|
|
9432
9436
|
`Transaction ${txHash ?? "(unknown)"} is confirmed on chain; recording it is pending. Waiting up to ${Math.round(timeoutMs / 1e3)}s for the backend to record it...`
|
|
9433
9437
|
);
|
|
9434
9438
|
const headers = (await signReadAuth())?.headers ?? {};
|
|
9435
|
-
const
|
|
9439
|
+
const path9 = `/api/intents?idempotencyKey=${encodeURIComponent(idempotencyKey)}`;
|
|
9436
9440
|
const deadline = now() + timeoutMs;
|
|
9437
9441
|
while (now() < deadline) {
|
|
9438
9442
|
await sleep4(intervalMs);
|
|
9439
9443
|
let intent;
|
|
9440
9444
|
try {
|
|
9441
|
-
intent = IntentStatusResponseSchema.safeParse(await apiGet(
|
|
9445
|
+
intent = IntentStatusResponseSchema.safeParse(await apiGet(path9, { headers }));
|
|
9442
9446
|
} catch {
|
|
9443
9447
|
continue;
|
|
9444
9448
|
}
|
|
@@ -11118,7 +11122,7 @@ var submitCmd = new Command14("submit").description("Submit work for a task").ar
|
|
|
11118
11122
|
const { submissionId, idempotencyKey } = await submitTaskFiles(
|
|
11119
11123
|
cliTaskWriteContext(keystore),
|
|
11120
11124
|
{ taskId },
|
|
11121
|
-
opts.file.map((
|
|
11125
|
+
opts.file.map((path9) => ({ path: path9, role: opts.role })),
|
|
11122
11126
|
{ idempotencyKey: submissionKey }
|
|
11123
11127
|
);
|
|
11124
11128
|
printResult({ submissionId }, { idempotencyKey });
|
|
@@ -11698,20 +11702,20 @@ var bidCmd = new Command26("bid").description("Submit a bid on an auction task")
|
|
|
11698
11702
|
}
|
|
11699
11703
|
if (!await confirmUnverifiedHooks("bid", taskId, opts.acceptUnverifiedHooks)) return;
|
|
11700
11704
|
if (!await confirmStakeTerms("bid", taskId, opts.yes)) return;
|
|
11701
|
-
const
|
|
11705
|
+
const path9 = `/api/tasks/${taskId}/bids`;
|
|
11702
11706
|
const body = { taskId, price: priceBaseUnits };
|
|
11703
11707
|
const task = await taskRequirementsOf(taskId);
|
|
11704
11708
|
const gated = (task?.identity?.length ?? 0) > 0 || taskRequiresTap(task);
|
|
11705
11709
|
const { data: result, idempotencyKey } = gated ? await attestedWorkerAction(
|
|
11706
11710
|
taskId,
|
|
11707
11711
|
await loadKeystore(),
|
|
11708
|
-
async (tap) => x402Post(
|
|
11712
|
+
async (tap) => x402Post(path9, body, {
|
|
11709
11713
|
maxAmount: ACTION_FEE_MAX_AMOUNT,
|
|
11710
11714
|
headers: (await signReadAuth())?.headers ?? {},
|
|
11711
11715
|
...tap ? { tap } : {}
|
|
11712
11716
|
}),
|
|
11713
11717
|
task
|
|
11714
|
-
) : await x402Post(
|
|
11718
|
+
) : await x402Post(path9, body, { maxAmount: ACTION_FEE_MAX_AMOUNT });
|
|
11715
11719
|
printResult({ bidId: result.bidId }, { idempotencyKey });
|
|
11716
11720
|
}
|
|
11717
11721
|
);
|
|
@@ -11731,19 +11735,19 @@ var auctionAcceptCmd = new Command27("auction-accept").description("Accept curre
|
|
|
11731
11735
|
return;
|
|
11732
11736
|
}
|
|
11733
11737
|
}
|
|
11734
|
-
const
|
|
11738
|
+
const path9 = `/api/tasks/${taskId}/bids/accept`;
|
|
11735
11739
|
const task = await taskRequirementsOf(taskId);
|
|
11736
11740
|
const gated = (task?.identity?.length ?? 0) > 0 || taskRequiresTap(task);
|
|
11737
11741
|
const { data: result, idempotencyKey } = gated ? await attestedWorkerAction(
|
|
11738
11742
|
taskId,
|
|
11739
11743
|
await loadKeystore(),
|
|
11740
|
-
async (tap) => x402Post(
|
|
11744
|
+
async (tap) => x402Post(path9, body, {
|
|
11741
11745
|
maxAmount: ACTION_FEE_MAX_AMOUNT,
|
|
11742
11746
|
headers: (await signReadAuth())?.headers ?? {},
|
|
11743
11747
|
...tap ? { tap } : {}
|
|
11744
11748
|
}),
|
|
11745
11749
|
task
|
|
11746
|
-
) : await x402Post(
|
|
11750
|
+
) : await x402Post(path9, body, { maxAmount: ACTION_FEE_MAX_AMOUNT });
|
|
11747
11751
|
const { chainId } = selectedNetwork();
|
|
11748
11752
|
printResult(
|
|
11749
11753
|
{
|
|
@@ -12976,7 +12980,7 @@ async function runAgentCommand(options) {
|
|
|
12976
12980
|
try {
|
|
12977
12981
|
const { assertAgentCompatibility } = await import("./compatibility-636WJOEX.js");
|
|
12978
12982
|
const pi = assertAgentCompatibility();
|
|
12979
|
-
const { runAgent } = await import("./launch-
|
|
12983
|
+
const { runAgent } = await import("./launch-QWDD4WLN.js");
|
|
12980
12984
|
result = await runAgent({
|
|
12981
12985
|
model: options.model,
|
|
12982
12986
|
pi,
|
|
@@ -13410,13 +13414,13 @@ function agentManagementCommands() {
|
|
|
13410
13414
|
const status = new Command57("status").description(
|
|
13411
13415
|
"Show the agent channels (locked, charged, refundable), purchases with an unknown outcome, the sandbox and compute credit. Reads only."
|
|
13412
13416
|
).action(async () => {
|
|
13413
|
-
const { collectAgentStatus } = await import("./status-
|
|
13417
|
+
const { collectAgentStatus } = await import("./status-CBGRCJQO.js");
|
|
13414
13418
|
await run(() => collectAgentStatus());
|
|
13415
13419
|
});
|
|
13416
13420
|
const doctor = new Command57("doctor").description(
|
|
13417
13421
|
"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."
|
|
13418
13422
|
).action(async () => {
|
|
13419
|
-
const { runDoctor } = await import("./doctor-
|
|
13423
|
+
const { runDoctor } = await import("./doctor-WFGKN5ZB.js");
|
|
13420
13424
|
const report = await run(() => runDoctor());
|
|
13421
13425
|
if (report && !report.ok) process.exitCode = 1;
|
|
13422
13426
|
});
|
|
@@ -13427,7 +13431,7 @@ function agentManagementCommands() {
|
|
|
13427
13431
|
"Reconcile the open purchases of this channel, as status lists it; also reaches retired channels"
|
|
13428
13432
|
).action(
|
|
13429
13433
|
async (invocationId, options) => {
|
|
13430
|
-
const { reconcileChannelPurchases, reconcileInvocation } = await import("./reconcile-
|
|
13434
|
+
const { reconcileChannelPurchases, reconcileInvocation } = await import("./reconcile-B33L7D3M.js");
|
|
13431
13435
|
const choice = { rail: options.rail, channel: options.channel };
|
|
13432
13436
|
if (invocationId !== void 0) {
|
|
13433
13437
|
await run(() => reconcileInvocation(invocationId, { choice }));
|
|
@@ -13459,7 +13463,7 @@ function agentManagementCommands() {
|
|
|
13459
13463
|
`Not a USDC amount: ${options.amount} (digits, at most 6 decimals)`
|
|
13460
13464
|
);
|
|
13461
13465
|
}
|
|
13462
|
-
const { openAgentChannels, requestTopUp, selectRail, withdrawalHatch } = await import("./channels-
|
|
13466
|
+
const { openAgentChannels, requestTopUp, selectRail, withdrawalHatch } = await import("./channels-FAOZ67V2.js");
|
|
13463
13467
|
const { rails } = await openAgentChannels();
|
|
13464
13468
|
const result = await requestTopUp(selectRail(rails, options.rail), amount);
|
|
13465
13469
|
return {
|
|
@@ -13479,8 +13483,8 @@ function agentManagementCommands() {
|
|
|
13479
13483
|
await run(async () => {
|
|
13480
13484
|
await requireExperimental();
|
|
13481
13485
|
const { AGENT_VIEW_VERSION } = await import("./budget-view-J6L7X6EY.js");
|
|
13482
|
-
const { closeChannel, openAgentChannels, selectChannel } = await import("./channels-
|
|
13483
|
-
const { reconcileLeasedPurchase } = await import("./reconcile-
|
|
13486
|
+
const { closeChannel, openAgentChannels, selectChannel } = await import("./channels-FAOZ67V2.js");
|
|
13487
|
+
const { reconcileLeasedPurchase } = await import("./reconcile-B33L7D3M.js");
|
|
13484
13488
|
const opened = await openAgentChannels();
|
|
13485
13489
|
const { rail, retired } = selectChannel(opened, options);
|
|
13486
13490
|
const result = await closeChannel(
|
|
@@ -13534,7 +13538,7 @@ function agentManagementCommands() {
|
|
|
13534
13538
|
async (options) => {
|
|
13535
13539
|
await run(async () => {
|
|
13536
13540
|
await requireExperimental();
|
|
13537
|
-
const { runPull } = await import("./sync-pull-
|
|
13541
|
+
const { runPull } = await import("./sync-pull-EA6TBOHC.js");
|
|
13538
13542
|
const { terminalPrompter } = await import("./prompter-LSICEYSQ.js");
|
|
13539
13543
|
return runPull(options, {
|
|
13540
13544
|
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
@@ -17507,8 +17511,8 @@ async function readHistory(options) {
|
|
|
17507
17511
|
return;
|
|
17508
17512
|
}
|
|
17509
17513
|
const headers = options.task ? (await signReadAuth())?.headers ?? {} : (await readAuthHeaders()).headers;
|
|
17510
|
-
const
|
|
17511
|
-
printResult(await apiGet(
|
|
17514
|
+
const path9 = options.task ? `/api/market-events/tasks/${encodeURIComponent(options.task)}${query3({ since, limit })}` : `/api/market-events${query3({ since, limit })}`;
|
|
17515
|
+
printResult(await apiGet(path9, { headers }));
|
|
17512
17516
|
}
|
|
17513
17517
|
function warn(message) {
|
|
17514
17518
|
process.stderr.write(`${JSON.stringify({ ok: true, warning: message })}
|
|
@@ -17681,7 +17685,7 @@ async function assertTaskVisible(taskId, auth, options) {
|
|
|
17681
17685
|
readAuth: async () => auth,
|
|
17682
17686
|
transport: {
|
|
17683
17687
|
...cliTaskTransport,
|
|
17684
|
-
get: (
|
|
17688
|
+
get: (path9, headers) => apiGet(path9, { headers, signal })
|
|
17685
17689
|
}
|
|
17686
17690
|
};
|
|
17687
17691
|
let task;
|
|
@@ -18004,8 +18008,100 @@ async function agentEmailAddress(walletAddress, signal) {
|
|
|
18004
18008
|
return result.emailAddress ?? null;
|
|
18005
18009
|
}
|
|
18006
18010
|
|
|
18011
|
+
// src/lib/bug-follow.ts
|
|
18012
|
+
import { promises as fs9 } from "fs";
|
|
18013
|
+
import path7 from "path";
|
|
18014
|
+
function bugCursorPath(walletAddress, network) {
|
|
18015
|
+
return path7.join(
|
|
18016
|
+
getTaskmarketHome(),
|
|
18017
|
+
"bug-cursor",
|
|
18018
|
+
`${network}-${walletAddress.toLowerCase()}.json`
|
|
18019
|
+
);
|
|
18020
|
+
}
|
|
18021
|
+
async function loadBugCursor(file) {
|
|
18022
|
+
try {
|
|
18023
|
+
const record = JSON.parse(await fs9.readFile(file, "utf-8"));
|
|
18024
|
+
return record.reports && typeof record.reports === "object" ? record.reports : void 0;
|
|
18025
|
+
} catch {
|
|
18026
|
+
return void 0;
|
|
18027
|
+
}
|
|
18028
|
+
}
|
|
18029
|
+
async function saveBugCursor(file, reports) {
|
|
18030
|
+
await fs9.mkdir(path7.dirname(file), { recursive: true });
|
|
18031
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
18032
|
+
await fs9.writeFile(temp, JSON.stringify({ reports }, null, 2), { mode: 384 });
|
|
18033
|
+
await fs9.rename(temp, file);
|
|
18034
|
+
}
|
|
18035
|
+
function bugLine(report) {
|
|
18036
|
+
return {
|
|
18037
|
+
source: "bugs",
|
|
18038
|
+
id: report.id,
|
|
18039
|
+
number: report.number,
|
|
18040
|
+
title: report.title,
|
|
18041
|
+
status: report.status,
|
|
18042
|
+
updatedAt: report.updatedAt,
|
|
18043
|
+
command: `taskmarket bug show ${report.id}`
|
|
18044
|
+
};
|
|
18045
|
+
}
|
|
18046
|
+
function diffBugReports(reports, cursor) {
|
|
18047
|
+
const lines = [];
|
|
18048
|
+
const next = {};
|
|
18049
|
+
for (const report of reports) {
|
|
18050
|
+
const seen = cursor?.[report.id];
|
|
18051
|
+
if (cursor && report.status !== (seen?.status ?? report.status)) {
|
|
18052
|
+
lines.push({
|
|
18053
|
+
...bugLine(report),
|
|
18054
|
+
type: "bug.status_changed",
|
|
18055
|
+
previousStatus: seen.status
|
|
18056
|
+
});
|
|
18057
|
+
}
|
|
18058
|
+
let replyAt = seen?.replyAt ?? null;
|
|
18059
|
+
if (report.unread && replyAt !== report.updatedAt) {
|
|
18060
|
+
lines.push({ ...bugLine(report), type: "bug.reply" });
|
|
18061
|
+
replyAt = report.updatedAt;
|
|
18062
|
+
}
|
|
18063
|
+
next[report.id] = { status: report.status, replyAt };
|
|
18064
|
+
}
|
|
18065
|
+
return { lines, cursor: next };
|
|
18066
|
+
}
|
|
18067
|
+
var BUG_POLL_INTERVAL_MS = 6e4;
|
|
18068
|
+
var BUG_RETRY_MAX_MS = 15 * 6e4;
|
|
18069
|
+
var BUG_PAGE_SIZE = 100;
|
|
18070
|
+
async function followBugs(options) {
|
|
18071
|
+
const { signal } = options;
|
|
18072
|
+
const sleep4 = options.sleep ?? abortableSleep2;
|
|
18073
|
+
const file = bugCursorPath(options.walletAddress, selectedNetwork().name);
|
|
18074
|
+
let cursor = await loadBugCursor(file);
|
|
18075
|
+
let failures = 0;
|
|
18076
|
+
while (!signal?.aborted) {
|
|
18077
|
+
let waitMs = BUG_POLL_INTERVAL_MS;
|
|
18078
|
+
try {
|
|
18079
|
+
const auth = await signReadAuth();
|
|
18080
|
+
const result = await apiGet(`/api/bug-reports/mine?limit=${BUG_PAGE_SIZE}`, {
|
|
18081
|
+
headers: auth?.headers ?? {},
|
|
18082
|
+
signal
|
|
18083
|
+
});
|
|
18084
|
+
const diff = diffBugReports(result.reports, cursor);
|
|
18085
|
+
for (const line of diff.lines) options.print(line);
|
|
18086
|
+
if (JSON.stringify(diff.cursor) !== JSON.stringify(cursor)) {
|
|
18087
|
+
cursor = diff.cursor;
|
|
18088
|
+
await saveBugCursor(file, cursor);
|
|
18089
|
+
}
|
|
18090
|
+
failures = 0;
|
|
18091
|
+
} catch (error) {
|
|
18092
|
+
if (signal?.aborted) return;
|
|
18093
|
+
waitMs = Math.min(BUG_POLL_INTERVAL_MS * 2 ** (failures + 1), BUG_RETRY_MAX_MS);
|
|
18094
|
+
failures += 1;
|
|
18095
|
+
warn2(
|
|
18096
|
+
`Reading your bug reports failed (${error instanceof Error ? error.message : String(error)}); retrying in ${Math.round(waitMs / 1e3)}s.`
|
|
18097
|
+
);
|
|
18098
|
+
}
|
|
18099
|
+
await sleep4(waitMs, signal);
|
|
18100
|
+
}
|
|
18101
|
+
}
|
|
18102
|
+
|
|
18007
18103
|
// src/commands/daemon.ts
|
|
18008
|
-
var DAEMON_SOURCES = ["market", "xmtp", "email"];
|
|
18104
|
+
var DAEMON_SOURCES = ["market", "xmtp", "email", "bugs"];
|
|
18009
18105
|
function parseDaemonSources(value) {
|
|
18010
18106
|
const names = value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
18011
18107
|
const unknown = names.filter((name) => !DAEMON_SOURCES.includes(name));
|
|
@@ -18138,7 +18234,7 @@ function createDaemonCommand(seams = {}) {
|
|
|
18138
18234
|
emailMissing = `Could not check for an agent email (${err instanceof Error ? err.message : String(err)}).`;
|
|
18139
18235
|
}
|
|
18140
18236
|
}
|
|
18141
|
-
const othersRun = (source) => source !== "market" && sources.has("market") || source !== "xmtp" && xmtpAvailable || source !== "email" && emailAvailable;
|
|
18237
|
+
const othersRun = (source) => source !== "market" && sources.has("market") || source !== "xmtp" && xmtpAvailable || source !== "email" && emailAvailable || source !== "bugs" && sources.has("bugs");
|
|
18142
18238
|
if (xmtpUnsupported) {
|
|
18143
18239
|
if (!othersRun("xmtp")) throw xmtpUnsupported;
|
|
18144
18240
|
process.stderr.write(
|
|
@@ -18243,8 +18339,22 @@ function createDaemonCommand(seams = {}) {
|
|
|
18243
18339
|
stop();
|
|
18244
18340
|
});
|
|
18245
18341
|
};
|
|
18342
|
+
const bugsLoop = async () => {
|
|
18343
|
+
if (!sources.has("bugs")) return;
|
|
18344
|
+
await followBugs({
|
|
18345
|
+
walletAddress: keystore.walletAddress,
|
|
18346
|
+
signal: abortController.signal,
|
|
18347
|
+
print: (line) => printResult(line)
|
|
18348
|
+
});
|
|
18349
|
+
};
|
|
18246
18350
|
try {
|
|
18247
|
-
await Promise.allSettled([
|
|
18351
|
+
await Promise.allSettled([
|
|
18352
|
+
xmtpLoop(),
|
|
18353
|
+
heartbeatLoop(),
|
|
18354
|
+
eventsLoop(),
|
|
18355
|
+
emailLoop(),
|
|
18356
|
+
bugsLoop()
|
|
18357
|
+
]);
|
|
18248
18358
|
} finally {
|
|
18249
18359
|
xmtpPolicy?.stop();
|
|
18250
18360
|
}
|
|
@@ -18288,8 +18398,8 @@ var listCommand = new Command80("list").description(
|
|
|
18288
18398
|
const channel = parseChannel(options.channel);
|
|
18289
18399
|
const headers = await walletHeaders();
|
|
18290
18400
|
if (!headers) return;
|
|
18291
|
-
const
|
|
18292
|
-
printResult(await apiGet(
|
|
18401
|
+
const path9 = channel === "email" ? PREFERENCES_PATH : `${PREFERENCES_PATH}?channel=${channel}`;
|
|
18402
|
+
printResult(await apiGet(path9, { headers }));
|
|
18293
18403
|
} catch (err) {
|
|
18294
18404
|
renderFailure(err);
|
|
18295
18405
|
}
|
|
@@ -19190,7 +19300,7 @@ async function walk(root) {
|
|
|
19190
19300
|
const names = (await readdir(dir)).sort();
|
|
19191
19301
|
for (const name of names) {
|
|
19192
19302
|
const full = join(dir, name);
|
|
19193
|
-
const
|
|
19303
|
+
const path9 = relative(root, full).split(sep).join("/");
|
|
19194
19304
|
const info = await lstat(full);
|
|
19195
19305
|
if (info.isDirectory()) {
|
|
19196
19306
|
await visit(full);
|
|
@@ -19199,7 +19309,7 @@ async function walk(root) {
|
|
|
19199
19309
|
if (entries.length >= MAX_ENTRIES)
|
|
19200
19310
|
throw new Error(`The skill directory has more than ${MAX_ENTRIES} files`);
|
|
19201
19311
|
const mode = info.isSymbolicLink() ? USER_SKILL_GIT_MODES.symlink : !info.isFile() ? "other" : info.mode & 73 ? USER_SKILL_GIT_MODES.executable : USER_SKILL_GIT_MODES.file;
|
|
19202
|
-
entries.push({ path:
|
|
19312
|
+
entries.push({ path: path9, mode, full });
|
|
19203
19313
|
}
|
|
19204
19314
|
};
|
|
19205
19315
|
await visit(root);
|
|
@@ -19388,15 +19498,15 @@ skillsCommand.addCommand(archiveCommand);
|
|
|
19388
19498
|
|
|
19389
19499
|
// src/commands/brief.ts
|
|
19390
19500
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
19391
|
-
import
|
|
19392
|
-
import
|
|
19501
|
+
import fs10 from "fs/promises";
|
|
19502
|
+
import path8 from "path";
|
|
19393
19503
|
import { Command as Command103 } from "commander";
|
|
19394
19504
|
var BRIEF_COOKIE = "taskmarket_brief";
|
|
19395
19505
|
var CREDENTIAL_PATTERN = /^[0-9a-f-]{36}\.[0-9a-f]{64}$/;
|
|
19396
|
-
var credentialFile = () =>
|
|
19506
|
+
var credentialFile = () => path8.join(getTaskmarketHome(), "brief.json");
|
|
19397
19507
|
async function readCredentials() {
|
|
19398
19508
|
try {
|
|
19399
|
-
const parsed = JSON.parse(await
|
|
19509
|
+
const parsed = JSON.parse(await fs10.readFile(credentialFile(), "utf8"));
|
|
19400
19510
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
19401
19511
|
} catch {
|
|
19402
19512
|
return {};
|
|
@@ -19406,8 +19516,8 @@ async function writeCredential(value) {
|
|
|
19406
19516
|
const all = await readCredentials();
|
|
19407
19517
|
if (value) all[apiUrl()] = value;
|
|
19408
19518
|
else delete all[apiUrl()];
|
|
19409
|
-
await
|
|
19410
|
-
await
|
|
19519
|
+
await fs10.mkdir(getTaskmarketHome(), { recursive: true, mode: 448 });
|
|
19520
|
+
await fs10.writeFile(credentialFile(), JSON.stringify(all, null, 2), { mode: 384 });
|
|
19411
19521
|
}
|
|
19412
19522
|
async function savedCredential() {
|
|
19413
19523
|
const value = (await readCredentials())[apiUrl()];
|
|
@@ -19638,7 +19748,7 @@ x402PaymentsCommand.command("resolve").description("Manually record an externall
|
|
|
19638
19748
|
);
|
|
19639
19749
|
|
|
19640
19750
|
// src/commands/x402/policy.ts
|
|
19641
|
-
import { promises as
|
|
19751
|
+
import { promises as fs11 } from "fs";
|
|
19642
19752
|
import { Command as Command108 } from "commander";
|
|
19643
19753
|
import { createInterface as createInterface6 } from "readline";
|
|
19644
19754
|
async function confirmUnattendedRule(rule) {
|
|
@@ -19680,7 +19790,7 @@ x402PolicyCommand.command("validate").description("Validate the policy file").ac
|
|
|
19680
19790
|
});
|
|
19681
19791
|
x402PolicyCommand.command("schema").description("Print the policy JSON Schema").action(() => printResult(X402_POLICY_JSON_SCHEMA));
|
|
19682
19792
|
x402PolicyCommand.command("add").description("Add one rule from a JSON file").requiredOption("--rule-file <path>", "JSON file containing one policy rule").action(async (options) => {
|
|
19683
|
-
const rule = JSON.parse(await
|
|
19793
|
+
const rule = JSON.parse(await fs11.readFile(options.ruleFile, "utf8"));
|
|
19684
19794
|
const policy = await addX402PolicyRule(rule, getX402PolicyPath(), confirmUnattendedRule);
|
|
19685
19795
|
printResult({ path: getX402PolicyPath(), policy });
|
|
19686
19796
|
});
|
|
@@ -25122,14 +25232,14 @@ function describeSolanaAwards(awards, vaultAddress, solanaChainId, taskId) {
|
|
|
25122
25232
|
function isRetryableClaimConflict(err) {
|
|
25123
25233
|
return err instanceof ApiError && (err.status === 409 || err.status >= 500) && /retry/i.test(err.message);
|
|
25124
25234
|
}
|
|
25125
|
-
async function postClaimWithRetry(
|
|
25235
|
+
async function postClaimWithRetry(path9, body, options = {}) {
|
|
25126
25236
|
const sleep4 = options.sleep ?? ((ms2) => new Promise((r) => setTimeout(r, ms2)));
|
|
25127
25237
|
const deadline = Date.now() + (options.budgetMs ?? CLAIM_RETRY_BUDGET_MS);
|
|
25128
25238
|
const idempotencyKey = resolveIdempotencyKey();
|
|
25129
25239
|
let delayMs = 500;
|
|
25130
25240
|
for (; ; ) {
|
|
25131
25241
|
try {
|
|
25132
|
-
return await apiPost(
|
|
25242
|
+
return await apiPost(path9, body, { idempotencyKey });
|
|
25133
25243
|
} catch (err) {
|
|
25134
25244
|
if (!isRetryableClaimConflict(err) || Date.now() + delayMs > deadline) throw err;
|
|
25135
25245
|
await sleep4(delayMs);
|
|
@@ -25533,9 +25643,9 @@ function parseAmount(value, flag) {
|
|
|
25533
25643
|
}
|
|
25534
25644
|
|
|
25535
25645
|
// src/commands/project/write.ts
|
|
25536
|
-
async function postProjectWrite(
|
|
25646
|
+
async function postProjectWrite(path9, body, options) {
|
|
25537
25647
|
const { data: result, idempotencyKey } = await x402Post(
|
|
25538
|
-
|
|
25648
|
+
path9,
|
|
25539
25649
|
{ chainId: selectedNetwork().chainId, ...body },
|
|
25540
25650
|
{ maxAmount: options.maxAmount }
|
|
25541
25651
|
);
|
|
@@ -26159,22 +26269,22 @@ var UUID2 = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-
|
|
|
26159
26269
|
var ADDRESS2 = /^0x[0-9a-fA-F]{40}$/;
|
|
26160
26270
|
var FILE_MAX_BYTES = 256 * 1024;
|
|
26161
26271
|
var PARAM_NAME = /^[A-Za-z][A-Za-z0-9_]{0,39}$/;
|
|
26162
|
-
async function readJsonFile(
|
|
26163
|
-
if (!
|
|
26272
|
+
async function readJsonFile(path9, what = "template") {
|
|
26273
|
+
if (!path9) return { error: `Pass the ${what} with --file <path> (JSON)` };
|
|
26164
26274
|
let text;
|
|
26165
26275
|
try {
|
|
26166
|
-
const buffer = await readFile4(
|
|
26276
|
+
const buffer = await readFile4(path9);
|
|
26167
26277
|
if (buffer.length > FILE_MAX_BYTES) {
|
|
26168
|
-
return { error: `${
|
|
26278
|
+
return { error: `${path9} is ${buffer.length} bytes; a ${what} is at most 64 KiB as JSON` };
|
|
26169
26279
|
}
|
|
26170
26280
|
text = buffer.toString("utf8");
|
|
26171
26281
|
} catch (error) {
|
|
26172
|
-
return { error: `Unable to read ${
|
|
26282
|
+
return { error: `Unable to read ${path9}: ${error.message}` };
|
|
26173
26283
|
}
|
|
26174
26284
|
try {
|
|
26175
26285
|
return { document: JSON.parse(text) };
|
|
26176
26286
|
} catch (error) {
|
|
26177
|
-
return { error: `${
|
|
26287
|
+
return { error: `${path9} is not valid JSON: ${error.message}` };
|
|
26178
26288
|
}
|
|
26179
26289
|
}
|
|
26180
26290
|
function templateChoice(value) {
|
|
@@ -26226,9 +26336,12 @@ function parseParams(pairs) {
|
|
|
26226
26336
|
}
|
|
26227
26337
|
return { params };
|
|
26228
26338
|
}
|
|
26339
|
+
function updateNote(workflowId, status) {
|
|
26340
|
+
return `Update available: ${status.templateId} is at version ${status.latestVersion}, this workflow has ${status.currentVersion}. Apply it with: taskmarket workflow update-template ${workflowId}`;
|
|
26341
|
+
}
|
|
26229
26342
|
var collect6 = (value, previous = []) => [...previous, value];
|
|
26230
|
-
async function readValidTemplate(
|
|
26231
|
-
const parsed = await readJsonFile(
|
|
26343
|
+
async function readValidTemplate(path9) {
|
|
26344
|
+
const parsed = await readJsonFile(path9);
|
|
26232
26345
|
if ("error" in parsed) {
|
|
26233
26346
|
printError(parsed.error);
|
|
26234
26347
|
return null;
|
|
@@ -26257,7 +26370,7 @@ var createCommand3 = new Command141("create").description(
|
|
|
26257
26370
|
);
|
|
26258
26371
|
});
|
|
26259
26372
|
var updateCommand = new Command141("update").description(
|
|
26260
|
-
"Replace a saved template with a JSON file, as the wallet that saved it; workflows already made from it keep their document
|
|
26373
|
+
"Replace a saved template with a JSON file, as the wallet that saved it. A change to its content makes a new version; workflows already made from it keep their document until their owner runs `taskmarket workflow update-template`. Costs 0.001 in the payment token"
|
|
26261
26374
|
).argument("<templateId>", "Template id").requiredOption("--file <path>", "The template, JSON").action(async (value, opts) => {
|
|
26262
26375
|
const choice = templateChoice(value);
|
|
26263
26376
|
if (!("templateId" in choice) || OFFICIAL_WORKFLOW_TEMPLATE_ID.test(choice.templateId)) {
|
|
@@ -26276,52 +26389,127 @@ var updateCommand = new Command141("update").description(
|
|
|
26276
26389
|
{ maxAmount: ACTION_FEE_MAX_AMOUNT }
|
|
26277
26390
|
);
|
|
26278
26391
|
});
|
|
26392
|
+
function parseTemplateSearch(opts) {
|
|
26393
|
+
const query4 = new URLSearchParams();
|
|
26394
|
+
if (opts.search !== void 0) {
|
|
26395
|
+
const q = opts.search.trim();
|
|
26396
|
+
if (q.length === 0 || q.length > WORKFLOW_TEMPLATE_SEARCH_MAX_LENGTH) {
|
|
26397
|
+
return {
|
|
26398
|
+
error: `--search is 1 to ${WORKFLOW_TEMPLATE_SEARCH_MAX_LENGTH} characters of text to find in a template's name, description or tags`
|
|
26399
|
+
};
|
|
26400
|
+
}
|
|
26401
|
+
query4.set("q", q);
|
|
26402
|
+
}
|
|
26403
|
+
if (opts.tag && opts.tag.length > 0) {
|
|
26404
|
+
if (opts.tag.length > WORKFLOW_TEMPLATE_SEARCH_TAGS_MAX) {
|
|
26405
|
+
return {
|
|
26406
|
+
error: `--tag may be given at most ${WORKFLOW_TEMPLATE_SEARCH_TAGS_MAX} times; a template must carry all of them`
|
|
26407
|
+
};
|
|
26408
|
+
}
|
|
26409
|
+
const tags = normalizeWorkflowTemplateTags(opts.tag);
|
|
26410
|
+
if (!tags.ok) {
|
|
26411
|
+
return {
|
|
26412
|
+
error: `--tag "${tags.invalid.slice(0, 40)}" is not a tag: use letters, digits and hyphens, at most 24 characters`
|
|
26413
|
+
};
|
|
26414
|
+
}
|
|
26415
|
+
query4.set("tags", tags.tags.join(","));
|
|
26416
|
+
}
|
|
26417
|
+
if (opts.featured) query4.set("featured", "true");
|
|
26418
|
+
if (opts.sort !== void 0) {
|
|
26419
|
+
if (!WORKFLOW_TEMPLATE_SEARCH_SORTS.includes(opts.sort)) {
|
|
26420
|
+
return { error: `--sort is one of ${WORKFLOW_TEMPLATE_SEARCH_SORTS.join(", ")}` };
|
|
26421
|
+
}
|
|
26422
|
+
query4.set("sort", opts.sort);
|
|
26423
|
+
}
|
|
26424
|
+
return { query: query4 };
|
|
26425
|
+
}
|
|
26279
26426
|
var listCommand6 = new Command141("list").description(
|
|
26280
|
-
"List the official templates (official: true, ids official:<slug>), the built-in presets and a wallet's saved templates, newest first (your wallet unless --owner is given). Any wallet may make a workflow from any of them (free)"
|
|
26427
|
+
"List the official templates (official: true, ids official:<slug>), the built-in presets and a wallet's saved templates, newest first (your wallet unless --owner is given). Any wallet may make a workflow from any of them (free). With --search, --tag, --featured or --sort, search instead: one page of templates, featured first, with `hasMore`, `nextCursor` and the catalog's most used tags in `catalogTags`; each template lists its `tags` and `featured`"
|
|
26281
26428
|
).option("--owner <address>", "The wallet whose templates to list").option(
|
|
26282
26429
|
"--mine",
|
|
26283
26430
|
'Only the templates your wallet saved: no official templates or presets (the web Templates page "Yours" filter)'
|
|
26284
|
-
).option(
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
|
|
26291
|
-
|
|
26292
|
-
|
|
26293
|
-
|
|
26294
|
-
|
|
26295
|
-
|
|
26296
|
-
|
|
26297
|
-
|
|
26298
|
-
|
|
26299
|
-
if (opts.mine) {
|
|
26300
|
-
|
|
26301
|
-
|
|
26302
|
-
|
|
26303
|
-
|
|
26304
|
-
|
|
26431
|
+
).option(
|
|
26432
|
+
"--search <text>",
|
|
26433
|
+
`Find templates whose name, description or tags contain every word (up to ${WORKFLOW_TEMPLATE_SEARCH_MAX_LENGTH} characters)`
|
|
26434
|
+
).option(
|
|
26435
|
+
"--tag <tag>",
|
|
26436
|
+
`Only templates with this tag; repeat for more (at most ${WORKFLOW_TEMPLATE_SEARCH_TAGS_MAX}, all required)`,
|
|
26437
|
+
collect6
|
|
26438
|
+
).option("--featured", "Only the featured templates, which the repository curates").option(
|
|
26439
|
+
"--gallery",
|
|
26440
|
+
"The public gallery: only the saved templates their authors listed with `template publish`, each with its author's wallet in `owner` (with --owner, only that wallet's); no official templates or presets"
|
|
26441
|
+
).option(
|
|
26442
|
+
"--sort <order>",
|
|
26443
|
+
`Order of a search: ${WORKFLOW_TEMPLATE_SEARCH_SORTS.join(" (featured first, default) or ")}`
|
|
26444
|
+
).option("--limit <count>", "Templates per page (1-100, default 20)").option("--cursor <cursor>", "nextCursor from the previous page").action(
|
|
26445
|
+
async (opts) => {
|
|
26446
|
+
if (opts.mine && opts.owner !== void 0) {
|
|
26447
|
+
return void printError("Use either --mine or --owner <address>, not both");
|
|
26448
|
+
}
|
|
26449
|
+
if (opts.gallery && (opts.mine || opts.featured)) {
|
|
26450
|
+
return void printError(
|
|
26451
|
+
"--gallery lists the saved templates authors listed; it does not combine with --mine or --featured"
|
|
26452
|
+
);
|
|
26453
|
+
}
|
|
26454
|
+
if (opts.limit !== void 0 && !/^(100|[1-9][0-9]?)$/.test(opts.limit.trim())) {
|
|
26455
|
+
return void printError("--limit must be an integer from 1 to 100");
|
|
26456
|
+
}
|
|
26457
|
+
if (opts.owner !== void 0 && !ADDRESS2.test(opts.owner.trim())) {
|
|
26458
|
+
return void printError("--owner is a wallet address (0x and 40 hex digits)");
|
|
26459
|
+
}
|
|
26460
|
+
const searching = opts.search !== void 0 || (opts.tag?.length ?? 0) > 0 || opts.featured === true || opts.gallery === true || opts.sort !== void 0;
|
|
26461
|
+
const search = parseTemplateSearch(opts);
|
|
26462
|
+
if ("error" in search) return void printError(search.error);
|
|
26463
|
+
try {
|
|
26464
|
+
const owner = opts.owner?.trim() ?? (opts.gallery ? void 0 : await getWalletAddress());
|
|
26465
|
+
if (searching) {
|
|
26466
|
+
const query4 = search.query;
|
|
26467
|
+
if (owner) query4.set("owner", owner);
|
|
26468
|
+
if (opts.mine) query4.set("scope", "saved");
|
|
26469
|
+
if (opts.gallery) query4.set("scope", "community");
|
|
26470
|
+
if (opts.limit) query4.set("limit", opts.limit.trim());
|
|
26471
|
+
if (opts.cursor) query4.set("cursor", opts.cursor.trim());
|
|
26472
|
+
const page2 = await apiGet(
|
|
26473
|
+
`/api/project-workflow-template-search?${query4.toString()}`
|
|
26474
|
+
);
|
|
26475
|
+
return void printResult({
|
|
26476
|
+
owner: owner ? owner.toLowerCase() : null,
|
|
26477
|
+
templates: page2.templates ?? [],
|
|
26478
|
+
hasMore: page2.hasMore ?? false,
|
|
26479
|
+
nextCursor: page2.nextCursor ?? null,
|
|
26480
|
+
catalogTags: page2.catalogTags ?? []
|
|
26481
|
+
});
|
|
26482
|
+
}
|
|
26483
|
+
const params = new URLSearchParams({ owner });
|
|
26484
|
+
if (opts.limit) params.set("limit", opts.limit.trim());
|
|
26485
|
+
if (opts.cursor) params.set("cursor", opts.cursor.trim());
|
|
26486
|
+
if (opts.mine) {
|
|
26487
|
+
const mine = await apiGet(`/api/project-workflow-templates?${params.toString()}`);
|
|
26488
|
+
return void printResult({
|
|
26489
|
+
owner: mine.owner ?? owner.toLowerCase(),
|
|
26490
|
+
templates: mine.templates ?? [],
|
|
26491
|
+
nextCursor: mine.nextCursor ?? null
|
|
26492
|
+
});
|
|
26493
|
+
}
|
|
26494
|
+
const [presets, page] = await Promise.all([
|
|
26495
|
+
apiGet("/api/project-workflow-presets"),
|
|
26496
|
+
apiGet(`/api/project-workflow-templates?${params.toString()}`)
|
|
26497
|
+
]);
|
|
26498
|
+
const builtIn = presets.presets ?? [];
|
|
26499
|
+
printResult({
|
|
26500
|
+
official: builtIn.filter((t) => t.official === true),
|
|
26501
|
+
presets: builtIn.filter((t) => t.official !== true),
|
|
26502
|
+
owner: page.owner ?? owner.toLowerCase(),
|
|
26503
|
+
templates: page.templates ?? [],
|
|
26504
|
+
nextCursor: page.nextCursor ?? null
|
|
26305
26505
|
});
|
|
26506
|
+
} catch (err) {
|
|
26507
|
+
renderFailure(err);
|
|
26306
26508
|
}
|
|
26307
|
-
const [presets, page] = await Promise.all([
|
|
26308
|
-
apiGet("/api/project-workflow-presets"),
|
|
26309
|
-
apiGet(`/api/project-workflow-templates?${params.toString()}`)
|
|
26310
|
-
]);
|
|
26311
|
-
const builtIn = presets.presets ?? [];
|
|
26312
|
-
printResult({
|
|
26313
|
-
official: builtIn.filter((t) => t.official === true),
|
|
26314
|
-
presets: builtIn.filter((t) => t.official !== true),
|
|
26315
|
-
owner: page.owner ?? owner.toLowerCase(),
|
|
26316
|
-
templates: page.templates ?? [],
|
|
26317
|
-
nextCursor: page.nextCursor ?? null
|
|
26318
|
-
});
|
|
26319
|
-
} catch (err) {
|
|
26320
|
-
renderFailure(err);
|
|
26321
26509
|
}
|
|
26322
|
-
|
|
26510
|
+
);
|
|
26323
26511
|
var showCommand3 = new Command141("show").description(
|
|
26324
|
-
"Show a saved template, an official template (official:<slug>) or a preset (code, content, research): its parameters, steps and worst case (free)"
|
|
26512
|
+
"Show a saved template, an official template (official:<slug>) or a preset (code, content, research): its version (a counter for a saved template, a content hash for an official one), the earlier versions of a saved template as `versions` (number, hash, date), whether it is `listed` in the gallery, its parameters, steps and worst case (free)"
|
|
26325
26513
|
).argument("<template>", "Template id, official template id or preset name").action(async (value) => {
|
|
26326
26514
|
const choice = templateChoice(value);
|
|
26327
26515
|
if ("error" in choice)
|
|
@@ -26333,6 +26521,38 @@ var showCommand3 = new Command141("show").description(
|
|
|
26333
26521
|
renderFailure(err);
|
|
26334
26522
|
}
|
|
26335
26523
|
});
|
|
26524
|
+
function savedTemplateId(value, verb) {
|
|
26525
|
+
const choice = templateChoice(value);
|
|
26526
|
+
if (!("templateId" in choice) || OFFICIAL_WORKFLOW_TEMPLATE_ID.test(choice.templateId)) {
|
|
26527
|
+
printError(
|
|
26528
|
+
`Presets and official templates are read-only; ${verb} takes a saved template id (UUID)`
|
|
26529
|
+
);
|
|
26530
|
+
return null;
|
|
26531
|
+
}
|
|
26532
|
+
return choice.templateId;
|
|
26533
|
+
}
|
|
26534
|
+
var publishCommand = new Command141("publish").description(
|
|
26535
|
+
"List a saved template in the public gallery, as the wallet that saved it, so others can find it with `template list --gallery` (and on the web Templates page) without being given its id; it is shown with your wallet as its author. It needs a description and at most 10 templates per wallet can be listed. Listing again changes nothing. Costs 0.001 in the payment token"
|
|
26536
|
+
).argument("<templateId>", "Saved template id").action(async (value) => {
|
|
26537
|
+
const id = savedTemplateId(value, "publish");
|
|
26538
|
+
if (!id) return;
|
|
26539
|
+
await postProjectWrite(
|
|
26540
|
+
`/api/project-workflow-templates/${id}/publish`,
|
|
26541
|
+
{ templateId: id },
|
|
26542
|
+
{ maxAmount: ACTION_FEE_MAX_AMOUNT }
|
|
26543
|
+
);
|
|
26544
|
+
});
|
|
26545
|
+
var unpublishCommand = new Command141("unpublish").description(
|
|
26546
|
+
"Take a saved template out of the public gallery, as the wallet that saved it. It stays usable by anyone who has its id. Costs 0.001 in the payment token"
|
|
26547
|
+
).argument("<templateId>", "Saved template id").action(async (value) => {
|
|
26548
|
+
const id = savedTemplateId(value, "unpublish");
|
|
26549
|
+
if (!id) return;
|
|
26550
|
+
await postProjectWrite(
|
|
26551
|
+
`/api/project-workflow-templates/${id}/unpublish`,
|
|
26552
|
+
{ templateId: id },
|
|
26553
|
+
{ maxAmount: ACTION_FEE_MAX_AMOUNT }
|
|
26554
|
+
);
|
|
26555
|
+
});
|
|
26336
26556
|
var deleteCommand2 = new Command141("delete").description(
|
|
26337
26557
|
"Delete a saved template, as the wallet that saved it; workflows already made from it are unaffected. Costs 0.001 in the payment token"
|
|
26338
26558
|
).argument("<templateId>", "Template id").action(async (value) => {
|
|
@@ -26352,7 +26572,7 @@ var deleteCommand2 = new Command141("delete").description(
|
|
|
26352
26572
|
});
|
|
26353
26573
|
var workflowTemplateCommand = new Command141("template").description(
|
|
26354
26574
|
"Workflow templates: a workflow saved once with declared parameters ({{reward}}, {{topic}}) and made into a workflow on any of your projects with `taskmarket workflow create <projectId> --template <id|official:slug|preset> --param name=value`. Any wallet may use any template; only the wallet that saved one may update or delete it. Official templates: see `taskmarket workflow template list`. Presets: code, content, research"
|
|
26355
|
-
).addCommand(createCommand3).addCommand(updateCommand).addCommand(listCommand6).addCommand(showCommand3).addCommand(deleteCommand2);
|
|
26575
|
+
).addCommand(createCommand3).addCommand(updateCommand).addCommand(listCommand6).addCommand(showCommand3).addCommand(publishCommand).addCommand(unpublishCommand).addCommand(deleteCommand2);
|
|
26356
26576
|
async function createWorkflowFromTemplate(projectId, template, pairs) {
|
|
26357
26577
|
const choice = templateChoice(template);
|
|
26358
26578
|
if ("error" in choice) return void printError(choice.error);
|
|
@@ -26556,9 +26776,9 @@ function scheduleSettingsBody(projectId, opts) {
|
|
|
26556
26776
|
function scheduleId(value) {
|
|
26557
26777
|
return UUID3.test(value.trim()) ? value.trim().toLowerCase() : { error: "The schedule id must be a UUID" };
|
|
26558
26778
|
}
|
|
26559
|
-
async function read(
|
|
26779
|
+
async function read(path9) {
|
|
26560
26780
|
try {
|
|
26561
|
-
printResult(await apiGet(
|
|
26781
|
+
printResult(await apiGet(path9));
|
|
26562
26782
|
} catch (err) {
|
|
26563
26783
|
renderFailure(err);
|
|
26564
26784
|
}
|
|
@@ -26870,19 +27090,19 @@ function parseWorkflowText(text) {
|
|
|
26870
27090
|
return { error: `The file is not valid JSON: ${error.message}` };
|
|
26871
27091
|
}
|
|
26872
27092
|
}
|
|
26873
|
-
async function readDocument(
|
|
26874
|
-
if (!
|
|
27093
|
+
async function readDocument(path9) {
|
|
27094
|
+
if (!path9) return { error: "Pass the workflow document with --file <path> (JSON)" };
|
|
26875
27095
|
let text;
|
|
26876
27096
|
try {
|
|
26877
|
-
const buffer = await readFile5(
|
|
27097
|
+
const buffer = await readFile5(path9);
|
|
26878
27098
|
if (buffer.length > FILE_MAX_BYTES2) {
|
|
26879
27099
|
return {
|
|
26880
|
-
error: `${
|
|
27100
|
+
error: `${path9} is ${buffer.length} bytes; a workflow document is at most 64 KiB as JSON`
|
|
26881
27101
|
};
|
|
26882
27102
|
}
|
|
26883
27103
|
text = buffer.toString("utf8");
|
|
26884
27104
|
} catch (error) {
|
|
26885
|
-
return { error: `Unable to read ${
|
|
27105
|
+
return { error: `Unable to read ${path9}: ${error.message}` };
|
|
26886
27106
|
}
|
|
26887
27107
|
return parseWorkflowText(text);
|
|
26888
27108
|
}
|
|
@@ -26898,9 +27118,9 @@ function stepKey(value) {
|
|
|
26898
27118
|
}
|
|
26899
27119
|
return trimmed;
|
|
26900
27120
|
}
|
|
26901
|
-
async function read2(
|
|
27121
|
+
async function read2(path9) {
|
|
26902
27122
|
try {
|
|
26903
|
-
printResult(await apiGet(
|
|
27123
|
+
printResult(await apiGet(path9));
|
|
26904
27124
|
} catch (err) {
|
|
26905
27125
|
renderFailure(err);
|
|
26906
27126
|
}
|
|
@@ -27040,10 +27260,29 @@ var listCommand8 = new Command146("list").description(
|
|
|
27040
27260
|
const query4 = params.toString();
|
|
27041
27261
|
await read2(withChainId(`/api/projects/${projectId}/workflows${query4 ? `?${query4}` : ""}`));
|
|
27042
27262
|
});
|
|
27043
|
-
var showCommand5 = new Command146("show").description(
|
|
27263
|
+
var showCommand5 = new Command146("show").description(
|
|
27264
|
+
"Show a workflow, its validated document, its newest runs and, for one made from a template, `workflow.templateUpdate` (the version it has, the template's latest and `available`); when an update is available a `note` says how to apply it (free)"
|
|
27265
|
+
).argument("<workflowId>", "Workflow id").action(async (value) => {
|
|
27266
|
+
const id = uuid(value, "workflow");
|
|
27267
|
+
if (typeof id !== "string") return void printError(id.error);
|
|
27268
|
+
try {
|
|
27269
|
+
const shown = await apiGet(`/api/project-workflows/${id}`);
|
|
27270
|
+
const update = shown.workflow?.templateUpdate;
|
|
27271
|
+
printResult(update?.available ? { ...shown, note: updateNote(id, update) } : shown);
|
|
27272
|
+
} catch (err) {
|
|
27273
|
+
renderFailure(err);
|
|
27274
|
+
}
|
|
27275
|
+
});
|
|
27276
|
+
var updateTemplateCommand = new Command146("update-template").description(
|
|
27277
|
+
"Apply the newest version of the template a workflow was made from, as the project owner: the document is made again from the template with the workflow's own parameter values and checked against the project, like a new workflow. It never happens on its own; `workflow show` says when an update is available. Runs already started keep the version they started with. Costs 0.001 in the payment token"
|
|
27278
|
+
).argument("<workflowId>", "Workflow id").action(async (value) => {
|
|
27044
27279
|
const id = uuid(value, "workflow");
|
|
27045
27280
|
if (typeof id !== "string") return void printError(id.error);
|
|
27046
|
-
await
|
|
27281
|
+
await postProjectWrite(
|
|
27282
|
+
`/api/project-workflows/${id}/update-template`,
|
|
27283
|
+
{ workflowId: id },
|
|
27284
|
+
{ maxAmount: ACTION_FEE_MAX_AMOUNT }
|
|
27285
|
+
);
|
|
27047
27286
|
});
|
|
27048
27287
|
var runsCommand = new Command146("runs").description("Page through a workflow's runs, newest first (free)").argument("<workflowId>", "Workflow id").option("--limit <count>", "Runs per page (1-100, default 20)").option("--cursor <cursor>", "nextCursor from the previous page").action(async (value, opts) => {
|
|
27049
27288
|
const id = uuid(value, "workflow");
|
|
@@ -27124,13 +27363,13 @@ var deleteCommand3 = new Command146("delete").description(
|
|
|
27124
27363
|
{ maxAmount: ACTION_FEE_MAX_AMOUNT }
|
|
27125
27364
|
);
|
|
27126
27365
|
});
|
|
27127
|
-
async function ownerGet(
|
|
27366
|
+
async function ownerGet(path9) {
|
|
27128
27367
|
const auth = await signReadAuth();
|
|
27129
|
-
return apiGet(
|
|
27368
|
+
return apiGet(path9, { headers: auth?.headers ?? {} });
|
|
27130
27369
|
}
|
|
27131
|
-
async function ownerRead(
|
|
27370
|
+
async function ownerRead(path9) {
|
|
27132
27371
|
try {
|
|
27133
|
-
printResult(await ownerGet(
|
|
27372
|
+
printResult(await ownerGet(path9));
|
|
27134
27373
|
} catch (err) {
|
|
27135
27374
|
renderFailure(err);
|
|
27136
27375
|
}
|
|
@@ -27218,7 +27457,7 @@ var workflowCommand = new Command146("workflow").description(
|
|
|
27218
27457
|
"retry",
|
|
27219
27458
|
"Retry a failed step the run waits on, as a new attempt, as the owner; a forEach that failed over_budget recounts its list, and one that failed too_many_items is refused (costs 0.001 in the payment token)"
|
|
27220
27459
|
)
|
|
27221
|
-
).addCommand(cancelCommand2).addCommand(stopAutoPayoutCommand).addCommand(deleteCommand3).addCommand(settingsCommand2).addCommand(payoutCommand).addCommand(workflowTemplateCommand);
|
|
27460
|
+
).addCommand(cancelCommand2).addCommand(stopAutoPayoutCommand).addCommand(updateTemplateCommand).addCommand(deleteCommand3).addCommand(settingsCommand2).addCommand(payoutCommand).addCommand(workflowTemplateCommand);
|
|
27222
27461
|
|
|
27223
27462
|
// src/commands/drops.ts
|
|
27224
27463
|
import { Command as Command147 } from "commander";
|
|
@@ -27431,7 +27670,7 @@ var attachmentConfigCommand = new Command148("attachment-config").description(
|
|
|
27431
27670
|
var hooksCommand = new Command148("hooks").description("Browse the hook registry on the selected --network").addCommand(listCommand10).addCommand(showCommand7).addCommand(encodeConfigCommand).addCommand(attachmentConfigCommand);
|
|
27432
27671
|
|
|
27433
27672
|
// src/commands/tap.ts
|
|
27434
|
-
import { promises as
|
|
27673
|
+
import { promises as fs12 } from "fs";
|
|
27435
27674
|
import { Command as Command149 } from "commander";
|
|
27436
27675
|
var tapCommand = new Command149("tap").description(
|
|
27437
27676
|
"Manage the TAP signing key used on tasks that require TAP verification"
|
|
@@ -27453,7 +27692,7 @@ tapCommand.command("import").description(
|
|
|
27453
27692
|
try {
|
|
27454
27693
|
const keyId = validateTapKeyId(opts.keyId);
|
|
27455
27694
|
const signatureAgent = opts.signatureAgent === void 0 ? void 0 : validateTapSignatureAgent(opts.signatureAgent);
|
|
27456
|
-
const text = opts.keyFile === "-" ? await textOrStdin("-") : await
|
|
27695
|
+
const text = opts.keyFile === "-" ? await textOrStdin("-") : await fs12.readFile(opts.keyFile, "utf8");
|
|
27457
27696
|
if (!text) throw new Error("No TAP key given: pass --key-file <path> or pipe it on stdin");
|
|
27458
27697
|
const key = parseTapPrivateKey(text, opts.alg);
|
|
27459
27698
|
const keystore = await loadKeystore();
|