@syfthub/sdk 0.1.0 → 0.1.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 +0 -3
- package/dist/index.cjs +219 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +165 -40
- package/dist/index.d.ts +165 -40
- package/dist/index.js +219 -102
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -170,6 +170,8 @@ interface User {
|
|
|
170
170
|
readonly updatedAt: Date | null;
|
|
171
171
|
/** Domain for endpoint URL construction (e.g., "api.example.com" or "api.example.com:8080") */
|
|
172
172
|
readonly domain: string | null;
|
|
173
|
+
/** Custom aggregator URL for RAG/chat workflows */
|
|
174
|
+
readonly aggregatorUrl: string | null;
|
|
173
175
|
}
|
|
174
176
|
/**
|
|
175
177
|
* Input for user registration.
|
|
@@ -204,6 +206,8 @@ interface UserUpdateInput {
|
|
|
204
206
|
avatarUrl?: string;
|
|
205
207
|
/** Domain for endpoint URL construction (no protocol, e.g., "api.example.com:8080") */
|
|
206
208
|
domain?: string;
|
|
209
|
+
/** Custom aggregator URL for RAG/chat workflows */
|
|
210
|
+
aggregatorUrl?: string;
|
|
207
211
|
}
|
|
208
212
|
/**
|
|
209
213
|
* Input for changing password.
|
|
@@ -287,6 +291,42 @@ interface EndpointPublic {
|
|
|
287
291
|
readonly createdAt: Date;
|
|
288
292
|
readonly updatedAt: Date;
|
|
289
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Search result with relevance score from semantic search.
|
|
296
|
+
*
|
|
297
|
+
* Extends the public endpoint fields with a relevance score indicating
|
|
298
|
+
* how well the endpoint matches the search query.
|
|
299
|
+
*/
|
|
300
|
+
interface EndpointSearchResult {
|
|
301
|
+
readonly name: string;
|
|
302
|
+
readonly slug: string;
|
|
303
|
+
readonly description: string;
|
|
304
|
+
readonly type: EndpointType;
|
|
305
|
+
readonly ownerUsername: string;
|
|
306
|
+
/** Number of contributors (user IDs not exposed for privacy) */
|
|
307
|
+
readonly contributorsCount: number;
|
|
308
|
+
readonly version: string;
|
|
309
|
+
readonly readme: string;
|
|
310
|
+
readonly tags: readonly string[];
|
|
311
|
+
readonly starsCount: number;
|
|
312
|
+
readonly policies: readonly Policy[];
|
|
313
|
+
readonly connect: readonly Connection[];
|
|
314
|
+
readonly createdAt: Date;
|
|
315
|
+
readonly updatedAt: Date;
|
|
316
|
+
/** Relevance score from semantic search (0.0-1.0) */
|
|
317
|
+
readonly relevanceScore: number;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Options for semantic search.
|
|
321
|
+
*/
|
|
322
|
+
interface SearchOptions {
|
|
323
|
+
/** Maximum number of results to return (default: 10) */
|
|
324
|
+
topK?: number;
|
|
325
|
+
/** Filter by endpoint type */
|
|
326
|
+
type?: EndpointType;
|
|
327
|
+
/** Minimum relevance score threshold (0.0-1.0, default: 0.0) */
|
|
328
|
+
minScore?: number;
|
|
329
|
+
}
|
|
290
330
|
/**
|
|
291
331
|
* Input for creating a new endpoint.
|
|
292
332
|
*/
|
|
@@ -331,6 +371,20 @@ declare function getEndpointOwnerType(endpoint: Endpoint): 'user' | 'organizatio
|
|
|
331
371
|
* @returns The path in "owner/slug" format
|
|
332
372
|
*/
|
|
333
373
|
declare function getEndpointPublicPath(endpoint: EndpointPublic): string;
|
|
374
|
+
/**
|
|
375
|
+
* Response from the sync endpoints operation.
|
|
376
|
+
*
|
|
377
|
+
* Contains details about the sync operation including how many endpoints
|
|
378
|
+
* were deleted, how many were created, and the full list of created endpoints.
|
|
379
|
+
*/
|
|
380
|
+
interface SyncEndpointsResponse {
|
|
381
|
+
/** Number of endpoints created */
|
|
382
|
+
readonly synced: number;
|
|
383
|
+
/** Number of endpoints deleted */
|
|
384
|
+
readonly deleted: number;
|
|
385
|
+
/** List of created endpoints with full details */
|
|
386
|
+
readonly endpoints: readonly Endpoint[];
|
|
387
|
+
}
|
|
334
388
|
|
|
335
389
|
/**
|
|
336
390
|
* Accounting Models
|
|
@@ -609,6 +663,8 @@ interface ChatOptions {
|
|
|
609
663
|
similarityThreshold?: number;
|
|
610
664
|
/** AbortSignal for request cancellation */
|
|
611
665
|
signal?: AbortSignal;
|
|
666
|
+
/** Custom aggregator URL to use instead of the default */
|
|
667
|
+
aggregatorUrl?: string;
|
|
612
668
|
}
|
|
613
669
|
/**
|
|
614
670
|
* Options for querying a data source directly.
|
|
@@ -1110,13 +1166,6 @@ declare class MyEndpointsResource {
|
|
|
1110
1166
|
* @throws {Error} If path format is invalid
|
|
1111
1167
|
*/
|
|
1112
1168
|
private parsePath;
|
|
1113
|
-
/**
|
|
1114
|
-
* Resolve an endpoint path to its ID.
|
|
1115
|
-
*
|
|
1116
|
-
* @param path - Endpoint path in "owner/slug" format
|
|
1117
|
-
* @returns The endpoint ID
|
|
1118
|
-
*/
|
|
1119
|
-
private resolveEndpointId;
|
|
1120
1169
|
/**
|
|
1121
1170
|
* List the current user's endpoints.
|
|
1122
1171
|
*
|
|
@@ -1167,6 +1216,40 @@ declare class MyEndpointsResource {
|
|
|
1167
1216
|
* @throws {AuthorizationError} If not owner/admin
|
|
1168
1217
|
*/
|
|
1169
1218
|
delete(path: string): Promise<void>;
|
|
1219
|
+
/**
|
|
1220
|
+
* Synchronize user's endpoints with provided list.
|
|
1221
|
+
*
|
|
1222
|
+
* This is a DESTRUCTIVE operation that:
|
|
1223
|
+
* 1. Deletes ALL existing endpoints owned by the current user
|
|
1224
|
+
* 2. Creates ALL endpoints from the provided list
|
|
1225
|
+
* 3. Is ATOMIC: either all endpoints sync successfully, or none do
|
|
1226
|
+
*
|
|
1227
|
+
* Important Notes:
|
|
1228
|
+
* - Organization endpoints are NOT affected
|
|
1229
|
+
* - Stars on existing endpoints will be lost (reset to 0)
|
|
1230
|
+
* - Endpoint IDs will change (new IDs assigned)
|
|
1231
|
+
* - Maximum 100 endpoints per sync request
|
|
1232
|
+
*
|
|
1233
|
+
* @param endpoints - List of endpoint specifications to sync.
|
|
1234
|
+
* Pass an empty array to delete ALL user endpoints.
|
|
1235
|
+
* @returns SyncEndpointsResponse with synced count, deleted count, and created endpoints
|
|
1236
|
+
* @throws {AuthenticationError} If not authenticated
|
|
1237
|
+
* @throws {ValidationError} If any endpoint fails validation (entire batch rejected)
|
|
1238
|
+
*
|
|
1239
|
+
* @example
|
|
1240
|
+
* // Sync with new endpoints
|
|
1241
|
+
* const result = await client.myEndpoints.sync([
|
|
1242
|
+
* { name: 'Model A', type: 'model', visibility: 'public' },
|
|
1243
|
+
* { name: 'Data Source B', type: 'data_source', visibility: 'private' },
|
|
1244
|
+
* ]);
|
|
1245
|
+
* console.log(`Deleted ${result.deleted}, created ${result.synced} endpoints`);
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* // Clear all endpoints
|
|
1249
|
+
* const result = await client.myEndpoints.sync([]);
|
|
1250
|
+
* console.log(`Deleted ${result.deleted} endpoints`);
|
|
1251
|
+
*/
|
|
1252
|
+
sync(endpoints?: EndpointCreateInput[]): Promise<SyncEndpointsResponse>;
|
|
1170
1253
|
}
|
|
1171
1254
|
|
|
1172
1255
|
/**
|
|
@@ -1203,6 +1286,13 @@ interface TrendingOptions {
|
|
|
1203
1286
|
* }
|
|
1204
1287
|
*
|
|
1205
1288
|
* @example
|
|
1289
|
+
* // Semantic search for endpoints
|
|
1290
|
+
* const results = await client.hub.search('machine learning for images');
|
|
1291
|
+
* for (const result of results) {
|
|
1292
|
+
* console.log(`${result.ownerUsername}/${result.slug}: ${result.relevanceScore.toFixed(2)}`);
|
|
1293
|
+
* }
|
|
1294
|
+
*
|
|
1295
|
+
* @example
|
|
1206
1296
|
* // Get a specific endpoint
|
|
1207
1297
|
* const endpoint = await client.hub.get('alice/cool-api');
|
|
1208
1298
|
* console.log(endpoint.readme);
|
|
@@ -1248,6 +1338,35 @@ declare class HubResource {
|
|
|
1248
1338
|
* @returns PageIterator that lazily fetches endpoints
|
|
1249
1339
|
*/
|
|
1250
1340
|
trending(options?: TrendingOptions): PageIterator<EndpointPublic>;
|
|
1341
|
+
/**
|
|
1342
|
+
* Search for endpoints using semantic search.
|
|
1343
|
+
*
|
|
1344
|
+
* Uses RAG-powered semantic search to find endpoints that match the
|
|
1345
|
+
* natural language query. Returns results sorted by relevance score.
|
|
1346
|
+
*
|
|
1347
|
+
* Note: If RAG is not configured on the server (no OpenAI API key),
|
|
1348
|
+
* this method returns an empty array.
|
|
1349
|
+
*
|
|
1350
|
+
* @param query - Natural language search query (e.g., "machine learning models for image classification")
|
|
1351
|
+
* @param options - Search options (topK, type filter, minScore)
|
|
1352
|
+
* @returns Promise resolving to array of EndpointSearchResult with relevance scores.
|
|
1353
|
+
* Returns empty array if query is too short (<3 chars) or no matches found.
|
|
1354
|
+
*
|
|
1355
|
+
* @example
|
|
1356
|
+
* // Search for machine learning models
|
|
1357
|
+
* const results = await client.hub.search('image classification models');
|
|
1358
|
+
* for (const result of results) {
|
|
1359
|
+
* console.log(`${result.ownerUsername}/${result.slug}: ${result.relevanceScore.toFixed(2)}`);
|
|
1360
|
+
* }
|
|
1361
|
+
*
|
|
1362
|
+
* @example
|
|
1363
|
+
* // Filter by type and minimum score
|
|
1364
|
+
* const dataSources = await client.hub.search('customer data', {
|
|
1365
|
+
* type: EndpointType.DATA_SOURCE,
|
|
1366
|
+
* minScore: 0.5,
|
|
1367
|
+
* });
|
|
1368
|
+
*/
|
|
1369
|
+
search(query: string, options?: SearchOptions): Promise<EndpointSearchResult[]>;
|
|
1251
1370
|
/**
|
|
1252
1371
|
* Get an endpoint by its path.
|
|
1253
1372
|
*
|
|
@@ -1968,21 +2087,6 @@ interface SyftHubClientOptions {
|
|
|
1968
2087
|
* Defaults to {baseUrl}/aggregator/api/v1
|
|
1969
2088
|
*/
|
|
1970
2089
|
aggregatorUrl?: string;
|
|
1971
|
-
/**
|
|
1972
|
-
* Base URL for the accounting service (optional).
|
|
1973
|
-
* Falls back to SYFTHUB_ACCOUNTING_URL environment variable.
|
|
1974
|
-
*/
|
|
1975
|
-
accountingUrl?: string;
|
|
1976
|
-
/**
|
|
1977
|
-
* Email for accounting service authentication (optional).
|
|
1978
|
-
* Falls back to SYFTHUB_ACCOUNTING_EMAIL environment variable.
|
|
1979
|
-
*/
|
|
1980
|
-
accountingEmail?: string;
|
|
1981
|
-
/**
|
|
1982
|
-
* Password for accounting service authentication (optional).
|
|
1983
|
-
* Falls back to SYFTHUB_ACCOUNTING_PASSWORD environment variable.
|
|
1984
|
-
*/
|
|
1985
|
-
accountingPassword?: string;
|
|
1986
2090
|
}
|
|
1987
2091
|
/**
|
|
1988
2092
|
* SyftHub SDK client for interacting with the SyftHub API.
|
|
@@ -2036,6 +2140,7 @@ declare class SyftHubClient {
|
|
|
2036
2140
|
private _myEndpoints?;
|
|
2037
2141
|
private _hub?;
|
|
2038
2142
|
private _accounting?;
|
|
2143
|
+
private _accountingInitPromise;
|
|
2039
2144
|
private _chat?;
|
|
2040
2145
|
private _syftai?;
|
|
2041
2146
|
/**
|
|
@@ -2084,23 +2189,43 @@ declare class SyftHubClient {
|
|
|
2084
2189
|
* The accounting service is external and uses separate credentials
|
|
2085
2190
|
* (email/password Basic auth) from SyftHub's JWT authentication.
|
|
2086
2191
|
*
|
|
2087
|
-
* Credentials
|
|
2088
|
-
*
|
|
2089
|
-
* - Environment variables: SYFTHUB_ACCOUNTING_URL, SYFTHUB_ACCOUNTING_EMAIL, SYFTHUB_ACCOUNTING_PASSWORD
|
|
2192
|
+
* Credentials are automatically retrieved from the backend after login.
|
|
2193
|
+
* You must call `initAccounting()` after login to initialize this resource.
|
|
2090
2194
|
*
|
|
2091
|
-
* @throws {
|
|
2195
|
+
* @throws {AuthenticationError} If not initialized
|
|
2092
2196
|
*
|
|
2093
2197
|
* @example
|
|
2094
|
-
*
|
|
2095
|
-
*
|
|
2198
|
+
* // Login first, then initialize accounting
|
|
2199
|
+
* await client.auth.login('alice', 'password');
|
|
2200
|
+
* await client.initAccounting();
|
|
2096
2201
|
*
|
|
2097
|
-
* //
|
|
2098
|
-
* const
|
|
2099
|
-
* recipientEmail: 'bob@example.com',
|
|
2100
|
-
* amount: 10.0
|
|
2101
|
-
* });
|
|
2202
|
+
* // Now accounting is available
|
|
2203
|
+
* const user = await client.accounting.getUser();
|
|
2102
2204
|
*/
|
|
2103
2205
|
get accounting(): AccountingResource;
|
|
2206
|
+
/**
|
|
2207
|
+
* Initialize accounting resource by fetching credentials from the backend.
|
|
2208
|
+
*
|
|
2209
|
+
* This method retrieves accounting credentials from the SyftHub backend
|
|
2210
|
+
* and initializes the accounting resource. Requires authentication.
|
|
2211
|
+
*
|
|
2212
|
+
* @returns The initialized AccountingResource
|
|
2213
|
+
* @throws {AuthenticationError} If not authenticated
|
|
2214
|
+
* @throws {ConfigurationError} If user has no accounting service configured
|
|
2215
|
+
*
|
|
2216
|
+
* @example
|
|
2217
|
+
* // Login first, then initialize accounting
|
|
2218
|
+
* await client.auth.login('alice', 'password');
|
|
2219
|
+
* await client.initAccounting();
|
|
2220
|
+
*
|
|
2221
|
+
* // Now accounting is available
|
|
2222
|
+
* const user = await client.accounting.getUser();
|
|
2223
|
+
*/
|
|
2224
|
+
initAccounting(): Promise<AccountingResource>;
|
|
2225
|
+
/**
|
|
2226
|
+
* Internal method to perform accounting initialization.
|
|
2227
|
+
*/
|
|
2228
|
+
private _doInitAccounting;
|
|
2104
2229
|
/**
|
|
2105
2230
|
* Chat resource for RAG-augmented conversations via the Aggregator.
|
|
2106
2231
|
*
|
|
@@ -2188,19 +2313,19 @@ declare class SyftHubClient {
|
|
|
2188
2313
|
*/
|
|
2189
2314
|
get isAuthenticated(): boolean;
|
|
2190
2315
|
/**
|
|
2191
|
-
* Check if accounting
|
|
2316
|
+
* Check if accounting has been initialized.
|
|
2192
2317
|
*
|
|
2193
|
-
* Use this to check if accounting
|
|
2194
|
-
*
|
|
2318
|
+
* Use this to check if accounting is available before accessing
|
|
2319
|
+
* the `accounting` property, which will throw if not initialized.
|
|
2195
2320
|
*
|
|
2196
|
-
* @returns True if accounting
|
|
2321
|
+
* @returns True if accounting has been initialized via `initAccounting()`
|
|
2197
2322
|
*
|
|
2198
2323
|
* @example
|
|
2199
|
-
* if (client.
|
|
2324
|
+
* if (client.isAccountingInitialized) {
|
|
2200
2325
|
* const user = await client.accounting.getUser();
|
|
2201
2326
|
* }
|
|
2202
2327
|
*/
|
|
2203
|
-
get
|
|
2328
|
+
get isAccountingInitialized(): boolean;
|
|
2204
2329
|
/**
|
|
2205
2330
|
* Close the client and clean up resources.
|
|
2206
2331
|
*
|
|
@@ -2209,4 +2334,4 @@ declare class SyftHubClient {
|
|
|
2209
2334
|
close(): void;
|
|
2210
2335
|
}
|
|
2211
2336
|
|
|
2212
|
-
export { APIError, AccountingAccountExistsError, type AccountingCredentials, AccountingResource, type AccountingResourceOptions, AccountingServiceUnavailableError, type AccountingUser, AggregatorError, type AuthTokens, AuthenticationError, AuthorizationError, type BrowseOptions, type ChatMetadata, type ChatOptions, ChatResource, type ChatResponse, type ChatStreamEvent, ConfigurationError, type Connection, type CreateDelegatedTransactionInput, type CreateTransactionInput, CreatorType, type Document, type DoneEvent, type Endpoint, type EndpointCreateInput, type EndpointPublic, type EndpointRef, EndpointResolutionError, EndpointType, type EndpointUpdateInput, type ErrorEvent, GenerationError, type GenerationStartEvent, InvalidAccountingPasswordError, type ListEndpointsOptions, type Message, NetworkError, NotFoundError, OrganizationRole, type PageFetcher, PageIterator, type PasswordChangeInput, type Policy, type QueryDataSourceOptions, type QueryModelOptions, type RetrievalCompleteEvent, RetrievalError, type RetrievalStartEvent, type SourceCompleteEvent, type SourceInfo, type SourceStatus, SyftAIResource, SyftHubClient, type SyftHubClientOptions, SyftHubError, type TokenEvent, type Transaction, type TransactionResponse, TransactionStatus, type TransactionTokenResponse, type TransactionsOptions, type TrendingOptions, type UpdatePasswordInput, type User, UserAlreadyExistsError, type UserRegisterInput, UserRole, type UserUpdateInput, ValidationError, Visibility, createAccountingResource, getEndpointOwnerType, getEndpointPublicPath, isTransactionCancelled, isTransactionCompleted, isTransactionPending, parseTransaction };
|
|
2337
|
+
export { APIError, AccountingAccountExistsError, type AccountingCredentials, AccountingResource, type AccountingResourceOptions, AccountingServiceUnavailableError, type AccountingUser, AggregatorError, type AuthTokens, AuthenticationError, AuthorizationError, type BrowseOptions, type ChatMetadata, type ChatOptions, ChatResource, type ChatResponse, type ChatStreamEvent, ConfigurationError, type Connection, type CreateDelegatedTransactionInput, type CreateTransactionInput, CreatorType, type Document, type DoneEvent, type Endpoint, type EndpointCreateInput, type EndpointPublic, type EndpointRef, EndpointResolutionError, EndpointType, type EndpointUpdateInput, type ErrorEvent, GenerationError, type GenerationStartEvent, InvalidAccountingPasswordError, type ListEndpointsOptions, type Message, NetworkError, NotFoundError, OrganizationRole, type PageFetcher, PageIterator, type PasswordChangeInput, type Policy, type QueryDataSourceOptions, type QueryModelOptions, type RetrievalCompleteEvent, RetrievalError, type RetrievalStartEvent, type SourceCompleteEvent, type SourceInfo, type SourceStatus, SyftAIResource, SyftHubClient, type SyftHubClientOptions, SyftHubError, type SyncEndpointsResponse, type TokenEvent, type Transaction, type TransactionResponse, TransactionStatus, type TransactionTokenResponse, type TransactionsOptions, type TrendingOptions, type UpdatePasswordInput, type User, UserAlreadyExistsError, type UserRegisterInput, UserRole, type UserUpdateInput, ValidationError, Visibility, createAccountingResource, getEndpointOwnerType, getEndpointPublicPath, isTransactionCancelled, isTransactionCompleted, isTransactionPending, parseTransaction };
|
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,8 @@ interface User {
|
|
|
170
170
|
readonly updatedAt: Date | null;
|
|
171
171
|
/** Domain for endpoint URL construction (e.g., "api.example.com" or "api.example.com:8080") */
|
|
172
172
|
readonly domain: string | null;
|
|
173
|
+
/** Custom aggregator URL for RAG/chat workflows */
|
|
174
|
+
readonly aggregatorUrl: string | null;
|
|
173
175
|
}
|
|
174
176
|
/**
|
|
175
177
|
* Input for user registration.
|
|
@@ -204,6 +206,8 @@ interface UserUpdateInput {
|
|
|
204
206
|
avatarUrl?: string;
|
|
205
207
|
/** Domain for endpoint URL construction (no protocol, e.g., "api.example.com:8080") */
|
|
206
208
|
domain?: string;
|
|
209
|
+
/** Custom aggregator URL for RAG/chat workflows */
|
|
210
|
+
aggregatorUrl?: string;
|
|
207
211
|
}
|
|
208
212
|
/**
|
|
209
213
|
* Input for changing password.
|
|
@@ -287,6 +291,42 @@ interface EndpointPublic {
|
|
|
287
291
|
readonly createdAt: Date;
|
|
288
292
|
readonly updatedAt: Date;
|
|
289
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Search result with relevance score from semantic search.
|
|
296
|
+
*
|
|
297
|
+
* Extends the public endpoint fields with a relevance score indicating
|
|
298
|
+
* how well the endpoint matches the search query.
|
|
299
|
+
*/
|
|
300
|
+
interface EndpointSearchResult {
|
|
301
|
+
readonly name: string;
|
|
302
|
+
readonly slug: string;
|
|
303
|
+
readonly description: string;
|
|
304
|
+
readonly type: EndpointType;
|
|
305
|
+
readonly ownerUsername: string;
|
|
306
|
+
/** Number of contributors (user IDs not exposed for privacy) */
|
|
307
|
+
readonly contributorsCount: number;
|
|
308
|
+
readonly version: string;
|
|
309
|
+
readonly readme: string;
|
|
310
|
+
readonly tags: readonly string[];
|
|
311
|
+
readonly starsCount: number;
|
|
312
|
+
readonly policies: readonly Policy[];
|
|
313
|
+
readonly connect: readonly Connection[];
|
|
314
|
+
readonly createdAt: Date;
|
|
315
|
+
readonly updatedAt: Date;
|
|
316
|
+
/** Relevance score from semantic search (0.0-1.0) */
|
|
317
|
+
readonly relevanceScore: number;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Options for semantic search.
|
|
321
|
+
*/
|
|
322
|
+
interface SearchOptions {
|
|
323
|
+
/** Maximum number of results to return (default: 10) */
|
|
324
|
+
topK?: number;
|
|
325
|
+
/** Filter by endpoint type */
|
|
326
|
+
type?: EndpointType;
|
|
327
|
+
/** Minimum relevance score threshold (0.0-1.0, default: 0.0) */
|
|
328
|
+
minScore?: number;
|
|
329
|
+
}
|
|
290
330
|
/**
|
|
291
331
|
* Input for creating a new endpoint.
|
|
292
332
|
*/
|
|
@@ -331,6 +371,20 @@ declare function getEndpointOwnerType(endpoint: Endpoint): 'user' | 'organizatio
|
|
|
331
371
|
* @returns The path in "owner/slug" format
|
|
332
372
|
*/
|
|
333
373
|
declare function getEndpointPublicPath(endpoint: EndpointPublic): string;
|
|
374
|
+
/**
|
|
375
|
+
* Response from the sync endpoints operation.
|
|
376
|
+
*
|
|
377
|
+
* Contains details about the sync operation including how many endpoints
|
|
378
|
+
* were deleted, how many were created, and the full list of created endpoints.
|
|
379
|
+
*/
|
|
380
|
+
interface SyncEndpointsResponse {
|
|
381
|
+
/** Number of endpoints created */
|
|
382
|
+
readonly synced: number;
|
|
383
|
+
/** Number of endpoints deleted */
|
|
384
|
+
readonly deleted: number;
|
|
385
|
+
/** List of created endpoints with full details */
|
|
386
|
+
readonly endpoints: readonly Endpoint[];
|
|
387
|
+
}
|
|
334
388
|
|
|
335
389
|
/**
|
|
336
390
|
* Accounting Models
|
|
@@ -609,6 +663,8 @@ interface ChatOptions {
|
|
|
609
663
|
similarityThreshold?: number;
|
|
610
664
|
/** AbortSignal for request cancellation */
|
|
611
665
|
signal?: AbortSignal;
|
|
666
|
+
/** Custom aggregator URL to use instead of the default */
|
|
667
|
+
aggregatorUrl?: string;
|
|
612
668
|
}
|
|
613
669
|
/**
|
|
614
670
|
* Options for querying a data source directly.
|
|
@@ -1110,13 +1166,6 @@ declare class MyEndpointsResource {
|
|
|
1110
1166
|
* @throws {Error} If path format is invalid
|
|
1111
1167
|
*/
|
|
1112
1168
|
private parsePath;
|
|
1113
|
-
/**
|
|
1114
|
-
* Resolve an endpoint path to its ID.
|
|
1115
|
-
*
|
|
1116
|
-
* @param path - Endpoint path in "owner/slug" format
|
|
1117
|
-
* @returns The endpoint ID
|
|
1118
|
-
*/
|
|
1119
|
-
private resolveEndpointId;
|
|
1120
1169
|
/**
|
|
1121
1170
|
* List the current user's endpoints.
|
|
1122
1171
|
*
|
|
@@ -1167,6 +1216,40 @@ declare class MyEndpointsResource {
|
|
|
1167
1216
|
* @throws {AuthorizationError} If not owner/admin
|
|
1168
1217
|
*/
|
|
1169
1218
|
delete(path: string): Promise<void>;
|
|
1219
|
+
/**
|
|
1220
|
+
* Synchronize user's endpoints with provided list.
|
|
1221
|
+
*
|
|
1222
|
+
* This is a DESTRUCTIVE operation that:
|
|
1223
|
+
* 1. Deletes ALL existing endpoints owned by the current user
|
|
1224
|
+
* 2. Creates ALL endpoints from the provided list
|
|
1225
|
+
* 3. Is ATOMIC: either all endpoints sync successfully, or none do
|
|
1226
|
+
*
|
|
1227
|
+
* Important Notes:
|
|
1228
|
+
* - Organization endpoints are NOT affected
|
|
1229
|
+
* - Stars on existing endpoints will be lost (reset to 0)
|
|
1230
|
+
* - Endpoint IDs will change (new IDs assigned)
|
|
1231
|
+
* - Maximum 100 endpoints per sync request
|
|
1232
|
+
*
|
|
1233
|
+
* @param endpoints - List of endpoint specifications to sync.
|
|
1234
|
+
* Pass an empty array to delete ALL user endpoints.
|
|
1235
|
+
* @returns SyncEndpointsResponse with synced count, deleted count, and created endpoints
|
|
1236
|
+
* @throws {AuthenticationError} If not authenticated
|
|
1237
|
+
* @throws {ValidationError} If any endpoint fails validation (entire batch rejected)
|
|
1238
|
+
*
|
|
1239
|
+
* @example
|
|
1240
|
+
* // Sync with new endpoints
|
|
1241
|
+
* const result = await client.myEndpoints.sync([
|
|
1242
|
+
* { name: 'Model A', type: 'model', visibility: 'public' },
|
|
1243
|
+
* { name: 'Data Source B', type: 'data_source', visibility: 'private' },
|
|
1244
|
+
* ]);
|
|
1245
|
+
* console.log(`Deleted ${result.deleted}, created ${result.synced} endpoints`);
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* // Clear all endpoints
|
|
1249
|
+
* const result = await client.myEndpoints.sync([]);
|
|
1250
|
+
* console.log(`Deleted ${result.deleted} endpoints`);
|
|
1251
|
+
*/
|
|
1252
|
+
sync(endpoints?: EndpointCreateInput[]): Promise<SyncEndpointsResponse>;
|
|
1170
1253
|
}
|
|
1171
1254
|
|
|
1172
1255
|
/**
|
|
@@ -1203,6 +1286,13 @@ interface TrendingOptions {
|
|
|
1203
1286
|
* }
|
|
1204
1287
|
*
|
|
1205
1288
|
* @example
|
|
1289
|
+
* // Semantic search for endpoints
|
|
1290
|
+
* const results = await client.hub.search('machine learning for images');
|
|
1291
|
+
* for (const result of results) {
|
|
1292
|
+
* console.log(`${result.ownerUsername}/${result.slug}: ${result.relevanceScore.toFixed(2)}`);
|
|
1293
|
+
* }
|
|
1294
|
+
*
|
|
1295
|
+
* @example
|
|
1206
1296
|
* // Get a specific endpoint
|
|
1207
1297
|
* const endpoint = await client.hub.get('alice/cool-api');
|
|
1208
1298
|
* console.log(endpoint.readme);
|
|
@@ -1248,6 +1338,35 @@ declare class HubResource {
|
|
|
1248
1338
|
* @returns PageIterator that lazily fetches endpoints
|
|
1249
1339
|
*/
|
|
1250
1340
|
trending(options?: TrendingOptions): PageIterator<EndpointPublic>;
|
|
1341
|
+
/**
|
|
1342
|
+
* Search for endpoints using semantic search.
|
|
1343
|
+
*
|
|
1344
|
+
* Uses RAG-powered semantic search to find endpoints that match the
|
|
1345
|
+
* natural language query. Returns results sorted by relevance score.
|
|
1346
|
+
*
|
|
1347
|
+
* Note: If RAG is not configured on the server (no OpenAI API key),
|
|
1348
|
+
* this method returns an empty array.
|
|
1349
|
+
*
|
|
1350
|
+
* @param query - Natural language search query (e.g., "machine learning models for image classification")
|
|
1351
|
+
* @param options - Search options (topK, type filter, minScore)
|
|
1352
|
+
* @returns Promise resolving to array of EndpointSearchResult with relevance scores.
|
|
1353
|
+
* Returns empty array if query is too short (<3 chars) or no matches found.
|
|
1354
|
+
*
|
|
1355
|
+
* @example
|
|
1356
|
+
* // Search for machine learning models
|
|
1357
|
+
* const results = await client.hub.search('image classification models');
|
|
1358
|
+
* for (const result of results) {
|
|
1359
|
+
* console.log(`${result.ownerUsername}/${result.slug}: ${result.relevanceScore.toFixed(2)}`);
|
|
1360
|
+
* }
|
|
1361
|
+
*
|
|
1362
|
+
* @example
|
|
1363
|
+
* // Filter by type and minimum score
|
|
1364
|
+
* const dataSources = await client.hub.search('customer data', {
|
|
1365
|
+
* type: EndpointType.DATA_SOURCE,
|
|
1366
|
+
* minScore: 0.5,
|
|
1367
|
+
* });
|
|
1368
|
+
*/
|
|
1369
|
+
search(query: string, options?: SearchOptions): Promise<EndpointSearchResult[]>;
|
|
1251
1370
|
/**
|
|
1252
1371
|
* Get an endpoint by its path.
|
|
1253
1372
|
*
|
|
@@ -1968,21 +2087,6 @@ interface SyftHubClientOptions {
|
|
|
1968
2087
|
* Defaults to {baseUrl}/aggregator/api/v1
|
|
1969
2088
|
*/
|
|
1970
2089
|
aggregatorUrl?: string;
|
|
1971
|
-
/**
|
|
1972
|
-
* Base URL for the accounting service (optional).
|
|
1973
|
-
* Falls back to SYFTHUB_ACCOUNTING_URL environment variable.
|
|
1974
|
-
*/
|
|
1975
|
-
accountingUrl?: string;
|
|
1976
|
-
/**
|
|
1977
|
-
* Email for accounting service authentication (optional).
|
|
1978
|
-
* Falls back to SYFTHUB_ACCOUNTING_EMAIL environment variable.
|
|
1979
|
-
*/
|
|
1980
|
-
accountingEmail?: string;
|
|
1981
|
-
/**
|
|
1982
|
-
* Password for accounting service authentication (optional).
|
|
1983
|
-
* Falls back to SYFTHUB_ACCOUNTING_PASSWORD environment variable.
|
|
1984
|
-
*/
|
|
1985
|
-
accountingPassword?: string;
|
|
1986
2090
|
}
|
|
1987
2091
|
/**
|
|
1988
2092
|
* SyftHub SDK client for interacting with the SyftHub API.
|
|
@@ -2036,6 +2140,7 @@ declare class SyftHubClient {
|
|
|
2036
2140
|
private _myEndpoints?;
|
|
2037
2141
|
private _hub?;
|
|
2038
2142
|
private _accounting?;
|
|
2143
|
+
private _accountingInitPromise;
|
|
2039
2144
|
private _chat?;
|
|
2040
2145
|
private _syftai?;
|
|
2041
2146
|
/**
|
|
@@ -2084,23 +2189,43 @@ declare class SyftHubClient {
|
|
|
2084
2189
|
* The accounting service is external and uses separate credentials
|
|
2085
2190
|
* (email/password Basic auth) from SyftHub's JWT authentication.
|
|
2086
2191
|
*
|
|
2087
|
-
* Credentials
|
|
2088
|
-
*
|
|
2089
|
-
* - Environment variables: SYFTHUB_ACCOUNTING_URL, SYFTHUB_ACCOUNTING_EMAIL, SYFTHUB_ACCOUNTING_PASSWORD
|
|
2192
|
+
* Credentials are automatically retrieved from the backend after login.
|
|
2193
|
+
* You must call `initAccounting()` after login to initialize this resource.
|
|
2090
2194
|
*
|
|
2091
|
-
* @throws {
|
|
2195
|
+
* @throws {AuthenticationError} If not initialized
|
|
2092
2196
|
*
|
|
2093
2197
|
* @example
|
|
2094
|
-
*
|
|
2095
|
-
*
|
|
2198
|
+
* // Login first, then initialize accounting
|
|
2199
|
+
* await client.auth.login('alice', 'password');
|
|
2200
|
+
* await client.initAccounting();
|
|
2096
2201
|
*
|
|
2097
|
-
* //
|
|
2098
|
-
* const
|
|
2099
|
-
* recipientEmail: 'bob@example.com',
|
|
2100
|
-
* amount: 10.0
|
|
2101
|
-
* });
|
|
2202
|
+
* // Now accounting is available
|
|
2203
|
+
* const user = await client.accounting.getUser();
|
|
2102
2204
|
*/
|
|
2103
2205
|
get accounting(): AccountingResource;
|
|
2206
|
+
/**
|
|
2207
|
+
* Initialize accounting resource by fetching credentials from the backend.
|
|
2208
|
+
*
|
|
2209
|
+
* This method retrieves accounting credentials from the SyftHub backend
|
|
2210
|
+
* and initializes the accounting resource. Requires authentication.
|
|
2211
|
+
*
|
|
2212
|
+
* @returns The initialized AccountingResource
|
|
2213
|
+
* @throws {AuthenticationError} If not authenticated
|
|
2214
|
+
* @throws {ConfigurationError} If user has no accounting service configured
|
|
2215
|
+
*
|
|
2216
|
+
* @example
|
|
2217
|
+
* // Login first, then initialize accounting
|
|
2218
|
+
* await client.auth.login('alice', 'password');
|
|
2219
|
+
* await client.initAccounting();
|
|
2220
|
+
*
|
|
2221
|
+
* // Now accounting is available
|
|
2222
|
+
* const user = await client.accounting.getUser();
|
|
2223
|
+
*/
|
|
2224
|
+
initAccounting(): Promise<AccountingResource>;
|
|
2225
|
+
/**
|
|
2226
|
+
* Internal method to perform accounting initialization.
|
|
2227
|
+
*/
|
|
2228
|
+
private _doInitAccounting;
|
|
2104
2229
|
/**
|
|
2105
2230
|
* Chat resource for RAG-augmented conversations via the Aggregator.
|
|
2106
2231
|
*
|
|
@@ -2188,19 +2313,19 @@ declare class SyftHubClient {
|
|
|
2188
2313
|
*/
|
|
2189
2314
|
get isAuthenticated(): boolean;
|
|
2190
2315
|
/**
|
|
2191
|
-
* Check if accounting
|
|
2316
|
+
* Check if accounting has been initialized.
|
|
2192
2317
|
*
|
|
2193
|
-
* Use this to check if accounting
|
|
2194
|
-
*
|
|
2318
|
+
* Use this to check if accounting is available before accessing
|
|
2319
|
+
* the `accounting` property, which will throw if not initialized.
|
|
2195
2320
|
*
|
|
2196
|
-
* @returns True if accounting
|
|
2321
|
+
* @returns True if accounting has been initialized via `initAccounting()`
|
|
2197
2322
|
*
|
|
2198
2323
|
* @example
|
|
2199
|
-
* if (client.
|
|
2324
|
+
* if (client.isAccountingInitialized) {
|
|
2200
2325
|
* const user = await client.accounting.getUser();
|
|
2201
2326
|
* }
|
|
2202
2327
|
*/
|
|
2203
|
-
get
|
|
2328
|
+
get isAccountingInitialized(): boolean;
|
|
2204
2329
|
/**
|
|
2205
2330
|
* Close the client and clean up resources.
|
|
2206
2331
|
*
|
|
@@ -2209,4 +2334,4 @@ declare class SyftHubClient {
|
|
|
2209
2334
|
close(): void;
|
|
2210
2335
|
}
|
|
2211
2336
|
|
|
2212
|
-
export { APIError, AccountingAccountExistsError, type AccountingCredentials, AccountingResource, type AccountingResourceOptions, AccountingServiceUnavailableError, type AccountingUser, AggregatorError, type AuthTokens, AuthenticationError, AuthorizationError, type BrowseOptions, type ChatMetadata, type ChatOptions, ChatResource, type ChatResponse, type ChatStreamEvent, ConfigurationError, type Connection, type CreateDelegatedTransactionInput, type CreateTransactionInput, CreatorType, type Document, type DoneEvent, type Endpoint, type EndpointCreateInput, type EndpointPublic, type EndpointRef, EndpointResolutionError, EndpointType, type EndpointUpdateInput, type ErrorEvent, GenerationError, type GenerationStartEvent, InvalidAccountingPasswordError, type ListEndpointsOptions, type Message, NetworkError, NotFoundError, OrganizationRole, type PageFetcher, PageIterator, type PasswordChangeInput, type Policy, type QueryDataSourceOptions, type QueryModelOptions, type RetrievalCompleteEvent, RetrievalError, type RetrievalStartEvent, type SourceCompleteEvent, type SourceInfo, type SourceStatus, SyftAIResource, SyftHubClient, type SyftHubClientOptions, SyftHubError, type TokenEvent, type Transaction, type TransactionResponse, TransactionStatus, type TransactionTokenResponse, type TransactionsOptions, type TrendingOptions, type UpdatePasswordInput, type User, UserAlreadyExistsError, type UserRegisterInput, UserRole, type UserUpdateInput, ValidationError, Visibility, createAccountingResource, getEndpointOwnerType, getEndpointPublicPath, isTransactionCancelled, isTransactionCompleted, isTransactionPending, parseTransaction };
|
|
2337
|
+
export { APIError, AccountingAccountExistsError, type AccountingCredentials, AccountingResource, type AccountingResourceOptions, AccountingServiceUnavailableError, type AccountingUser, AggregatorError, type AuthTokens, AuthenticationError, AuthorizationError, type BrowseOptions, type ChatMetadata, type ChatOptions, ChatResource, type ChatResponse, type ChatStreamEvent, ConfigurationError, type Connection, type CreateDelegatedTransactionInput, type CreateTransactionInput, CreatorType, type Document, type DoneEvent, type Endpoint, type EndpointCreateInput, type EndpointPublic, type EndpointRef, EndpointResolutionError, EndpointType, type EndpointUpdateInput, type ErrorEvent, GenerationError, type GenerationStartEvent, InvalidAccountingPasswordError, type ListEndpointsOptions, type Message, NetworkError, NotFoundError, OrganizationRole, type PageFetcher, PageIterator, type PasswordChangeInput, type Policy, type QueryDataSourceOptions, type QueryModelOptions, type RetrievalCompleteEvent, RetrievalError, type RetrievalStartEvent, type SourceCompleteEvent, type SourceInfo, type SourceStatus, SyftAIResource, SyftHubClient, type SyftHubClientOptions, SyftHubError, type SyncEndpointsResponse, type TokenEvent, type Transaction, type TransactionResponse, TransactionStatus, type TransactionTokenResponse, type TransactionsOptions, type TrendingOptions, type UpdatePasswordInput, type User, UserAlreadyExistsError, type UserRegisterInput, UserRole, type UserUpdateInput, ValidationError, Visibility, createAccountingResource, getEndpointOwnerType, getEndpointPublicPath, isTransactionCancelled, isTransactionCompleted, isTransactionPending, parseTransaction };
|