@blockrun/llm 3.8.1 → 3.8.3
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 +10 -21
- package/dist/index.d.cts +19 -30
- package/dist/index.d.ts +19 -30
- package/dist/index.js +10 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38,7 +38,6 @@ __export(index_exports, {
|
|
|
38
38
|
ImageClient: () => ImageClient,
|
|
39
39
|
KNOWN_PROVIDERS: () => KNOWN_PROVIDERS,
|
|
40
40
|
LLMClient: () => LLMClient,
|
|
41
|
-
MAX_TOKENS_SANITY_LIMIT: () => MAX_TOKENS_SANITY_LIMIT,
|
|
42
41
|
MusicClient: () => MusicClient,
|
|
43
42
|
NETWORK_ALIASES: () => NETWORK_ALIASES,
|
|
44
43
|
OpenAI: () => OpenAI,
|
|
@@ -356,7 +355,6 @@ function validateModel(model) {
|
|
|
356
355
|
throw new Error("Model must be a non-empty string");
|
|
357
356
|
}
|
|
358
357
|
}
|
|
359
|
-
var MAX_TOKENS_SANITY_LIMIT = 1e6;
|
|
360
358
|
function validateMaxTokens(maxTokens) {
|
|
361
359
|
if (maxTokens === void 0 || maxTokens === null) {
|
|
362
360
|
return;
|
|
@@ -367,14 +365,6 @@ function validateMaxTokens(maxTokens) {
|
|
|
367
365
|
if (maxTokens < 1) {
|
|
368
366
|
throw new Error("maxTokens must be positive (minimum: 1)");
|
|
369
367
|
}
|
|
370
|
-
if (maxTokens > MAX_TOKENS_SANITY_LIMIT) {
|
|
371
|
-
throw Object.assign(
|
|
372
|
-
new Error(
|
|
373
|
-
`maxTokens implausibly large (client-side sanity limit: ${MAX_TOKENS_SANITY_LIMIT}). This is not a model limit \u2014 the gateway enforces the real per-model ceiling and reports it.`
|
|
374
|
-
),
|
|
375
|
-
{ code: "MAX_TOKENS_SANITY_LIMIT", limit: MAX_TOKENS_SANITY_LIMIT }
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
368
|
}
|
|
379
369
|
function validateTemperature(temperature) {
|
|
380
370
|
if (temperature === void 0 || temperature === null) {
|
|
@@ -513,6 +503,10 @@ function getCostSummary() {
|
|
|
513
503
|
return { totalUsd, calls, byModel, byEndpoint };
|
|
514
504
|
}
|
|
515
505
|
|
|
506
|
+
// src/version.ts
|
|
507
|
+
var SDK_VERSION = "3.8.3";
|
|
508
|
+
var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
|
|
509
|
+
|
|
516
510
|
// src/client.ts
|
|
517
511
|
function isTransientError(err) {
|
|
518
512
|
if (err instanceof PaymentError) return false;
|
|
@@ -575,8 +569,6 @@ function resolveDefaultTimeout() {
|
|
|
575
569
|
return 6e5;
|
|
576
570
|
}
|
|
577
571
|
var DEFAULT_TIMEOUT = resolveDefaultTimeout();
|
|
578
|
-
var SDK_VERSION = "1.5.0";
|
|
579
|
-
var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
|
|
580
572
|
var LLMClient = class _LLMClient {
|
|
581
573
|
static DEFAULT_API_URL = DEFAULT_API_URL;
|
|
582
574
|
account;
|
|
@@ -5022,8 +5014,6 @@ async function getOrCreateSolanaWallet() {
|
|
|
5022
5014
|
var SOLANA_API_URL = "https://sol.blockrun.ai/api";
|
|
5023
5015
|
var DEFAULT_MAX_TOKENS2 = 1024;
|
|
5024
5016
|
var DEFAULT_TIMEOUT14 = 6e4;
|
|
5025
|
-
var SDK_VERSION2 = "0.3.0";
|
|
5026
|
-
var USER_AGENT2 = `blockrun-ts/${SDK_VERSION2}`;
|
|
5027
5017
|
var DEFAULT_SOLANA_RPC_URL = "https://sol.blockrun.ai/api/v1/solana/rpc";
|
|
5028
5018
|
function resolveRpcConfig(rpcUrl, rpcHeaders) {
|
|
5029
5019
|
const env = typeof process !== "undefined" && process.env ? process.env : {};
|
|
@@ -5354,7 +5344,7 @@ var SolanaLLMClient = class {
|
|
|
5354
5344
|
const url = `${this.apiUrl}${endpoint}`;
|
|
5355
5345
|
const response = await this.fetchWithTimeout(url, {
|
|
5356
5346
|
method: "POST",
|
|
5357
|
-
headers: { "Content-Type": "application/json", "User-Agent":
|
|
5347
|
+
headers: { "Content-Type": "application/json", "User-Agent": USER_AGENT },
|
|
5358
5348
|
body: JSON.stringify(body)
|
|
5359
5349
|
});
|
|
5360
5350
|
if (response.status === 402) {
|
|
@@ -5420,7 +5410,7 @@ var SolanaLLMClient = class {
|
|
|
5420
5410
|
method: "POST",
|
|
5421
5411
|
headers: {
|
|
5422
5412
|
"Content-Type": "application/json",
|
|
5423
|
-
"User-Agent":
|
|
5413
|
+
"User-Agent": USER_AGENT,
|
|
5424
5414
|
"PAYMENT-SIGNATURE": paymentPayload
|
|
5425
5415
|
},
|
|
5426
5416
|
body: JSON.stringify(body)
|
|
@@ -5446,7 +5436,7 @@ var SolanaLLMClient = class {
|
|
|
5446
5436
|
const url = `${this.apiUrl}${endpoint}`;
|
|
5447
5437
|
const response = await this.fetchWithTimeout(url, {
|
|
5448
5438
|
method: "POST",
|
|
5449
|
-
headers: { "Content-Type": "application/json", "User-Agent":
|
|
5439
|
+
headers: { "Content-Type": "application/json", "User-Agent": USER_AGENT },
|
|
5450
5440
|
body: JSON.stringify(body)
|
|
5451
5441
|
});
|
|
5452
5442
|
if (response.status === 402) {
|
|
@@ -5512,7 +5502,7 @@ var SolanaLLMClient = class {
|
|
|
5512
5502
|
method: "POST",
|
|
5513
5503
|
headers: {
|
|
5514
5504
|
"Content-Type": "application/json",
|
|
5515
|
-
"User-Agent":
|
|
5505
|
+
"User-Agent": USER_AGENT,
|
|
5516
5506
|
"PAYMENT-SIGNATURE": paymentPayload
|
|
5517
5507
|
},
|
|
5518
5508
|
body: JSON.stringify(body)
|
|
@@ -5539,7 +5529,7 @@ var SolanaLLMClient = class {
|
|
|
5539
5529
|
const url = `${this.apiUrl}${endpoint}${query}`;
|
|
5540
5530
|
const response = await this.fetchWithTimeout(url, {
|
|
5541
5531
|
method: "GET",
|
|
5542
|
-
headers: { "User-Agent":
|
|
5532
|
+
headers: { "User-Agent": USER_AGENT }
|
|
5543
5533
|
});
|
|
5544
5534
|
if (response.status === 402) {
|
|
5545
5535
|
return this.handleGetPaymentAndRetryRaw(url, endpoint, params, response);
|
|
@@ -5605,7 +5595,7 @@ var SolanaLLMClient = class {
|
|
|
5605
5595
|
const retryResponse = await this.fetchWithTimeout(retryUrl, {
|
|
5606
5596
|
method: "GET",
|
|
5607
5597
|
headers: {
|
|
5608
|
-
"User-Agent":
|
|
5598
|
+
"User-Agent": USER_AGENT,
|
|
5609
5599
|
"PAYMENT-SIGNATURE": paymentPayload
|
|
5610
5600
|
}
|
|
5611
5601
|
});
|
|
@@ -6139,7 +6129,6 @@ var AnthropicClient = class {
|
|
|
6139
6129
|
ImageClient,
|
|
6140
6130
|
KNOWN_PROVIDERS,
|
|
6141
6131
|
LLMClient,
|
|
6142
|
-
MAX_TOKENS_SANITY_LIMIT,
|
|
6143
6132
|
MusicClient,
|
|
6144
6133
|
NETWORK_ALIASES,
|
|
6145
6134
|
OpenAI,
|
package/dist/index.d.cts
CHANGED
|
@@ -3161,37 +3161,26 @@ declare const KNOWN_PROVIDERS: Set<string>;
|
|
|
3161
3161
|
*/
|
|
3162
3162
|
declare function validateModel(model: string): void;
|
|
3163
3163
|
/**
|
|
3164
|
-
*
|
|
3165
|
-
*
|
|
3166
|
-
*
|
|
3167
|
-
*
|
|
3168
|
-
*
|
|
3169
|
-
*
|
|
3170
|
-
*
|
|
3171
|
-
*
|
|
3172
|
-
*
|
|
3173
|
-
*
|
|
3174
|
-
*
|
|
3175
|
-
*
|
|
3176
|
-
*
|
|
3177
|
-
*
|
|
3178
|
-
*
|
|
3179
|
-
*
|
|
3180
|
-
*
|
|
3181
|
-
* as-of-date probe results, not a maintained invariant — nothing in this repo
|
|
3182
|
-
* ships a model catalog, so CI cannot detect when they go stale.
|
|
3183
|
-
*
|
|
3184
|
-
* Keep a bound so an obvious mistake (1e9, a byte count, a timestamp) fails
|
|
3185
|
-
* fast locally instead of becoming a payment quote. Set it far above any real
|
|
3186
|
-
* model so it can never be the binding constraint again.
|
|
3187
|
-
*/
|
|
3188
|
-
declare const MAX_TOKENS_SANITY_LIMIT = 1000000;
|
|
3189
|
-
/**
|
|
3190
|
-
* Validates that max_tokens is a positive integer no larger than
|
|
3191
|
-
* {@link MAX_TOKENS_SANITY_LIMIT}.
|
|
3164
|
+
* Mirrors the gateway's own contract for `max_tokens`, which is exactly
|
|
3165
|
+
* `z.number().int().min(1).optional()` — an integer, at least 1, and
|
|
3166
|
+
* deliberately **no upper bound**.
|
|
3167
|
+
*
|
|
3168
|
+
* There is no ceiling here on purpose. The gateway clamps every request with
|
|
3169
|
+
* `min(requested, model.maxOutput, contextHeadroom)` and then quotes only a
|
|
3170
|
+
* fraction of the clamped value, so an oversized `maxTokens` cannot inflate a
|
|
3171
|
+
* payment: 1e9 and 1_000_000 produce a byte-identical quote, because both land
|
|
3172
|
+
* on the same `model.maxOutput`. A client-side ceiling could therefore only
|
|
3173
|
+
* ever reject a request the gateway would have accepted and handled correctly.
|
|
3174
|
+
*
|
|
3175
|
+
* Earlier versions of this file did carry one, justified in a comment as
|
|
3176
|
+
* stopping a stray 1e9 from "becoming a payment quote". That was never true —
|
|
3177
|
+
* it was asserted here without being checked against the route handler, which
|
|
3178
|
+
* is the same mistake as the old `"maxTokens too large (maximum: 100000)"`
|
|
3179
|
+
* message that got recorded downstream as an upstream model ceiling. Verify
|
|
3180
|
+
* against the gateway before reintroducing any number in this file.
|
|
3192
3181
|
*
|
|
3193
3182
|
* @param maxTokens - Maximum number of tokens to generate
|
|
3194
|
-
* @throws {Error} If maxTokens is
|
|
3183
|
+
* @throws {Error} If maxTokens is not a positive integer
|
|
3195
3184
|
*
|
|
3196
3185
|
* @example
|
|
3197
3186
|
* validateMaxTokens(1000);
|
|
@@ -3218,4 +3207,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
3218
3207
|
*/
|
|
3219
3208
|
declare function validateTopP(topP?: number): void;
|
|
3220
3209
|
|
|
3221
|
-
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, 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, 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,
|
|
3210
|
+
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, 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, 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, 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, type RoutingDecision, type RoutingProfile, type RoutingTier, 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 SmartChatOptions, type SmartChatResponse, 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_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, 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 XSearchSource, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
package/dist/index.d.ts
CHANGED
|
@@ -3161,37 +3161,26 @@ declare const KNOWN_PROVIDERS: Set<string>;
|
|
|
3161
3161
|
*/
|
|
3162
3162
|
declare function validateModel(model: string): void;
|
|
3163
3163
|
/**
|
|
3164
|
-
*
|
|
3165
|
-
*
|
|
3166
|
-
*
|
|
3167
|
-
*
|
|
3168
|
-
*
|
|
3169
|
-
*
|
|
3170
|
-
*
|
|
3171
|
-
*
|
|
3172
|
-
*
|
|
3173
|
-
*
|
|
3174
|
-
*
|
|
3175
|
-
*
|
|
3176
|
-
*
|
|
3177
|
-
*
|
|
3178
|
-
*
|
|
3179
|
-
*
|
|
3180
|
-
*
|
|
3181
|
-
* as-of-date probe results, not a maintained invariant — nothing in this repo
|
|
3182
|
-
* ships a model catalog, so CI cannot detect when they go stale.
|
|
3183
|
-
*
|
|
3184
|
-
* Keep a bound so an obvious mistake (1e9, a byte count, a timestamp) fails
|
|
3185
|
-
* fast locally instead of becoming a payment quote. Set it far above any real
|
|
3186
|
-
* model so it can never be the binding constraint again.
|
|
3187
|
-
*/
|
|
3188
|
-
declare const MAX_TOKENS_SANITY_LIMIT = 1000000;
|
|
3189
|
-
/**
|
|
3190
|
-
* Validates that max_tokens is a positive integer no larger than
|
|
3191
|
-
* {@link MAX_TOKENS_SANITY_LIMIT}.
|
|
3164
|
+
* Mirrors the gateway's own contract for `max_tokens`, which is exactly
|
|
3165
|
+
* `z.number().int().min(1).optional()` — an integer, at least 1, and
|
|
3166
|
+
* deliberately **no upper bound**.
|
|
3167
|
+
*
|
|
3168
|
+
* There is no ceiling here on purpose. The gateway clamps every request with
|
|
3169
|
+
* `min(requested, model.maxOutput, contextHeadroom)` and then quotes only a
|
|
3170
|
+
* fraction of the clamped value, so an oversized `maxTokens` cannot inflate a
|
|
3171
|
+
* payment: 1e9 and 1_000_000 produce a byte-identical quote, because both land
|
|
3172
|
+
* on the same `model.maxOutput`. A client-side ceiling could therefore only
|
|
3173
|
+
* ever reject a request the gateway would have accepted and handled correctly.
|
|
3174
|
+
*
|
|
3175
|
+
* Earlier versions of this file did carry one, justified in a comment as
|
|
3176
|
+
* stopping a stray 1e9 from "becoming a payment quote". That was never true —
|
|
3177
|
+
* it was asserted here without being checked against the route handler, which
|
|
3178
|
+
* is the same mistake as the old `"maxTokens too large (maximum: 100000)"`
|
|
3179
|
+
* message that got recorded downstream as an upstream model ceiling. Verify
|
|
3180
|
+
* against the gateway before reintroducing any number in this file.
|
|
3192
3181
|
*
|
|
3193
3182
|
* @param maxTokens - Maximum number of tokens to generate
|
|
3194
|
-
* @throws {Error} If maxTokens is
|
|
3183
|
+
* @throws {Error} If maxTokens is not a positive integer
|
|
3195
3184
|
*
|
|
3196
3185
|
* @example
|
|
3197
3186
|
* validateMaxTokens(1000);
|
|
@@ -3218,4 +3207,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
3218
3207
|
*/
|
|
3219
3208
|
declare function validateTopP(topP?: number): void;
|
|
3220
3209
|
|
|
3221
|
-
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, 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, 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,
|
|
3210
|
+
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, 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, 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, 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, type RoutingDecision, type RoutingProfile, type RoutingTier, 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 SmartChatOptions, type SmartChatResponse, 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_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, 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 XSearchSource, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
package/dist/index.js
CHANGED
|
@@ -242,7 +242,6 @@ function validateModel(model) {
|
|
|
242
242
|
throw new Error("Model must be a non-empty string");
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
var MAX_TOKENS_SANITY_LIMIT = 1e6;
|
|
246
245
|
function validateMaxTokens(maxTokens) {
|
|
247
246
|
if (maxTokens === void 0 || maxTokens === null) {
|
|
248
247
|
return;
|
|
@@ -253,14 +252,6 @@ function validateMaxTokens(maxTokens) {
|
|
|
253
252
|
if (maxTokens < 1) {
|
|
254
253
|
throw new Error("maxTokens must be positive (minimum: 1)");
|
|
255
254
|
}
|
|
256
|
-
if (maxTokens > MAX_TOKENS_SANITY_LIMIT) {
|
|
257
|
-
throw Object.assign(
|
|
258
|
-
new Error(
|
|
259
|
-
`maxTokens implausibly large (client-side sanity limit: ${MAX_TOKENS_SANITY_LIMIT}). This is not a model limit \u2014 the gateway enforces the real per-model ceiling and reports it.`
|
|
260
|
-
),
|
|
261
|
-
{ code: "MAX_TOKENS_SANITY_LIMIT", limit: MAX_TOKENS_SANITY_LIMIT }
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
255
|
}
|
|
265
256
|
function validateTemperature(temperature) {
|
|
266
257
|
if (temperature === void 0 || temperature === null) {
|
|
@@ -399,6 +390,10 @@ function getCostSummary() {
|
|
|
399
390
|
return { totalUsd, calls, byModel, byEndpoint };
|
|
400
391
|
}
|
|
401
392
|
|
|
393
|
+
// src/version.ts
|
|
394
|
+
var SDK_VERSION = "3.8.3";
|
|
395
|
+
var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
|
|
396
|
+
|
|
402
397
|
// src/client.ts
|
|
403
398
|
function isTransientError(err) {
|
|
404
399
|
if (err instanceof PaymentError) return false;
|
|
@@ -461,8 +456,6 @@ function resolveDefaultTimeout() {
|
|
|
461
456
|
return 6e5;
|
|
462
457
|
}
|
|
463
458
|
var DEFAULT_TIMEOUT = resolveDefaultTimeout();
|
|
464
|
-
var SDK_VERSION = "1.5.0";
|
|
465
|
-
var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
|
|
466
459
|
var LLMClient = class _LLMClient {
|
|
467
460
|
static DEFAULT_API_URL = DEFAULT_API_URL;
|
|
468
461
|
account;
|
|
@@ -4908,8 +4901,6 @@ async function getOrCreateSolanaWallet() {
|
|
|
4908
4901
|
var SOLANA_API_URL = "https://sol.blockrun.ai/api";
|
|
4909
4902
|
var DEFAULT_MAX_TOKENS2 = 1024;
|
|
4910
4903
|
var DEFAULT_TIMEOUT14 = 6e4;
|
|
4911
|
-
var SDK_VERSION2 = "0.3.0";
|
|
4912
|
-
var USER_AGENT2 = `blockrun-ts/${SDK_VERSION2}`;
|
|
4913
4904
|
var DEFAULT_SOLANA_RPC_URL = "https://sol.blockrun.ai/api/v1/solana/rpc";
|
|
4914
4905
|
function resolveRpcConfig(rpcUrl, rpcHeaders) {
|
|
4915
4906
|
const env = typeof process !== "undefined" && process.env ? process.env : {};
|
|
@@ -5240,7 +5231,7 @@ var SolanaLLMClient = class {
|
|
|
5240
5231
|
const url = `${this.apiUrl}${endpoint}`;
|
|
5241
5232
|
const response = await this.fetchWithTimeout(url, {
|
|
5242
5233
|
method: "POST",
|
|
5243
|
-
headers: { "Content-Type": "application/json", "User-Agent":
|
|
5234
|
+
headers: { "Content-Type": "application/json", "User-Agent": USER_AGENT },
|
|
5244
5235
|
body: JSON.stringify(body)
|
|
5245
5236
|
});
|
|
5246
5237
|
if (response.status === 402) {
|
|
@@ -5306,7 +5297,7 @@ var SolanaLLMClient = class {
|
|
|
5306
5297
|
method: "POST",
|
|
5307
5298
|
headers: {
|
|
5308
5299
|
"Content-Type": "application/json",
|
|
5309
|
-
"User-Agent":
|
|
5300
|
+
"User-Agent": USER_AGENT,
|
|
5310
5301
|
"PAYMENT-SIGNATURE": paymentPayload
|
|
5311
5302
|
},
|
|
5312
5303
|
body: JSON.stringify(body)
|
|
@@ -5332,7 +5323,7 @@ var SolanaLLMClient = class {
|
|
|
5332
5323
|
const url = `${this.apiUrl}${endpoint}`;
|
|
5333
5324
|
const response = await this.fetchWithTimeout(url, {
|
|
5334
5325
|
method: "POST",
|
|
5335
|
-
headers: { "Content-Type": "application/json", "User-Agent":
|
|
5326
|
+
headers: { "Content-Type": "application/json", "User-Agent": USER_AGENT },
|
|
5336
5327
|
body: JSON.stringify(body)
|
|
5337
5328
|
});
|
|
5338
5329
|
if (response.status === 402) {
|
|
@@ -5398,7 +5389,7 @@ var SolanaLLMClient = class {
|
|
|
5398
5389
|
method: "POST",
|
|
5399
5390
|
headers: {
|
|
5400
5391
|
"Content-Type": "application/json",
|
|
5401
|
-
"User-Agent":
|
|
5392
|
+
"User-Agent": USER_AGENT,
|
|
5402
5393
|
"PAYMENT-SIGNATURE": paymentPayload
|
|
5403
5394
|
},
|
|
5404
5395
|
body: JSON.stringify(body)
|
|
@@ -5425,7 +5416,7 @@ var SolanaLLMClient = class {
|
|
|
5425
5416
|
const url = `${this.apiUrl}${endpoint}${query}`;
|
|
5426
5417
|
const response = await this.fetchWithTimeout(url, {
|
|
5427
5418
|
method: "GET",
|
|
5428
|
-
headers: { "User-Agent":
|
|
5419
|
+
headers: { "User-Agent": USER_AGENT }
|
|
5429
5420
|
});
|
|
5430
5421
|
if (response.status === 402) {
|
|
5431
5422
|
return this.handleGetPaymentAndRetryRaw(url, endpoint, params, response);
|
|
@@ -5491,7 +5482,7 @@ var SolanaLLMClient = class {
|
|
|
5491
5482
|
const retryResponse = await this.fetchWithTimeout(retryUrl, {
|
|
5492
5483
|
method: "GET",
|
|
5493
5484
|
headers: {
|
|
5494
|
-
"User-Agent":
|
|
5485
|
+
"User-Agent": USER_AGENT,
|
|
5495
5486
|
"PAYMENT-SIGNATURE": paymentPayload
|
|
5496
5487
|
}
|
|
5497
5488
|
});
|
|
@@ -6024,7 +6015,6 @@ export {
|
|
|
6024
6015
|
ImageClient,
|
|
6025
6016
|
KNOWN_PROVIDERS,
|
|
6026
6017
|
LLMClient,
|
|
6027
|
-
MAX_TOKENS_SANITY_LIMIT,
|
|
6028
6018
|
MusicClient,
|
|
6029
6019
|
NETWORK_ALIASES,
|
|
6030
6020
|
OpenAI,
|