@blockrun/llm 3.20.1 → 3.21.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/index.d.cts CHANGED
@@ -3173,6 +3173,40 @@ declare class SolanaLLMClient {
3173
3173
  n?: number;
3174
3174
  } & Record<string, unknown>): Promise<ImageResponse>;
3175
3175
  imageEdit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
3176
+ /**
3177
+ * Generate a short video on Solana.
3178
+ *
3179
+ * The POST is verified, not charged. The job is then polled with a wallet
3180
+ * signature (no payment) until it finishes, and ONE payment is signed for
3181
+ * the finished video; a failed job is never charged. If the gateway does not
3182
+ * accept poll signatures for the job, it is polled with a payment per poll
3183
+ * instead, which is likewise only charged on completion.
3184
+ *
3185
+ * @param prompt - text description of the video.
3186
+ * @param options - `model` (default `xai/grok-imagine-video`), `budgetMs`
3187
+ * (total wait, default 15 min); any other keys are sent verbatim, so use
3188
+ * the gateway's snake_case names (`duration_seconds`, `image_url`,
3189
+ * `aspect_ratio`, `resolution`, …).
3190
+ */
3191
+ video(prompt: string, options?: {
3192
+ model?: string;
3193
+ budgetMs?: number;
3194
+ } & Record<string, unknown>): Promise<VideoResponse>;
3195
+ /**
3196
+ * Generate a music track on Solana. Paid at the POST; a slow track is then
3197
+ * polled with a wallet signature, never another payment.
3198
+ *
3199
+ * @param prompt - music style, mood, or description.
3200
+ * @param options - `model` (default `minimax/music-2.5+`), `instrumental`
3201
+ * (default true), `lyrics` (requires `instrumental: false`), `budgetMs`
3202
+ * (total wait, default 5 min); other keys are sent verbatim.
3203
+ */
3204
+ music(prompt: string, options?: {
3205
+ model?: string;
3206
+ instrumental?: boolean;
3207
+ lyrics?: string;
3208
+ budgetMs?: number;
3209
+ } & Record<string, unknown>): Promise<MusicResponse>;
3176
3210
  /** Standalone search (Solana payment). */
3177
3211
  search(query: string, options?: SearchOptions): Promise<SearchResult>;
3178
3212
  pm(path: string, params?: Record<string, string>): Promise<Record<string, unknown>>;
@@ -3306,6 +3340,47 @@ declare class SolanaLLMClient {
3306
3340
  private sendUnpaid;
3307
3341
  /** Read a paid 2xx response's JSON body. The call was charged, so a failure here is never retried. */
3308
3342
  private readPaidJson;
3343
+ /**
3344
+ * Follow a 202 `{ id, poll_url }` to completion on a Solana media route
3345
+ * (image, music, video).
3346
+ *
3347
+ * **Polls prove ownership, they do not pay.** A Solana payment is a
3348
+ * transaction pinned to a recent blockhash (~60s), so paying every poll of a
3349
+ * multi-minute job meant signing a fresh transaction every few seconds. Each
3350
+ * poll here instead carries the `x-poll-*` headers: the submitting wallet's
3351
+ * ed25519 signature over `blockrun-poll:v1:<kind>:<job id>:<unix seconds>`
3352
+ * (see `poll-ownership.ts`). That proof never charges.
3353
+ *
3354
+ * **Who pays when:**
3355
+ * - image / music: the POST already settled (sol settles at submit because the
3356
+ * signed transaction would be dead by completion). The caller recorded the
3357
+ * cost at POST; this loop only fetches the result and never signs a payment.
3358
+ * A batch-billed image job still answers its proof poll with 402: that job
3359
+ * falls back to the per-poll payment below.
3360
+ * - video: settles on completion, and a failed job is never charged. A
3361
+ * finished, unpaid job answers the proof poll with 402 `{status:"completed"}`
3362
+ * and a normal x402 challenge; ONE payment is signed from that challenge and
3363
+ * the same poll is re-sent with it. The cost is recorded here, on delivery.
3364
+ * A paid poll the gateway answers 402 (settlement in progress on another
3365
+ * poll, outcome unknown, stale blockhash) is re-polled after its
3366
+ * Retry-After — the gateway's per-job settlement claim makes a later fresh
3367
+ * payment safe — up to `MAX_PAID_POLL_REFUSALS` times.
3368
+ *
3369
+ * **Fallback, once per job:** if the gateway refuses the proof with its "no
3370
+ * such job" answer (video 400, image/music 404) or answers it with a plain
3371
+ * payment challenge (a gateway or job that predates poll proofs), the rest of
3372
+ * this job is polled the old way — an x-payment signed per poll, which the
3373
+ * gateway verifies against the job's payer and does not charge until a video
3374
+ * completes. Logged to stderr; never switches back.
3375
+ */
3376
+ private followSolanaJob;
3377
+ /**
3378
+ * Absolute URL for a job's `poll_url`. The gateway returns `/api/v1/...`;
3379
+ * {@link buildUrl} drops the `/api` that `apiUrl` already ends with. An
3380
+ * absolute poll_url must be on the gateway's own origin: the poll carries a
3381
+ * wallet signature (and, for a finished video, a payment).
3382
+ */
3383
+ private resolvePollUrl;
3309
3384
  /**
3310
3385
  * Turn a `402` into a signed Solana payment payload.
3311
3386
  *
@@ -3324,27 +3399,6 @@ declare class SolanaLLMClient {
3324
3399
  * @returns the header value to replay with, and what it will settle for.
3325
3400
  * @throws PaymentError when the 402 carries no usable Solana requirements.
3326
3401
  */
3327
- /**
3328
- * Follow a 202 `{ id, poll_url }` to completion, on Solana **image** routes.
3329
- *
3330
- * Two things differ from Base and both come from the same constraint — a
3331
- * Solana payment is a transaction pinned to a recent blockhash, valid for
3332
- * ~150 blocks (~60s), and a long render outlives it:
3333
- *
3334
- * 1. **The POST already settled.** Base settles on the completed poll; Solana
3335
- * cannot, because by then the signed transaction has expired. So sol
3336
- * settles optimistically at submit, and this loop only fetches the result.
3337
- * The cost is recorded by the caller at POST, never here — recording it on
3338
- * completion would lose the charge whenever a paid job then fails.
3339
- * Solana VIDEO is the exception: it settles on the completed poll and a
3340
- * failed job is not charged. Do not route video through this loop as-is —
3341
- * it would book spend for jobs that were never charged.
3342
- * 2. **Every poll re-signs.** One authorization cannot be replayed across a
3343
- * long render. The gateway binds the job to the payer address rather than
3344
- * to the signature, so a fresh signature from the same wallet is accepted
3345
- * and is never charged again.
3346
- */
3347
- private followSolanaJob;
3348
3402
  private signPaymentFrom402;
3349
3403
  /** Read a `402`'s payment requirements from its header, or its JSON body. */
3350
3404
  private readPaymentRequired;
package/dist/index.d.ts CHANGED
@@ -3173,6 +3173,40 @@ declare class SolanaLLMClient {
3173
3173
  n?: number;
3174
3174
  } & Record<string, unknown>): Promise<ImageResponse>;
3175
3175
  imageEdit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
3176
+ /**
3177
+ * Generate a short video on Solana.
3178
+ *
3179
+ * The POST is verified, not charged. The job is then polled with a wallet
3180
+ * signature (no payment) until it finishes, and ONE payment is signed for
3181
+ * the finished video; a failed job is never charged. If the gateway does not
3182
+ * accept poll signatures for the job, it is polled with a payment per poll
3183
+ * instead, which is likewise only charged on completion.
3184
+ *
3185
+ * @param prompt - text description of the video.
3186
+ * @param options - `model` (default `xai/grok-imagine-video`), `budgetMs`
3187
+ * (total wait, default 15 min); any other keys are sent verbatim, so use
3188
+ * the gateway's snake_case names (`duration_seconds`, `image_url`,
3189
+ * `aspect_ratio`, `resolution`, …).
3190
+ */
3191
+ video(prompt: string, options?: {
3192
+ model?: string;
3193
+ budgetMs?: number;
3194
+ } & Record<string, unknown>): Promise<VideoResponse>;
3195
+ /**
3196
+ * Generate a music track on Solana. Paid at the POST; a slow track is then
3197
+ * polled with a wallet signature, never another payment.
3198
+ *
3199
+ * @param prompt - music style, mood, or description.
3200
+ * @param options - `model` (default `minimax/music-2.5+`), `instrumental`
3201
+ * (default true), `lyrics` (requires `instrumental: false`), `budgetMs`
3202
+ * (total wait, default 5 min); other keys are sent verbatim.
3203
+ */
3204
+ music(prompt: string, options?: {
3205
+ model?: string;
3206
+ instrumental?: boolean;
3207
+ lyrics?: string;
3208
+ budgetMs?: number;
3209
+ } & Record<string, unknown>): Promise<MusicResponse>;
3176
3210
  /** Standalone search (Solana payment). */
3177
3211
  search(query: string, options?: SearchOptions): Promise<SearchResult>;
3178
3212
  pm(path: string, params?: Record<string, string>): Promise<Record<string, unknown>>;
@@ -3306,6 +3340,47 @@ declare class SolanaLLMClient {
3306
3340
  private sendUnpaid;
3307
3341
  /** Read a paid 2xx response's JSON body. The call was charged, so a failure here is never retried. */
3308
3342
  private readPaidJson;
3343
+ /**
3344
+ * Follow a 202 `{ id, poll_url }` to completion on a Solana media route
3345
+ * (image, music, video).
3346
+ *
3347
+ * **Polls prove ownership, they do not pay.** A Solana payment is a
3348
+ * transaction pinned to a recent blockhash (~60s), so paying every poll of a
3349
+ * multi-minute job meant signing a fresh transaction every few seconds. Each
3350
+ * poll here instead carries the `x-poll-*` headers: the submitting wallet's
3351
+ * ed25519 signature over `blockrun-poll:v1:<kind>:<job id>:<unix seconds>`
3352
+ * (see `poll-ownership.ts`). That proof never charges.
3353
+ *
3354
+ * **Who pays when:**
3355
+ * - image / music: the POST already settled (sol settles at submit because the
3356
+ * signed transaction would be dead by completion). The caller recorded the
3357
+ * cost at POST; this loop only fetches the result and never signs a payment.
3358
+ * A batch-billed image job still answers its proof poll with 402: that job
3359
+ * falls back to the per-poll payment below.
3360
+ * - video: settles on completion, and a failed job is never charged. A
3361
+ * finished, unpaid job answers the proof poll with 402 `{status:"completed"}`
3362
+ * and a normal x402 challenge; ONE payment is signed from that challenge and
3363
+ * the same poll is re-sent with it. The cost is recorded here, on delivery.
3364
+ * A paid poll the gateway answers 402 (settlement in progress on another
3365
+ * poll, outcome unknown, stale blockhash) is re-polled after its
3366
+ * Retry-After — the gateway's per-job settlement claim makes a later fresh
3367
+ * payment safe — up to `MAX_PAID_POLL_REFUSALS` times.
3368
+ *
3369
+ * **Fallback, once per job:** if the gateway refuses the proof with its "no
3370
+ * such job" answer (video 400, image/music 404) or answers it with a plain
3371
+ * payment challenge (a gateway or job that predates poll proofs), the rest of
3372
+ * this job is polled the old way — an x-payment signed per poll, which the
3373
+ * gateway verifies against the job's payer and does not charge until a video
3374
+ * completes. Logged to stderr; never switches back.
3375
+ */
3376
+ private followSolanaJob;
3377
+ /**
3378
+ * Absolute URL for a job's `poll_url`. The gateway returns `/api/v1/...`;
3379
+ * {@link buildUrl} drops the `/api` that `apiUrl` already ends with. An
3380
+ * absolute poll_url must be on the gateway's own origin: the poll carries a
3381
+ * wallet signature (and, for a finished video, a payment).
3382
+ */
3383
+ private resolvePollUrl;
3309
3384
  /**
3310
3385
  * Turn a `402` into a signed Solana payment payload.
3311
3386
  *
@@ -3324,27 +3399,6 @@ declare class SolanaLLMClient {
3324
3399
  * @returns the header value to replay with, and what it will settle for.
3325
3400
  * @throws PaymentError when the 402 carries no usable Solana requirements.
3326
3401
  */
3327
- /**
3328
- * Follow a 202 `{ id, poll_url }` to completion, on Solana **image** routes.
3329
- *
3330
- * Two things differ from Base and both come from the same constraint — a
3331
- * Solana payment is a transaction pinned to a recent blockhash, valid for
3332
- * ~150 blocks (~60s), and a long render outlives it:
3333
- *
3334
- * 1. **The POST already settled.** Base settles on the completed poll; Solana
3335
- * cannot, because by then the signed transaction has expired. So sol
3336
- * settles optimistically at submit, and this loop only fetches the result.
3337
- * The cost is recorded by the caller at POST, never here — recording it on
3338
- * completion would lose the charge whenever a paid job then fails.
3339
- * Solana VIDEO is the exception: it settles on the completed poll and a
3340
- * failed job is not charged. Do not route video through this loop as-is —
3341
- * it would book spend for jobs that were never charged.
3342
- * 2. **Every poll re-signs.** One authorization cannot be replayed across a
3343
- * long render. The gateway binds the job to the payer address rather than
3344
- * to the signature, so a fresh signature from the same wallet is accepted
3345
- * and is never charged again.
3346
- */
3347
- private followSolanaJob;
3348
3402
  private signPaymentFrom402;
3349
3403
  /** Read a `402`'s payment requirements from its header, or its JSON body. */
3350
3404
  private readPaymentRequired;