@dvmkit/sdk 0.1.5-rc.9 → 0.2.0-rc.9
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/README.md +12 -0
- package/dist/{chunk-BIP6G74V.js → chunk-2ATUAUAO.js} +8 -8
- package/dist/{chunk-27V2ILSR.js → chunk-4A2RAKCW.js} +2 -2
- package/dist/{chunk-EVBK675R.js → chunk-6GRIKOFB.js} +28 -23
- package/dist/{chunk-CEOAHV2I.js → chunk-FDKRXOZO.js} +0 -5
- package/dist/{chunk-L4OYF4DQ.js → chunk-FT6HTUM4.js} +1 -1
- package/dist/{chunk-BTZY7VPH.js → chunk-GAIPXGM3.js} +1 -1
- package/dist/{chunk-U6M3ATSG.js → chunk-JDT5LCJC.js} +40 -6
- package/dist/{chunk-FROTD5XQ.js → chunk-JLXYOV4Y.js} +1 -2
- package/dist/{chunk-M7LHFJ5K.js → chunk-KMZXTBLA.js} +2 -2
- package/dist/{chunk-6BQM7TOW.js → chunk-L67WTZX2.js} +3 -7
- package/dist/{chunk-CGKZDODG.js → chunk-MG67KXU7.js} +0 -5
- package/dist/{chunk-JZWELPFH.js → chunk-MRAGS5VP.js} +1 -1
- package/dist/{chunk-2UUXIIOC.js → chunk-O2X2CCKH.js} +3 -3
- package/dist/{chunk-TQWGQCNV.js → chunk-OMIQMMME.js} +3 -3
- package/dist/{chunk-5PBOA25N.js → chunk-PCUQZDZA.js} +436 -355
- package/dist/{chunk-KVEHHC7W.js → chunk-PHHAYRQV.js} +7 -9
- package/dist/{chunk-SSSZUVWM.js → chunk-QP53RWAD.js} +88 -38
- package/dist/{chunk-DMNLFNTW.js → chunk-QT4ONTST.js} +1 -1
- package/dist/{chunk-RW5LP57K.js → chunk-SDK6KDJN.js} +0 -1
- package/dist/{chunk-MLRCSJYX.js → chunk-V7EVFLAK.js} +87 -90
- package/dist/{chunk-E4EVGPDX.js → chunk-XQXJKJ3P.js} +0 -2
- package/dist/{credit-ledger-2DFQHNLB.js → credit-ledger-5ZEJRI46.js} +1 -1
- package/dist/{credit-menu-enwMbn55.d.ts → credit-menu-D4Gcdgc4.d.ts} +487 -643
- package/dist/{fx-D860pZvP.d.ts → fx-B0SLBe5x.d.ts} +38 -82
- package/dist/index.d.ts +11 -14
- package/dist/index.js +2 -2
- package/dist/internal/caller.d.ts +618 -1525
- package/dist/internal/caller.js +28 -60
- package/dist/internal/server.d.ts +36 -61
- package/dist/internal/server.js +11 -11
- package/dist/{job-store-BUGqvCfL.d.ts → job-store-B2uZvga4.d.ts} +70 -59
- package/dist/{lightning-backend-BozcevPZ.d.ts → lightning-backend-CQBnQgsT.d.ts} +19 -27
- package/dist/{memory-credit-ledger-MNUOTQO5.js → memory-credit-ledger-ZOH6C3N4.js} +2 -2
- package/dist/{mpp-setup-4FJD6ZHV.js → mpp-setup-IOJBF7DB.js} +1 -1
- package/dist/{payout-reporter-RG6XNGPI.js → payout-reporter-5PIRYFVQ.js} +1 -1
- package/dist/{postgres-consumed-credential-store-VHBT4KEA.js → postgres-consumed-credential-store-ISRHBMOU.js} +1 -1
- package/dist/{postgres-job-store-3RAXMNSY.js → postgres-job-store-OGQ6IT4U.js} +1 -1
- package/dist/{postgres-kv-store-JFBDP5IP.js → postgres-kv-store-D5E2EZ24.js} +1 -1
- package/dist/{postgres-replay-store-UJXRT6VO.js → postgres-replay-store-IZFLTTAC.js} +1 -1
- package/dist/{pricing-4CEB34RM.js → pricing-MU5GNUJZ.js} +1 -1
- package/dist/{processed-payment-store-HAA4SFNK.js → processed-payment-store-FIDI3RNH.js} +1 -1
- package/dist/{revenue-reporter-ASZ7SHHH.js → revenue-reporter-NNCNRY4C.js} +1 -1
- package/dist/server/index.d.ts +53 -59
- package/dist/server/index.js +38 -37
- package/dist/{ssrf-DbFkpDv0.d.ts → ssrf-dMooihtY.d.ts} +1 -2
- package/dist/{step-cache-5dljDqrQ.d.ts → step-cache-CXg7ziML.d.ts} +389 -551
- package/dist/{tempo-charge-store-RIFTALZK.js → tempo-charge-store-76TDAF34.js} +1 -1
- package/dist/{tempo-lifecycle-DFIXQ54Q.js → tempo-lifecycle-DXM7QXJQ.js} +3 -3
- package/dist/{tempo-wallet-4QKSV65O.js → tempo-wallet-O67H5M4N.js} +2 -2
- package/dist/testing/index.d.ts +5 -15
- package/dist/testing/index.js +4 -11
- package/dist/{usd-DoRuAckA.d.ts → usd-BNDg1715.d.ts} +14 -16
- package/dist/{wallet-CJC8lwxx.d.ts → wallet-Dwjs5n_M.d.ts} +1 -1
- package/dist/{x402-5H27DCBE.js → x402-7S2EFINY.js} +2 -2
- package/package.json +2 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertTempoWalletIdle
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-OMIQMMME.js";
|
|
4
|
+
import "./chunk-O2X2CCKH.js";
|
|
5
5
|
import "./chunk-KSQEFVFJ.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-MG67KXU7.js";
|
|
7
7
|
import "./chunk-5URG56JJ.js";
|
|
8
8
|
import "./chunk-MKI6OVW4.js";
|
|
9
9
|
import "./chunk-FUJ36YDV.js";
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
tempoTokenReference,
|
|
16
16
|
tempoWrongAssetHint,
|
|
17
17
|
tryResolveTempoAsset
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-O2X2CCKH.js";
|
|
19
|
+
import "./chunk-MG67KXU7.js";
|
|
20
20
|
import "./chunk-MKI6OVW4.js";
|
|
21
21
|
import "./chunk-FUJ36YDV.js";
|
|
22
22
|
export {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Y as JobReceipt, a1 as Message, a2 as MessageType, K as KVStore, L as Logger, u as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache-
|
|
2
|
-
import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-
|
|
1
|
+
import { Y as JobReceipt, a1 as Message, a2 as MessageType, K as KVStore, L as Logger, u as ResponseContent, P as PaymentContent, S as SDKJobContext } from '../step-cache-CXg7ziML.js';
|
|
2
|
+
import { c as StreamableJobStore, R as ReceiptIssuingStore, J as JobRecord, d as RequestIdClaim, e as RequestIdClaimResult, f as JobRetentionCursor, O as OutgoingMessage, A as AppendOutgoingOptions, P as PaymentCreditDelta, V as VerifyAndCreditResult, g as JobCounters } from '../job-store-B2uZvga4.js';
|
|
3
3
|
import 'hono';
|
|
4
4
|
import 'mppx';
|
|
5
5
|
import '@x402/core/server';
|
|
@@ -11,8 +11,8 @@ import 'zod';
|
|
|
11
11
|
import '@cashu/cashu-ts';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* In-memory JobStore implementing the transactional + streaming surface
|
|
15
|
-
*
|
|
14
|
+
* In-memory JobStore implementing the transactional + streaming surface;
|
|
15
|
+
* used by unit tests and not production-safe — there's no real
|
|
16
16
|
* concurrency control beyond JS's single-threaded execution.
|
|
17
17
|
*/
|
|
18
18
|
declare class MemoryJobStore implements StreamableJobStore, ReceiptIssuingStore {
|
|
@@ -23,9 +23,7 @@ declare class MemoryJobStore implements StreamableJobStore, ReceiptIssuingStore
|
|
|
23
23
|
private notifySubscribers;
|
|
24
24
|
private reactivationLocks;
|
|
25
25
|
private requestIdClaims;
|
|
26
|
-
/** Per-DVM monotonic receipt counter (internal-review) — the `receipt_counter` row. */
|
|
27
26
|
private receiptCounter;
|
|
28
|
-
/** Receipt sequence already allocated to a job, keyed by job id. */
|
|
29
27
|
private receiptSeqs;
|
|
30
28
|
get(id: string): Promise<JobRecord | undefined>;
|
|
31
29
|
findJobByPaymentTxHash(txHash: string): Promise<JobRecord | undefined>;
|
|
@@ -85,12 +83,9 @@ declare class MemoryJobStore implements StreamableJobStore, ReceiptIssuingStore
|
|
|
85
83
|
|
|
86
84
|
/** Recorded outbound message. */
|
|
87
85
|
interface RecordedMessage {
|
|
88
|
-
/** Message type (e.g. "text", "artifact", "prompt", "complete"). */
|
|
89
86
|
type: MessageType;
|
|
90
|
-
/** Message content payload. */
|
|
91
87
|
content: Record<string, unknown>;
|
|
92
88
|
}
|
|
93
|
-
/** Options for creating a test context. */
|
|
94
89
|
interface TestContextOpts<State = Record<string, unknown>, Input = string> {
|
|
95
90
|
/** Override the job ID. Default: "test-job-1". */
|
|
96
91
|
jobId?: string;
|
|
@@ -98,7 +93,6 @@ interface TestContextOpts<State = Record<string, unknown>, Input = string> {
|
|
|
98
93
|
tags?: string[];
|
|
99
94
|
/** Job input — string for unstructured, or the parsed type for schema-based DVMs. */
|
|
100
95
|
input?: Input;
|
|
101
|
-
/** Job parameters as key-value pairs. */
|
|
102
96
|
params?: Record<string, string>;
|
|
103
97
|
/** Opaque requester identifier. */
|
|
104
98
|
requesterId?: string;
|
|
@@ -121,15 +115,11 @@ interface TestContextOpts<State = Record<string, unknown>, Input = string> {
|
|
|
121
115
|
interface TestJobContext<State = Record<string, unknown>, Input = string> extends SDKJobContext<State, Input> {
|
|
122
116
|
/** All outbound messages sent during the handler. */
|
|
123
117
|
readonly messages: RecordedMessage[];
|
|
124
|
-
/** Whether complete() was called. */
|
|
125
118
|
readonly completed: boolean;
|
|
126
|
-
/** Whether fail() was called. */
|
|
127
119
|
readonly failed: boolean;
|
|
128
120
|
/** Whether fail() was called with `{ refund: true }`. */
|
|
129
121
|
readonly refundRequested: boolean;
|
|
130
|
-
/** The summary string passed to complete(). */
|
|
131
122
|
readonly summary: string | undefined;
|
|
132
|
-
/** The error string passed to fail(). */
|
|
133
123
|
readonly failError: string | undefined;
|
|
134
124
|
/**
|
|
135
125
|
* What the handler declared through `ctx.cost()`, summed, in 1e-6 of
|
|
@@ -142,7 +132,7 @@ interface TestJobContext<State = Record<string, unknown>, Input = string> extend
|
|
|
142
132
|
currency: string;
|
|
143
133
|
} | undefined;
|
|
144
134
|
/**
|
|
145
|
-
* Cancel the job under test
|
|
135
|
+
* Cancel the job under test — aborts `ctx.signal` exactly as a
|
|
146
136
|
* caller cancel, idle timeout, or stale-sweep would in the real runtime, and
|
|
147
137
|
* puts the context into the same post-terminal shape: every emitter
|
|
148
138
|
* (`text` / `artifact` / `sendMessage` / `working` / `progress` /
|
package/dist/testing/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MemoryKVStore
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-SDK6KDJN.js";
|
|
4
4
|
import {
|
|
5
5
|
JobCancelledError,
|
|
6
6
|
MemoryJobStore,
|
|
7
7
|
createInstrumentedFetch
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-JDT5LCJC.js";
|
|
9
9
|
import {
|
|
10
10
|
createNoopLogger
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-XQXJKJ3P.js";
|
|
12
12
|
import "../chunk-66HGCPBU.js";
|
|
13
13
|
import "../chunk-FUJ36YDV.js";
|
|
14
14
|
import {
|
|
15
15
|
validateCurrency
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-4A2RAKCW.js";
|
|
17
17
|
import "../chunk-AT6V3SY7.js";
|
|
18
18
|
|
|
19
19
|
// src/sdk/testing/test-context.ts
|
|
@@ -36,14 +36,12 @@ function createTestContext(opts) {
|
|
|
36
36
|
const log = opts?.log ?? createNoopLogger();
|
|
37
37
|
const input = opts?.input ?? "";
|
|
38
38
|
const ctx = {
|
|
39
|
-
// --- Identity ---
|
|
40
39
|
jobId: opts?.jobId ?? "test-job-1",
|
|
41
40
|
tags: opts?.tags ?? [],
|
|
42
41
|
input,
|
|
43
42
|
params: opts?.params ?? {},
|
|
44
43
|
requesterId: opts?.requesterId ?? "test-requester",
|
|
45
44
|
paidMsats: opts?.paidMsats ?? 0,
|
|
46
|
-
// --- Test inspection ---
|
|
47
45
|
get messages() {
|
|
48
46
|
return messages;
|
|
49
47
|
},
|
|
@@ -66,7 +64,6 @@ function createTestContext(opts) {
|
|
|
66
64
|
if (costPoisoned || costCurrency === void 0) return void 0;
|
|
67
65
|
return { amountMicro: costMicro, currency: costCurrency };
|
|
68
66
|
},
|
|
69
|
-
// --- Messaging ---
|
|
70
67
|
text(message) {
|
|
71
68
|
if (cancelled) return;
|
|
72
69
|
messages.push({ type: "text", content: { text: message } });
|
|
@@ -82,7 +79,6 @@ function createTestContext(opts) {
|
|
|
82
79
|
if (cancelled) return;
|
|
83
80
|
messages.push({ type, content });
|
|
84
81
|
},
|
|
85
|
-
// --- Flow control ---
|
|
86
82
|
prompt(id, text, promptOpts) {
|
|
87
83
|
if (cancelled) return Promise.reject(new JobCancelledError());
|
|
88
84
|
messages.push({
|
|
@@ -148,7 +144,6 @@ function createTestContext(opts) {
|
|
|
148
144
|
cancelled = true;
|
|
149
145
|
abort.abort(new JobCancelledError(reason));
|
|
150
146
|
},
|
|
151
|
-
// --- Accounting ---
|
|
152
147
|
cost(declared) {
|
|
153
148
|
if (cancelled) return;
|
|
154
149
|
const currency = validateCurrency(declared.currency);
|
|
@@ -165,11 +160,9 @@ function createTestContext(opts) {
|
|
|
165
160
|
costAmount = total;
|
|
166
161
|
costMicro = micro;
|
|
167
162
|
},
|
|
168
|
-
// --- Durable execution ---
|
|
169
163
|
async step(_id, fn) {
|
|
170
164
|
return fn();
|
|
171
165
|
},
|
|
172
|
-
// --- Platform services ---
|
|
173
166
|
state,
|
|
174
167
|
store,
|
|
175
168
|
fetch: createInstrumentedFetch(abort.signal),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as Currency } from './step-cache-
|
|
1
|
+
import { C as Currency } from './step-cache-CXg7ziML.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Thrown by `fiatToSatsCeil` / `satsToFiat` when the supplied `ratePerBtc` is
|
|
5
5
|
* non-finite or non-positive. Surfaces a misconfigured fx fetcher loudly
|
|
6
6
|
* instead of silently producing a 0-sats charge or a 0-fiat display string —
|
|
7
|
-
*
|
|
7
|
+
* callers obtain a valid rate
|
|
8
8
|
* from the SDK's fx fetcher (which raises `FxRateUnavailableError` on
|
|
9
9
|
* upstream failure); this error is the defence-in-depth backstop for any
|
|
10
10
|
* caller that constructs a rate by other means.
|
|
@@ -16,8 +16,8 @@ declare class InvalidFxRateError extends Error {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Convert a fiat amount to integer sats at the supplied fiat-per-BTC rate.
|
|
19
|
-
* Rounds
|
|
20
|
-
*
|
|
19
|
+
* Rounds up to cover the fiat amount. Negative or non-finite amounts
|
|
20
|
+
* collapse to 0 (a $0 charge is
|
|
21
21
|
* well-defined). A non-finite or non-positive `ratePerBtc` raises
|
|
22
22
|
* `InvalidFxRateError` — a silent 0 would mask a misconfigured fetcher into
|
|
23
23
|
* shipping a free charge. The math is currency-agnostic — `ratePerBtc` is the
|
|
@@ -33,7 +33,7 @@ declare function fiatToSatsCeil(amount: number, ratePerBtc: number): number;
|
|
|
33
33
|
*/
|
|
34
34
|
declare function satsToFiat(sats: number, ratePerBtc: number): number;
|
|
35
35
|
/**
|
|
36
|
-
* Thrown when a builder-declared USD price literal is malformed
|
|
36
|
+
* Thrown when a builder-declared USD price literal is malformed.
|
|
37
37
|
* Carries the offending value and the config field it came from so
|
|
38
38
|
* `configureDVM`'s boot check can surface both without re-deriving them.
|
|
39
39
|
*/
|
|
@@ -52,13 +52,13 @@ declare class InvalidUsdPriceError extends Error {
|
|
|
52
52
|
* Strict by construction on both format and precision:
|
|
53
53
|
*
|
|
54
54
|
* - The grammar is `$` followed by a decimal number, so `"$1abc"` (which every
|
|
55
|
-
*
|
|
55
|
+
* ad-hoc `parseFloat(v.slice(1))` used to accept as 1) is rejected.
|
|
56
56
|
* - The amount must be expressible at {@link roundUsd}'s four decimal places,
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
57
|
+
* which is the precision **every** advertisement surface carries — `/v1/info`
|
|
58
|
+
* pricing ceilings, `/v1/quote` upfronts, the isolate tier's re-emit. A price
|
|
59
|
+
* finer than that advertises as a different number than it charges, and one
|
|
60
|
+
* below `$0.0001` advertises as `$0` while still gating the job: advertised
|
|
61
|
+
* paid, apparently free, which is the mismatch this parser exists to close.
|
|
62
62
|
*
|
|
63
63
|
* The floor is deliberately 100× coarser than the credit ledger's micro-unit.
|
|
64
64
|
* The ledger could denominate `$0.000001`; no surface a caller reads can
|
|
@@ -66,12 +66,10 @@ declare class InvalidUsdPriceError extends Error {
|
|
|
66
66
|
*/
|
|
67
67
|
declare function parseUsdPrice(value: string, field: string): number;
|
|
68
68
|
/**
|
|
69
|
-
* Round a USD value to 4 decimal places
|
|
70
|
-
* precision
|
|
69
|
+
* Round a USD value to 4 decimal places. This is the **storage / accounting**
|
|
70
|
+
* precision — preserves
|
|
71
71
|
* sub-cent amounts so a `$0.0150` per-minute rate doesn't collapse to
|
|
72
|
-
* `$0.02` before it ever reaches a multiplier.
|
|
73
|
-
* human-render precision, which deliberately truncates at the cent boundary
|
|
74
|
-
* for amounts ≥ $0.01.
|
|
72
|
+
* `$0.02` before it ever reaches a multiplier.
|
|
75
73
|
*/
|
|
76
74
|
declare function roundUsd(usd: number): number;
|
|
77
75
|
/**
|
|
@@ -5,7 +5,7 @@ import { Wallet } from '@cashu/cashu-ts';
|
|
|
5
5
|
* session.
|
|
6
6
|
*
|
|
7
7
|
* When the agent has a mnemonic on disk at `~/.dvm/wallet.mnemonic` AND
|
|
8
|
-
* the wallet's `mnemonic_fingerprint` matches it
|
|
8
|
+
* the wallet's `mnemonic_fingerprint` matches it, NUT-13
|
|
9
9
|
* deterministic secrets are eligible: the constructor receives `bip39seed`
|
|
10
10
|
* derived via `mnemonicToSeedSync` and a {@link PersistentCounterSource}
|
|
11
11
|
* backed by `wallet.nut13_counters`.
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
saveX402Wallet,
|
|
11
11
|
tryX402Payment,
|
|
12
12
|
x402WrongAssetHint
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2ATUAUAO.js";
|
|
14
14
|
import "./chunk-KSQEFVFJ.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-MG67KXU7.js";
|
|
16
16
|
import {
|
|
17
17
|
verifyX402Payment
|
|
18
18
|
} from "./chunk-BIFLRKMO.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvmkit/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-rc.9",
|
|
4
4
|
"description": "SDK for building accountless, pay-per-use Digital Vending Machines",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"esbuild": "0.27.7",
|
|
95
95
|
"eslint": "10.9.1",
|
|
96
96
|
"globals": "17.11.0",
|
|
97
|
+
"sdk-receipt-compat": "npm:@dvmkit/sdk@0.1.5-rc.9",
|
|
97
98
|
"tsup": "8.5.1",
|
|
98
99
|
"tsx": "4.21.0",
|
|
99
100
|
"typescript": "5.9.3",
|