@dvmkit/dvm-cli 0.8.2 → 0.9.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-JZPSF4C6.js → chunk-5R3BLFVO.js} +2 -2
- package/dist/{chunk-AGGWYE3D.js → chunk-6XTWANVN.js} +4702 -2214
- package/dist/{chunk-EDK4X4F3.js → chunk-BCDMVIPI.js} +4 -4
- package/dist/{chunk-MULGWPBV.js → chunk-BHR7QHJG.js} +2 -2
- package/dist/{chunk-HY65VFLL.js → chunk-C7ZNQONB.js} +2 -2
- package/dist/{chunk-QPT5KD7H.js → chunk-GD25CUI4.js} +4 -4
- package/dist/{chunk-PKZUEXMJ.js → chunk-HUBCGZJL.js} +10 -2
- package/dist/{chunk-DSNUC4J7.js → chunk-IEWV3CM2.js} +77 -13
- package/dist/{chunk-4U43FVT4.js → chunk-PMPHS3LS.js} +3 -3
- package/dist/{chunk-YJQNDNYK.js → chunk-QDOY3JF2.js} +2 -2
- package/dist/{chunk-7ICHLPOY.js → chunk-XDYBVNFS.js} +3 -3
- package/dist/{chunk-AX6COXU3.js → chunk-Y3X74XH2.js} +110 -57
- package/dist/{client-65B5WQPC.js → client-MMJYIMKJ.js} +6 -6
- package/dist/dvm.js +4693 -4436
- package/dist/{internal-BT3U2FFW.js → internal-LRW4XR3J.js} +5 -5
- package/dist/{lifecycle-2LISVEWB.js → lifecycle-QE3KHIHQ.js} +6 -6
- package/dist/{payout-reporter-HQSIIBFL-XHOVIA5Q.js → payout-reporter-NXWQVKXW-KHVN6C4Z.js} +2 -2
- package/dist/{pocket-refill-K24FKUXH.js → pocket-refill-DGA7UD7L.js} +10 -10
- package/dist/{revenue-reporter-X52GPZ5U-JQKBYUBQ.js → revenue-reporter-HD4GMXGD-LAZU45ZA.js} +2 -2
- package/dist/{tempo-lifecycle-L5C55URR.js → tempo-lifecycle-HJQYBOZR.js} +8 -8
- package/dist/{tempo-wallet-XPXR3T3E.js → tempo-wallet-XN72C2GK.js} +7 -7
- package/dist/{wallet-2XALZRFL.js → wallet-UEQTGVJE.js} +7 -7
- package/dist/{x402-Q4S36NHQ-KWEN7KSE.js → x402-RUJ4LUKF-ZB7JM22B.js} +2 -2
- package/package.json +2 -2
|
@@ -4,14 +4,14 @@ const require = __dvmCreateRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
loadConfig,
|
|
6
6
|
updateConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QDOY3JF2.js";
|
|
8
8
|
import {
|
|
9
9
|
tempoAccountFromConfig,
|
|
10
10
|
tryResolveTempoAsset
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6XTWANVN.js";
|
|
12
12
|
import {
|
|
13
13
|
DvmError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-GD25CUI4.js";
|
|
15
15
|
|
|
16
16
|
// src/lib/payment-rails/tempo-wallet.ts
|
|
17
17
|
function tempoBalanceCheckHint(token) {
|
|
@@ -46,7 +46,7 @@ async function generateTempoKey(opts = {}) {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
if (existing && opts.force) {
|
|
49
|
-
const { assertTempoWalletIdle } = await import("./tempo-lifecycle-
|
|
49
|
+
const { assertTempoWalletIdle } = await import("./tempo-lifecycle-HJQYBOZR.js");
|
|
50
50
|
await assertTempoWalletIdle("replace");
|
|
51
51
|
}
|
|
52
52
|
const { privateKeyToAccount, generatePrivateKey } = await import("./accounts-2WZE4N5F.js");
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
} from "./chunk-R2DSAZBO.js";
|
|
7
7
|
import {
|
|
8
8
|
diagnosticConsole
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IEWV3CM2.js";
|
|
10
10
|
|
|
11
|
-
// node_modules/@dvmkit/sdk/dist/chunk-
|
|
11
|
+
// node_modules/@dvmkit/sdk/dist/chunk-ITRSITFP.js
|
|
12
12
|
import { createHash, randomUUID } from "crypto";
|
|
13
13
|
async function x402EarnedCeiling(channel, earnedNative) {
|
|
14
14
|
let earned;
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
isSignableExactRequirement,
|
|
13
13
|
maxAdvertisedMicro,
|
|
14
14
|
withinAdvertisedTolerance
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-6XTWANVN.js";
|
|
16
16
|
import {
|
|
17
17
|
DvmError,
|
|
18
18
|
X402_V1_VERSION,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
usdcToMsats,
|
|
31
31
|
x402NetworkByCaip2,
|
|
32
32
|
x402NetworkToCaip2
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-GD25CUI4.js";
|
|
34
34
|
|
|
35
35
|
// src/lib/x402/client.ts
|
|
36
36
|
import { randomBytes } from "crypto";
|
|
@@ -3,7 +3,7 @@ import { createRequire as __dvmCreateRequire } from "node:module";
|
|
|
3
3
|
const require = __dvmCreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
diagnosticConsole
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IEWV3CM2.js";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
9
|
} from "./chunk-IYHTITNZ.js";
|
|
@@ -3105,7 +3105,7 @@ function buildNoopLoggers() {
|
|
|
3105
3105
|
};
|
|
3106
3106
|
}
|
|
3107
3107
|
|
|
3108
|
-
// node_modules/@dvmkit/sdk/dist/chunk-
|
|
3108
|
+
// node_modules/@dvmkit/sdk/dist/chunk-E7ZBCT5U.js
|
|
3109
3109
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3110
3110
|
import { createPrivateKey, randomBytes as randomBytes2 } from "crypto";
|
|
3111
3111
|
|
|
@@ -10597,7 +10597,7 @@ var SignJWT = class {
|
|
|
10597
10597
|
}
|
|
10598
10598
|
};
|
|
10599
10599
|
|
|
10600
|
-
// node_modules/@dvmkit/sdk/dist/chunk-
|
|
10600
|
+
// node_modules/@dvmkit/sdk/dist/chunk-E7ZBCT5U.js
|
|
10601
10601
|
var scopes = new AsyncLocalStorage();
|
|
10602
10602
|
function withPaymentDiagnostics(fn) {
|
|
10603
10603
|
return scopes.run({}, fn);
|
|
@@ -10772,7 +10772,7 @@ function logRejected(stage) {
|
|
|
10772
10772
|
});
|
|
10773
10773
|
}
|
|
10774
10774
|
|
|
10775
|
-
// node_modules/@dvmkit/sdk/dist/chunk-
|
|
10775
|
+
// node_modules/@dvmkit/sdk/dist/chunk-3YFFZLW7.js
|
|
10776
10776
|
async function verifyX402Payment(paymentHeader, config, requiredUsdcMicro, resource, btcUsdRate, exactVersions = { v1: true, v2: true }) {
|
|
10777
10777
|
return callerLoggers.x402.span(
|
|
10778
10778
|
"x402.verify_payment",
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
} from "./chunk-R2DSAZBO.js";
|
|
7
7
|
import {
|
|
8
8
|
diagnosticConsole
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IEWV3CM2.js";
|
|
10
10
|
|
|
11
|
-
// node_modules/@dvmkit/sdk/dist/chunk-
|
|
11
|
+
// node_modules/@dvmkit/sdk/dist/chunk-566CFXGU.js
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
13
|
var ENDPOINTS = {
|
|
14
14
|
job_terminal: "/_internal/job-terminal",
|
|
@@ -16,6 +16,7 @@ var ENDPOINTS = {
|
|
|
16
16
|
cost: "/_internal/job-cost",
|
|
17
17
|
deposit: "/_internal/credit-deposit",
|
|
18
18
|
release: "/_internal/credit-draw-release",
|
|
19
|
+
refund: "/_internal/credit-draw-refund",
|
|
19
20
|
drain: "/_internal/credit-drain",
|
|
20
21
|
payout: "/_internal/payout",
|
|
21
22
|
expiry_release: "/_internal/credit-expiry-release"
|
|
@@ -169,6 +170,10 @@ var RevenueReporter = class _RevenueReporter {
|
|
|
169
170
|
async enqueueDeposit(tx, payload) {
|
|
170
171
|
await this.insertPending(tx, "deposit", payload);
|
|
171
172
|
}
|
|
173
|
+
/** Persist without network delivery before the refund accounting transaction commits. */
|
|
174
|
+
async enqueueCreditDrawRefund(tx, payload) {
|
|
175
|
+
await this.insertPending(tx, "refund", payload);
|
|
176
|
+
}
|
|
172
177
|
/** Join a released draw to the transaction that made the hold terminal. */
|
|
173
178
|
async enqueueCreditDrawRelease(tx, payload) {
|
|
174
179
|
await this.insertPending(tx, "release", payload);
|
|
@@ -623,6 +628,9 @@ var RevenueReporter = class _RevenueReporter {
|
|
|
623
628
|
diagnosticConsole.log(`[revenue-reporter] reported ${kind} ${label}`);
|
|
624
629
|
return;
|
|
625
630
|
}
|
|
631
|
+
if (kind === "refund" && res.status === 409) {
|
|
632
|
+
throw new Error("Original draw revenue has not arrived yet");
|
|
633
|
+
}
|
|
626
634
|
if (res.status === 401) {
|
|
627
635
|
await this.markStale(id, "token_rotated");
|
|
628
636
|
diagnosticConsole.warn(
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire as __dvmCreateRequire } from "node:module";
|
|
3
3
|
const require = __dvmCreateRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
-
// node_modules/@dvmkit/sdk/dist/chunk-
|
|
5
|
+
// node_modules/@dvmkit/sdk/dist/chunk-Z4FOPROB.js
|
|
6
6
|
import { isIP } from "net";
|
|
7
7
|
var diagnostic_catalogue_v1_default = {
|
|
8
8
|
version: 1,
|
|
@@ -407,9 +407,13 @@ var diagnostic_catalogue_v1_default = {
|
|
|
407
407
|
"tempo_close_observer_tick",
|
|
408
408
|
"tempo_credential_rejected",
|
|
409
409
|
"tempo_deposit_registration_alert_failed",
|
|
410
|
+
"tempo_drain_booked_as_refunded",
|
|
411
|
+
"tempo_drain_hold_reason_write_failed",
|
|
410
412
|
"tempo_drain_refund_below_debit",
|
|
413
|
+
"tempo_drain_refund_evidence_write_failed",
|
|
411
414
|
"tempo_drain_refund_forecast_below_debit",
|
|
412
415
|
"tempo_drain_refund_forecast_unavailable",
|
|
416
|
+
"tempo_drain_released",
|
|
413
417
|
"tempo_drain_written_off",
|
|
414
418
|
"tempo_observer_health_unavailable",
|
|
415
419
|
"tempo_observer_scan_failed",
|
|
@@ -418,11 +422,24 @@ var diagnostic_catalogue_v1_default = {
|
|
|
418
422
|
"tempo_routine_sweep",
|
|
419
423
|
"tempo_routine_sweep_failed",
|
|
420
424
|
"tempo_session_advertised_refresh_failed",
|
|
425
|
+
"tempo_session_close_attempts_exhausted",
|
|
421
426
|
"tempo_session_close_challenge_failed",
|
|
427
|
+
"tempo_session_close_descriptor_refused",
|
|
428
|
+
"tempo_session_close_exit_resolved",
|
|
422
429
|
"tempo_session_close_failed",
|
|
423
430
|
"tempo_session_close_failure_reconcile_failed",
|
|
431
|
+
"tempo_session_close_reconcile_failed",
|
|
424
432
|
"tempo_session_close_recovery_failed",
|
|
433
|
+
"tempo_session_close_recovery_search_paused",
|
|
425
434
|
"tempo_session_close_recovery_unmatched",
|
|
435
|
+
"tempo_session_close_report_reopened",
|
|
436
|
+
"tempo_session_close_report_written_off",
|
|
437
|
+
"tempo_session_close_reservation_released",
|
|
438
|
+
"tempo_session_close_settlement_callback_failed",
|
|
439
|
+
"tempo_session_close_settlement_unreported",
|
|
440
|
+
"tempo_session_drain_finalized",
|
|
441
|
+
"tempo_session_drain_refund_unproven",
|
|
442
|
+
"tempo_session_drain_unbacked_resolved",
|
|
426
443
|
"tempo_session_open_refused",
|
|
427
444
|
"tempo_session_settled",
|
|
428
445
|
"tempo_session_withheld",
|
|
@@ -535,6 +552,7 @@ var diagnostic_catalogue_v1_default = {
|
|
|
535
552
|
"/admin/cashu/rotate-lock-pubkey",
|
|
536
553
|
"/admin/credit/bitcoin-liability",
|
|
537
554
|
"/admin/credit/blocked-invoices",
|
|
555
|
+
"/admin/credit/book-tempo-drain",
|
|
538
556
|
"/admin/credit/mark-drain-sent",
|
|
539
557
|
"/admin/credit/park-drain",
|
|
540
558
|
"/admin/credit/pending-drains",
|
|
@@ -542,9 +560,13 @@ var diagnostic_catalogue_v1_default = {
|
|
|
542
560
|
"/admin/credit/reconcile-tempo-drain",
|
|
543
561
|
"/admin/credit/reconcile-x402-exact-settlement",
|
|
544
562
|
"/admin/credit/reconcile-x402-settlement",
|
|
563
|
+
"/admin/credit/release-tempo-drain",
|
|
564
|
+
"/admin/credit/retry-tempo-close-report",
|
|
565
|
+
"/admin/credit/tempo-close-reports",
|
|
545
566
|
"/admin/credit/tempo-drains",
|
|
546
567
|
"/admin/credit/tempo-losses",
|
|
547
568
|
"/admin/credit/write-off-invoice",
|
|
569
|
+
"/admin/credit/write-off-tempo-close-report",
|
|
548
570
|
"/admin/credit/write-off-tempo-drain",
|
|
549
571
|
"/admin/credit/write-off-x402-settlement",
|
|
550
572
|
"/admin/credit/x402-exact-settlements",
|
|
@@ -949,7 +971,8 @@ var diagnostic_catalogue_v1_default = {
|
|
|
949
971
|
"storefront_probe",
|
|
950
972
|
"success",
|
|
951
973
|
"verified",
|
|
952
|
-
"wallet_reported_budget"
|
|
974
|
+
"wallet_reported_budget",
|
|
975
|
+
"written_off"
|
|
953
976
|
],
|
|
954
977
|
integerFields: [
|
|
955
978
|
"ageMs",
|
|
@@ -990,6 +1013,9 @@ var diagnostic_catalogue_v1_default = {
|
|
|
990
1013
|
"key_hash",
|
|
991
1014
|
"prefix_hash"
|
|
992
1015
|
],
|
|
1016
|
+
transactionHashFields: [
|
|
1017
|
+
"transaction_hash"
|
|
1018
|
+
],
|
|
993
1019
|
urlFields: [
|
|
994
1020
|
"url",
|
|
995
1021
|
"facilitator_url",
|
|
@@ -1091,6 +1117,10 @@ var diagnostic_catalogue_v1_default = {
|
|
|
1091
1117
|
"builder_pause",
|
|
1092
1118
|
"withdrawn",
|
|
1093
1119
|
"operator"
|
|
1120
|
+
],
|
|
1121
|
+
tempoCloseReportPriorStatuses: [
|
|
1122
|
+
"no_report",
|
|
1123
|
+
"unmatched"
|
|
1094
1124
|
]
|
|
1095
1125
|
};
|
|
1096
1126
|
var DIAGNOSTIC_CATALOGUE_VERSION = diagnostic_catalogue_v1_default.version;
|
|
@@ -1121,10 +1151,12 @@ var RAILS = new Set(diagnostic_catalogue_v1_default.rails);
|
|
|
1121
1151
|
var STAGES = new Set(diagnostic_catalogue_v1_default.stages);
|
|
1122
1152
|
var HANDLERS = new Set(diagnostic_catalogue_v1_default.handlers);
|
|
1123
1153
|
var CURRENCIES = new Set(diagnostic_catalogue_v1_default.currencyTokens);
|
|
1154
|
+
var TEMPO_CLOSE_REPORT_PRIOR_STATUSES = new Set(diagnostic_catalogue_v1_default.tempoCloseReportPriorStatuses);
|
|
1124
1155
|
var BOOLEAN_FIELDS = new Set(diagnostic_catalogue_v1_default.booleanFields);
|
|
1125
1156
|
var INTEGER_FIELDS = new Set(diagnostic_catalogue_v1_default.integerFields);
|
|
1126
1157
|
var TOKEN_FIELDS = new Set(diagnostic_catalogue_v1_default.tokenFields);
|
|
1127
1158
|
var HASH_FIELDS = new Set(diagnostic_catalogue_v1_default.hashFields);
|
|
1159
|
+
var TRANSACTION_HASH_FIELDS = new Set(diagnostic_catalogue_v1_default.transactionHashFields);
|
|
1128
1160
|
var URL_FIELDS = new Set(diagnostic_catalogue_v1_default.urlFields);
|
|
1129
1161
|
var IDENTITY_FIELDS = new Set(diagnostic_catalogue_v1_default.identityFields);
|
|
1130
1162
|
var CAPABILITY_FIELDS = new Set(diagnostic_catalogue_v1_default.capabilityFields);
|
|
@@ -1225,13 +1257,13 @@ function projectSpanRow(input) {
|
|
|
1225
1257
|
}
|
|
1226
1258
|
const sampleRate = ownValue(input, "sample_rate");
|
|
1227
1259
|
const pid = ownValue(input, "pid");
|
|
1228
|
-
const
|
|
1260
|
+
const name = projectEventName(ownValue(input, "name"));
|
|
1229
1261
|
const row = {
|
|
1230
1262
|
span_id: spanId,
|
|
1231
1263
|
trace_id: traceId,
|
|
1232
1264
|
parent_span_id: parentSpanId,
|
|
1233
1265
|
dataset,
|
|
1234
|
-
name
|
|
1266
|
+
name,
|
|
1235
1267
|
level,
|
|
1236
1268
|
status,
|
|
1237
1269
|
started_at_ms: startedAtMs,
|
|
@@ -1246,13 +1278,15 @@ function projectSpanRow(input) {
|
|
|
1246
1278
|
ownValue(input, "dimensions"),
|
|
1247
1279
|
dataset,
|
|
1248
1280
|
authority,
|
|
1249
|
-
identityAuthority
|
|
1281
|
+
identityAuthority,
|
|
1282
|
+
name
|
|
1250
1283
|
),
|
|
1251
1284
|
attributes: projectFields(
|
|
1252
1285
|
ownValue(input, "attributes"),
|
|
1253
1286
|
dataset,
|
|
1254
1287
|
authority,
|
|
1255
|
-
identityAuthority
|
|
1288
|
+
identityAuthority,
|
|
1289
|
+
name
|
|
1256
1290
|
),
|
|
1257
1291
|
error_message: null,
|
|
1258
1292
|
error_stack: null,
|
|
@@ -1268,7 +1302,7 @@ function projectSpanRow(input) {
|
|
|
1268
1302
|
return { ok: false, code: "invalid_span" };
|
|
1269
1303
|
}
|
|
1270
1304
|
}
|
|
1271
|
-
function projectDiagnosticFields(input, dataset, authority, identityAuthority) {
|
|
1305
|
+
function projectDiagnosticFields(input, dataset, authority, identityAuthority, eventName) {
|
|
1272
1306
|
try {
|
|
1273
1307
|
const inheritedAuthority = isObject(input) ? VALUE_AUTHORITIES.get(input) : void 0;
|
|
1274
1308
|
const effectiveAuthority = validAuthority(authority) ?? inheritedAuthority;
|
|
@@ -1278,7 +1312,8 @@ function projectDiagnosticFields(input, dataset, authority, identityAuthority) {
|
|
|
1278
1312
|
input,
|
|
1279
1313
|
dataset,
|
|
1280
1314
|
effectiveAuthority,
|
|
1281
|
-
effectiveIdentityAuthority
|
|
1315
|
+
effectiveIdentityAuthority,
|
|
1316
|
+
eventName
|
|
1282
1317
|
);
|
|
1283
1318
|
bindDiagnosticCapabilityAuthority(output, effectiveAuthority);
|
|
1284
1319
|
bindDiagnosticIdentityAuthority(output, effectiveIdentityAuthority);
|
|
@@ -1290,7 +1325,7 @@ function projectDiagnosticFields(input, dataset, authority, identityAuthority) {
|
|
|
1290
1325
|
function projectEventName(input, fallback = "diagnostic.unknown") {
|
|
1291
1326
|
return typeof input === "string" && EVENTS.has(input) ? input : fallback;
|
|
1292
1327
|
}
|
|
1293
|
-
function projectFields(input, dataset, authority, identityAuthority) {
|
|
1328
|
+
function projectFields(input, dataset, authority, identityAuthority, eventName) {
|
|
1294
1329
|
if (!isObject(input)) return {};
|
|
1295
1330
|
const output = {};
|
|
1296
1331
|
for (const [key, value] of ownDataEntries(input, 64)) {
|
|
@@ -1300,22 +1335,50 @@ function projectFields(input, dataset, authority, identityAuthority) {
|
|
|
1300
1335
|
value,
|
|
1301
1336
|
dataset,
|
|
1302
1337
|
authority,
|
|
1303
|
-
identityAuthority
|
|
1338
|
+
identityAuthority,
|
|
1339
|
+
eventName
|
|
1304
1340
|
);
|
|
1305
1341
|
if (projected !== void 0) output[key] = projected;
|
|
1306
1342
|
}
|
|
1307
1343
|
return output;
|
|
1308
1344
|
}
|
|
1309
|
-
function projectField(key, value, dataset, authority, identityAuthority) {
|
|
1345
|
+
function projectField(key, value, dataset, authority, identityAuthority, eventName) {
|
|
1310
1346
|
const closedEnum = Object.hasOwn(PAYMENT_ENUMS, key) ? PAYMENT_ENUMS[key] : Object.hasOwn(ROUTER_ENUMS, key) ? ROUTER_ENUMS[key] : void 0;
|
|
1311
1347
|
if (closedEnum)
|
|
1312
1348
|
return typeof value === "string" && closedEnum.has(value) ? value : void 0;
|
|
1349
|
+
if (dataset === "tempo") {
|
|
1350
|
+
if (key === "prior_status")
|
|
1351
|
+
return typeof value === "string" && TEMPO_CLOSE_REPORT_PRIOR_STATUSES.has(value) ? value : void 0;
|
|
1352
|
+
const closeReportEvent = eventName === "tempo_session_close_report_written_off" || eventName === "tempo_session_close_report_reopened";
|
|
1353
|
+
const drainDecisionEvent = eventName === "tempo_drain_booked_as_refunded" || eventName === "tempo_drain_released";
|
|
1354
|
+
if (drainDecisionEvent) {
|
|
1355
|
+
if (key === "drain_reference")
|
|
1356
|
+
return typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value) ? value : void 0;
|
|
1357
|
+
if (key === "credit_id" || key === "drain_id")
|
|
1358
|
+
return typeof value === "string" && /^[a-zA-Z0-9_.:-]{1,512}$/.test(value) ? value : void 0;
|
|
1359
|
+
if (key === "channel_id")
|
|
1360
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value) ? value : void 0;
|
|
1361
|
+
if (key === "amount_native")
|
|
1362
|
+
return value === null || typeof value === "string" && DECIMAL_RE.test(value) ? value : void 0;
|
|
1363
|
+
}
|
|
1364
|
+
const payerExitEvent = eventName === "tempo_session_close_exit_resolved";
|
|
1365
|
+
if (closeReportEvent || payerExitEvent) {
|
|
1366
|
+
if (key === "obligation_id")
|
|
1367
|
+
return typeof value === "string" && UUID_RE.test(value) ? value : void 0;
|
|
1368
|
+
if (key === "channel_id")
|
|
1369
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value) ? value : void 0;
|
|
1370
|
+
if (closeReportEvent && (key === "amount_native" || key === "amount_forgone_native") || payerExitEvent && key === "amount_at_stake_native")
|
|
1371
|
+
return typeof value === "string" && DECIMAL_RE.test(value) ? value : void 0;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1313
1374
|
if (BOOLEAN_FIELDS.has(key))
|
|
1314
1375
|
return typeof value === "boolean" ? value : void 0;
|
|
1315
1376
|
if (INTEGER_FIELDS.has(key))
|
|
1316
1377
|
return isNonnegativeSafeInteger(value) ? value : void 0;
|
|
1317
1378
|
if (HASH_FIELDS.has(key))
|
|
1318
1379
|
return typeof value === "string" && HASH_RE.test(value) ? value : void 0;
|
|
1380
|
+
if (TRANSACTION_HASH_FIELDS.has(key))
|
|
1381
|
+
return typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value) ? value : void 0;
|
|
1319
1382
|
if (URL_FIELDS.has(key)) return projectOrigin(value);
|
|
1320
1383
|
if (IDENTITY_FIELDS.has(key)) return projectIdentity(key, identityAuthority);
|
|
1321
1384
|
if (TOKEN_FIELDS.has(key)) return void 0;
|
|
@@ -1485,10 +1548,11 @@ function writeDiagnostic(sinkLevel, event, fields, dataset, severityOverride) {
|
|
|
1485
1548
|
try {
|
|
1486
1549
|
const defaultSeverity = sinkLevel === "debug" || sinkLevel === "log" ? "info" : sinkLevel;
|
|
1487
1550
|
const severity = severityOverride === "info" || severityOverride === "warn" || severityOverride === "error" ? severityOverride : defaultSeverity;
|
|
1551
|
+
const eventName = projectEventName(event);
|
|
1488
1552
|
const record = {
|
|
1489
|
-
event:
|
|
1553
|
+
event: eventName,
|
|
1490
1554
|
level: severity,
|
|
1491
|
-
...projectDiagnosticFields(fields, dataset)
|
|
1555
|
+
...projectDiagnosticFields(fields, dataset, void 0, void 0, eventName)
|
|
1492
1556
|
};
|
|
1493
1557
|
const sink = sinkLevel === "log" ? console.log : console[sinkLevel];
|
|
1494
1558
|
sink(JSON.stringify(record));
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
authorizeProtectedRemoval,
|
|
6
6
|
loadConfig,
|
|
7
7
|
updateConfig
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QDOY3JF2.js";
|
|
9
9
|
import {
|
|
10
10
|
withX402ChannelLock,
|
|
11
11
|
x402WalletFromConfig
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6XTWANVN.js";
|
|
13
13
|
import {
|
|
14
14
|
DvmError,
|
|
15
15
|
X402_DEFAULT_NETWORK,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
ensureAddress,
|
|
18
18
|
isValidEvmPrivateKey,
|
|
19
19
|
x402NetworkByCaip2
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GD25CUI4.js";
|
|
21
21
|
|
|
22
22
|
// src/lib/x402/networks.ts
|
|
23
23
|
function x402NetworkLabel(network) {
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
CONFIG_PINNED_FILE,
|
|
9
9
|
ensureConfigDir,
|
|
10
10
|
require_proper_lockfile
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6XTWANVN.js";
|
|
12
12
|
import {
|
|
13
13
|
DvmError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-GD25CUI4.js";
|
|
15
15
|
import {
|
|
16
16
|
__toESM
|
|
17
17
|
} from "./chunk-IYHTITNZ.js";
|
|
@@ -3,7 +3,7 @@ import { createRequire as __dvmCreateRequire } from "node:module";
|
|
|
3
3
|
const require = __dvmCreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
connectedTempoAccount
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BCDMVIPI.js";
|
|
7
7
|
import {
|
|
8
8
|
deriveIdentityFromPrivkey,
|
|
9
9
|
formatUsdcMicrounits,
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
reconcileTempoChannelOnChain,
|
|
14
14
|
shellQuoteArg,
|
|
15
15
|
tempoChannelControlledBy
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6XTWANVN.js";
|
|
17
17
|
import {
|
|
18
18
|
DvmError
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GD25CUI4.js";
|
|
20
20
|
|
|
21
21
|
// src/lib/cli-identity-resolve.ts
|
|
22
22
|
function resolveSigningIdentity(opts) {
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
import { createRequire as __dvmCreateRequire } from "node:module";
|
|
3
3
|
const require = __dvmCreateRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./chunk-4U43FVT4.js";
|
|
5
|
+
connectedTempoAccount
|
|
6
|
+
} from "./chunk-BCDMVIPI.js";
|
|
8
7
|
import {
|
|
9
8
|
costAnchor,
|
|
10
9
|
info,
|
|
@@ -12,14 +11,15 @@ import {
|
|
|
12
11
|
resolveBtcUsdRate,
|
|
13
12
|
tryResolveBtcUsdRate,
|
|
14
13
|
tryX402Payment
|
|
15
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-C7ZNQONB.js";
|
|
16
15
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
loadX402Wallet,
|
|
17
|
+
x402NetworkLabel
|
|
18
|
+
} from "./chunk-PMPHS3LS.js";
|
|
19
19
|
import {
|
|
20
20
|
isCreditPosture,
|
|
21
21
|
loadConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QDOY3JF2.js";
|
|
23
23
|
import {
|
|
24
24
|
BUDGET_FILE,
|
|
25
25
|
JOBS_FILE,
|
|
@@ -108,6 +108,7 @@ import {
|
|
|
108
108
|
recordPendingTempoChargeFunding,
|
|
109
109
|
recordPendingX402ExactFunding,
|
|
110
110
|
recordPendingX402Funding,
|
|
111
|
+
require_proper_lockfile,
|
|
111
112
|
restoreProofsFromOutputs,
|
|
112
113
|
retirePendingX402Funding,
|
|
113
114
|
retryMintQuoteOperation,
|
|
@@ -156,7 +157,7 @@ import {
|
|
|
156
157
|
x402PendingUnsettled,
|
|
157
158
|
x402RequiredFromError,
|
|
158
159
|
x402VoucherPendingState
|
|
159
|
-
} from "./chunk-
|
|
160
|
+
} from "./chunk-6XTWANVN.js";
|
|
160
161
|
import {
|
|
161
162
|
Challenge_exports,
|
|
162
163
|
Credential_exports
|
|
@@ -173,10 +174,13 @@ import {
|
|
|
173
174
|
redactUrlsInText,
|
|
174
175
|
usdToMsats,
|
|
175
176
|
x402NetworkToCaip2
|
|
176
|
-
} from "./chunk-
|
|
177
|
+
} from "./chunk-GD25CUI4.js";
|
|
177
178
|
import {
|
|
178
179
|
privateKeyToAccount
|
|
179
180
|
} from "./chunk-EVQERRCP.js";
|
|
181
|
+
import {
|
|
182
|
+
__toESM
|
|
183
|
+
} from "./chunk-IYHTITNZ.js";
|
|
180
184
|
|
|
181
185
|
// src/lib/budget-ledger.ts
|
|
182
186
|
function loadLedger() {
|
|
@@ -856,18 +860,19 @@ function fail(mode, refusal) {
|
|
|
856
860
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
857
861
|
|
|
858
862
|
// src/lib/job-store.ts
|
|
859
|
-
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
863
|
+
import { existsSync, readFileSync, writeFileSync, renameSync, openSync, closeSync, fsyncSync } from "fs";
|
|
864
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
865
|
+
import { dirname } from "path";
|
|
860
866
|
function saveJob(job) {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
867
|
+
mutateJobs((jobs) => {
|
|
868
|
+
jobs.push(job);
|
|
869
|
+
});
|
|
864
870
|
}
|
|
865
871
|
function updateJob(id, update) {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
writeJobs(jobs);
|
|
872
|
+
mutateJobs((jobs) => {
|
|
873
|
+
const idx = jobs.findIndex((j) => j.id === id);
|
|
874
|
+
if (idx !== -1) jobs[idx] = { ...jobs[idx], ...update };
|
|
875
|
+
});
|
|
871
876
|
}
|
|
872
877
|
function markJobTerminal(id, status, completion, extra) {
|
|
873
878
|
const existing = loadJob(id);
|
|
@@ -892,16 +897,62 @@ function loadAllJobs() {
|
|
|
892
897
|
}
|
|
893
898
|
}
|
|
894
899
|
function addPayment(jobId, amountMsats) {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
totalPaidMsats
|
|
899
|
-
paymentsHonoured
|
|
900
|
+
mutateJobs((jobs) => {
|
|
901
|
+
const job = jobs.find((entry) => entry.id === jobId);
|
|
902
|
+
if (!job) return;
|
|
903
|
+
job.totalPaidMsats = (job.totalPaidMsats ?? 0) + amountMsats;
|
|
904
|
+
job.paymentsHonoured = (job.paymentsHonoured ?? 0) + 1;
|
|
905
|
+
if (job.creditBinding && "unbound" in job.creditBinding) delete job.creditBinding;
|
|
900
906
|
});
|
|
901
907
|
}
|
|
902
908
|
function writeJobs(jobs) {
|
|
903
909
|
ensureConfigDir();
|
|
904
|
-
|
|
910
|
+
const temporary = `${JOBS_FILE}.${process.pid}.tmp`;
|
|
911
|
+
const fd = openSync(temporary, "w", 384);
|
|
912
|
+
try {
|
|
913
|
+
writeFileSync(fd, JSON.stringify(jobs, null, 2) + "\n");
|
|
914
|
+
fsyncSync(fd);
|
|
915
|
+
} finally {
|
|
916
|
+
closeSync(fd);
|
|
917
|
+
}
|
|
918
|
+
renameSync(temporary, JOBS_FILE);
|
|
919
|
+
const directory = openSync(dirname(JOBS_FILE), "r");
|
|
920
|
+
try {
|
|
921
|
+
fsyncSync(directory);
|
|
922
|
+
} finally {
|
|
923
|
+
closeSync(directory);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function mutateJobs(change) {
|
|
927
|
+
ensureConfigDir();
|
|
928
|
+
const release = import_proper_lockfile.default.lockSync(JOBS_FILE, { realpath: false });
|
|
929
|
+
try {
|
|
930
|
+
const jobs = loadAllJobs();
|
|
931
|
+
const before = JSON.stringify(jobs);
|
|
932
|
+
const result = change(jobs);
|
|
933
|
+
if (JSON.stringify(jobs) !== before) writeJobs(jobs);
|
|
934
|
+
return result;
|
|
935
|
+
} finally {
|
|
936
|
+
release();
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
function mutateCreditPayment(jobId, change) {
|
|
940
|
+
return mutateJobs((jobs) => {
|
|
941
|
+
const job = jobs.find((entry) => entry.id === jobId);
|
|
942
|
+
if (!job) throw new Error("Cannot persist a balance payment for an unknown job.");
|
|
943
|
+
return change(job);
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
function bookCreditPayment(jobId, intent) {
|
|
947
|
+
mutateCreditPayment(jobId, (job) => {
|
|
948
|
+
if (!job.bookedCreditPayments?.some((entry) => entry.authorization.payment_id === intent.authorization.payment_id)) {
|
|
949
|
+
job.totalPaidMsats = (job.totalPaidMsats ?? 0) + (intent.amountMsats ?? intent.request.amount_msats);
|
|
950
|
+
job.paymentsHonoured = (job.paymentsHonoured ?? 0) + 1;
|
|
951
|
+
(job.bookedCreditPayments ??= []).push(intent);
|
|
952
|
+
}
|
|
953
|
+
if (job.pendingCreditPayment?.authorization.payment_id === intent.authorization.payment_id)
|
|
954
|
+
delete job.pendingCreditPayment;
|
|
955
|
+
});
|
|
905
956
|
}
|
|
906
957
|
|
|
907
958
|
// src/lib/receipt-verify.ts
|
|
@@ -5404,40 +5455,9 @@ export {
|
|
|
5404
5455
|
loadJob,
|
|
5405
5456
|
loadAllJobs,
|
|
5406
5457
|
addPayment,
|
|
5458
|
+
mutateCreditPayment,
|
|
5459
|
+
bookCreditPayment,
|
|
5407
5460
|
buildTempoCredential,
|
|
5408
|
-
extractBuilderHandle,
|
|
5409
|
-
reservedForMarker,
|
|
5410
|
-
inFlightTimeoutSeconds,
|
|
5411
|
-
meltInFlightTimeoutSeconds,
|
|
5412
|
-
proofKey,
|
|
5413
|
-
markProofsInFlight,
|
|
5414
|
-
revertInFlight,
|
|
5415
|
-
sweepStaleInFlight,
|
|
5416
|
-
DEFAULT_RESERVE_LOCKTIME_SECONDS,
|
|
5417
|
-
parseLocktime,
|
|
5418
|
-
formatLocktime,
|
|
5419
|
-
prepareAgentSpend,
|
|
5420
|
-
commitAgentSpend,
|
|
5421
|
-
correctPendingFundAmount,
|
|
5422
|
-
abandonPendingSubmission,
|
|
5423
|
-
markPendingSubmissionUnresolved,
|
|
5424
|
-
withAcceptedUnresolved,
|
|
5425
|
-
drainReceiptsDisplay,
|
|
5426
|
-
drainReceiptsHint,
|
|
5427
|
-
receiptDisplay,
|
|
5428
|
-
receiptIssuedAtIso,
|
|
5429
|
-
epochMsToIso,
|
|
5430
|
-
receiptHint,
|
|
5431
|
-
receiptFailureDetail,
|
|
5432
|
-
captureFundingReceipt,
|
|
5433
|
-
captureTransportReceipt,
|
|
5434
|
-
receiptJsonFields,
|
|
5435
|
-
renderReceiptHuman,
|
|
5436
|
-
receiptTrustFields,
|
|
5437
|
-
fetchTrustAnchor,
|
|
5438
|
-
fetchMissingJobReceipt,
|
|
5439
|
-
backfillTrustAnchor,
|
|
5440
|
-
replayStoredReceipt,
|
|
5441
5461
|
loadLedger,
|
|
5442
5462
|
saveLedger,
|
|
5443
5463
|
recordSpend,
|
|
@@ -5457,6 +5477,39 @@ export {
|
|
|
5457
5477
|
parseStatedBudget,
|
|
5458
5478
|
floatBudgetJson,
|
|
5459
5479
|
toFloatError,
|
|
5480
|
+
drainReceiptsDisplay,
|
|
5481
|
+
drainReceiptsHint,
|
|
5482
|
+
receiptDisplay,
|
|
5483
|
+
receiptIssuedAtIso,
|
|
5484
|
+
epochMsToIso,
|
|
5485
|
+
receiptHint,
|
|
5486
|
+
receiptFailureDetail,
|
|
5487
|
+
captureFundingReceipt,
|
|
5488
|
+
captureTransportReceipt,
|
|
5489
|
+
receiptJsonFields,
|
|
5490
|
+
renderReceiptHuman,
|
|
5491
|
+
receiptTrustFields,
|
|
5492
|
+
fetchTrustAnchor,
|
|
5493
|
+
fetchMissingJobReceipt,
|
|
5494
|
+
backfillTrustAnchor,
|
|
5495
|
+
replayStoredReceipt,
|
|
5496
|
+
extractBuilderHandle,
|
|
5497
|
+
reservedForMarker,
|
|
5498
|
+
inFlightTimeoutSeconds,
|
|
5499
|
+
meltInFlightTimeoutSeconds,
|
|
5500
|
+
proofKey,
|
|
5501
|
+
markProofsInFlight,
|
|
5502
|
+
revertInFlight,
|
|
5503
|
+
sweepStaleInFlight,
|
|
5504
|
+
DEFAULT_RESERVE_LOCKTIME_SECONDS,
|
|
5505
|
+
parseLocktime,
|
|
5506
|
+
formatLocktime,
|
|
5507
|
+
prepareAgentSpend,
|
|
5508
|
+
commitAgentSpend,
|
|
5509
|
+
correctPendingFundAmount,
|
|
5510
|
+
abandonPendingSubmission,
|
|
5511
|
+
markPendingSubmissionUnresolved,
|
|
5512
|
+
withAcceptedUnresolved,
|
|
5460
5513
|
fundCredit,
|
|
5461
5514
|
pollPendingCreditFundings,
|
|
5462
5515
|
availableRails,
|