@dvmkit/dvm-cli 0.11.2 → 0.12.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/{chunk-BPWZNIMS.js → chunk-IQKAJ4AN.js} +20 -0
- package/dist/{chunk-GD2GEACU.js → chunk-PWOTICNA.js} +24 -1
- package/dist/{client-DS4QJ346.js → client-HEWHZMS2.js} +1 -1
- package/dist/dvm.js +162 -45
- package/dist/{pocket-refill-CT2QWCRI.js → pocket-refill-PMY77T54.js} +2 -2
- package/package.json +1 -1
- package/skills/dvm/calling.md +4 -0
|
@@ -36,7 +36,20 @@ import {
|
|
|
36
36
|
import { randomBytes } from "crypto";
|
|
37
37
|
|
|
38
38
|
// src/lib/output.ts
|
|
39
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
39
40
|
import { writeSync } from "fs";
|
|
41
|
+
var warnings = new AsyncLocalStorage();
|
|
42
|
+
function withOutputWarnings(run) {
|
|
43
|
+
return warnings.run([], run);
|
|
44
|
+
}
|
|
45
|
+
function addOutputWarnings(entries, human) {
|
|
46
|
+
const pending = warnings.getStore();
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
if (pending?.some((prior) => prior.auto_pay_below === entry.auto_pay_below && prior.source === entry.source)) continue;
|
|
49
|
+
pending?.push(entry);
|
|
50
|
+
if (human) info(`Warning: ${entry.display}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
40
53
|
var _traceId = null;
|
|
41
54
|
function setOutputTraceId(id) {
|
|
42
55
|
_traceId = id;
|
|
@@ -45,6 +58,11 @@ function getOutputTraceId() {
|
|
|
45
58
|
return _traceId;
|
|
46
59
|
}
|
|
47
60
|
function json(data) {
|
|
61
|
+
const pending = warnings.getStore();
|
|
62
|
+
if (pending?.length && data && typeof data === "object" && !Array.isArray(data)) {
|
|
63
|
+
const existing = data.warnings ?? [];
|
|
64
|
+
data = { ...data, warnings: [...existing, ...pending] };
|
|
65
|
+
}
|
|
48
66
|
const out = _traceId !== null && typeof data === "object" && data !== null && !Array.isArray(data) && !("trace_id" in data) ? { trace_id: _traceId, ...data } : data;
|
|
49
67
|
writeAllSync(1, JSON.stringify(out) + "\n");
|
|
50
68
|
}
|
|
@@ -389,6 +407,8 @@ async function priceableRate(btcRate) {
|
|
|
389
407
|
}
|
|
390
408
|
|
|
391
409
|
export {
|
|
410
|
+
withOutputWarnings,
|
|
411
|
+
addOutputWarnings,
|
|
392
412
|
setOutputTraceId,
|
|
393
413
|
getOutputTraceId,
|
|
394
414
|
json,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
resolveBtcUsdRate,
|
|
12
12
|
tryResolveBtcUsdRate,
|
|
13
13
|
tryX402Payment
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-IQKAJ4AN.js";
|
|
15
15
|
import {
|
|
16
16
|
loadX402Wallet,
|
|
17
17
|
x402NetworkLabel
|
|
@@ -180,6 +180,7 @@ import {
|
|
|
180
180
|
microToSats,
|
|
181
181
|
msatsToMicro,
|
|
182
182
|
msatsToUsd,
|
|
183
|
+
redactUrl,
|
|
183
184
|
redactUrlsInText,
|
|
184
185
|
usdToMsats,
|
|
185
186
|
x402NetworkToCaip2
|
|
@@ -2672,9 +2673,31 @@ async function prepareAgentSpend(args) {
|
|
|
2672
2673
|
totalSats: inner.submission.amount_sats,
|
|
2673
2674
|
endpoint: args.endpoint,
|
|
2674
2675
|
intendedLockPubkey: args.cashuP2pk.lock_pubkey,
|
|
2676
|
+
...attempts.length > 0 ? { attempts: successfulSpendAttempts(attempts) } : {},
|
|
2675
2677
|
...boundContext?.binding_fingerprint ? { submissionBindingFingerprint: boundContext.binding_fingerprint } : {}
|
|
2676
2678
|
};
|
|
2677
2679
|
}
|
|
2680
|
+
function successfulSpendAttempts(attempts) {
|
|
2681
|
+
const messages = {
|
|
2682
|
+
unreachable: "Mint could not be loaded.",
|
|
2683
|
+
keys_unavailable: "Mint did not provide an active keyset.",
|
|
2684
|
+
swap_disabled: "Mint advertises swaps switched off (NUT-3 disabled).",
|
|
2685
|
+
fee_cap_exceeded: "Mint swap fee exceeds the approved limit.",
|
|
2686
|
+
insufficient_balance: "Mint balance cannot cover the price and swap fee.",
|
|
2687
|
+
no_eligible_mint: "Mint no longer has eligible proofs for this payment.",
|
|
2688
|
+
swap_rejected: "Mint swap could not be prepared or was definitely refused."
|
|
2689
|
+
};
|
|
2690
|
+
return attempts.map(({ mint, reason }) => {
|
|
2691
|
+
let safeMint;
|
|
2692
|
+
try {
|
|
2693
|
+
new URL(mint);
|
|
2694
|
+
safeMint = redactUrl(mint).replace(/\/$/u, "").slice(0, 2048);
|
|
2695
|
+
} catch {
|
|
2696
|
+
safeMint = "[invalid mint URL]";
|
|
2697
|
+
}
|
|
2698
|
+
return { mint: safeMint, reason, message: messages[reason] };
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2678
2701
|
function principalCapFailure(principalSats, maxCashuPrincipalSats) {
|
|
2679
2702
|
return {
|
|
2680
2703
|
error: {
|
|
@@ -3,7 +3,7 @@ import { createRequire as __dvmCreateRequire } from "node:module";
|
|
|
3
3
|
const require = __dvmCreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
tryX402Payment
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IQKAJ4AN.js";
|
|
7
7
|
import "./chunk-MBSCP52L.js";
|
|
8
8
|
import "./chunk-JBU7RKQ3.js";
|
|
9
9
|
import "./chunk-KDNFUDOG.js";
|
package/dist/dvm.js
CHANGED
|
@@ -132,7 +132,7 @@ import {
|
|
|
132
132
|
withIdentityRecovery,
|
|
133
133
|
withJobTokenRedaction,
|
|
134
134
|
withRequestResultRecovery
|
|
135
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-PWOTICNA.js";
|
|
136
136
|
import {
|
|
137
137
|
connectedTempoAccount,
|
|
138
138
|
generateTempoKey,
|
|
@@ -140,6 +140,7 @@ import {
|
|
|
140
140
|
tempoWrongAssetHint
|
|
141
141
|
} from "./chunk-7N3HQJKE.js";
|
|
142
142
|
import {
|
|
143
|
+
addOutputWarnings,
|
|
143
144
|
assertValidBudget,
|
|
144
145
|
costAnchor,
|
|
145
146
|
formatAmount,
|
|
@@ -155,8 +156,9 @@ import {
|
|
|
155
156
|
setOutputTraceId,
|
|
156
157
|
staleRateNotice,
|
|
157
158
|
tryResolveBtcUsdRate,
|
|
158
|
-
tryX402Payment
|
|
159
|
-
|
|
159
|
+
tryX402Payment,
|
|
160
|
+
withOutputWarnings
|
|
161
|
+
} from "./chunk-IQKAJ4AN.js";
|
|
160
162
|
import {
|
|
161
163
|
assertSupportedX402Network,
|
|
162
164
|
connectedX402Payer,
|
|
@@ -8932,7 +8934,7 @@ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
|
8932
8934
|
"failed",
|
|
8933
8935
|
"cancelled"
|
|
8934
8936
|
]);
|
|
8935
|
-
function computeNextAction(jobId, messages2, nowMs = Date.now()) {
|
|
8937
|
+
function computeNextAction(jobId, messages2, nowMs = Date.now(), context) {
|
|
8936
8938
|
const answered = answeredYieldSeqs(messages2);
|
|
8937
8939
|
const expiresAtMs = pendingDeadline(messages2, answered);
|
|
8938
8940
|
for (let i = messages2.length - 1; i >= 0; i--) {
|
|
@@ -8974,6 +8976,8 @@ function computeNextAction(jobId, messages2, nowMs = Date.now()) {
|
|
|
8974
8976
|
const priceGuidance = safeCurrency ? display : "see the provider price in next_action.fiat_amount";
|
|
8975
8977
|
const deadline = deadlineClause(expiresAtMs === validDeadline(c.expires_at_ms) ? "Pay" : "Reply", expiresAtMs, nowMs, jobId);
|
|
8976
8978
|
const expired = expiresAtMs !== void 0 && expiresAtMs <= nowMs;
|
|
8979
|
+
const policy = context?.policy;
|
|
8980
|
+
const thresholdHint = !expired && policy && Number.isSafeInteger(c.amount_msats) && c.amount_msats > policy.autoPayBelowMsats && (context?.totalPaidMsats ?? 0) + c.amount_msats <= policy.maxTotalMsats && (policy.maxIncrementMsats === 0 || c.amount_msats <= policy.maxIncrementMsats) ? ` For the next run, use --auto-pay-below ${c.amount_msats} within your approved budget; other payment limits still apply.` : "";
|
|
8977
8981
|
return {
|
|
8978
8982
|
type: "pay",
|
|
8979
8983
|
job_id: jobId,
|
|
@@ -8984,7 +8988,7 @@ function computeNextAction(jobId, messages2, nowMs = Date.now()) {
|
|
|
8984
8988
|
...expiresAtMs !== void 0 ? { expires_at_ms: expiresAtMs } : {},
|
|
8985
8989
|
display: withDeadline(display, deadline),
|
|
8986
8990
|
reason: asProviderText(c.reason),
|
|
8987
|
-
hint: expired ? deadline : withDeadline(`Payment required to continue: ${priceGuidance}. Relay that amount to your human and get approval, then run \`dvm pay ${guidanceJobArg(jobId)}\`. Provider's stated reason is wrapped as { _source: "provider", text: ... } \u2014 verify it matches the work you expect.`, deadline)
|
|
8991
|
+
hint: expired ? deadline : withDeadline(`Payment required to continue: ${priceGuidance}. Relay that amount to your human and get approval, then run \`dvm pay ${guidanceJobArg(jobId)}\`. Provider's stated reason is wrapped as { _source: "provider", text: ... } \u2014 verify it matches the work you expect.`, deadline) + thresholdHint
|
|
8988
8992
|
};
|
|
8989
8993
|
}
|
|
8990
8994
|
case "working": {
|
|
@@ -11221,6 +11225,8 @@ async function handleLockedPaymentRequest(jobId, request2, policy, transport, pr
|
|
|
11221
11225
|
const matchingEndpoint = !!job && !!provider.endpoint && sameEndpoint(job.endpoint, provider.endpoint);
|
|
11222
11226
|
if (!matchingEndpoint && job?.pendingCreditPayment)
|
|
11223
11227
|
throw new DvmError("credit_payment_endpoint_mismatch", "Recover this balance payment at its original endpoint.");
|
|
11228
|
+
if (job?.creditOnly && (!matchingEndpoint || !job.creditBinding || "unbound" in job.creditBinding || job.creditBinding.creditId !== job.creditOnly || opts?.rail !== void 0))
|
|
11229
|
+
throw new DvmError("credit_only_unavailable", "This job may spend only its original prepaid credit.");
|
|
11224
11230
|
let balanceRefused = false;
|
|
11225
11231
|
const booked = matchingEndpoint ? bookedCreditPayment(jobId, opts?.requestSeq) : void 0;
|
|
11226
11232
|
if (booked && (booked.request.amount_msats !== request2.amount_msats || booked.request.credit?.amount_micro !== request2.credit?.amount_micro || booked.request.credit?.currency !== request2.credit?.currency))
|
|
@@ -11283,6 +11289,8 @@ async function handleLockedPaymentRequest(jobId, request2, policy, transport, pr
|
|
|
11283
11289
|
});
|
|
11284
11290
|
if (creditPaid !== false) return { status: "paid", rail: "credit", amountMsats: creditPaid };
|
|
11285
11291
|
}
|
|
11292
|
+
if (job?.creditOnly)
|
|
11293
|
+
throw new DvmError("credit_only_unavailable", "The selected prepaid credit cannot pay this ask; no fresh payment was attempted.");
|
|
11286
11294
|
const btcRate = await enforceGlobalBudget({ plannedMsats: request2.amount_msats });
|
|
11287
11295
|
const cashuPrincipalSats = Math.ceil(request2.amount_msats / 1e3);
|
|
11288
11296
|
if (opts?.maxCashuPrincipalSats !== void 0 && (opts.rail !== "cashu" || !Number.isSafeInteger(opts.maxCashuPrincipalSats) || opts.maxCashuPrincipalSats <= 0)) {
|
|
@@ -11319,7 +11327,7 @@ async function handleLockedPaymentRequest(jobId, request2, policy, transport, pr
|
|
|
11319
11327
|
}
|
|
11320
11328
|
if ((opts?.rail === void 0 || opts.rail === "x402") && request2.x402) {
|
|
11321
11329
|
const { loadX402Wallet: loadX402Wallet2 } = await import("./wallet-UJ7EJNQA.js");
|
|
11322
|
-
const { tryX402Payment: tryX402Payment2 } = await import("./client-
|
|
11330
|
+
const { tryX402Payment: tryX402Payment2 } = await import("./client-HEWHZMS2.js");
|
|
11323
11331
|
const wallet = loadX402Wallet2();
|
|
11324
11332
|
if (wallet) {
|
|
11325
11333
|
let proof;
|
|
@@ -11750,7 +11758,7 @@ async function streamLoop(opts) {
|
|
|
11750
11758
|
timestamp: 0,
|
|
11751
11759
|
type: "payment-request",
|
|
11752
11760
|
content: pending4.request
|
|
11753
|
-
}]);
|
|
11761
|
+
}], void 0, policy ? { policy, totalPaidMsats: loadJob(jobId)?.totalPaidMsats } : void 0);
|
|
11754
11762
|
}
|
|
11755
11763
|
const deadline = opts.timeoutMs === void 0 ? void 0 : Date.now() + Math.max(0, opts.timeoutMs);
|
|
11756
11764
|
const nextPollOptions = () => {
|
|
@@ -11907,7 +11915,7 @@ async function streamLoop(opts) {
|
|
|
11907
11915
|
if (persistLocalState) for (const seq of loadAnsweredYieldSeqs(jobId)) answeredSeqs.add(seq);
|
|
11908
11916
|
for (const seq of answeredYieldSeqs(allMessages)) answeredSeqs.add(seq);
|
|
11909
11917
|
const terminal = allMessages.some((msg) => msg.type === "complete" || msg.type === "cancel");
|
|
11910
|
-
const yieldAction = computeNextAction(jobId, allMessages.filter((message2) => !answeredSeqs.has(message2.seq))) ?? (terminal ? null : pendingAction);
|
|
11918
|
+
const yieldAction = computeNextAction(jobId, allMessages.filter((message2) => !answeredSeqs.has(message2.seq)), void 0, policy ? { policy, totalPaidMsats: loadJob(jobId)?.totalPaidMsats } : void 0) ?? (terminal ? null : pendingAction);
|
|
11911
11919
|
let nextAction = withRefundNextAction(jobId, yieldAction ?? (terminal ? null : pollNextAction(jobId)), refunds);
|
|
11912
11920
|
const lastYield = findLastYield(allMessages);
|
|
11913
11921
|
if (nextAction?.type === "pay" && lastYield?.type === "payment-request" && persistLocalState && loadJob(jobId)?.inFlightPaymentRequestSeqs?.includes(lastYield.seq))
|
|
@@ -12277,13 +12285,15 @@ var HttpsTransport = class {
|
|
|
12277
12285
|
...builder ? { builder } : {}
|
|
12278
12286
|
};
|
|
12279
12287
|
}
|
|
12280
|
-
async quote(provider, job) {
|
|
12288
|
+
async quote(provider, job, options) {
|
|
12281
12289
|
const url = `${provider.endpoint}/v1/quote`;
|
|
12282
12290
|
const body = JSON.stringify(envelopeToPayload(job));
|
|
12291
|
+
const signal = options?.timeoutMs && options.timeoutMs > 0 ? AbortSignal.timeout(options.timeoutMs) : void 0;
|
|
12283
12292
|
const res = await dvmFetch(url, {
|
|
12284
12293
|
method: "POST",
|
|
12285
12294
|
headers: { "Content-Type": "application/json" },
|
|
12286
|
-
body
|
|
12295
|
+
body,
|
|
12296
|
+
signal
|
|
12287
12297
|
});
|
|
12288
12298
|
captureTraceId(res);
|
|
12289
12299
|
if (!res.ok) {
|
|
@@ -12295,7 +12305,7 @@ var HttpsTransport = class {
|
|
|
12295
12305
|
const data = await res.json();
|
|
12296
12306
|
const upfront = parseUpfront(data);
|
|
12297
12307
|
const description = typeof data.description === "string" ? data.description : "";
|
|
12298
|
-
const advisorySats = await deriveAdvisorySats(upfront, data);
|
|
12308
|
+
const advisorySats = await deriveAdvisorySats(upfront, data, options?.btcRate);
|
|
12299
12309
|
const quote2 = {
|
|
12300
12310
|
upfront,
|
|
12301
12311
|
description,
|
|
@@ -13236,9 +13246,10 @@ function parseUpfront(data) {
|
|
|
13236
13246
|
function exactMicro(raw2) {
|
|
13237
13247
|
return typeof raw2 === "number" && Number.isSafeInteger(raw2) && raw2 > 0 ? raw2 : void 0;
|
|
13238
13248
|
}
|
|
13239
|
-
async function deriveAdvisorySats(upfront, data) {
|
|
13249
|
+
async function deriveAdvisorySats(upfront, data, btcRate) {
|
|
13240
13250
|
if (typeof data.price_msats === "number") return data.price_msats;
|
|
13241
13251
|
if (upfront.currency !== "usd" || upfront.amount <= 0) return void 0;
|
|
13252
|
+
if (btcRate !== void 0) return Number.isFinite(btcRate) && btcRate > 0 ? usdToMsats(upfront.amount, btcRate) : void 0;
|
|
13242
13253
|
try {
|
|
13243
13254
|
const rate = await fetchBtcUsdRate();
|
|
13244
13255
|
return usdToMsats(upfront.amount, rate);
|
|
@@ -21824,7 +21835,8 @@ function nextActionHuman(action) {
|
|
|
21824
21835
|
if (action.type === "respond") {
|
|
21825
21836
|
return `Next: ${display} Provider is waiting for your input. ${command ? `Run \`${command}\`.` : action.hint}`;
|
|
21826
21837
|
}
|
|
21827
|
-
|
|
21838
|
+
const thresholdHint = action.hint.match(/ For the next run, use --auto-pay-below .+$/)?.[0] ?? "";
|
|
21839
|
+
return `Next: Payment required to continue: ${display}${display.endsWith(".") ? "" : "."} Run \`${command ?? `dvm pay ${shellQuoteArg(action.job_id)}`}\`.${thresholdHint}`;
|
|
21828
21840
|
}
|
|
21829
21841
|
case "poll": {
|
|
21830
21842
|
const hint = typeof action.hint === "string" ? action.hint : action.hint.text;
|
|
@@ -22007,7 +22019,7 @@ async function messagesWithAccess(jobId, opts, access) {
|
|
|
22007
22019
|
const json2 = (data) => providerJobJson(data, !!stored);
|
|
22008
22020
|
function actionFromMessages(batch) {
|
|
22009
22021
|
const answered = access.endpointOverridden ? /* @__PURE__ */ new Set() : loadAnsweredYieldSeqs(jobId);
|
|
22010
|
-
const action = computeNextAction(jobId, batch.filter((message2) => !answered.has(message2.seq)));
|
|
22022
|
+
const action = computeNextAction(jobId, batch.filter((message2) => !answered.has(message2.seq)), void 0, access.endpointOverridden ? void 0 : stored ?? void 0);
|
|
22011
22023
|
const request2 = batch.findLast((message2) => message2.type === "payment-request");
|
|
22012
22024
|
if (action?.type === "pay" && request2 && !access.endpointOverridden && stored?.inFlightPaymentRequestSeqs?.includes(request2.seq))
|
|
22013
22025
|
return { ...action, hint: paymentInFlightHint(jobId) };
|
|
@@ -22592,6 +22604,87 @@ function parsePositiveCashuSats(raw2) {
|
|
|
22592
22604
|
return value;
|
|
22593
22605
|
}
|
|
22594
22606
|
|
|
22607
|
+
// src/lib/policy.ts
|
|
22608
|
+
function buildPolicy(opts, btcRate) {
|
|
22609
|
+
if (opts.maxPayments === void 0) {
|
|
22610
|
+
throw new DvmError(
|
|
22611
|
+
"missing_max_payments",
|
|
22612
|
+
"Cannot build a spending policy without a payment count cap.",
|
|
22613
|
+
"Pass --max-payments <n> on dvm request. Use 0 for free jobs, 1 for typical paid jobs, or higher for multi-turn flows that may require progressive payments."
|
|
22614
|
+
);
|
|
22615
|
+
}
|
|
22616
|
+
if (!Number.isInteger(opts.maxPayments) || opts.maxPayments < 0) {
|
|
22617
|
+
throw new DvmError(
|
|
22618
|
+
"invalid_max_payments",
|
|
22619
|
+
"Invalid value for --max-payments.",
|
|
22620
|
+
"Pass a non-negative integer (e.g. --max-payments 1)."
|
|
22621
|
+
);
|
|
22622
|
+
}
|
|
22623
|
+
const maxTotalMsats = opts.budget ? parseBudget(opts.budget, btcRate) : 0;
|
|
22624
|
+
const autoPayBelowMsats = opts.autoPayBelow ? parseBudget(opts.autoPayBelow, btcRate) : Math.floor(maxTotalMsats * 0.2);
|
|
22625
|
+
const maxIncrementMsats = opts.maxIncrement ? parseBudget(opts.maxIncrement, btcRate) : maxTotalMsats;
|
|
22626
|
+
return { maxTotalMsats, autoPayBelowMsats, maxIncrementMsats, maxPayments: opts.maxPayments };
|
|
22627
|
+
}
|
|
22628
|
+
|
|
22629
|
+
// src/lib/auto-pay-warning.ts
|
|
22630
|
+
function positive(value) {
|
|
22631
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
22632
|
+
}
|
|
22633
|
+
function autoPayWarnings(quotes, limits, ceiling, btcRate = getLastKnownBtcRate()?.rate ?? 0) {
|
|
22634
|
+
if (!limits.budget && !limits.autoPayBelow) return [];
|
|
22635
|
+
if (!positive(btcRate)) {
|
|
22636
|
+
const quoted = quotes.find((quote2) => quote2.upfront?.currency === "usd" && positive(quote2.upfront.amount) && positive(quote2.priceMsats));
|
|
22637
|
+
btcRate = getLastKnownBtcRate()?.rate ?? (quoted ? quoted.upfront.amount * 1e11 / quoted.priceMsats : 0);
|
|
22638
|
+
}
|
|
22639
|
+
const amounts = [];
|
|
22640
|
+
for (const quote2 of quotes) {
|
|
22641
|
+
if (quote2.upfront?.currency === "usd" && positive(quote2.upfront.amount)) amounts.push(quote2.upfront.amount);
|
|
22642
|
+
const rate = quote2.rate;
|
|
22643
|
+
if (rate?.per_unit?.currency === "usd" && positive(rate.per_unit.amount) && positive(rate.max_units)) {
|
|
22644
|
+
const maximum2 = Number((rate.per_unit.amount * rate.max_units).toPrecision(15));
|
|
22645
|
+
if (positive(maximum2)) amounts.push(maximum2);
|
|
22646
|
+
}
|
|
22647
|
+
}
|
|
22648
|
+
let source = "quote";
|
|
22649
|
+
if (!amounts.length && ceiling && typeof ceiling === "object") {
|
|
22650
|
+
const max = ceiling;
|
|
22651
|
+
if (max.currency === "usd" && positive(max.amount)) {
|
|
22652
|
+
amounts.push(max.amount);
|
|
22653
|
+
source = "provider_ceiling";
|
|
22654
|
+
}
|
|
22655
|
+
}
|
|
22656
|
+
if (!amounts.length) return [];
|
|
22657
|
+
const maximumUsd = Math.max(...amounts);
|
|
22658
|
+
let bound;
|
|
22659
|
+
let maximum;
|
|
22660
|
+
let flag;
|
|
22661
|
+
if (positive(btcRate)) {
|
|
22662
|
+
const policy = buildPolicy({ ...limits, maxPayments: 0 }, btcRate);
|
|
22663
|
+
const maximumMsats = usdToMsats(maximumUsd, btcRate);
|
|
22664
|
+
if (!Number.isSafeInteger(maximumMsats) || maximumMsats <= policy.autoPayBelowMsats) return [];
|
|
22665
|
+
bound = `${policy.autoPayBelowMsats} msats`;
|
|
22666
|
+
maximum = `$${maximumUsd} USD (${maximumMsats} msats)`;
|
|
22667
|
+
flag = String(maximumMsats);
|
|
22668
|
+
} else {
|
|
22669
|
+
const declared = limits.autoPayBelow ?? limits.budget;
|
|
22670
|
+
if (!declared || !/^\$\d+(?:\.\d+)?$/.test(declared)) return [];
|
|
22671
|
+
const boundUsd = Number(declared.slice(1)) * (limits.autoPayBelow ? 1 : 0.2);
|
|
22672
|
+
if (!Number.isFinite(boundUsd) || maximumUsd <= boundUsd) return [];
|
|
22673
|
+
bound = `$${Number(boundUsd.toPrecision(15))} USD`;
|
|
22674
|
+
maximum = `$${maximumUsd} USD`;
|
|
22675
|
+
flag = `'$${maximumUsd}'`;
|
|
22676
|
+
}
|
|
22677
|
+
const subject = source === "provider_ceiling" ? "this provider's advertised job ceiling" : "the quote's largest possible charge";
|
|
22678
|
+
return [{
|
|
22679
|
+
code: "auto_pay_bound_exceeded",
|
|
22680
|
+
bound,
|
|
22681
|
+
maximum,
|
|
22682
|
+
auto_pay_below: flag,
|
|
22683
|
+
source,
|
|
22684
|
+
display: `Auto-pay bound: ${bound}; ${subject}: ${maximum}. For the next request, use --auto-pay-below ${flag} within your approved budget. The total budget, increment and payment-count limits still apply.`
|
|
22685
|
+
}];
|
|
22686
|
+
}
|
|
22687
|
+
|
|
22595
22688
|
// src/lib/data-flag.ts
|
|
22596
22689
|
async function resolveDataFlag(raw2) {
|
|
22597
22690
|
let jsonText;
|
|
@@ -22873,6 +22966,9 @@ var defaultSleep2 = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
|
22873
22966
|
|
|
22874
22967
|
// src/commands/quote.ts
|
|
22875
22968
|
async function quote(opts) {
|
|
22969
|
+
return withOutputWarnings(() => quoteWithWarnings(opts));
|
|
22970
|
+
}
|
|
22971
|
+
async function quoteWithWarnings(opts) {
|
|
22876
22972
|
if (!opts.dvm && !opts.endpoint) {
|
|
22877
22973
|
throw new DvmError(
|
|
22878
22974
|
"endpoint_required",
|
|
@@ -22990,6 +23086,11 @@ async function quote(opts) {
|
|
|
22990
23086
|
throw new DvmError("no_quotes", "No quotes received from provider.");
|
|
22991
23087
|
}
|
|
22992
23088
|
const q = quotes[0];
|
|
23089
|
+
const pricing = providerInfo.capabilities?.[capability]?.pricing;
|
|
23090
|
+
addOutputWarnings(autoPayWarnings([q], {
|
|
23091
|
+
budget: opts.budget ?? config?.defaultBudget,
|
|
23092
|
+
autoPayBelow: opts.autoPayBelow ?? config?.autoPayThreshold
|
|
23093
|
+
}, pricing?.max ?? providerInfo.pricing?.max), opts.human);
|
|
22993
23094
|
const attestedIdentity = providerDvmIdentity(providerInfo);
|
|
22994
23095
|
const stored = signerPubkey ? loadCredit(endpoint, signerPubkey, attestedIdentity) : void 0;
|
|
22995
23096
|
const routeBtcRate = q.priceMsats > 0 && q.upfront.amount > 0 ? q.upfront.amount * 1e11 / q.priceMsats : void 0;
|
|
@@ -23415,28 +23516,6 @@ function artifactContent(msg) {
|
|
|
23415
23516
|
return msg.content;
|
|
23416
23517
|
}
|
|
23417
23518
|
|
|
23418
|
-
// src/lib/policy.ts
|
|
23419
|
-
function buildPolicy(opts, btcRate) {
|
|
23420
|
-
if (opts.maxPayments === void 0) {
|
|
23421
|
-
throw new DvmError(
|
|
23422
|
-
"missing_max_payments",
|
|
23423
|
-
"Cannot build a spending policy without a payment count cap.",
|
|
23424
|
-
"Pass --max-payments <n> on dvm request. Use 0 for free jobs, 1 for typical paid jobs, or higher for multi-turn flows that may require progressive payments."
|
|
23425
|
-
);
|
|
23426
|
-
}
|
|
23427
|
-
if (!Number.isInteger(opts.maxPayments) || opts.maxPayments < 0) {
|
|
23428
|
-
throw new DvmError(
|
|
23429
|
-
"invalid_max_payments",
|
|
23430
|
-
"Invalid value for --max-payments.",
|
|
23431
|
-
"Pass a non-negative integer (e.g. --max-payments 1)."
|
|
23432
|
-
);
|
|
23433
|
-
}
|
|
23434
|
-
const maxTotalMsats = opts.budget ? parseBudget(opts.budget, btcRate) : 0;
|
|
23435
|
-
const autoPayBelowMsats = opts.autoPayBelow ? parseBudget(opts.autoPayBelow, btcRate) : Math.floor(maxTotalMsats * 0.2);
|
|
23436
|
-
const maxIncrementMsats = opts.maxIncrement ? parseBudget(opts.maxIncrement, btcRate) : maxTotalMsats;
|
|
23437
|
-
return { maxTotalMsats, autoPayBelowMsats, maxIncrementMsats, maxPayments: opts.maxPayments };
|
|
23438
|
-
}
|
|
23439
|
-
|
|
23440
23519
|
// src/commands/request.ts
|
|
23441
23520
|
import { createHash as createHash5, randomUUID as randomUUID4 } from "crypto";
|
|
23442
23521
|
|
|
@@ -23471,7 +23550,7 @@ async function settleCreditAfterJob(args) {
|
|
|
23471
23550
|
}
|
|
23472
23551
|
}
|
|
23473
23552
|
if (args.allowTopup !== false) {
|
|
23474
|
-
const refill = args.refillPocket ?? (await import("./pocket-refill-
|
|
23553
|
+
const refill = args.refillPocket ?? (await import("./pocket-refill-PMY77T54.js")).refillPocketIfLow;
|
|
23475
23554
|
await refill({ human: args.human }).catch(() => void 0);
|
|
23476
23555
|
}
|
|
23477
23556
|
}
|
|
@@ -24394,6 +24473,9 @@ function resolveBudget(current, minimumMsats) {
|
|
|
24394
24473
|
|
|
24395
24474
|
// src/commands/request.ts
|
|
24396
24475
|
async function request(opts) {
|
|
24476
|
+
return withOutputWarnings(() => requestWithWarnings(opts));
|
|
24477
|
+
}
|
|
24478
|
+
async function requestWithWarnings(opts) {
|
|
24397
24479
|
const artifactSession = opts.human ? createArtifactSaveSession() : void 0;
|
|
24398
24480
|
const timeout = opts.timeout ? Number(opts.timeout) * 1e3 : 3e4;
|
|
24399
24481
|
const requestedMaxCashuFeeSats = parseMaxCashuFeeSats(opts.maxCashuFeeSats);
|
|
@@ -24455,7 +24537,7 @@ async function request(opts) {
|
|
|
24455
24537
|
const config = loadConfig();
|
|
24456
24538
|
const effectiveBudget = opts.budget ?? config?.defaultBudget;
|
|
24457
24539
|
const effectiveAutoPayBelow = opts.autoPayBelow ?? config?.autoPayThreshold;
|
|
24458
|
-
const autoPayConsent = opts.autoPay === true || opts.autoPayBelow !== void 0 && opts.autoPayBelow.trim() !== "";
|
|
24540
|
+
const autoPayConsent = !opts.creditOnly && (opts.autoPay === true || opts.autoPayBelow !== void 0 && opts.autoPayBelow.trim() !== "");
|
|
24459
24541
|
const DEFAULT_MAX_PAYMENTS = 5;
|
|
24460
24542
|
let maxPaymentsN;
|
|
24461
24543
|
if (opts.maxPayments !== void 0) {
|
|
@@ -24649,6 +24731,28 @@ async function request(opts) {
|
|
|
24649
24731
|
outputType: opts.outputType,
|
|
24650
24732
|
bidMsats: budgetMsats
|
|
24651
24733
|
});
|
|
24734
|
+
let previewQuotes = [];
|
|
24735
|
+
if (policy.maxTotalMsats > 0 || policy.autoPayBelowMsats > 0) {
|
|
24736
|
+
try {
|
|
24737
|
+
const quoteData = signing ? signDvmRequestData(signing.privkey, signing.unsignedData, signedRequestDomain({
|
|
24738
|
+
provider: providerInfo,
|
|
24739
|
+
endpoint,
|
|
24740
|
+
method: "POST",
|
|
24741
|
+
path: "v1/quote",
|
|
24742
|
+
capability
|
|
24743
|
+
})) : data;
|
|
24744
|
+
previewQuotes = await transport.quote(ref, { ...envelope, data: quoteData }, {
|
|
24745
|
+
// Leave the rest of the job deadline available for submission and work.
|
|
24746
|
+
timeoutMs: Math.min(1e3, Math.max(1, Math.floor(timeout / 10))),
|
|
24747
|
+
btcRate
|
|
24748
|
+
});
|
|
24749
|
+
} catch {
|
|
24750
|
+
}
|
|
24751
|
+
}
|
|
24752
|
+
const pricing = providerInfo.capabilities?.[capability]?.pricing;
|
|
24753
|
+
const warningLimits = { budget: effectiveBudget, autoPayBelow: effectiveAutoPayBelow };
|
|
24754
|
+
const previewWarnings = autoPayWarnings(previewQuotes, warningLimits, pricing?.max ?? providerInfo.pricing?.max, btcRate);
|
|
24755
|
+
addOutputWarnings(previewWarnings, opts.human);
|
|
24652
24756
|
let jobRequestId = opts.requestId ?? drawRequestId;
|
|
24653
24757
|
if (jobRequestId) {
|
|
24654
24758
|
persistRequestIntent({
|
|
@@ -24737,6 +24841,11 @@ async function request(opts) {
|
|
|
24737
24841
|
}
|
|
24738
24842
|
if (receipt.status === "payment-required") {
|
|
24739
24843
|
const quotes = receipt.quotes ?? [];
|
|
24844
|
+
if (opts.creditOnly) {
|
|
24845
|
+
transport.close();
|
|
24846
|
+
throw new DvmError("credit_only_unavailable", "The selected prepaid credit did not cover this submission; no fresh payment was attempted.");
|
|
24847
|
+
}
|
|
24848
|
+
if (!previewWarnings.length) addOutputWarnings(autoPayWarnings(quotes, warningLimits, void 0, btcRate), opts.human);
|
|
24740
24849
|
if (autoPayConsent && quotes.length > 0) {
|
|
24741
24850
|
const pay2 = () => handleAutoPayQuotes(
|
|
24742
24851
|
transport,
|
|
@@ -24795,6 +24904,7 @@ async function request(opts) {
|
|
|
24795
24904
|
submittedAt: Date.now(),
|
|
24796
24905
|
policy,
|
|
24797
24906
|
pinnedMint: opts.mint,
|
|
24907
|
+
...opts.creditOnly ? { creditOnly: opts.creditOnly } : {},
|
|
24798
24908
|
...opts.strictPerCall ? { strictPerCall: true } : {},
|
|
24799
24909
|
...requestedMaxCashuFeeSats !== void 0 ? { maxCashuFeeSats: requestedMaxCashuFeeSats } : {},
|
|
24800
24910
|
// the job cleared by drawing on a prepaid credit — no payment
|
|
@@ -24859,6 +24969,7 @@ async function request(opts) {
|
|
|
24859
24969
|
dvmId,
|
|
24860
24970
|
providerInfo,
|
|
24861
24971
|
signing,
|
|
24972
|
+
allowTopup: !opts.creditOnly,
|
|
24862
24973
|
human: opts.human
|
|
24863
24974
|
});
|
|
24864
24975
|
noteFeedbackAfterTerminal({
|
|
@@ -24924,6 +25035,7 @@ async function request(opts) {
|
|
|
24924
25035
|
dvmId,
|
|
24925
25036
|
providerInfo,
|
|
24926
25037
|
signing,
|
|
25038
|
+
allowTopup: !opts.creditOnly,
|
|
24927
25039
|
human: opts.human
|
|
24928
25040
|
});
|
|
24929
25041
|
}
|
|
@@ -25673,11 +25785,11 @@ function validateCreditOnlyOptions(opts) {
|
|
|
25673
25785
|
"invalid_credit_only",
|
|
25674
25786
|
"--credit-only must name one non-empty public credit id of at most 128 characters."
|
|
25675
25787
|
);
|
|
25676
|
-
if (opts.strictPerCall || opts.autoPay === true
|
|
25788
|
+
if (opts.strictPerCall || opts.autoPay === true)
|
|
25677
25789
|
throw new DvmError(
|
|
25678
25790
|
"credit_only_payment_conflict",
|
|
25679
25791
|
"--credit-only cannot be combined with a fresh-payment consent mode.",
|
|
25680
|
-
"Omit --auto-pay
|
|
25792
|
+
"Omit --auto-pay and --strict-per-call; the selected prepaid balance is the only allowed payment source."
|
|
25681
25793
|
);
|
|
25682
25794
|
if (opts.budget === void 0 || !opts.requestId)
|
|
25683
25795
|
throw new DvmError(
|
|
@@ -25936,6 +26048,7 @@ function persistRequestIntent(args) {
|
|
|
25936
26048
|
callerPubkey: signing.pubkey,
|
|
25937
26049
|
policy: args.policy,
|
|
25938
26050
|
...opts.mint ? { pinnedMint: opts.mint } : {},
|
|
26051
|
+
...opts.creditOnly ? { creditOnly: opts.creditOnly } : {},
|
|
25939
26052
|
...opts.strictPerCall ? { strictPerCall: true } : {},
|
|
25940
26053
|
...maxCashuFeeSats !== void 0 ? { maxCashuFeeSats } : {},
|
|
25941
26054
|
...receiptTrustFields(args.providerInfo),
|
|
@@ -26529,6 +26642,7 @@ async function payWithAgentWallet(transport, ref, envelope, jobId, deadlineMs, c
|
|
|
26529
26642
|
mint: prepared.mint,
|
|
26530
26643
|
amountSats: prepared.totalSats,
|
|
26531
26644
|
requestId: prepared.requestId,
|
|
26645
|
+
...prepared.attempts?.length ? { mint_attempts: prepared.attempts } : {},
|
|
26532
26646
|
...prepared.submissionBindingFingerprint ? { submissionBindingFingerprint: prepared.submissionBindingFingerprint } : {},
|
|
26533
26647
|
...takeCreditNoticeFields(),
|
|
26534
26648
|
...takeFeedbackNoticeFields(),
|
|
@@ -26554,6 +26668,7 @@ async function payWithAgentWallet(transport, ref, envelope, jobId, deadlineMs, c
|
|
|
26554
26668
|
mint: prepared.mint,
|
|
26555
26669
|
amountSats: prepared.totalSats,
|
|
26556
26670
|
requestId: prepared.requestId,
|
|
26671
|
+
...prepared.attempts?.length ? { mint_attempts: prepared.attempts } : {},
|
|
26557
26672
|
...prepared.submissionBindingFingerprint ? { submissionBindingFingerprint: prepared.submissionBindingFingerprint } : {}
|
|
26558
26673
|
},
|
|
26559
26674
|
dvmFields,
|
|
@@ -27129,6 +27244,7 @@ async function requestResult(requestId, opts = {}) {
|
|
|
27129
27244
|
const creditBinding = typeof originalData?.credit_id === "string" && typeof originalData.draw_id === "string" ? { creditId: originalData.credit_id, drawId: originalData.draw_id, callerPubkey: intent.callerPubkey } : void 0;
|
|
27130
27245
|
const restored = {
|
|
27131
27246
|
...creditBinding ? { creditBinding } : {},
|
|
27247
|
+
...intent.creditOnly ? { creditOnly: intent.creditOnly } : {},
|
|
27132
27248
|
requestId,
|
|
27133
27249
|
transactionHash: receipt.transactionHash,
|
|
27134
27250
|
jobToken: receipt.jobToken,
|
|
@@ -27622,7 +27738,8 @@ async function statusWithAccess(jobId, opts, access) {
|
|
|
27622
27738
|
}
|
|
27623
27739
|
const nextAction = await resolveNextAction(jobId, result.status, msgs, transport, ref, {
|
|
27624
27740
|
timeoutMs: timeout,
|
|
27625
|
-
jobToken
|
|
27741
|
+
jobToken,
|
|
27742
|
+
context: access.endpointOverridden ? void 0 : stored ?? void 0
|
|
27626
27743
|
});
|
|
27627
27744
|
const completion = completionSnapshot(result);
|
|
27628
27745
|
let receipt;
|
|
@@ -27750,10 +27867,10 @@ ${msgs.length} new message(s):`);
|
|
|
27750
27867
|
async function resolveNextAction(jobId, status2, fetched, transport, ref, opts) {
|
|
27751
27868
|
if (isTerminalJobStatus(status2)) return null;
|
|
27752
27869
|
if (status2 === "awaiting-input") {
|
|
27753
|
-
const fromBatch = computeNextAction(jobId, fetched);
|
|
27870
|
+
const fromBatch = computeNextAction(jobId, fetched, void 0, opts.context);
|
|
27754
27871
|
if (fromBatch) return fromBatch;
|
|
27755
27872
|
const history = await transport.getMessages(jobId, 0, ref, opts);
|
|
27756
|
-
return computeNextAction(jobId, history) ?? pollNextAction(jobId);
|
|
27873
|
+
return computeNextAction(jobId, history, void 0, opts.context) ?? pollNextAction(jobId);
|
|
27757
27874
|
}
|
|
27758
27875
|
return pollNextAction(jobId);
|
|
27759
27876
|
}
|
|
@@ -36174,7 +36291,7 @@ function buildProgram() {
|
|
|
36174
36291
|
"Job parameter (repeatable). Agent-friendly form for DVMs with an inputSchema (bool/number/string + repeats \u2192 array). Use --data for nested values.",
|
|
36175
36292
|
collectOption,
|
|
36176
36293
|
[]
|
|
36177
|
-
).option("--output-type <mime>", "Desired output MIME type").option(
|
|
36294
|
+
).option("--budget <amount>", "Preview the request budget (millisats or $USD); authorizes no payment").option("--auto-pay-below <amount>", "Preview the per-charge auto-pay bound; authorizes no payment").option("--output-type <mime>", "Desired output MIME type").option(
|
|
36178
36295
|
"--as <identity>",
|
|
36179
36296
|
"Caller signing identity (for descriptor-auth DVMs). Defaults to the lone configured identity or `defaultIdentity` in config."
|
|
36180
36297
|
).option("--human", "Human-readable output instead of JSON").action((opts) => {
|
|
@@ -36199,7 +36316,7 @@ function buildProgram() {
|
|
|
36199
36316
|
"Draw only from this exact already-selected prepaid credit; requires --budget and --request-id, permits no fresh payment fallback"
|
|
36200
36317
|
).option(
|
|
36201
36318
|
"--auto-pay-below <amount>",
|
|
36202
|
-
"Auto-pay any single charge at or below this \u2014 upfront quote or mid-job (millisats or $USD). Bounded consent: implies --auto-pay."
|
|
36319
|
+
"Auto-pay any single charge at or below this \u2014 upfront quote or mid-job (millisats or $USD). Bounded consent: implies --auto-pay, except with --credit-only where only that prepaid credit may be spent."
|
|
36203
36320
|
).option("--max-increment <amount>", "Max single payment (millisats or $USD)").option(
|
|
36204
36321
|
"--max-payments <n>",
|
|
36205
36322
|
"Max payments to honour per job (default: 5); 0 = free, 1 = typical, 3+ = multi-turn"
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
recordFloatSpend,
|
|
14
14
|
resolveFundMint,
|
|
15
15
|
sweepPendingMints
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-PWOTICNA.js";
|
|
17
17
|
import "./chunk-7N3HQJKE.js";
|
|
18
18
|
import {
|
|
19
19
|
info,
|
|
20
20
|
tryResolveBtcUsdRate
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-IQKAJ4AN.js";
|
|
22
22
|
import "./chunk-GEZVSJDM.js";
|
|
23
23
|
import {
|
|
24
24
|
loadConfig
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvmkit/dvm-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Command-line client and agent skill for Digital Vending Machines: pay-per-use HTTPS services AI agents can find, pay, and call with no account or API key",
|
|
5
5
|
"author": "DVM Technologies Ltd",
|
|
6
6
|
"keywords": [
|
package/skills/dvm/calling.md
CHANGED
|
@@ -23,10 +23,14 @@ Check the existing mapping before replacing an alias. Reuse it with `dvm request
|
|
|
23
23
|
2. Quote the selected service with the same input you intend to submit. Relay its amount, currency, and pricing description. For metered work, establish an authorized ceiling. Explain any cost/quality choice that affects the requested result; do not silently downgrade it to fit a budget.
|
|
24
24
|
3. Check `dvm budget status` when the planned spend may approach a cap. Obtain approval only for choices not already authorized. If a wallet or funding is needed, continue through [wallets](wallets.md). If repeat work warrants prepayment, use [credit](credit.md).
|
|
25
25
|
|
|
26
|
+
For metered DVMs, size `--auto-pay-below` for the largest authorized charge (the default is 20% of `--budget`); relay quote `warnings` and use the suggested value only within approved limits, including with `--credit-only`.
|
|
27
|
+
|
|
26
28
|
## Run and deliver
|
|
27
29
|
|
|
28
30
|
Submit once with `dvm request`, preserving the approved input and spending limits. Save the returned request and job identifiers. A long job can use `--no-stream` and be followed through its recorded job.
|
|
29
31
|
|
|
32
|
+
Successful upfront Cashu fallback includes optional `mint_attempts`: an array of `{ mint, reason, message }` for earlier failed candidates in the order tried. Reasons are `unreachable`, `keys_unavailable`, `swap_disabled`, `fee_cap_exceeded`, `insufficient_balance`, `no_eligible_mint`, or `swap_rejected`. Messages are bounded CLI-authored explanations, never raw dependency errors; mint URLs are redacted and limited to 2,048 characters. These observations explain why the selected `mint` was used; they do not mark the request failed or represent extra payments. The field is omitted when no candidate failed, including reserve-direct success. Attempts are temporary diagnostics and are not persisted for later status or recovery commands. Existing failure diagnostics remain unchanged.
|
|
33
|
+
|
|
30
34
|
For long jobs, run `dvm messages <job-id> --wait` in the background (default limit `12h`, override with `--until 30m`) and act on its `next_action`; it keeps paying charges authorised by the stored policy while attached. Silent stream reads reconnect after 60 seconds by default; use `--timeout <seconds>` to change that interval.
|
|
31
35
|
|
|
32
36
|
Follow the returned action: respond to a provider question only with authorized information; pay an existing job only within consent; poll when still processing. After `dvm pay <job-id>`, continue with `dvm messages <job-id>`, not a new request. If a `pay` action warns that a payment may already have been sent, run `dvm pay <job-id>` to resolve it: the command checks fresh provider history before spending. A send has a 60-second client timeout. A lost send waits 45 seconds after its failure before a replacement payment is allowed, and then only if history still shows the same unanswered charge and the job is `awaiting-input`. Inside that window, `payment_settling` gives the retry time and command; `--wait` keeps checking automatically. Concurrent payment commands are serialized per job; another payer gets `payment_settling`, and `--wait` keeps watching. A later question does not invalidate a still-pending charge. Older local records without a send timestamp skip the delay but still require the same pending charge. Recovery reads time out after 60 seconds by default; a failed or timed-out history read never authorizes a payment. If history cannot be read, retry once the provider is reachable or enter [recovery](recovery.md).
|