@blockrun/llm 3.22.1 → 3.23.1
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 +959 -1319
- package/dist/index.cjs +61 -4
- package/dist/index.d.cts +433 -4
- package/dist/index.d.ts +433 -4
- package/dist/index.js +60 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1655,7 +1655,7 @@ declare class LLMClient {
|
|
|
1655
1655
|
/**
|
|
1656
1656
|
* Query Predexon prediction market data (GET endpoints).
|
|
1657
1657
|
*
|
|
1658
|
-
* Access real-time data from Polymarket, Kalshi,
|
|
1658
|
+
* Access real-time data from Polymarket, Kalshi, Limitless, Opinion, Predict.Fun, Binance Futures, UMA and sports markets.
|
|
1659
1659
|
* Powered by Predexon. Billed per request.
|
|
1660
1660
|
*
|
|
1661
1661
|
* @param path - Endpoint path, e.g. "polymarket/events", "kalshi/markets/12345"
|
|
@@ -1853,7 +1853,8 @@ declare class ImageClient {
|
|
|
1853
1853
|
* combined with multiple source images.
|
|
1854
1854
|
*
|
|
1855
1855
|
* Edit-capable models: `openai/gpt-image-1`, `openai/gpt-image-2`,
|
|
1856
|
-
* `google/nano-banana`, `google/nano-banana-
|
|
1856
|
+
* `openai/gpt-image-2.5-sunburst`, `google/nano-banana`, `google/nano-banana-2`,
|
|
1857
|
+
* `google/nano-banana-pro`. `mask` is OpenAI-only.
|
|
1857
1858
|
*
|
|
1858
1859
|
* @param prompt - Text description of the desired edit
|
|
1859
1860
|
* @param image - A base64 `data:image/...` URI, or an array of 2–4 such URIs to fuse
|
|
@@ -3143,6 +3144,434 @@ declare class BatchCloseDeferredError extends BlockrunError {
|
|
|
3143
3144
|
detail: string;
|
|
3144
3145
|
});
|
|
3145
3146
|
}
|
|
3147
|
+
/**
|
|
3148
|
+
* The outcome of one batch attempt.
|
|
3149
|
+
*
|
|
3150
|
+
* - `paid`: served, and paid with batch.
|
|
3151
|
+
* - `fallback`: pay `exact`. One after a 429 wait carries the fresh 402 it
|
|
3152
|
+
* fetched, which the `exact` payment must be signed against.
|
|
3153
|
+
* - `served`: the fresh, unpaid challenge sent after a wait was answered with
|
|
3154
|
+
* a 2xx. That response is the call's result; nothing was paid, and nothing
|
|
3155
|
+
* must be.
|
|
3156
|
+
* - `failed`: that fresh challenge got neither a 402 nor a 2xx (or no answer,
|
|
3157
|
+
* or a 402 that cannot be read). Raise `error`, which carries the `"unpaid"`
|
|
3158
|
+
* retry disposition: the 429 waited out proved nothing was charged, so
|
|
3159
|
+
* nothing was paid for the call. Never pay `exact` against the stale
|
|
3160
|
+
* challenge instead.
|
|
3161
|
+
*/
|
|
3162
|
+
type BatchAttempt = {
|
|
3163
|
+
kind: "paid";
|
|
3164
|
+
response: Response;
|
|
3165
|
+
chargedUsd: number;
|
|
3166
|
+
} | {
|
|
3167
|
+
kind: "fallback";
|
|
3168
|
+
reason: string;
|
|
3169
|
+
paymentRequired?: PaymentRequired;
|
|
3170
|
+
} | {
|
|
3171
|
+
kind: "served";
|
|
3172
|
+
response: Response;
|
|
3173
|
+
} | {
|
|
3174
|
+
kind: "failed";
|
|
3175
|
+
error: unknown;
|
|
3176
|
+
};
|
|
3177
|
+
/**
|
|
3178
|
+
* The answer to a fresh, unpaid challenge request (see
|
|
3179
|
+
* {@link SolanaBatchPayer.pay}): a 402 to pay, or a 2xx that served the
|
|
3180
|
+
* request without a payment. Anything else is thrown.
|
|
3181
|
+
*/
|
|
3182
|
+
type Rechallenge = {
|
|
3183
|
+
kind: "challenge";
|
|
3184
|
+
paymentRequired: PaymentRequired;
|
|
3185
|
+
} | {
|
|
3186
|
+
kind: "served";
|
|
3187
|
+
response: Response;
|
|
3188
|
+
};
|
|
3189
|
+
interface SolanaBatchPayerInit {
|
|
3190
|
+
options: SolanaBatchOptions;
|
|
3191
|
+
secretKey: () => Promise<Uint8Array>;
|
|
3192
|
+
address: () => Promise<string>;
|
|
3193
|
+
rpcUrl: string;
|
|
3194
|
+
/** Headers the exact path sends to `rpcUrl` (`rpcHeaders`, `SOLANA_RPC_HEADERS`, `SOLANA_RPC_API_KEY`). */
|
|
3195
|
+
rpcHeaders?: Record<string, string>;
|
|
3196
|
+
/**
|
|
3197
|
+
* Called once, when the payer is constructed, with a registrar for x402
|
|
3198
|
+
* payment-creation hooks. An embedder that enforces its own spend rules
|
|
3199
|
+
* registers its hooks here, so they see every batch payment THIS payer signs
|
|
3200
|
+
* (each one's `selectedRequirements.amount` is the per-call ceiling, not the
|
|
3201
|
+
* channel deposit) exactly as they see the embedder's own `exact` payments.
|
|
3202
|
+
*
|
|
3203
|
+
* The hooks are this payer's own: payers that share a wallet (and so its
|
|
3204
|
+
* channel and scheme client) never run each other's hooks. A before-hook
|
|
3205
|
+
* that throws refuses the payment: nothing is signed or sent, and `pay()`
|
|
3206
|
+
* reports a fallback. An after-hook that throws does the same: the payment
|
|
3207
|
+
* was signed but is rolled back unsent, so the channel is not left pending,
|
|
3208
|
+
* and the failure hooks are told. Failure hooks are notifications only: a
|
|
3209
|
+
* payload one returns as `recovered` is ignored, since a batch payment is
|
|
3210
|
+
* never replaced by a payment built outside the batch scheme.
|
|
3211
|
+
*/
|
|
3212
|
+
configureClient?: (client: X402ClientLike) => void;
|
|
3213
|
+
}
|
|
3214
|
+
/**
|
|
3215
|
+
* The slice of `@x402/core`'s x402Client handed to
|
|
3216
|
+
* {@link SolanaBatchPayerInit.configureClient}: its payment-creation hooks.
|
|
3217
|
+
* Structural, so this package's types never require the optional
|
|
3218
|
+
* `@x402/core` peer to be installed.
|
|
3219
|
+
*/
|
|
3220
|
+
interface X402ClientLike {
|
|
3221
|
+
onBeforePaymentCreation(hook: (context: X402HookContext) => Promise<unknown> | unknown): unknown;
|
|
3222
|
+
onAfterPaymentCreation(hook: (context: X402HookContext) => Promise<unknown> | unknown): unknown;
|
|
3223
|
+
onPaymentCreationFailure(hook: (context: X402HookContext) => Promise<unknown> | unknown): unknown;
|
|
3224
|
+
}
|
|
3225
|
+
/** What a payment-creation hook receives: at least the requirement being paid. */
|
|
3226
|
+
interface X402HookContext {
|
|
3227
|
+
selectedRequirements: PaymentRequirement & {
|
|
3228
|
+
scheme: string;
|
|
3229
|
+
network: string;
|
|
3230
|
+
amount?: string;
|
|
3231
|
+
};
|
|
3232
|
+
[key: string]: unknown;
|
|
3233
|
+
}
|
|
3234
|
+
/**
|
|
3235
|
+
* One wallet's batch-settlement payer. Owned by a SolanaLLMClient.
|
|
3236
|
+
*
|
|
3237
|
+
* At most one batch request is in flight per wallet: the server-signed scheme
|
|
3238
|
+
* allows a single pending authorization per channel. Concurrent calls do not
|
|
3239
|
+
* queue behind it, they pay with `exact`, so batch never makes a parallel
|
|
3240
|
+
* workload slower than it is today. The exception is a 429 cooldown: then
|
|
3241
|
+
* every call for the wallet waits it out (within its own `rateLimit` budget)
|
|
3242
|
+
* rather than send the gateway another channel open it would refuse.
|
|
3243
|
+
*/
|
|
3244
|
+
declare class SolanaBatchPayer {
|
|
3245
|
+
private readonly init;
|
|
3246
|
+
private state?;
|
|
3247
|
+
private readonly maxAttempts;
|
|
3248
|
+
private readonly maxWaitMs;
|
|
3249
|
+
private readonly inDoubtMaxWaitMs;
|
|
3250
|
+
private readonly counters;
|
|
3251
|
+
private readonly hooks;
|
|
3252
|
+
constructor(init: SolanaBatchPayerInit);
|
|
3253
|
+
/** A copy of this client's batch counters. */
|
|
3254
|
+
stats(): SolanaBatchStats;
|
|
3255
|
+
private storeFile;
|
|
3256
|
+
/**
|
|
3257
|
+
* This wallet's shared batch state, or why this client cannot use batch:
|
|
3258
|
+
* another client in this process holds the wallet with a different trust
|
|
3259
|
+
* configuration, or another live process owns its channel file.
|
|
3260
|
+
*/
|
|
3261
|
+
private wallet;
|
|
3262
|
+
private build;
|
|
3263
|
+
/** Run a scheme call so its RPC requests carry this client's `rpcHeaders`. */
|
|
3264
|
+
private withRpcHeaders;
|
|
3265
|
+
/**
|
|
3266
|
+
* Drop everything this wallet knows about one channel, on disk and in
|
|
3267
|
+
* memory, leaving its other channels' records alone. The scheme is rebuilt
|
|
3268
|
+
* on the next call, without the closed channel in its memory.
|
|
3269
|
+
*/
|
|
3270
|
+
private forget;
|
|
3271
|
+
/**
|
|
3272
|
+
* Stop trusting the record of the channel a payload paid into: the next
|
|
3273
|
+
* payment re-reads that channel from the chain first. The scheme has
|
|
3274
|
+
* already restored (or, for an open, dropped) its record; the book still
|
|
3275
|
+
* knows the channel and the cumulative it last confirmed.
|
|
3276
|
+
*/
|
|
3277
|
+
private distrust;
|
|
3278
|
+
/**
|
|
3279
|
+
* The channel's total deposit if a deposit payload landed: the confirmed
|
|
3280
|
+
* deposit plus this one (for an open, nothing plus this one). Undefined for
|
|
3281
|
+
* a payment without a deposit, or a channel the SDK has no record of.
|
|
3282
|
+
*/
|
|
3283
|
+
private depositExpectation;
|
|
3284
|
+
/**
|
|
3285
|
+
* Re-read every distrusted channel from the chain, at `finalized`
|
|
3286
|
+
* commitment, and rewrite its record: the on-chain deposit, and the highest
|
|
3287
|
+
* of the cumulative the SDK can vouch for, the cumulative the stored record
|
|
3288
|
+
* already confirmed, and the on-chain settled amount. A closing or closed
|
|
3289
|
+
* channel is dropped. The scheme is rebuilt to load the repaired record.
|
|
3290
|
+
*
|
|
3291
|
+
* The stored cumulative is never moved backwards. A deposit's intent can
|
|
3292
|
+
* outlive the receipt that reconciled it (the process died, or the journal
|
|
3293
|
+
* could not be cleared, after the scheme saved the new state), so its
|
|
3294
|
+
* cumulative may predate vouchers the scheme has since confirmed; and
|
|
3295
|
+
* vouchers are redeemed on-chain asynchronously, so `settled` can lag too.
|
|
3296
|
+
* Rewriting the record with either would leave every later voucher
|
|
3297
|
+
* unreconcilable.
|
|
3298
|
+
*
|
|
3299
|
+
* A deposit in doubt is settled by the chain alone:
|
|
3300
|
+
* - landed: the finalized channel holds at least the deposit it would
|
|
3301
|
+
* bring (and at least what the record already claimed);
|
|
3302
|
+
* - never landed: the finalized chain is {@link LANDING_MARGIN_BLOCKS}
|
|
3303
|
+
* past the target's anchor height, and a read at least that recent still
|
|
3304
|
+
* does not show it. An open's record is then dropped; a top-up's channel
|
|
3305
|
+
* is rewritten with the deposit it really has.
|
|
3306
|
+
* Until one of those holds, it is pending. This settles only the deposit:
|
|
3307
|
+
* whether the gateway charged the payment that carried it is never read
|
|
3308
|
+
* from the chain.
|
|
3309
|
+
*
|
|
3310
|
+
* @throws ResyncError when the chain cannot be read, or a deposit may still
|
|
3311
|
+
* land: the caller pays exact and the re-read is tried again next call.
|
|
3312
|
+
* Nothing opens or tops up a channel while any re-read is pending.
|
|
3313
|
+
*/
|
|
3314
|
+
private resync;
|
|
3315
|
+
/**
|
|
3316
|
+
* A distrusted channel's account at `finalized` commitment, checked to be
|
|
3317
|
+
* this wallet's channel for the record's operator and mint.
|
|
3318
|
+
*
|
|
3319
|
+
* @throws ResyncError (`channel_unreadable`) for any other payment channel.
|
|
3320
|
+
*/
|
|
3321
|
+
private readOwnChannel;
|
|
3322
|
+
/**
|
|
3323
|
+
* Make one event observable three ways: a stderr line (every time, never
|
|
3324
|
+
* deduplicated), this client's counters, and the caller's `onEvent`.
|
|
3325
|
+
*/
|
|
3326
|
+
private report;
|
|
3327
|
+
/** Report a fallback and tell the caller to pay exact. */
|
|
3328
|
+
private fallback;
|
|
3329
|
+
/**
|
|
3330
|
+
* Pay one 402 with batch-settlement, or say why the caller should use exact.
|
|
3331
|
+
*
|
|
3332
|
+
* `send` replays the original request with the payment headers. Every send
|
|
3333
|
+
* goes through {@link sendOnce}, the one place an answer is classified as
|
|
3334
|
+
* charged, not charged, or in doubt:
|
|
3335
|
+
*
|
|
3336
|
+
* - charged: the 2xx is returned (`paid`);
|
|
3337
|
+
* - not charged (the gateway's explicit answer to a first send): a 429
|
|
3338
|
+
* whose receipt proves nothing was broadcast is backed off
|
|
3339
|
+
* (`Retry-After`, else 1s, 2s, 4s with jitter) and paid again with a new
|
|
3340
|
+
* payment built from a fresh 402 (`rechallenge`: the original's
|
|
3341
|
+
* `recentBlockhash` / `recentSlot` can be stale by then), within
|
|
3342
|
+
* `rateLimit.maxAttempts` / `maxWaitMs`, then with exact; any other is
|
|
3343
|
+
* paid with exact (`fallback`). A fresh challenge served with a 2xx is
|
|
3344
|
+
* the call's result (`served`, nothing paid); one that fails otherwise
|
|
3345
|
+
* is the call's error (`failed`, `"unpaid"`), never an exact payment
|
|
3346
|
+
* against the stale challenge;
|
|
3347
|
+
* - in doubt: ends only with a definitive success receipt from a replay
|
|
3348
|
+
* of the identical payment ({@link resolveInDoubt}: the one replay a
|
|
3349
|
+
* receipt-less 429 is allowed, or the replays of a payment carrying a
|
|
3350
|
+
* payment identifier while the gateway says one can succeed, within
|
|
3351
|
+
* `inDoubt.maxWaitMs`), or a thrown {@link BatchPaymentUnresolvedError}.
|
|
3352
|
+
* No new authorization, no new deposit, no exact payment and no fallback
|
|
3353
|
+
* model is ever paid for a call in doubt.
|
|
3354
|
+
*
|
|
3355
|
+
* The wallet stays in cooldown after a 429, so its other calls wait
|
|
3356
|
+
* instead of sending opens of their own. After a deposit the facilitator
|
|
3357
|
+
* refused before broadcasting it (a 402 with a failed `batch_*` admission
|
|
3358
|
+
* receipt), its calls do not wait: they pay exact at once
|
|
3359
|
+
* (`admission_refused`) until the refusal cooldown ends.
|
|
3360
|
+
*
|
|
3361
|
+
* @param closesAtStart - {@link closeFence}, taken before the call's first
|
|
3362
|
+
* (unpaid) request. If a close completed since, the call pays exact
|
|
3363
|
+
* (`closed_during_call`): it started before the close, so it must not
|
|
3364
|
+
* open a channel the caller believes is closed.
|
|
3365
|
+
*/
|
|
3366
|
+
pay(paymentRequired: PaymentRequired, send: (headers: Record<string, string>) => Promise<Response>, rechallenge: () => Promise<Rechallenge>, closesAtStart?: number): Promise<BatchAttempt>;
|
|
3367
|
+
/**
|
|
3368
|
+
* The close fence for a call about to send its first request: how many
|
|
3369
|
+
* closes this wallet has completed so far, to hand to {@link pay}.
|
|
3370
|
+
* `close()` refuses while a call is inside `pay()`, but a call still
|
|
3371
|
+
* waiting for its 402 is not there yet; the fence covers that window.
|
|
3372
|
+
* Undefined when the wallet cannot be named (no fence then; `pay()`
|
|
3373
|
+
* reports why batch is unavailable).
|
|
3374
|
+
*/
|
|
3375
|
+
closeFence(): Promise<number | undefined>;
|
|
3376
|
+
/** {@link pay}, for a wallet this client may use. */
|
|
3377
|
+
private payWith;
|
|
3378
|
+
/**
|
|
3379
|
+
* Put the wallet in a 429 cooldown for `delay` ms (`Retry-After`, or the
|
|
3380
|
+
* default backoff), and return how long this call would have to wait.
|
|
3381
|
+
*
|
|
3382
|
+
* The shared cooldown is capped at `rateLimit.maxWaitMs`, so one header,
|
|
3383
|
+
* however long, never keeps the wallet's calls off batch for longer than
|
|
3384
|
+
* the retry budget. This call still weighs the full delay: one it cannot
|
|
3385
|
+
* wait out within its budget is not waited at all, and the caller pays
|
|
3386
|
+
* exact (or raises a payment in doubt) at once.
|
|
3387
|
+
*/
|
|
3388
|
+
private coolDown;
|
|
3389
|
+
/**
|
|
3390
|
+
* Try to end a payment in doubt with the gateway's own word.
|
|
3391
|
+
*
|
|
3392
|
+
* The one source of evidence this SDK accepts is a definitive success
|
|
3393
|
+
* receipt on a byte-identical replay of the payment. Any other answer to a
|
|
3394
|
+
* replay (a 402 or `duplicate_settlement`, which mean the original reached
|
|
3395
|
+
* the gateway; a 409; another 429; a 5xx; a timeout) leaves it in doubt.
|
|
3396
|
+
*
|
|
3397
|
+
* - A payment carrying a payment identifier is replayed for as long as
|
|
3398
|
+
* the gateway says a later replay can succeed ({@link replayInDoubt}).
|
|
3399
|
+
* - Any other payment gets a replay only after a 429 without a receipt:
|
|
3400
|
+
* one, after its backoff (the owner's bounded safety attempt), within
|
|
3401
|
+
* `rateLimit`. Every other in-doubt outcome is never replayed.
|
|
3402
|
+
*
|
|
3403
|
+
* Chain state is not evidence here: it can settle a deposit (see
|
|
3404
|
+
* `resync`), never whether the gateway charged.
|
|
3405
|
+
*
|
|
3406
|
+
* @returns the charged replay, or the doubt to raise.
|
|
3407
|
+
*/
|
|
3408
|
+
private resolveInDoubt;
|
|
3409
|
+
/**
|
|
3410
|
+
* Replay a payment in doubt that carries a payment identifier until the
|
|
3411
|
+
* gateway's answer settles it.
|
|
3412
|
+
*
|
|
3413
|
+
* A gateway that declares `payment-identifier` stores each paid response
|
|
3414
|
+
* under its identifier and answers a byte-identical replay of a completed
|
|
3415
|
+
* request with it, the original receipt included; while the original is
|
|
3416
|
+
* still running, it answers 409 with a `Retry-After`. So the identical
|
|
3417
|
+
* payment (the same `PAYMENT-SIGNATURE` header and the same body) is
|
|
3418
|
+
* replayed for as long as the last answer says a later one can succeed
|
|
3419
|
+
* ({@link replayMayResolve}), after {@link inDoubtWait} each time, as long
|
|
3420
|
+
* as the wait fits in `inDoubt.maxWaitMs`, counted from the first doubt:
|
|
3421
|
+
* every wait (as long as it really took) and every replay's round trip. A
|
|
3422
|
+
* replay already sent is not cut short. These replays do not count
|
|
3423
|
+
* against `rateLimit`; a 429 among them still puts the wallet in cooldown.
|
|
3424
|
+
*
|
|
3425
|
+
* Every answer that does not settle it is held back from the scheme
|
|
3426
|
+
* ({@link InDoubt.held}) and handed over only once no replay follows, so
|
|
3427
|
+
* the scheme rolls the payment back once, or takes the receipt that answer
|
|
3428
|
+
* carries. That is the last answer, unless an earlier one carried a
|
|
3429
|
+
* success receipt and the later ones do not: a success receipt is the
|
|
3430
|
+
* gateway's word that it charged, and handing the scheme a receipt-less
|
|
3431
|
+
* refusal of a replay instead would roll a real charge back and desync the
|
|
3432
|
+
* channel's cumulative.
|
|
3433
|
+
*
|
|
3434
|
+
* @returns the charged replay, or the doubt to raise.
|
|
3435
|
+
*/
|
|
3436
|
+
private replayInDoubt;
|
|
3437
|
+
/**
|
|
3438
|
+
* Raise a payment in doubt: release the scheme's hold on it (the channel
|
|
3439
|
+
* goes back to its confirmed state), put a deposit's channel in doubt so
|
|
3440
|
+
* it is re-read from the chain before anything pays into it again, report
|
|
3441
|
+
* the `unresolved` event, and throw {@link BatchPaymentUnresolvedError}.
|
|
3442
|
+
*/
|
|
3443
|
+
private raiseUnresolved;
|
|
3444
|
+
/** Build a new batch payment for a 402: the payload, its headers and its kind. */
|
|
3445
|
+
private buildPayment;
|
|
3446
|
+
/**
|
|
3447
|
+
* Write a deposit's intent to the wallet's journal before it is sent
|
|
3448
|
+
* (with the file store: the file and its directory fsynced).
|
|
3449
|
+
*
|
|
3450
|
+
* @throws when it cannot be recorded; the deposit must then not be sent.
|
|
3451
|
+
*/
|
|
3452
|
+
private journalDeposit;
|
|
3453
|
+
/**
|
|
3454
|
+
* Remove a deposit's intent once it is reconciled. A failure is logged,
|
|
3455
|
+
* not thrown: the intent then outlives its deposit, and after a restart
|
|
3456
|
+
* the chain re-read settles it again.
|
|
3457
|
+
*/
|
|
3458
|
+
private forgetIntent;
|
|
3459
|
+
/**
|
|
3460
|
+
* THE choke point: send a batch payment once and classify the answer.
|
|
3461
|
+
*
|
|
3462
|
+
* The only caller of `send` for a batch payment, and the only place its
|
|
3463
|
+
* outcome is decided (see {@link SendOutcome}). Every exception once the
|
|
3464
|
+
* send has started is `in_doubt`, whatever its type or `cause.code`: the
|
|
3465
|
+
* request may have reached the gateway. "Not charged" is only ever minted
|
|
3466
|
+
* here, and only for a first send.
|
|
3467
|
+
*
|
|
3468
|
+
* @param retry - count this send in `retries` (it follows this call's own 429).
|
|
3469
|
+
* @param replay - this is a replay of a payment in doubt: only a 2xx with
|
|
3470
|
+
* a success receipt counts, everything else stays in doubt.
|
|
3471
|
+
*/
|
|
3472
|
+
private sendOnce;
|
|
3473
|
+
/** {@link sendOnce}'s classifier, for an HTTP answer. */
|
|
3474
|
+
private classify;
|
|
3475
|
+
/**
|
|
3476
|
+
* {@link classify}, past a receipt-less 429. With `hold`, the answer is not
|
|
3477
|
+
* handed to the scheme: its receipt is only read.
|
|
3478
|
+
*/
|
|
3479
|
+
private classifyAnswer;
|
|
3480
|
+
/**
|
|
3481
|
+
* Build the payment payload, re-reading any distrusted channel from the
|
|
3482
|
+
* chain first. A stored record the book refuses to hand over (a deposit a
|
|
3483
|
+
* dead process never heard back about), or one a top-up's read found
|
|
3484
|
+
* unusable ({@link prepareTopUp}), is re-read and the payload rebuilt
|
|
3485
|
+
* once.
|
|
3486
|
+
*/
|
|
3487
|
+
private createPayload;
|
|
3488
|
+
/**
|
|
3489
|
+
* When this payment will top up the wallet's channel, read how much of its
|
|
3490
|
+
* deposit is already settled on-chain (at `finalized` commitment, so never
|
|
3491
|
+
* more than will stay settled), so `maxDeposit` caps the escrow still at
|
|
3492
|
+
* stake rather than every deposit the channel ever took.
|
|
3493
|
+
*
|
|
3494
|
+
* Only a top-up costs this read (a channel's balance decides it, from the
|
|
3495
|
+
* stored record). If the read fails, nothing settled is assumed, which is
|
|
3496
|
+
* the stricter, lifetime cap. If the chain shows a larger deposit than the
|
|
3497
|
+
* record, the record is behind (a deposit it never heard about landed):
|
|
3498
|
+
* sizing a top-up from it could exceed `maxDeposit`, so this call pays
|
|
3499
|
+
* exact and the channel is re-read before the next payment. If
|
|
3500
|
+
* `@x402/svm`'s channel layout is not the one this SDK decodes, or the
|
|
3501
|
+
* account at the channel's address cannot be read as a channel, the call
|
|
3502
|
+
* pays exact (`channel_unreadable`), record kept. If
|
|
3503
|
+
* the finalized channel is closing or closed, or is not this wallet's for
|
|
3504
|
+
* the record's operator and mint, no top-up is sized from the record: it
|
|
3505
|
+
* is re-read at once (`channel_unusable`), see {@link createPayload}.
|
|
3506
|
+
*/
|
|
3507
|
+
private prepareTopUp;
|
|
3508
|
+
/**
|
|
3509
|
+
* Hand the gateway's answer to the scheme, which verifies the operator's
|
|
3510
|
+
* voucher and advances (or rolls back) the channel's local state.
|
|
3511
|
+
*
|
|
3512
|
+
* A malformed receipt must not lose a response the caller has been served,
|
|
3513
|
+
* so a scheme error is logged rather than thrown.
|
|
3514
|
+
*/
|
|
3515
|
+
private settle;
|
|
3516
|
+
/**
|
|
3517
|
+
* Close the channel the gateway's current challenge names and return its
|
|
3518
|
+
* unused escrow to the wallet.
|
|
3519
|
+
*
|
|
3520
|
+
* The scheme keeps a closed channel in its records, and would go on paying
|
|
3521
|
+
* into it, so a successful close forgets that channel. The next batch call
|
|
3522
|
+
* finds no open channel on-chain and opens a new one. Any other channel
|
|
3523
|
+
* (say, one opened with an operator key that is being rotated out) keeps
|
|
3524
|
+
* its record, so it can still be closed without an on-chain scan. A
|
|
3525
|
+
* client-signed channel an earlier SDK version opened is closed too, once
|
|
3526
|
+
* the trusted server-signed one has no record (see {@link refundTarget}).
|
|
3527
|
+
*
|
|
3528
|
+
* @param url - any batch-enabled route on the gateway the channel was opened with.
|
|
3529
|
+
* @throws BatchCloseDeferredError while a batch call for the wallet is in
|
|
3530
|
+
* flight, or while any of its deposits is in doubt (until a finalized
|
|
3531
|
+
* chain read settles it). Nothing is refunded or forgotten then.
|
|
3532
|
+
*/
|
|
3533
|
+
close(url: string): Promise<unknown>;
|
|
3534
|
+
/**
|
|
3535
|
+
* Re-read every distrusted channel before a close. A deposit still in
|
|
3536
|
+
* doubt defers the close: refunding (or forgetting) a channel a deposit
|
|
3537
|
+
* may yet land on could strand that deposit, and after a restart nothing
|
|
3538
|
+
* would remember it. A record re-read that only failed for another reason
|
|
3539
|
+
* (an RPC error on a channel with no deposit in doubt) does not.
|
|
3540
|
+
*/
|
|
3541
|
+
private settleDoubtsForClose;
|
|
3542
|
+
/**
|
|
3543
|
+
* The channel a close targets: the one the gateway's refund challenge
|
|
3544
|
+
* names, by the scheme's storage key for its trusted server-signed accept
|
|
3545
|
+
* (network, asset, receiver, fee payer, withdraw delay, receiver
|
|
3546
|
+
* authorizer, operator). Probed with an unpaid GET, as `@x402/svm`'s own
|
|
3547
|
+
* refund probes; that accept is then handed to the refund, so upstream
|
|
3548
|
+
* does not probe again and pick another accept.
|
|
3549
|
+
*
|
|
3550
|
+
* A legacy client-signed channel (opened by an earlier SDK version, which
|
|
3551
|
+
* could pay a client-signed accept; this one never opens one) must stay
|
|
3552
|
+
* refundable. When the trusted server-signed accept has no stored record,
|
|
3553
|
+
* or there is none, a client-signed accept in the challenge whose storage
|
|
3554
|
+
* key names a stored client-signed record is the target instead, and the
|
|
3555
|
+
* refund runs through `@x402/svm`'s client-signed path (a refund voucher
|
|
3556
|
+
* signed by the payer at its confirmed cumulative). The signer modes match:
|
|
3557
|
+
* a server-signed record is never refunded under a client-signed accept.
|
|
3558
|
+
*/
|
|
3559
|
+
private refundTarget;
|
|
3560
|
+
/**
|
|
3561
|
+
* Get the stored channel `key` ready to refund.
|
|
3562
|
+
*
|
|
3563
|
+
* `@x402/svm` refunds a server-signed channel only from the scheme's memory,
|
|
3564
|
+
* or after an on-chain scan that many RPCs refuse; it never reads the
|
|
3565
|
+
* stored record. So the target channel is loaded into a freshly built
|
|
3566
|
+
* scheme, and only that one: upstream's refund falls back to the first
|
|
3567
|
+
* channel in memory for the same receiver and asset, whatever its operator.
|
|
3568
|
+
* A record in doubt (a deposit this process never confirmed, or a pending
|
|
3569
|
+
* deposit left by a process that died) is re-read from the chain before it
|
|
3570
|
+
* is loaded. If a re-read cannot settle a record, the refund is still
|
|
3571
|
+
* attempted and may find the channel by its scan.
|
|
3572
|
+
*/
|
|
3573
|
+
private prepareClose;
|
|
3574
|
+
}
|
|
3146
3575
|
|
|
3147
3576
|
interface SolanaLLMClientOptions extends ApiKeyOptions {
|
|
3148
3577
|
/** bs58-encoded Solana secret key (64 bytes). Optional if SOLANA_WALLET_KEY env var is set. */
|
|
@@ -3803,10 +4232,10 @@ declare class ChatCompletions {
|
|
|
3803
4232
|
/**
|
|
3804
4233
|
* Create a chat completion (OpenAI-compatible).
|
|
3805
4234
|
*/
|
|
3806
|
-
create(params: OpenAIChatCompletionParams): Promise<OpenAIChatCompletionResponse>;
|
|
3807
4235
|
create(params: OpenAIChatCompletionParams & {
|
|
3808
4236
|
stream: true;
|
|
3809
4237
|
}): Promise<AsyncIterable<OpenAIChatCompletionChunk>>;
|
|
4238
|
+
create(params: OpenAIChatCompletionParams): Promise<OpenAIChatCompletionResponse>;
|
|
3810
4239
|
private createStream;
|
|
3811
4240
|
private transformResponse;
|
|
3812
4241
|
}
|
|
@@ -3985,4 +4414,4 @@ declare function readSettlement(response: Response, quotedUsd: number, scheme: S
|
|
|
3985
4414
|
settlement: Settlement;
|
|
3986
4415
|
};
|
|
3987
4416
|
|
|
3988
|
-
export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_RATE_LIMIT, EVM_NETWORKS, type EvmNetwork, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PORTAL_URL, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, RPC_PRICE_USD, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, type SolanaBatchStats, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type WebSearchTool, type XSearchSource, type XSearchTool, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
|
4417
|
+
export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_RATE_LIMIT, EVM_NETWORKS, type EvmNetwork, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PORTAL_URL, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, RPC_PRICE_USD, type Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
package/dist/index.js
CHANGED
|
@@ -4702,7 +4702,7 @@ function getCostSummary() {
|
|
|
4702
4702
|
}
|
|
4703
4703
|
|
|
4704
4704
|
// src/version.ts
|
|
4705
|
-
var SDK_VERSION = "3.
|
|
4705
|
+
var SDK_VERSION = "3.23.1";
|
|
4706
4706
|
var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
|
|
4707
4707
|
|
|
4708
4708
|
// src/client.ts
|
|
@@ -6048,7 +6048,7 @@ var LLMClient = class _LLMClient {
|
|
|
6048
6048
|
/**
|
|
6049
6049
|
* Query Predexon prediction market data (GET endpoints).
|
|
6050
6050
|
*
|
|
6051
|
-
* Access real-time data from Polymarket, Kalshi,
|
|
6051
|
+
* Access real-time data from Polymarket, Kalshi, Limitless, Opinion, Predict.Fun, Binance Futures, UMA and sports markets.
|
|
6052
6052
|
* Powered by Predexon. Billed per request.
|
|
6053
6053
|
*
|
|
6054
6054
|
* @param path - Endpoint path, e.g. "polymarket/events", "kalshi/markets/12345"
|
|
@@ -6375,7 +6375,8 @@ var ImageClient = class {
|
|
|
6375
6375
|
* combined with multiple source images.
|
|
6376
6376
|
*
|
|
6377
6377
|
* Edit-capable models: `openai/gpt-image-1`, `openai/gpt-image-2`,
|
|
6378
|
-
* `google/nano-banana`, `google/nano-banana-
|
|
6378
|
+
* `openai/gpt-image-2.5-sunburst`, `google/nano-banana`, `google/nano-banana-2`,
|
|
6379
|
+
* `google/nano-banana-pro`. `mask` is OpenAI-only.
|
|
6379
6380
|
*
|
|
6380
6381
|
* @param prompt - Text description of the desired edit
|
|
6381
6382
|
* @param image - A base64 `data:image/...` URI, or an array of 2–4 such URIs to fuse
|
|
@@ -10729,6 +10730,38 @@ function capOutstandingEscrow(scheme, wallet) {
|
|
|
10729
10730
|
return original.call(this, requirements, requestAmount, needed, context, widened, existingDeposit);
|
|
10730
10731
|
};
|
|
10731
10732
|
}
|
|
10733
|
+
var payScope = new AsyncLocalStorage();
|
|
10734
|
+
function registerHookDispatchers(client) {
|
|
10735
|
+
client.onBeforePaymentCreation(async (context) => {
|
|
10736
|
+
for (const hook of payScope.getStore()?.hooks.before ?? []) {
|
|
10737
|
+
const result = await hook(context);
|
|
10738
|
+
if (result && typeof result === "object" && result.abort) return result;
|
|
10739
|
+
}
|
|
10740
|
+
return void 0;
|
|
10741
|
+
});
|
|
10742
|
+
client.onAfterPaymentCreation(async (context) => {
|
|
10743
|
+
const scope = payScope.getStore();
|
|
10744
|
+
for (const hook of scope?.hooks.after ?? []) {
|
|
10745
|
+
try {
|
|
10746
|
+
await hook(context);
|
|
10747
|
+
} catch (error) {
|
|
10748
|
+
if (scope && !scope.afterError) scope.afterError = { error };
|
|
10749
|
+
}
|
|
10750
|
+
}
|
|
10751
|
+
});
|
|
10752
|
+
client.onPaymentCreationFailure(async (context) => {
|
|
10753
|
+
await runFailureHooks(payScope.getStore(), context);
|
|
10754
|
+
return void 0;
|
|
10755
|
+
});
|
|
10756
|
+
}
|
|
10757
|
+
async function runFailureHooks(scope, context) {
|
|
10758
|
+
for (const hook of scope?.hooks.failure ?? []) {
|
|
10759
|
+
try {
|
|
10760
|
+
await hook(context);
|
|
10761
|
+
} catch {
|
|
10762
|
+
}
|
|
10763
|
+
}
|
|
10764
|
+
}
|
|
10732
10765
|
var RPC_SCOPE_STORE = /* @__PURE__ */ Symbol.for("@blockrun/llm/batch-rpc-scope/v1");
|
|
10733
10766
|
var RPC_HEADER_HOOK = /* @__PURE__ */ Symbol.for("@blockrun/llm/batch-rpc-headers/v1");
|
|
10734
10767
|
var sharedGlobal = globalThis;
|
|
@@ -10780,6 +10813,11 @@ function intentTarget(intent) {
|
|
|
10780
10813
|
var SolanaBatchPayer = class {
|
|
10781
10814
|
constructor(init) {
|
|
10782
10815
|
this.init = init;
|
|
10816
|
+
init.configureClient?.({
|
|
10817
|
+
onBeforePaymentCreation: (hook) => void this.hooks.before.push(hook),
|
|
10818
|
+
onAfterPaymentCreation: (hook) => void this.hooks.after.push(hook),
|
|
10819
|
+
onPaymentCreationFailure: (hook) => void this.hooks.failure.push(hook)
|
|
10820
|
+
});
|
|
10783
10821
|
const { operators, rateLimit, inDoubt } = init.options;
|
|
10784
10822
|
if (!Array.isArray(operators) || operators.length === 0 || operators.some((o) => typeof o !== "string" || !o)) {
|
|
10785
10823
|
throw new Error("batch.operators must list at least one base58 operator public key");
|
|
@@ -10812,6 +10850,7 @@ var SolanaBatchPayer = class {
|
|
|
10812
10850
|
unresolved: 0,
|
|
10813
10851
|
unresolvedByReason: {}
|
|
10814
10852
|
};
|
|
10853
|
+
hooks = { before: [], after: [], failure: [] };
|
|
10815
10854
|
/** A copy of this client's batch counters. */
|
|
10816
10855
|
stats() {
|
|
10817
10856
|
return {
|
|
@@ -10914,6 +10953,7 @@ var SolanaBatchPayer = class {
|
|
|
10914
10953
|
capOutstandingEscrow(scheme, wallet);
|
|
10915
10954
|
const client = new core.x402Client().register("solana:*", scheme).registerPolicy(scheme.paymentPolicy);
|
|
10916
10955
|
client.setSpendControls({ maxAmountPerPayment: false });
|
|
10956
|
+
registerHookDispatchers(client);
|
|
10917
10957
|
const raw = new core.x402HTTPClient(client);
|
|
10918
10958
|
const http = {
|
|
10919
10959
|
getPaymentSettleResponse: (getHeader) => raw.getPaymentSettleResponse(getHeader),
|
|
@@ -11207,7 +11247,10 @@ var SolanaBatchPayer = class {
|
|
|
11207
11247
|
}
|
|
11208
11248
|
wallet.active += 1;
|
|
11209
11249
|
try {
|
|
11210
|
-
return await
|
|
11250
|
+
return await payScope.run(
|
|
11251
|
+
{ hooks: this.hooks },
|
|
11252
|
+
() => this.payWith(wallet, paymentRequired, send, rechallenge, closesAtStart ?? wallet.closes)
|
|
11253
|
+
);
|
|
11211
11254
|
} finally {
|
|
11212
11255
|
wallet.active -= 1;
|
|
11213
11256
|
}
|
|
@@ -11619,6 +11662,18 @@ var SolanaBatchPayer = class {
|
|
|
11619
11662
|
/** Build a new batch payment for a 402: the payload, its headers and its kind. */
|
|
11620
11663
|
async buildPayment(wallet, paymentRequired) {
|
|
11621
11664
|
const { http, payload } = await this.createPayload(wallet, paymentRequired);
|
|
11665
|
+
const scope = payScope.getStore();
|
|
11666
|
+
if (scope?.afterError) {
|
|
11667
|
+
const { error } = scope.afterError;
|
|
11668
|
+
scope.afterError = void 0;
|
|
11669
|
+
await this.settle(http, payload, () => null, 0);
|
|
11670
|
+
await runFailureHooks(scope, {
|
|
11671
|
+
paymentRequired,
|
|
11672
|
+
selectedRequirements: payload.accepted,
|
|
11673
|
+
error
|
|
11674
|
+
});
|
|
11675
|
+
throw error;
|
|
11676
|
+
}
|
|
11622
11677
|
const headers = http.encodePaymentSignatureHeader(payload);
|
|
11623
11678
|
const channelId = payloadChannelId(payload);
|
|
11624
11679
|
const known = channelId ? wallet.book.find(channelId) : void 0;
|
|
@@ -14029,6 +14084,7 @@ export {
|
|
|
14029
14084
|
SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH,
|
|
14030
14085
|
SUPPORTED_NETWORKS,
|
|
14031
14086
|
SearchClient,
|
|
14087
|
+
SolanaBatchPayer,
|
|
14032
14088
|
SolanaLLMClient,
|
|
14033
14089
|
SpeechClient,
|
|
14034
14090
|
SurfClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/llm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TypeScript SDK for BlockRun - every frontier model behind one OpenAI-compatible client. Pay with a BlockRun API key or per-call in USDC. Smart routing picks the cheapest capable model. No rate limits.",
|
|
6
6
|
"main": "dist/index.cjs",
|