@routstr/sdk 0.3.5 → 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.
Files changed (39) hide show
  1. package/package.json +2 -2
  2. package/dist/client/index.d.mts +0 -411
  3. package/dist/client/index.d.ts +0 -411
  4. package/dist/client/index.js +0 -4819
  5. package/dist/client/index.js.map +0 -1
  6. package/dist/client/index.mjs +0 -4813
  7. package/dist/client/index.mjs.map +0 -1
  8. package/dist/discovery/index.d.mts +0 -196
  9. package/dist/discovery/index.d.ts +0 -196
  10. package/dist/discovery/index.js +0 -616
  11. package/dist/discovery/index.js.map +0 -1
  12. package/dist/discovery/index.mjs +0 -613
  13. package/dist/discovery/index.mjs.map +0 -1
  14. package/dist/index.d.mts +0 -190
  15. package/dist/index.d.ts +0 -190
  16. package/dist/index.js +0 -6114
  17. package/dist/index.js.map +0 -1
  18. package/dist/index.mjs +0 -6065
  19. package/dist/index.mjs.map +0 -1
  20. package/dist/interfaces-Bp0Ngmqv.d.mts +0 -176
  21. package/dist/interfaces-CIfd_phZ.d.ts +0 -112
  22. package/dist/interfaces-Cxi8R4TT.d.mts +0 -112
  23. package/dist/interfaces-D2FDCLyP.d.ts +0 -176
  24. package/dist/storage/index.d.mts +0 -87
  25. package/dist/storage/index.d.ts +0 -87
  26. package/dist/storage/index.js +0 -1734
  27. package/dist/storage/index.js.map +0 -1
  28. package/dist/storage/index.mjs +0 -1712
  29. package/dist/storage/index.mjs.map +0 -1
  30. package/dist/store-BD5zF9Hp.d.ts +0 -172
  31. package/dist/store-CBSyK2qg.d.mts +0 -172
  32. package/dist/types-DPQM6tIG.d.mts +0 -234
  33. package/dist/types-DPQM6tIG.d.ts +0 -234
  34. package/dist/wallet/index.d.mts +0 -245
  35. package/dist/wallet/index.d.ts +0 -245
  36. package/dist/wallet/index.js +0 -1329
  37. package/dist/wallet/index.js.map +0 -1
  38. package/dist/wallet/index.mjs +0 -1326
  39. package/dist/wallet/index.mjs.map +0 -1
@@ -1,196 +0,0 @@
1
- import { D as DiscoveryAdapter } from '../interfaces-Cxi8R4TT.mjs';
2
- import { S as SdkLogger, M as Model, P as ProviderInfo } from '../types-DPQM6tIG.mjs';
3
-
4
- /**
5
- * ModelManager class for discovering, fetching, and managing models from providers
6
- * Core responsibility: fetching models from providers, caching them, and selecting the best option
7
- * (lowest cost) across multiple providers
8
- */
9
-
10
- /**
11
- * Configuration for ModelManager
12
- */
13
- interface ModelManagerConfig {
14
- /** URL to fetch provider directory from */
15
- providerDirectoryUrl?: string;
16
- /** Additional provider base URLs to include */
17
- includeProviderUrls?: string[];
18
- /** Provider base URLs to exclude */
19
- excludeProviderUrls?: string[];
20
- /** Cache TTL in milliseconds (default: 21 minutes) */
21
- cacheTTL?: number;
22
- /** Optional injectable logger */
23
- logger?: SdkLogger;
24
- }
25
- /**
26
- * ModelManager handles all model discovery and caching logic
27
- * Abstracts away storage details via DiscoveryAdapter
28
- */
29
- declare class ModelManager {
30
- private adapter;
31
- private readonly cacheTTL;
32
- private readonly providerDirectoryUrl;
33
- private readonly includeProviderUrls;
34
- private readonly excludeProviderUrls;
35
- private readonly logger;
36
- constructor(adapter: DiscoveryAdapter, config?: ModelManagerConfig);
37
- /**
38
- * Get the list of bootstrapped provider base URLs
39
- * @returns Array of provider base URLs
40
- */
41
- getBaseUrls(): string[];
42
- static init(adapter: DiscoveryAdapter, config?: ModelManagerConfig, options?: {
43
- torMode?: boolean;
44
- forceRefresh?: boolean;
45
- }): Promise<ModelManager>;
46
- /**
47
- * Bootstrap provider list from the provider directory
48
- * First tries to fetch from Nostr (kind 30421), falls back to HTTP
49
- * @param torMode Whether running in Tor context
50
- * @param forceRefresh Ignore provider cache and refresh provider sources
51
- * @returns Array of provider base URLs
52
- * @throws ProviderBootstrapError if all providers fail to fetch
53
- */
54
- bootstrapProviders(torMode?: boolean, forceRefresh?: boolean): Promise<string[]>;
55
- /**
56
- * Bootstrap providers from Nostr network (kind 30421)
57
- * @param kind The Nostr kind to fetch
58
- * @param torMode Whether running in Tor context
59
- * @returns Array of provider base URLs
60
- */
61
- private bootstrapFromNostr;
62
- /**
63
- * Bootstrap providers from HTTP endpoint
64
- * @param torMode Whether running in Tor context
65
- * @param forceRefresh Ignore routstr21 cache and fetch fresh data
66
- * @returns Array of provider base URLs
67
- */
68
- private bootstrapFromHttp;
69
- /**
70
- * Fetch models from all providers and select best-priced options
71
- * Uses cache if available and not expired
72
- * @param baseUrls List of provider base URLs to fetch from
73
- * @param forceRefresh Ignore cache and fetch fresh data
74
- * @param onProgress Callback fired after each provider completes with current combined models
75
- * @returns Array of unique models with best prices selected
76
- */
77
- fetchModels(baseUrls: string[], forceRefresh?: boolean, onProgress?: (models: Model[]) => void): Promise<Model[]>;
78
- /**
79
- * Fetch models from a single provider
80
- * @param baseUrl Provider base URL
81
- * @returns Array of models from provider
82
- */
83
- private fetchModelsFromProvider;
84
- private isProviderDownError;
85
- /**
86
- * Get all cached models from all providers
87
- * @returns Record mapping baseUrl -> models
88
- */
89
- getAllCachedModels(): Record<string, Model[]>;
90
- /**
91
- * Clear cache for a specific provider
92
- * @param baseUrl Provider base URL
93
- */
94
- clearProviderCache(baseUrl: string): void;
95
- /**
96
- * Clear all model caches
97
- */
98
- clearAllCache(): void;
99
- /**
100
- * Filter base URLs based on Tor context
101
- * @param baseUrls Provider URLs to filter
102
- * @param torMode Whether in Tor context
103
- * @returns Filtered URLs appropriate for Tor mode
104
- */
105
- filterBaseUrlsForTor(baseUrls: string[], torMode: boolean): string[];
106
- /**
107
- * Get provider endpoints from provider info
108
- * @param provider Provider object from directory
109
- * @param torMode Whether in Tor context
110
- * @returns Array of endpoint URLs
111
- */
112
- private getProviderEndpoints;
113
- /**
114
- * Normalize provider URL with trailing slash
115
- * @param url URL to normalize
116
- * @returns Normalized URL
117
- */
118
- private normalizeUrl;
119
- /**
120
- * Fetch routstr21 models from Nostr network (kind 38423)
121
- * Uses cache if available and not expired
122
- * @returns Array of model IDs or empty array if not found
123
- */
124
- fetchRoutstr21Models(forceRefresh?: boolean): Promise<string[]>;
125
- }
126
-
127
- /**
128
- * MintDiscovery class for discovering mints and provider info
129
- * Core responsibility: fetching mint information from providers and caching it
130
- */
131
-
132
- /**
133
- * Configuration for MintDiscovery
134
- */
135
- interface MintDiscoveryConfig {
136
- /** Cache TTL in milliseconds (default: 21 minutes) */
137
- cacheTTL?: number;
138
- /** Optional injectable logger */
139
- logger?: SdkLogger;
140
- }
141
- /**
142
- * MintDiscovery handles mint and provider info discovery
143
- * Abstracts away storage details via DiscoveryAdapter
144
- */
145
- declare class MintDiscovery {
146
- private adapter;
147
- private readonly cacheTTL;
148
- private readonly logger;
149
- constructor(adapter: DiscoveryAdapter, config?: MintDiscoveryConfig);
150
- /**
151
- * Fetch mints from all providers via their /v1/info endpoints
152
- * Caches mints and full provider info for later access
153
- * @param baseUrls List of provider base URLs to fetch from
154
- * @returns Object with mints and provider info from all providers
155
- */
156
- discoverMints(baseUrls: string[], options?: {
157
- forceRefresh?: boolean;
158
- }): Promise<{
159
- mintsFromProviders: Record<string, string[]>;
160
- infoFromProviders: Record<string, ProviderInfo>;
161
- }>;
162
- /**
163
- * Get cached mints from all providers
164
- * @returns Record mapping baseUrl -> mint URLs
165
- */
166
- getCachedMints(): Record<string, string[]>;
167
- /**
168
- * Get cached provider info from all providers
169
- * @returns Record mapping baseUrl -> provider info
170
- */
171
- getCachedProviderInfo(): Record<string, ProviderInfo>;
172
- /**
173
- * Get mints for a specific provider
174
- * @param baseUrl Provider base URL
175
- * @returns Array of mint URLs for the provider
176
- */
177
- getProviderMints(baseUrl: string): string[];
178
- /**
179
- * Get info for a specific provider
180
- * @param baseUrl Provider base URL
181
- * @returns Provider info object or null if not found
182
- */
183
- getProviderInfo(baseUrl: string): ProviderInfo | null;
184
- /**
185
- * Clear mint cache for a specific provider
186
- * @param baseUrl Provider base URL
187
- */
188
- clearProviderMintCache(baseUrl: string): void;
189
- /**
190
- * Clear all mint caches
191
- */
192
- clearAllCache(): void;
193
- private isProviderDownError;
194
- }
195
-
196
- export { DiscoveryAdapter, MintDiscovery, ModelManager, type ModelManagerConfig, ProviderInfo };
@@ -1,196 +0,0 @@
1
- import { D as DiscoveryAdapter } from '../interfaces-CIfd_phZ.js';
2
- import { S as SdkLogger, M as Model, P as ProviderInfo } from '../types-DPQM6tIG.js';
3
-
4
- /**
5
- * ModelManager class for discovering, fetching, and managing models from providers
6
- * Core responsibility: fetching models from providers, caching them, and selecting the best option
7
- * (lowest cost) across multiple providers
8
- */
9
-
10
- /**
11
- * Configuration for ModelManager
12
- */
13
- interface ModelManagerConfig {
14
- /** URL to fetch provider directory from */
15
- providerDirectoryUrl?: string;
16
- /** Additional provider base URLs to include */
17
- includeProviderUrls?: string[];
18
- /** Provider base URLs to exclude */
19
- excludeProviderUrls?: string[];
20
- /** Cache TTL in milliseconds (default: 21 minutes) */
21
- cacheTTL?: number;
22
- /** Optional injectable logger */
23
- logger?: SdkLogger;
24
- }
25
- /**
26
- * ModelManager handles all model discovery and caching logic
27
- * Abstracts away storage details via DiscoveryAdapter
28
- */
29
- declare class ModelManager {
30
- private adapter;
31
- private readonly cacheTTL;
32
- private readonly providerDirectoryUrl;
33
- private readonly includeProviderUrls;
34
- private readonly excludeProviderUrls;
35
- private readonly logger;
36
- constructor(adapter: DiscoveryAdapter, config?: ModelManagerConfig);
37
- /**
38
- * Get the list of bootstrapped provider base URLs
39
- * @returns Array of provider base URLs
40
- */
41
- getBaseUrls(): string[];
42
- static init(adapter: DiscoveryAdapter, config?: ModelManagerConfig, options?: {
43
- torMode?: boolean;
44
- forceRefresh?: boolean;
45
- }): Promise<ModelManager>;
46
- /**
47
- * Bootstrap provider list from the provider directory
48
- * First tries to fetch from Nostr (kind 30421), falls back to HTTP
49
- * @param torMode Whether running in Tor context
50
- * @param forceRefresh Ignore provider cache and refresh provider sources
51
- * @returns Array of provider base URLs
52
- * @throws ProviderBootstrapError if all providers fail to fetch
53
- */
54
- bootstrapProviders(torMode?: boolean, forceRefresh?: boolean): Promise<string[]>;
55
- /**
56
- * Bootstrap providers from Nostr network (kind 30421)
57
- * @param kind The Nostr kind to fetch
58
- * @param torMode Whether running in Tor context
59
- * @returns Array of provider base URLs
60
- */
61
- private bootstrapFromNostr;
62
- /**
63
- * Bootstrap providers from HTTP endpoint
64
- * @param torMode Whether running in Tor context
65
- * @param forceRefresh Ignore routstr21 cache and fetch fresh data
66
- * @returns Array of provider base URLs
67
- */
68
- private bootstrapFromHttp;
69
- /**
70
- * Fetch models from all providers and select best-priced options
71
- * Uses cache if available and not expired
72
- * @param baseUrls List of provider base URLs to fetch from
73
- * @param forceRefresh Ignore cache and fetch fresh data
74
- * @param onProgress Callback fired after each provider completes with current combined models
75
- * @returns Array of unique models with best prices selected
76
- */
77
- fetchModels(baseUrls: string[], forceRefresh?: boolean, onProgress?: (models: Model[]) => void): Promise<Model[]>;
78
- /**
79
- * Fetch models from a single provider
80
- * @param baseUrl Provider base URL
81
- * @returns Array of models from provider
82
- */
83
- private fetchModelsFromProvider;
84
- private isProviderDownError;
85
- /**
86
- * Get all cached models from all providers
87
- * @returns Record mapping baseUrl -> models
88
- */
89
- getAllCachedModels(): Record<string, Model[]>;
90
- /**
91
- * Clear cache for a specific provider
92
- * @param baseUrl Provider base URL
93
- */
94
- clearProviderCache(baseUrl: string): void;
95
- /**
96
- * Clear all model caches
97
- */
98
- clearAllCache(): void;
99
- /**
100
- * Filter base URLs based on Tor context
101
- * @param baseUrls Provider URLs to filter
102
- * @param torMode Whether in Tor context
103
- * @returns Filtered URLs appropriate for Tor mode
104
- */
105
- filterBaseUrlsForTor(baseUrls: string[], torMode: boolean): string[];
106
- /**
107
- * Get provider endpoints from provider info
108
- * @param provider Provider object from directory
109
- * @param torMode Whether in Tor context
110
- * @returns Array of endpoint URLs
111
- */
112
- private getProviderEndpoints;
113
- /**
114
- * Normalize provider URL with trailing slash
115
- * @param url URL to normalize
116
- * @returns Normalized URL
117
- */
118
- private normalizeUrl;
119
- /**
120
- * Fetch routstr21 models from Nostr network (kind 38423)
121
- * Uses cache if available and not expired
122
- * @returns Array of model IDs or empty array if not found
123
- */
124
- fetchRoutstr21Models(forceRefresh?: boolean): Promise<string[]>;
125
- }
126
-
127
- /**
128
- * MintDiscovery class for discovering mints and provider info
129
- * Core responsibility: fetching mint information from providers and caching it
130
- */
131
-
132
- /**
133
- * Configuration for MintDiscovery
134
- */
135
- interface MintDiscoveryConfig {
136
- /** Cache TTL in milliseconds (default: 21 minutes) */
137
- cacheTTL?: number;
138
- /** Optional injectable logger */
139
- logger?: SdkLogger;
140
- }
141
- /**
142
- * MintDiscovery handles mint and provider info discovery
143
- * Abstracts away storage details via DiscoveryAdapter
144
- */
145
- declare class MintDiscovery {
146
- private adapter;
147
- private readonly cacheTTL;
148
- private readonly logger;
149
- constructor(adapter: DiscoveryAdapter, config?: MintDiscoveryConfig);
150
- /**
151
- * Fetch mints from all providers via their /v1/info endpoints
152
- * Caches mints and full provider info for later access
153
- * @param baseUrls List of provider base URLs to fetch from
154
- * @returns Object with mints and provider info from all providers
155
- */
156
- discoverMints(baseUrls: string[], options?: {
157
- forceRefresh?: boolean;
158
- }): Promise<{
159
- mintsFromProviders: Record<string, string[]>;
160
- infoFromProviders: Record<string, ProviderInfo>;
161
- }>;
162
- /**
163
- * Get cached mints from all providers
164
- * @returns Record mapping baseUrl -> mint URLs
165
- */
166
- getCachedMints(): Record<string, string[]>;
167
- /**
168
- * Get cached provider info from all providers
169
- * @returns Record mapping baseUrl -> provider info
170
- */
171
- getCachedProviderInfo(): Record<string, ProviderInfo>;
172
- /**
173
- * Get mints for a specific provider
174
- * @param baseUrl Provider base URL
175
- * @returns Array of mint URLs for the provider
176
- */
177
- getProviderMints(baseUrl: string): string[];
178
- /**
179
- * Get info for a specific provider
180
- * @param baseUrl Provider base URL
181
- * @returns Provider info object or null if not found
182
- */
183
- getProviderInfo(baseUrl: string): ProviderInfo | null;
184
- /**
185
- * Clear mint cache for a specific provider
186
- * @param baseUrl Provider base URL
187
- */
188
- clearProviderMintCache(baseUrl: string): void;
189
- /**
190
- * Clear all mint caches
191
- */
192
- clearAllCache(): void;
193
- private isProviderDownError;
194
- }
195
-
196
- export { DiscoveryAdapter, MintDiscovery, ModelManager, type ModelManagerConfig, ProviderInfo };