@routstr/sdk 0.3.6 → 0.3.7
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/package.json +2 -2
- package/dist/client/index.d.mts +0 -411
- package/dist/client/index.d.ts +0 -411
- package/dist/client/index.js +0 -4824
- package/dist/client/index.js.map +0 -1
- package/dist/client/index.mjs +0 -4818
- package/dist/client/index.mjs.map +0 -1
- package/dist/discovery/index.d.mts +0 -213
- package/dist/discovery/index.d.ts +0 -213
- package/dist/discovery/index.js +0 -735
- package/dist/discovery/index.js.map +0 -1
- package/dist/discovery/index.mjs +0 -732
- package/dist/discovery/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -192
- package/dist/index.d.ts +0 -192
- package/dist/index.js +0 -6240
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -6191
- package/dist/index.mjs.map +0 -1
- package/dist/interfaces-Bp0Ngmqv.d.mts +0 -176
- package/dist/interfaces-Cqkt41QR.d.mts +0 -118
- package/dist/interfaces-D2FDCLyP.d.ts +0 -176
- package/dist/interfaces-D9qI1ym6.d.ts +0 -118
- package/dist/storage/index.d.mts +0 -87
- package/dist/storage/index.d.ts +0 -87
- package/dist/storage/index.js +0 -1740
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/index.mjs +0 -1718
- package/dist/storage/index.mjs.map +0 -1
- package/dist/store-BFUGGr_v.d.ts +0 -172
- package/dist/store-C4FyyOnO.d.mts +0 -172
- package/dist/types-DPQM6tIG.d.mts +0 -234
- package/dist/types-DPQM6tIG.d.ts +0 -234
- package/dist/wallet/index.d.mts +0 -245
- package/dist/wallet/index.d.ts +0 -245
- package/dist/wallet/index.js +0 -1329
- package/dist/wallet/index.js.map +0 -1
- package/dist/wallet/index.mjs +0 -1326
- package/dist/wallet/index.mjs.map +0 -1
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { P as ProviderInfo, M as Model, a as Message, T as TransactionHistory } from './types-DPQM6tIG.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interfaces for the Routstr SDK wallet abstraction layer
|
|
5
|
-
* These interfaces allow the SDK to be framework-agnostic
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* WalletAdapter - Abstracts wallet operations (NIP-60 or legacy)
|
|
10
|
-
* The React app implements this using its hooks
|
|
11
|
-
*/
|
|
12
|
-
interface WalletAdapter {
|
|
13
|
-
/** Get balances for all mints (mintUrl -> balance in sats) */
|
|
14
|
-
getBalances(): Promise<Record<string, number>>;
|
|
15
|
-
/** Get unit type for each mint (mintUrl -> 'sat' | 'msat') */
|
|
16
|
-
getMintUnits(): Record<string, "sat" | "msat">;
|
|
17
|
-
/** Get the currently active mint URL */
|
|
18
|
-
getActiveMintUrl(): string | null;
|
|
19
|
-
/**
|
|
20
|
-
* Create and send a cashu token from a mint
|
|
21
|
-
* @param mintUrl The mint URL to send from
|
|
22
|
-
* @param amount Amount in sats
|
|
23
|
-
* @param p2pkPubkey Optional P2PK public key
|
|
24
|
-
* @returns Encoded cashu token string
|
|
25
|
-
*/
|
|
26
|
-
sendToken(mintUrl: string, amount: number, p2pkPubkey?: string): Promise<string>;
|
|
27
|
-
/**
|
|
28
|
-
* Receive/store a cashu token
|
|
29
|
-
* Handles both NIP-60 and legacy storage internally
|
|
30
|
-
* @param token Encoded cashu token string
|
|
31
|
-
* @returns Result with success flag and amount received
|
|
32
|
-
*/
|
|
33
|
-
receiveToken(token: string): Promise<{
|
|
34
|
-
success: boolean;
|
|
35
|
-
amount: number;
|
|
36
|
-
unit: "sat" | "msat";
|
|
37
|
-
message?: string;
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* StorageAdapter - Abstracts local storage operations
|
|
42
|
-
* Separates token storage from wallet operations
|
|
43
|
-
*/
|
|
44
|
-
interface ApiKeyEntry {
|
|
45
|
-
baseUrl: string;
|
|
46
|
-
key: string;
|
|
47
|
-
balance: number;
|
|
48
|
-
lastUsed: number | null;
|
|
49
|
-
}
|
|
50
|
-
interface ChildKeyEntry {
|
|
51
|
-
parentBaseUrl: string;
|
|
52
|
-
childKey: string;
|
|
53
|
-
balance: number;
|
|
54
|
-
balanceLimit?: number;
|
|
55
|
-
validityDate?: number;
|
|
56
|
-
createdAt: number;
|
|
57
|
-
}
|
|
58
|
-
interface XCashuTokenEntry {
|
|
59
|
-
baseUrl: string;
|
|
60
|
-
token: string;
|
|
61
|
-
createdAt: number;
|
|
62
|
-
tryCount: number;
|
|
63
|
-
}
|
|
64
|
-
interface StorageAdapter {
|
|
65
|
-
/** Save provider info to cache */
|
|
66
|
-
saveProviderInfo(baseUrl: string, info: ProviderInfo): void;
|
|
67
|
-
/** Get cached provider info */
|
|
68
|
-
getProviderInfo(baseUrl: string): ProviderInfo | null;
|
|
69
|
-
/** Get stored API key entry for a provider */
|
|
70
|
-
getApiKey(baseUrl: string): ApiKeyEntry | null;
|
|
71
|
-
/** Store API key for a provider */
|
|
72
|
-
setApiKey(baseUrl: string, key: string): void;
|
|
73
|
-
/** Update balance for an existing stored API key (based on provider response) */
|
|
74
|
-
updateApiKeyBalance(baseUrl: string, balance: number): void;
|
|
75
|
-
/** Remove API key for a provider */
|
|
76
|
-
removeApiKey(baseUrl: string): void;
|
|
77
|
-
/** Get all stored API keys */
|
|
78
|
-
getAllApiKeys(): ApiKeyEntry[];
|
|
79
|
-
/** Get all stored API keys as distribution (baseUrl -> amount in sats) */
|
|
80
|
-
getApiKeyDistribution(): Array<{
|
|
81
|
-
baseUrl: string;
|
|
82
|
-
amount: number;
|
|
83
|
-
}>;
|
|
84
|
-
/** Get stored child key for a parent provider */
|
|
85
|
-
getChildKey(parentBaseUrl: string): ChildKeyEntry | null;
|
|
86
|
-
/** Store a child key for a parent provider */
|
|
87
|
-
setChildKey(parentBaseUrl: string, childKey: string, balance?: number, validityDate?: number, balanceLimit?: number): void;
|
|
88
|
-
/** Update balance for an existing child key */
|
|
89
|
-
updateChildKeyBalance(parentBaseUrl: string, balance: number): void;
|
|
90
|
-
/** Remove child key for a parent provider */
|
|
91
|
-
removeChildKey(parentBaseUrl: string): void;
|
|
92
|
-
/** Get all stored child keys */
|
|
93
|
-
getAllChildKeys(): ChildKeyEntry[];
|
|
94
|
-
/** Get cached receive tokens (tokens that failed to receive due to mint errors) */
|
|
95
|
-
getCachedReceiveTokens(): Array<{
|
|
96
|
-
token: string;
|
|
97
|
-
amount: number;
|
|
98
|
-
unit: "sat" | "msat";
|
|
99
|
-
createdAt: number;
|
|
100
|
-
}>;
|
|
101
|
-
/** Set cached receive tokens */
|
|
102
|
-
setCachedReceiveTokens(tokens: Array<{
|
|
103
|
-
token: string;
|
|
104
|
-
amount: number;
|
|
105
|
-
unit: "sat" | "msat";
|
|
106
|
-
createdAt?: number;
|
|
107
|
-
}>): void;
|
|
108
|
-
/** Get all stored xcashu tokens */
|
|
109
|
-
getXcashuTokens(): Record<string, XCashuTokenEntry[]>;
|
|
110
|
-
/** Get xcashu tokens for a specific baseUrl */
|
|
111
|
-
getXcashuTokensForBaseUrl(baseUrl: string): XCashuTokenEntry[];
|
|
112
|
-
/** Add an xcashu token for a baseUrl */
|
|
113
|
-
addXcashuToken(baseUrl: string, token: string): void;
|
|
114
|
-
/** Remove an xcashu token */
|
|
115
|
-
removeXcashuToken(baseUrl: string, token: string): void;
|
|
116
|
-
/** Clear all xcashu tokens for a baseUrl */
|
|
117
|
-
clearXcashuTokensForBaseUrl(baseUrl: string): void;
|
|
118
|
-
/** Update try count for a specific token */
|
|
119
|
-
updateXcashuTokenTryCount(token: string, tryCount: number): void;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* ProviderRegistry - Provides access to provider/model data
|
|
123
|
-
* Used by ProviderManager for failover logic
|
|
124
|
-
*/
|
|
125
|
-
interface ProviderRegistry {
|
|
126
|
-
/** Get all models available from a provider */
|
|
127
|
-
getModelsForProvider(baseUrl: string): Model[];
|
|
128
|
-
/** Get list of disabled provider URLs */
|
|
129
|
-
getDisabledProviders(): string[];
|
|
130
|
-
/** Get mints accepted by a provider */
|
|
131
|
-
getProviderMints(baseUrl: string): string[];
|
|
132
|
-
/**
|
|
133
|
-
* Get provider info (version, etc.)
|
|
134
|
-
* Should fetch from network if not cached, or return cached version
|
|
135
|
-
*/
|
|
136
|
-
getProviderInfo(baseUrl: string): Promise<ProviderInfo | null>;
|
|
137
|
-
/** Get all providers with their models */
|
|
138
|
-
getAllProvidersModels(): Record<string, Model[]>;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* StreamingCallbacks - Callbacks for real-time updates during API calls
|
|
142
|
-
* Used by RoutstrClient to communicate with the UI
|
|
143
|
-
*/
|
|
144
|
-
interface StreamingCallbacks {
|
|
145
|
-
/** Called when new content arrives from the stream */
|
|
146
|
-
onStreamingUpdate: (content: string) => void;
|
|
147
|
-
/** Called when thinking/reasoning content arrives */
|
|
148
|
-
onThinkingUpdate: (content: string) => void;
|
|
149
|
-
/** Called when a complete message should be appended */
|
|
150
|
-
onMessageAppend: (message: Message) => void;
|
|
151
|
-
/** Called when balance changes */
|
|
152
|
-
onBalanceUpdate: (balance: number) => void;
|
|
153
|
-
/** Called when a transaction is recorded */
|
|
154
|
-
onTransactionUpdate: (transaction: TransactionHistory) => void;
|
|
155
|
-
/** Called when a new token is created (amount in sats) */
|
|
156
|
-
onTokenCreated?: (amount: number) => void;
|
|
157
|
-
/** Called when payment processing starts/stops */
|
|
158
|
-
onPaymentProcessing?: (isProcessing: boolean) => void;
|
|
159
|
-
/** Called when sats spent on the last message is known */
|
|
160
|
-
onLastMessageSatsUpdate?: (satsSpent: number, estimatedCosts: number) => void;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Options for creating a RoutstrClient
|
|
164
|
-
*/
|
|
165
|
-
interface RoutstrClientOptions {
|
|
166
|
-
/** Wallet adapter for cashu operations */
|
|
167
|
-
walletAdapter: WalletAdapter;
|
|
168
|
-
/** Storage adapter for token management */
|
|
169
|
-
storageAdapter: StorageAdapter;
|
|
170
|
-
/** Provider registry for failover logic */
|
|
171
|
-
providerRegistry: ProviderRegistry;
|
|
172
|
-
/** Nostr relay URLs (for future nostr-based features) */
|
|
173
|
-
relayUrls?: string[];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export type { ApiKeyEntry as A, ChildKeyEntry as C, ProviderRegistry as P, RoutstrClientOptions as R, StorageAdapter as S, WalletAdapter as W, XCashuTokenEntry as X, StreamingCallbacks as a };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { M as Model, P as ProviderInfo } from './types-DPQM6tIG.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interfaces for the model and provider discovery system
|
|
5
|
-
* These abstractions allow the discovery logic to be independent of storage implementation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Discovery adapter for managing cached provider and model data
|
|
10
|
-
* Abstracts localStorage operations so discovery logic is testable and reusable
|
|
11
|
-
*/
|
|
12
|
-
interface DiscoveryAdapter {
|
|
13
|
-
/**
|
|
14
|
-
* Get cached models from all providers
|
|
15
|
-
* @returns Record mapping baseUrl -> array of models
|
|
16
|
-
*/
|
|
17
|
-
getCachedModels(): Record<string, Model[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Save models cache
|
|
20
|
-
* @param models Record mapping baseUrl -> array of models
|
|
21
|
-
*/
|
|
22
|
-
setCachedModels(models: Record<string, Model[]>): void;
|
|
23
|
-
/**
|
|
24
|
-
* Get cached mints from all providers
|
|
25
|
-
* @returns Record mapping baseUrl -> array of mint URLs
|
|
26
|
-
*/
|
|
27
|
-
getCachedMints(): Record<string, string[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Save mints cache
|
|
30
|
-
* @param mints Record mapping baseUrl -> array of mint URLs
|
|
31
|
-
*/
|
|
32
|
-
setCachedMints(mints: Record<string, string[]>): void;
|
|
33
|
-
/**
|
|
34
|
-
* Get cached provider info from all providers
|
|
35
|
-
* @returns Record mapping baseUrl -> provider info object
|
|
36
|
-
*/
|
|
37
|
-
getCachedProviderInfo(): Record<string, ProviderInfo>;
|
|
38
|
-
/**
|
|
39
|
-
* Save provider info cache
|
|
40
|
-
* @param info Record mapping baseUrl -> provider info object
|
|
41
|
-
*/
|
|
42
|
-
setCachedProviderInfo(info: Record<string, ProviderInfo>): void;
|
|
43
|
-
/**
|
|
44
|
-
* Get provider last update timestamp
|
|
45
|
-
* @param baseUrl Provider base URL
|
|
46
|
-
* @returns Timestamp in milliseconds or null if never updated
|
|
47
|
-
*/
|
|
48
|
-
getProviderLastUpdate(baseUrl: string): number | null;
|
|
49
|
-
/**
|
|
50
|
-
* Set provider last update timestamp
|
|
51
|
-
* @param baseUrl Provider base URL
|
|
52
|
-
* @param timestamp Timestamp in milliseconds
|
|
53
|
-
*/
|
|
54
|
-
setProviderLastUpdate(baseUrl: string, timestamp: number): void;
|
|
55
|
-
/**
|
|
56
|
-
* Get last used model ID
|
|
57
|
-
* @returns Model ID or null if none
|
|
58
|
-
*/
|
|
59
|
-
getLastUsedModel(): string | null;
|
|
60
|
-
/**
|
|
61
|
-
* Save last used model ID
|
|
62
|
-
* @param modelId Model ID to save
|
|
63
|
-
*/
|
|
64
|
-
setLastUsedModel(modelId: string): void;
|
|
65
|
-
/**
|
|
66
|
-
* Get list of disabled provider base URLs
|
|
67
|
-
* @returns Array of disabled provider URLs
|
|
68
|
-
*/
|
|
69
|
-
getDisabledProviders(): string[];
|
|
70
|
-
/**
|
|
71
|
-
* Save list of disabled provider base URLs
|
|
72
|
-
* Optional because some read-only adapters can only expose current disabled state.
|
|
73
|
-
* @param urls Array of disabled provider URLs
|
|
74
|
-
*/
|
|
75
|
-
setDisabledProviders?(urls: string[]): void;
|
|
76
|
-
/**
|
|
77
|
-
* Get list of configured provider base URLs
|
|
78
|
-
* @returns Array of provider base URLs
|
|
79
|
-
*/
|
|
80
|
-
getBaseUrlsList(): string[];
|
|
81
|
-
/**
|
|
82
|
-
* Get base URLs list last update timestamp
|
|
83
|
-
* @returns Timestamp in milliseconds or null if never updated
|
|
84
|
-
*/
|
|
85
|
-
getBaseUrlsLastUpdate(): number | null;
|
|
86
|
-
/**
|
|
87
|
-
* Save list of provider base URLs
|
|
88
|
-
* @param urls Array of provider base URLs
|
|
89
|
-
*/
|
|
90
|
-
setBaseUrlsList(urls: string[]): void;
|
|
91
|
-
/**
|
|
92
|
-
* Set base URLs list last update timestamp
|
|
93
|
-
* @param timestamp Timestamp in milliseconds
|
|
94
|
-
*/
|
|
95
|
-
setBaseUrlsLastUpdate(timestamp: number): void;
|
|
96
|
-
/**
|
|
97
|
-
* Get list of routstr21 models
|
|
98
|
-
* @returns Array of model IDs
|
|
99
|
-
*/
|
|
100
|
-
getRoutstr21Models(): string[];
|
|
101
|
-
/**
|
|
102
|
-
* Save routstr21 models list
|
|
103
|
-
* @param models Array of model IDs
|
|
104
|
-
*/
|
|
105
|
-
setRoutstr21Models(models: string[]): void;
|
|
106
|
-
/**
|
|
107
|
-
* Get routstr21 models last update timestamp
|
|
108
|
-
* @returns Timestamp in milliseconds or null if never updated
|
|
109
|
-
*/
|
|
110
|
-
getRoutstr21ModelsLastUpdate(): number | null;
|
|
111
|
-
/**
|
|
112
|
-
* Set routstr21 models last update timestamp
|
|
113
|
-
* @param timestamp Timestamp in milliseconds
|
|
114
|
-
*/
|
|
115
|
-
setRoutstr21ModelsLastUpdate(timestamp: number): void;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export type { DiscoveryAdapter as D };
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { P as ProviderInfo, M as Model, a as Message, T as TransactionHistory } from './types-DPQM6tIG.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interfaces for the Routstr SDK wallet abstraction layer
|
|
5
|
-
* These interfaces allow the SDK to be framework-agnostic
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* WalletAdapter - Abstracts wallet operations (NIP-60 or legacy)
|
|
10
|
-
* The React app implements this using its hooks
|
|
11
|
-
*/
|
|
12
|
-
interface WalletAdapter {
|
|
13
|
-
/** Get balances for all mints (mintUrl -> balance in sats) */
|
|
14
|
-
getBalances(): Promise<Record<string, number>>;
|
|
15
|
-
/** Get unit type for each mint (mintUrl -> 'sat' | 'msat') */
|
|
16
|
-
getMintUnits(): Record<string, "sat" | "msat">;
|
|
17
|
-
/** Get the currently active mint URL */
|
|
18
|
-
getActiveMintUrl(): string | null;
|
|
19
|
-
/**
|
|
20
|
-
* Create and send a cashu token from a mint
|
|
21
|
-
* @param mintUrl The mint URL to send from
|
|
22
|
-
* @param amount Amount in sats
|
|
23
|
-
* @param p2pkPubkey Optional P2PK public key
|
|
24
|
-
* @returns Encoded cashu token string
|
|
25
|
-
*/
|
|
26
|
-
sendToken(mintUrl: string, amount: number, p2pkPubkey?: string): Promise<string>;
|
|
27
|
-
/**
|
|
28
|
-
* Receive/store a cashu token
|
|
29
|
-
* Handles both NIP-60 and legacy storage internally
|
|
30
|
-
* @param token Encoded cashu token string
|
|
31
|
-
* @returns Result with success flag and amount received
|
|
32
|
-
*/
|
|
33
|
-
receiveToken(token: string): Promise<{
|
|
34
|
-
success: boolean;
|
|
35
|
-
amount: number;
|
|
36
|
-
unit: "sat" | "msat";
|
|
37
|
-
message?: string;
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* StorageAdapter - Abstracts local storage operations
|
|
42
|
-
* Separates token storage from wallet operations
|
|
43
|
-
*/
|
|
44
|
-
interface ApiKeyEntry {
|
|
45
|
-
baseUrl: string;
|
|
46
|
-
key: string;
|
|
47
|
-
balance: number;
|
|
48
|
-
lastUsed: number | null;
|
|
49
|
-
}
|
|
50
|
-
interface ChildKeyEntry {
|
|
51
|
-
parentBaseUrl: string;
|
|
52
|
-
childKey: string;
|
|
53
|
-
balance: number;
|
|
54
|
-
balanceLimit?: number;
|
|
55
|
-
validityDate?: number;
|
|
56
|
-
createdAt: number;
|
|
57
|
-
}
|
|
58
|
-
interface XCashuTokenEntry {
|
|
59
|
-
baseUrl: string;
|
|
60
|
-
token: string;
|
|
61
|
-
createdAt: number;
|
|
62
|
-
tryCount: number;
|
|
63
|
-
}
|
|
64
|
-
interface StorageAdapter {
|
|
65
|
-
/** Save provider info to cache */
|
|
66
|
-
saveProviderInfo(baseUrl: string, info: ProviderInfo): void;
|
|
67
|
-
/** Get cached provider info */
|
|
68
|
-
getProviderInfo(baseUrl: string): ProviderInfo | null;
|
|
69
|
-
/** Get stored API key entry for a provider */
|
|
70
|
-
getApiKey(baseUrl: string): ApiKeyEntry | null;
|
|
71
|
-
/** Store API key for a provider */
|
|
72
|
-
setApiKey(baseUrl: string, key: string): void;
|
|
73
|
-
/** Update balance for an existing stored API key (based on provider response) */
|
|
74
|
-
updateApiKeyBalance(baseUrl: string, balance: number): void;
|
|
75
|
-
/** Remove API key for a provider */
|
|
76
|
-
removeApiKey(baseUrl: string): void;
|
|
77
|
-
/** Get all stored API keys */
|
|
78
|
-
getAllApiKeys(): ApiKeyEntry[];
|
|
79
|
-
/** Get all stored API keys as distribution (baseUrl -> amount in sats) */
|
|
80
|
-
getApiKeyDistribution(): Array<{
|
|
81
|
-
baseUrl: string;
|
|
82
|
-
amount: number;
|
|
83
|
-
}>;
|
|
84
|
-
/** Get stored child key for a parent provider */
|
|
85
|
-
getChildKey(parentBaseUrl: string): ChildKeyEntry | null;
|
|
86
|
-
/** Store a child key for a parent provider */
|
|
87
|
-
setChildKey(parentBaseUrl: string, childKey: string, balance?: number, validityDate?: number, balanceLimit?: number): void;
|
|
88
|
-
/** Update balance for an existing child key */
|
|
89
|
-
updateChildKeyBalance(parentBaseUrl: string, balance: number): void;
|
|
90
|
-
/** Remove child key for a parent provider */
|
|
91
|
-
removeChildKey(parentBaseUrl: string): void;
|
|
92
|
-
/** Get all stored child keys */
|
|
93
|
-
getAllChildKeys(): ChildKeyEntry[];
|
|
94
|
-
/** Get cached receive tokens (tokens that failed to receive due to mint errors) */
|
|
95
|
-
getCachedReceiveTokens(): Array<{
|
|
96
|
-
token: string;
|
|
97
|
-
amount: number;
|
|
98
|
-
unit: "sat" | "msat";
|
|
99
|
-
createdAt: number;
|
|
100
|
-
}>;
|
|
101
|
-
/** Set cached receive tokens */
|
|
102
|
-
setCachedReceiveTokens(tokens: Array<{
|
|
103
|
-
token: string;
|
|
104
|
-
amount: number;
|
|
105
|
-
unit: "sat" | "msat";
|
|
106
|
-
createdAt?: number;
|
|
107
|
-
}>): void;
|
|
108
|
-
/** Get all stored xcashu tokens */
|
|
109
|
-
getXcashuTokens(): Record<string, XCashuTokenEntry[]>;
|
|
110
|
-
/** Get xcashu tokens for a specific baseUrl */
|
|
111
|
-
getXcashuTokensForBaseUrl(baseUrl: string): XCashuTokenEntry[];
|
|
112
|
-
/** Add an xcashu token for a baseUrl */
|
|
113
|
-
addXcashuToken(baseUrl: string, token: string): void;
|
|
114
|
-
/** Remove an xcashu token */
|
|
115
|
-
removeXcashuToken(baseUrl: string, token: string): void;
|
|
116
|
-
/** Clear all xcashu tokens for a baseUrl */
|
|
117
|
-
clearXcashuTokensForBaseUrl(baseUrl: string): void;
|
|
118
|
-
/** Update try count for a specific token */
|
|
119
|
-
updateXcashuTokenTryCount(token: string, tryCount: number): void;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* ProviderRegistry - Provides access to provider/model data
|
|
123
|
-
* Used by ProviderManager for failover logic
|
|
124
|
-
*/
|
|
125
|
-
interface ProviderRegistry {
|
|
126
|
-
/** Get all models available from a provider */
|
|
127
|
-
getModelsForProvider(baseUrl: string): Model[];
|
|
128
|
-
/** Get list of disabled provider URLs */
|
|
129
|
-
getDisabledProviders(): string[];
|
|
130
|
-
/** Get mints accepted by a provider */
|
|
131
|
-
getProviderMints(baseUrl: string): string[];
|
|
132
|
-
/**
|
|
133
|
-
* Get provider info (version, etc.)
|
|
134
|
-
* Should fetch from network if not cached, or return cached version
|
|
135
|
-
*/
|
|
136
|
-
getProviderInfo(baseUrl: string): Promise<ProviderInfo | null>;
|
|
137
|
-
/** Get all providers with their models */
|
|
138
|
-
getAllProvidersModels(): Record<string, Model[]>;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* StreamingCallbacks - Callbacks for real-time updates during API calls
|
|
142
|
-
* Used by RoutstrClient to communicate with the UI
|
|
143
|
-
*/
|
|
144
|
-
interface StreamingCallbacks {
|
|
145
|
-
/** Called when new content arrives from the stream */
|
|
146
|
-
onStreamingUpdate: (content: string) => void;
|
|
147
|
-
/** Called when thinking/reasoning content arrives */
|
|
148
|
-
onThinkingUpdate: (content: string) => void;
|
|
149
|
-
/** Called when a complete message should be appended */
|
|
150
|
-
onMessageAppend: (message: Message) => void;
|
|
151
|
-
/** Called when balance changes */
|
|
152
|
-
onBalanceUpdate: (balance: number) => void;
|
|
153
|
-
/** Called when a transaction is recorded */
|
|
154
|
-
onTransactionUpdate: (transaction: TransactionHistory) => void;
|
|
155
|
-
/** Called when a new token is created (amount in sats) */
|
|
156
|
-
onTokenCreated?: (amount: number) => void;
|
|
157
|
-
/** Called when payment processing starts/stops */
|
|
158
|
-
onPaymentProcessing?: (isProcessing: boolean) => void;
|
|
159
|
-
/** Called when sats spent on the last message is known */
|
|
160
|
-
onLastMessageSatsUpdate?: (satsSpent: number, estimatedCosts: number) => void;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Options for creating a RoutstrClient
|
|
164
|
-
*/
|
|
165
|
-
interface RoutstrClientOptions {
|
|
166
|
-
/** Wallet adapter for cashu operations */
|
|
167
|
-
walletAdapter: WalletAdapter;
|
|
168
|
-
/** Storage adapter for token management */
|
|
169
|
-
storageAdapter: StorageAdapter;
|
|
170
|
-
/** Provider registry for failover logic */
|
|
171
|
-
providerRegistry: ProviderRegistry;
|
|
172
|
-
/** Nostr relay URLs (for future nostr-based features) */
|
|
173
|
-
relayUrls?: string[];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export type { ApiKeyEntry as A, ChildKeyEntry as C, ProviderRegistry as P, RoutstrClientOptions as R, StorageAdapter as S, WalletAdapter as W, XCashuTokenEntry as X, StreamingCallbacks as a };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { M as Model, P as ProviderInfo } from './types-DPQM6tIG.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interfaces for the model and provider discovery system
|
|
5
|
-
* These abstractions allow the discovery logic to be independent of storage implementation
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Discovery adapter for managing cached provider and model data
|
|
10
|
-
* Abstracts localStorage operations so discovery logic is testable and reusable
|
|
11
|
-
*/
|
|
12
|
-
interface DiscoveryAdapter {
|
|
13
|
-
/**
|
|
14
|
-
* Get cached models from all providers
|
|
15
|
-
* @returns Record mapping baseUrl -> array of models
|
|
16
|
-
*/
|
|
17
|
-
getCachedModels(): Record<string, Model[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Save models cache
|
|
20
|
-
* @param models Record mapping baseUrl -> array of models
|
|
21
|
-
*/
|
|
22
|
-
setCachedModels(models: Record<string, Model[]>): void;
|
|
23
|
-
/**
|
|
24
|
-
* Get cached mints from all providers
|
|
25
|
-
* @returns Record mapping baseUrl -> array of mint URLs
|
|
26
|
-
*/
|
|
27
|
-
getCachedMints(): Record<string, string[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Save mints cache
|
|
30
|
-
* @param mints Record mapping baseUrl -> array of mint URLs
|
|
31
|
-
*/
|
|
32
|
-
setCachedMints(mints: Record<string, string[]>): void;
|
|
33
|
-
/**
|
|
34
|
-
* Get cached provider info from all providers
|
|
35
|
-
* @returns Record mapping baseUrl -> provider info object
|
|
36
|
-
*/
|
|
37
|
-
getCachedProviderInfo(): Record<string, ProviderInfo>;
|
|
38
|
-
/**
|
|
39
|
-
* Save provider info cache
|
|
40
|
-
* @param info Record mapping baseUrl -> provider info object
|
|
41
|
-
*/
|
|
42
|
-
setCachedProviderInfo(info: Record<string, ProviderInfo>): void;
|
|
43
|
-
/**
|
|
44
|
-
* Get provider last update timestamp
|
|
45
|
-
* @param baseUrl Provider base URL
|
|
46
|
-
* @returns Timestamp in milliseconds or null if never updated
|
|
47
|
-
*/
|
|
48
|
-
getProviderLastUpdate(baseUrl: string): number | null;
|
|
49
|
-
/**
|
|
50
|
-
* Set provider last update timestamp
|
|
51
|
-
* @param baseUrl Provider base URL
|
|
52
|
-
* @param timestamp Timestamp in milliseconds
|
|
53
|
-
*/
|
|
54
|
-
setProviderLastUpdate(baseUrl: string, timestamp: number): void;
|
|
55
|
-
/**
|
|
56
|
-
* Get last used model ID
|
|
57
|
-
* @returns Model ID or null if none
|
|
58
|
-
*/
|
|
59
|
-
getLastUsedModel(): string | null;
|
|
60
|
-
/**
|
|
61
|
-
* Save last used model ID
|
|
62
|
-
* @param modelId Model ID to save
|
|
63
|
-
*/
|
|
64
|
-
setLastUsedModel(modelId: string): void;
|
|
65
|
-
/**
|
|
66
|
-
* Get list of disabled provider base URLs
|
|
67
|
-
* @returns Array of disabled provider URLs
|
|
68
|
-
*/
|
|
69
|
-
getDisabledProviders(): string[];
|
|
70
|
-
/**
|
|
71
|
-
* Save list of disabled provider base URLs
|
|
72
|
-
* Optional because some read-only adapters can only expose current disabled state.
|
|
73
|
-
* @param urls Array of disabled provider URLs
|
|
74
|
-
*/
|
|
75
|
-
setDisabledProviders?(urls: string[]): void;
|
|
76
|
-
/**
|
|
77
|
-
* Get list of configured provider base URLs
|
|
78
|
-
* @returns Array of provider base URLs
|
|
79
|
-
*/
|
|
80
|
-
getBaseUrlsList(): string[];
|
|
81
|
-
/**
|
|
82
|
-
* Get base URLs list last update timestamp
|
|
83
|
-
* @returns Timestamp in milliseconds or null if never updated
|
|
84
|
-
*/
|
|
85
|
-
getBaseUrlsLastUpdate(): number | null;
|
|
86
|
-
/**
|
|
87
|
-
* Save list of provider base URLs
|
|
88
|
-
* @param urls Array of provider base URLs
|
|
89
|
-
*/
|
|
90
|
-
setBaseUrlsList(urls: string[]): void;
|
|
91
|
-
/**
|
|
92
|
-
* Set base URLs list last update timestamp
|
|
93
|
-
* @param timestamp Timestamp in milliseconds
|
|
94
|
-
*/
|
|
95
|
-
setBaseUrlsLastUpdate(timestamp: number): void;
|
|
96
|
-
/**
|
|
97
|
-
* Get list of routstr21 models
|
|
98
|
-
* @returns Array of model IDs
|
|
99
|
-
*/
|
|
100
|
-
getRoutstr21Models(): string[];
|
|
101
|
-
/**
|
|
102
|
-
* Save routstr21 models list
|
|
103
|
-
* @param models Array of model IDs
|
|
104
|
-
*/
|
|
105
|
-
setRoutstr21Models(models: string[]): void;
|
|
106
|
-
/**
|
|
107
|
-
* Get routstr21 models last update timestamp
|
|
108
|
-
* @returns Timestamp in milliseconds or null if never updated
|
|
109
|
-
*/
|
|
110
|
-
getRoutstr21ModelsLastUpdate(): number | null;
|
|
111
|
-
/**
|
|
112
|
-
* Set routstr21 models last update timestamp
|
|
113
|
-
* @param timestamp Timestamp in milliseconds
|
|
114
|
-
*/
|
|
115
|
-
setRoutstr21ModelsLastUpdate(timestamp: number): void;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export type { DiscoveryAdapter as D };
|
package/dist/storage/index.d.mts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { a as StorageDriver, U as UsageTrackingDriver, b as UsageTrackingEntry, S as SdkStore } from '../store-C4FyyOnO.mjs';
|
|
2
|
-
export { L as ListUsageTrackingOptions, c as createDiscoveryAdapterFromStore, d as createProviderRegistryFromStore, e as createSdkStore, f as createStorageAdapterFromStore } from '../store-C4FyyOnO.mjs';
|
|
3
|
-
import { S as SdkLogger } from '../types-DPQM6tIG.mjs';
|
|
4
|
-
import { D as DiscoveryAdapter } from '../interfaces-Cqkt41QR.mjs';
|
|
5
|
-
import { P as ProviderRegistry, S as StorageAdapter } from '../interfaces-Bp0Ngmqv.mjs';
|
|
6
|
-
export { X as XCashuTokenEntry } from '../interfaces-Bp0Ngmqv.mjs';
|
|
7
|
-
import 'zustand/vanilla';
|
|
8
|
-
|
|
9
|
-
interface IndexedDBUsageTrackingDriverOptions {
|
|
10
|
-
dbName?: string;
|
|
11
|
-
storeName?: string;
|
|
12
|
-
legacyStorageDriver?: StorageDriver;
|
|
13
|
-
}
|
|
14
|
-
declare const createIndexedDBUsageTrackingDriver: (options?: IndexedDBUsageTrackingDriverOptions) => UsageTrackingDriver;
|
|
15
|
-
|
|
16
|
-
interface SqliteUsageTrackingDriverOptions {
|
|
17
|
-
dbPath?: string;
|
|
18
|
-
tableName?: string;
|
|
19
|
-
legacyStorageDriver?: StorageDriver;
|
|
20
|
-
}
|
|
21
|
-
declare const createSqliteUsageTrackingDriver: (options?: SqliteUsageTrackingDriverOptions) => UsageTrackingDriver;
|
|
22
|
-
|
|
23
|
-
interface BunSqliteUsageTrackingDriverOptions {
|
|
24
|
-
dbPath?: string;
|
|
25
|
-
tableName?: string;
|
|
26
|
-
legacyStorageDriver?: StorageDriver;
|
|
27
|
-
sqlite?: {
|
|
28
|
-
Database: any;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
declare const createBunSqliteUsageTrackingDriver: (options?: BunSqliteUsageTrackingDriverOptions) => UsageTrackingDriver;
|
|
32
|
-
|
|
33
|
-
declare const createMemoryUsageTrackingDriver: (seed?: UsageTrackingEntry[]) => UsageTrackingDriver;
|
|
34
|
-
|
|
35
|
-
declare const localStorageDriver: StorageDriver;
|
|
36
|
-
|
|
37
|
-
declare const createMemoryDriver: (seed?: Record<string, string>) => StorageDriver;
|
|
38
|
-
|
|
39
|
-
interface SqliteDriverOptions {
|
|
40
|
-
dbPath?: string;
|
|
41
|
-
tableName?: string;
|
|
42
|
-
}
|
|
43
|
-
declare const createSqliteDriver: (options?: SqliteDriverOptions) => StorageDriver;
|
|
44
|
-
declare function createBunSqliteDriver(dbPath: string, options?: {
|
|
45
|
-
logger?: SdkLogger;
|
|
46
|
-
}): Promise<StorageDriver>;
|
|
47
|
-
|
|
48
|
-
interface IndexedDBDriverOptions {
|
|
49
|
-
dbName?: string;
|
|
50
|
-
storeName?: string;
|
|
51
|
-
}
|
|
52
|
-
declare const createIndexedDBDriver: (options?: IndexedDBDriverOptions) => StorageDriver;
|
|
53
|
-
|
|
54
|
-
declare const SDK_STORAGE_KEYS: {
|
|
55
|
-
readonly MODELS_FROM_ALL_PROVIDERS: "modelsFromAllProviders";
|
|
56
|
-
readonly LAST_USED_MODEL: "lastUsedModel";
|
|
57
|
-
readonly BASE_URLS_LIST: "base_urls_list";
|
|
58
|
-
readonly DISABLED_PROVIDERS: "disabled_providers";
|
|
59
|
-
readonly MINTS_FROM_ALL_PROVIDERS: "mints_from_all_providers";
|
|
60
|
-
readonly INFO_FROM_ALL_PROVIDERS: "info_from_all_providers";
|
|
61
|
-
readonly LAST_MODELS_UPDATE: "lastModelsUpdate";
|
|
62
|
-
readonly LAST_BASE_URLS_UPDATE: "lastBaseUrlsUpdate";
|
|
63
|
-
readonly API_KEYS: "api_keys";
|
|
64
|
-
readonly CHILD_KEYS: "child_keys";
|
|
65
|
-
readonly XCASHU_TOKENS: "xcashu_tokens";
|
|
66
|
-
readonly ROUTSTR21_MODELS: "routstr21Models";
|
|
67
|
-
readonly LAST_ROUTSTR21_MODELS_UPDATE: "lastRoutstr21ModelsUpdate";
|
|
68
|
-
readonly CACHED_RECEIVE_TOKENS: "cached_receive_tokens";
|
|
69
|
-
readonly USAGE_TRACKING: "usage_tracking";
|
|
70
|
-
readonly CLIENT_IDS: "client_ids";
|
|
71
|
-
readonly FAILED_PROVIDERS: "failed_providers";
|
|
72
|
-
readonly LAST_FAILED: "last_failed";
|
|
73
|
-
readonly PROVIDERS_ON_COOLDOWN: "providers_on_cooldown";
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
declare const getDefaultSdkDriver: () => StorageDriver;
|
|
77
|
-
declare const getDefaultSdkStore: () => Promise<SdkStore>;
|
|
78
|
-
declare const getDefaultUsageTrackingDriver: () => UsageTrackingDriver;
|
|
79
|
-
/**
|
|
80
|
-
* Allow setting a custom usage tracking driver (useful for routstrd to use proper DB path)
|
|
81
|
-
*/
|
|
82
|
-
declare const setDefaultUsageTrackingDriver: (driver: UsageTrackingDriver) => void;
|
|
83
|
-
declare const getDefaultDiscoveryAdapter: () => Promise<DiscoveryAdapter>;
|
|
84
|
-
declare const getDefaultStorageAdapter: () => Promise<StorageAdapter>;
|
|
85
|
-
declare const getDefaultProviderRegistry: () => Promise<ProviderRegistry>;
|
|
86
|
-
|
|
87
|
-
export { DiscoveryAdapter, ProviderRegistry, SDK_STORAGE_KEYS, SdkStore, StorageAdapter, StorageDriver, UsageTrackingDriver, UsageTrackingEntry, createBunSqliteDriver, createBunSqliteUsageTrackingDriver, createIndexedDBDriver, createIndexedDBUsageTrackingDriver, createMemoryDriver, createMemoryUsageTrackingDriver, createSqliteDriver, createSqliteUsageTrackingDriver, getDefaultDiscoveryAdapter, getDefaultProviderRegistry, getDefaultSdkDriver, getDefaultSdkStore, getDefaultStorageAdapter, getDefaultUsageTrackingDriver, localStorageDriver, setDefaultUsageTrackingDriver };
|