@blockrun/llm 3.24.8 → 3.24.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/dist/index.cjs +235 -97
- package/dist/index.d.cts +62 -11
- package/dist/index.d.ts +62 -11
- package/dist/index.js +235 -97
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -231,12 +231,13 @@ interface Settlement {
|
|
|
231
231
|
/** Present and false only when the gateway reported a failed settlement. */
|
|
232
232
|
success?: false;
|
|
233
233
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
234
|
+
* Why the gateway served this paid request without settling it, from
|
|
235
|
+
* `X-Settlement-Skipped` (else `X-Payment-Waived`): `"free-fallback"` when a
|
|
236
|
+
* free fallback model answered, or another reason the gateway names. Nothing
|
|
236
237
|
* moved on chain, so `costUsd` is 0 and nothing was added to `getSpending()`.
|
|
237
238
|
* `quotedUsd` still states what was signed.
|
|
238
239
|
*/
|
|
239
|
-
skipped?: "free-fallback";
|
|
240
|
+
skipped?: "free-fallback" | (string & {});
|
|
240
241
|
}
|
|
241
242
|
interface FunctionCall {
|
|
242
243
|
name: string;
|
|
@@ -1491,12 +1492,21 @@ declare class LLMClient {
|
|
|
1491
1492
|
/** Send the signed payment and read the answer. The payment may settle from here on. */
|
|
1492
1493
|
private sendPaid;
|
|
1493
1494
|
/**
|
|
1494
|
-
* Book a served, paid chat call and attach its cost. A response
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1495
|
+
* Book a served, paid chat call and attach its cost. A response whose
|
|
1496
|
+
* settlement the gateway skipped ({@link settlementSkipped}: e.g.
|
|
1497
|
+
* `X-Settlement-Skipped: free-fallback`) moved nothing on chain, so it is
|
|
1497
1498
|
* not added to `getSpending()` or the cost log, and reports `costUsd: 0`.
|
|
1498
1499
|
*/
|
|
1499
1500
|
private bookPaid;
|
|
1501
|
+
/**
|
|
1502
|
+
* Book a served, paid raw (non-chat) call: the signed amount goes to
|
|
1503
|
+
* `getSpending()` and the cost log, unless the gateway skipped settlement
|
|
1504
|
+
* ({@link settlementSkipped}: e.g. `X-Settlement-Skipped: empty-result` on an
|
|
1505
|
+
* empty prediction-market search, `unexecuted` on a JSON-RPC call that never
|
|
1506
|
+
* ran, or `X-Payment-Waived`), in which case nothing moved and nothing is
|
|
1507
|
+
* booked. `X-Payment-Settled: false` alone is still booked: it is owed.
|
|
1508
|
+
*/
|
|
1509
|
+
private bookPaidRaw;
|
|
1500
1510
|
/**
|
|
1501
1511
|
* Sign a payment header and return the PAYMENT-SIGNATURE value.
|
|
1502
1512
|
* Extracted to share logic between streaming and non-streaming flows.
|
|
@@ -2517,12 +2527,18 @@ declare class BlockrunClient {
|
|
|
2517
2527
|
private handlePaymentAndRetry;
|
|
2518
2528
|
/**
|
|
2519
2529
|
* Read a 402 response's payment requirements (header or body), then sign and
|
|
2520
|
-
* return the base64 PAYMENT-SIGNATURE payload
|
|
2521
|
-
*
|
|
2530
|
+
* return the base64 PAYMENT-SIGNATURE payload with what it pays, in USD.
|
|
2531
|
+
* The cost stays with the call that signed it (booked by `recordSpending`):
|
|
2532
|
+
* concurrent calls on one client never share it.
|
|
2522
2533
|
*/
|
|
2523
2534
|
private signFrom402;
|
|
2524
|
-
/**
|
|
2525
|
-
|
|
2535
|
+
/**
|
|
2536
|
+
* Book `costUsd`, what the call that `response` answered signed. A response
|
|
2537
|
+
* whose settlement the gateway skipped ({@link settlementSkipped}:
|
|
2538
|
+
* `X-Settlement-Skipped: <reason>` or `X-Payment-Waived`) moved nothing, so
|
|
2539
|
+
* nothing is booked. `X-Payment-Settled: false` alone is still booked: the
|
|
2540
|
+
* payment is owed.
|
|
2541
|
+
*/
|
|
2526
2542
|
private recordSpending;
|
|
2527
2543
|
private throwApiError;
|
|
2528
2544
|
private fetchWithTimeout;
|
|
@@ -3492,6 +3508,33 @@ declare class SolanaBatchPayer {
|
|
|
3492
3508
|
* once.
|
|
3493
3509
|
*/
|
|
3494
3510
|
private createPayload;
|
|
3511
|
+
/**
|
|
3512
|
+
* Queue a re-read of a stored channel whose account is gone at finalized
|
|
3513
|
+
* and at confirmed commitment (closed, its account reclaimed), anchored at
|
|
3514
|
+
* the SDK's own `getBlockHeight` at confirmed. The anchor is saved in the
|
|
3515
|
+
* record (`reclaimAnchorHeight`), so a short-lived process finishes the
|
|
3516
|
+
* wait instead of starting it over; a failed read leaves resync to take it,
|
|
3517
|
+
* and a failed save only costs that. resync pays exact until finality is
|
|
3518
|
+
* LANDING_MARGIN_BLOCKS past the anchor, then drops the record if the
|
|
3519
|
+
* finalized chain still has no account (a lagging read finds the channel
|
|
3520
|
+
* and rewrites the record, without the anchor).
|
|
3521
|
+
*/
|
|
3522
|
+
private queueReclaimed;
|
|
3523
|
+
/**
|
|
3524
|
+
* After the gateway refused an authorization with a plain 402 (no receipt,
|
|
3525
|
+
* not an admission refusal), check the channel it paid into. That is how
|
|
3526
|
+
* the gateway answers an authorization into a channel the facilitator
|
|
3527
|
+
* closed (its verify rejects it), and a channel with deposit to spare is
|
|
3528
|
+
* otherwise never read again: every call would sign another authorization
|
|
3529
|
+
* into it and pay exact. A channel the finalized chain shows closing,
|
|
3530
|
+
* closed or not this wallet's is re-read through resync (record dropped,
|
|
3531
|
+
* or kept and paid exact); one gone at every commitment is queued as
|
|
3532
|
+
* {@link queueReclaimed}; an open one of this wallet's, or one only at
|
|
3533
|
+
* confirmed (not finalized yet), is left as it is. A queued re-read is run
|
|
3534
|
+
* at once. Best effort: a failed read changes nothing, and the next
|
|
3535
|
+
* refusal checks again.
|
|
3536
|
+
*/
|
|
3537
|
+
private recheckRefusedChannel;
|
|
3495
3538
|
/**
|
|
3496
3539
|
* When this payment will top up the wallet's channel, read how much of its
|
|
3497
3540
|
* deposit is already settled on-chain (at `finalized` commitment, so never
|
|
@@ -4016,7 +4059,15 @@ declare class SolanaLLMClient {
|
|
|
4016
4059
|
* first is marked `"paid-or-in-doubt"`: the payment may have settled.
|
|
4017
4060
|
*/
|
|
4018
4061
|
private assertPaid;
|
|
4019
|
-
/**
|
|
4062
|
+
/**
|
|
4063
|
+
* Count one settled x402 payment against the session total.
|
|
4064
|
+
*
|
|
4065
|
+
* Takes the paid response so no booking site can forget the check: a
|
|
4066
|
+
* response whose settlement the gateway skipped ({@link settlementSkipped}:
|
|
4067
|
+
* `X-Settlement-Skipped: free-fallback | empty-result | unexecuted | …`, or
|
|
4068
|
+
* `X-Payment-Waived`) moved nothing on chain and books nothing.
|
|
4069
|
+
* `X-Payment-Settled: false` alone is still booked: the payment is owed.
|
|
4070
|
+
*/
|
|
4020
4071
|
private recordSettlement;
|
|
4021
4072
|
private fetchWithTimeout;
|
|
4022
4073
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -231,12 +231,13 @@ interface Settlement {
|
|
|
231
231
|
/** Present and false only when the gateway reported a failed settlement. */
|
|
232
232
|
success?: false;
|
|
233
233
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
234
|
+
* Why the gateway served this paid request without settling it, from
|
|
235
|
+
* `X-Settlement-Skipped` (else `X-Payment-Waived`): `"free-fallback"` when a
|
|
236
|
+
* free fallback model answered, or another reason the gateway names. Nothing
|
|
236
237
|
* moved on chain, so `costUsd` is 0 and nothing was added to `getSpending()`.
|
|
237
238
|
* `quotedUsd` still states what was signed.
|
|
238
239
|
*/
|
|
239
|
-
skipped?: "free-fallback";
|
|
240
|
+
skipped?: "free-fallback" | (string & {});
|
|
240
241
|
}
|
|
241
242
|
interface FunctionCall {
|
|
242
243
|
name: string;
|
|
@@ -1491,12 +1492,21 @@ declare class LLMClient {
|
|
|
1491
1492
|
/** Send the signed payment and read the answer. The payment may settle from here on. */
|
|
1492
1493
|
private sendPaid;
|
|
1493
1494
|
/**
|
|
1494
|
-
* Book a served, paid chat call and attach its cost. A response
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1495
|
+
* Book a served, paid chat call and attach its cost. A response whose
|
|
1496
|
+
* settlement the gateway skipped ({@link settlementSkipped}: e.g.
|
|
1497
|
+
* `X-Settlement-Skipped: free-fallback`) moved nothing on chain, so it is
|
|
1497
1498
|
* not added to `getSpending()` or the cost log, and reports `costUsd: 0`.
|
|
1498
1499
|
*/
|
|
1499
1500
|
private bookPaid;
|
|
1501
|
+
/**
|
|
1502
|
+
* Book a served, paid raw (non-chat) call: the signed amount goes to
|
|
1503
|
+
* `getSpending()` and the cost log, unless the gateway skipped settlement
|
|
1504
|
+
* ({@link settlementSkipped}: e.g. `X-Settlement-Skipped: empty-result` on an
|
|
1505
|
+
* empty prediction-market search, `unexecuted` on a JSON-RPC call that never
|
|
1506
|
+
* ran, or `X-Payment-Waived`), in which case nothing moved and nothing is
|
|
1507
|
+
* booked. `X-Payment-Settled: false` alone is still booked: it is owed.
|
|
1508
|
+
*/
|
|
1509
|
+
private bookPaidRaw;
|
|
1500
1510
|
/**
|
|
1501
1511
|
* Sign a payment header and return the PAYMENT-SIGNATURE value.
|
|
1502
1512
|
* Extracted to share logic between streaming and non-streaming flows.
|
|
@@ -2517,12 +2527,18 @@ declare class BlockrunClient {
|
|
|
2517
2527
|
private handlePaymentAndRetry;
|
|
2518
2528
|
/**
|
|
2519
2529
|
* Read a 402 response's payment requirements (header or body), then sign and
|
|
2520
|
-
* return the base64 PAYMENT-SIGNATURE payload
|
|
2521
|
-
*
|
|
2530
|
+
* return the base64 PAYMENT-SIGNATURE payload with what it pays, in USD.
|
|
2531
|
+
* The cost stays with the call that signed it (booked by `recordSpending`):
|
|
2532
|
+
* concurrent calls on one client never share it.
|
|
2522
2533
|
*/
|
|
2523
2534
|
private signFrom402;
|
|
2524
|
-
/**
|
|
2525
|
-
|
|
2535
|
+
/**
|
|
2536
|
+
* Book `costUsd`, what the call that `response` answered signed. A response
|
|
2537
|
+
* whose settlement the gateway skipped ({@link settlementSkipped}:
|
|
2538
|
+
* `X-Settlement-Skipped: <reason>` or `X-Payment-Waived`) moved nothing, so
|
|
2539
|
+
* nothing is booked. `X-Payment-Settled: false` alone is still booked: the
|
|
2540
|
+
* payment is owed.
|
|
2541
|
+
*/
|
|
2526
2542
|
private recordSpending;
|
|
2527
2543
|
private throwApiError;
|
|
2528
2544
|
private fetchWithTimeout;
|
|
@@ -3492,6 +3508,33 @@ declare class SolanaBatchPayer {
|
|
|
3492
3508
|
* once.
|
|
3493
3509
|
*/
|
|
3494
3510
|
private createPayload;
|
|
3511
|
+
/**
|
|
3512
|
+
* Queue a re-read of a stored channel whose account is gone at finalized
|
|
3513
|
+
* and at confirmed commitment (closed, its account reclaimed), anchored at
|
|
3514
|
+
* the SDK's own `getBlockHeight` at confirmed. The anchor is saved in the
|
|
3515
|
+
* record (`reclaimAnchorHeight`), so a short-lived process finishes the
|
|
3516
|
+
* wait instead of starting it over; a failed read leaves resync to take it,
|
|
3517
|
+
* and a failed save only costs that. resync pays exact until finality is
|
|
3518
|
+
* LANDING_MARGIN_BLOCKS past the anchor, then drops the record if the
|
|
3519
|
+
* finalized chain still has no account (a lagging read finds the channel
|
|
3520
|
+
* and rewrites the record, without the anchor).
|
|
3521
|
+
*/
|
|
3522
|
+
private queueReclaimed;
|
|
3523
|
+
/**
|
|
3524
|
+
* After the gateway refused an authorization with a plain 402 (no receipt,
|
|
3525
|
+
* not an admission refusal), check the channel it paid into. That is how
|
|
3526
|
+
* the gateway answers an authorization into a channel the facilitator
|
|
3527
|
+
* closed (its verify rejects it), and a channel with deposit to spare is
|
|
3528
|
+
* otherwise never read again: every call would sign another authorization
|
|
3529
|
+
* into it and pay exact. A channel the finalized chain shows closing,
|
|
3530
|
+
* closed or not this wallet's is re-read through resync (record dropped,
|
|
3531
|
+
* or kept and paid exact); one gone at every commitment is queued as
|
|
3532
|
+
* {@link queueReclaimed}; an open one of this wallet's, or one only at
|
|
3533
|
+
* confirmed (not finalized yet), is left as it is. A queued re-read is run
|
|
3534
|
+
* at once. Best effort: a failed read changes nothing, and the next
|
|
3535
|
+
* refusal checks again.
|
|
3536
|
+
*/
|
|
3537
|
+
private recheckRefusedChannel;
|
|
3495
3538
|
/**
|
|
3496
3539
|
* When this payment will top up the wallet's channel, read how much of its
|
|
3497
3540
|
* deposit is already settled on-chain (at `finalized` commitment, so never
|
|
@@ -4016,7 +4059,15 @@ declare class SolanaLLMClient {
|
|
|
4016
4059
|
* first is marked `"paid-or-in-doubt"`: the payment may have settled.
|
|
4017
4060
|
*/
|
|
4018
4061
|
private assertPaid;
|
|
4019
|
-
/**
|
|
4062
|
+
/**
|
|
4063
|
+
* Count one settled x402 payment against the session total.
|
|
4064
|
+
*
|
|
4065
|
+
* Takes the paid response so no booking site can forget the check: a
|
|
4066
|
+
* response whose settlement the gateway skipped ({@link settlementSkipped}:
|
|
4067
|
+
* `X-Settlement-Skipped: free-fallback | empty-result | unexecuted | …`, or
|
|
4068
|
+
* `X-Payment-Waived`) moved nothing on chain and books nothing.
|
|
4069
|
+
* `X-Payment-Settled: false` alone is still booked: the payment is owed.
|
|
4070
|
+
*/
|
|
4020
4071
|
private recordSettlement;
|
|
4021
4072
|
private fetchWithTimeout;
|
|
4022
4073
|
}
|