@axiom-lattice/client-sdk 1.0.43 → 1.0.44
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/ChunkMessageMerger.d.ts +18 -0
- package/dist/ChunkMessageMerger.d.ts.map +1 -0
- package/dist/ChunkMessageMerger.js +264 -0
- package/dist/ChunkMessageMerger.js.map +1 -0
- package/dist/abstract-client.d.ts +129 -0
- package/dist/abstract-client.d.ts.map +1 -0
- package/dist/abstract-client.js +279 -0
- package/dist/abstract-client.js.map +1 -0
- package/dist/client.d.ts +54 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +224 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +96 -103
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2049 -358
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2061 -358
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +282 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +27 -0
- package/dist/types.js.map +1 -0
- package/dist/wechat-client.d.ts +56 -0
- package/dist/wechat-client.d.ts.map +1 -0
- package/dist/wechat-client.js +226 -0
- package/dist/wechat-client.js.map +1 -0
- package/dist/wechat_lib/encoding-indexes.d.ts +2 -0
- package/dist/wechat_lib/encoding-indexes.d.ts.map +1 -0
- package/dist/wechat_lib/encoding-indexes.js +46 -0
- package/dist/wechat_lib/encoding-indexes.js.map +1 -0
- package/dist/wechat_lib/encoding.d.ts +4 -0
- package/dist/wechat_lib/encoding.d.ts.map +1 -0
- package/dist/wechat_lib/encoding.js +2897 -0
- package/dist/wechat_lib/encoding.js.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -283,34 +283,48 @@ declare class AuthenticationError extends Error {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
|
-
*
|
|
286
|
+
* Abstract client class for interacting with the Axiom Lattice Agent Service API
|
|
287
|
+
* Provides common functionality for different client implementations
|
|
287
288
|
*/
|
|
288
|
-
declare class
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
private headers;
|
|
289
|
+
declare abstract class AbstractClient {
|
|
290
|
+
protected config: ClientConfig;
|
|
291
|
+
protected assistantId: string;
|
|
292
|
+
protected tenantId: string;
|
|
293
|
+
protected registeredTools: Map<string, RegisterToolOptions>;
|
|
294
294
|
/**
|
|
295
|
-
* Creates a new
|
|
295
|
+
* Creates a new AbstractClient instance
|
|
296
296
|
* @param config - Configuration options for the client
|
|
297
297
|
*/
|
|
298
298
|
constructor(config: ClientConfig);
|
|
299
299
|
/**
|
|
300
|
-
*
|
|
301
|
-
* @
|
|
300
|
+
* Set tenant ID for multi-tenant environments
|
|
301
|
+
* @param tenantId - Tenant identifier
|
|
302
302
|
*/
|
|
303
|
-
|
|
303
|
+
abstract setTenantId(tenantId: string): void;
|
|
304
304
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
305
|
+
* Abstract method for making API requests
|
|
306
|
+
* To be implemented by concrete client classes
|
|
307
307
|
*/
|
|
308
|
-
|
|
308
|
+
protected abstract makeRequest<T>(url: string, options?: {
|
|
309
|
+
method?: string;
|
|
310
|
+
body?: any;
|
|
311
|
+
headers?: Record<string, string>;
|
|
312
|
+
}): Promise<T>;
|
|
309
313
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
314
|
+
* Abstract method for streaming API requests
|
|
315
|
+
* To be implemented by concrete client classes
|
|
312
316
|
*/
|
|
313
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Helper method to build stream request parameters
|
|
319
|
+
* @param options - Options for running the agent
|
|
320
|
+
* @returns The formatted request parameters
|
|
321
|
+
*/
|
|
322
|
+
protected buildStreamRequestParams(options: RunOptions): {
|
|
323
|
+
url: string;
|
|
324
|
+
method: string;
|
|
325
|
+
body: any;
|
|
326
|
+
};
|
|
327
|
+
protected abstract streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
|
|
314
328
|
/**
|
|
315
329
|
* Creates a new thread
|
|
316
330
|
* @param options - Options for creating a thread
|
|
@@ -358,15 +372,6 @@ declare class Client {
|
|
|
358
372
|
* @returns A promise that resolves to the run result
|
|
359
373
|
*/
|
|
360
374
|
run(options: RunOptions): Promise<ChatResponse>;
|
|
361
|
-
/**
|
|
362
|
-
* Stream run results
|
|
363
|
-
* @param options - Options for streaming run results
|
|
364
|
-
* @param onEvent - Callback function that receives stream events
|
|
365
|
-
* @param onComplete - Optional callback function called when streaming completes
|
|
366
|
-
* @param onError - Optional callback function called when an error occurs
|
|
367
|
-
* @returns A function that can be called to stop the stream
|
|
368
|
-
*/
|
|
369
|
-
private streamRun;
|
|
370
375
|
/**
|
|
371
376
|
* Chat namespace for sending messages and streaming responses
|
|
372
377
|
*/
|
|
@@ -405,75 +410,90 @@ declare class Client {
|
|
|
405
410
|
}
|
|
406
411
|
|
|
407
412
|
/**
|
|
408
|
-
*
|
|
413
|
+
* Web client class for interacting with the Axiom Lattice Agent Service API
|
|
409
414
|
*/
|
|
410
|
-
declare class
|
|
411
|
-
private
|
|
412
|
-
private assistantId;
|
|
413
|
-
private tenantId;
|
|
414
|
-
private registeredTools;
|
|
415
|
+
declare class Client extends AbstractClient {
|
|
416
|
+
private headers;
|
|
415
417
|
/**
|
|
416
|
-
* Creates a new
|
|
418
|
+
* Creates a new Client instance
|
|
417
419
|
* @param config - Configuration options for the client
|
|
418
420
|
*/
|
|
419
421
|
constructor(config: ClientConfig);
|
|
420
422
|
/**
|
|
421
|
-
*
|
|
422
|
-
* @
|
|
423
|
+
* Helper method to handle fetch responses and errors
|
|
424
|
+
* @private
|
|
423
425
|
*/
|
|
424
|
-
|
|
426
|
+
private handleResponse;
|
|
425
427
|
/**
|
|
426
|
-
* Helper method to make
|
|
428
|
+
* Helper method to make fetch requests
|
|
427
429
|
* @private
|
|
428
430
|
*/
|
|
429
|
-
private
|
|
431
|
+
private fetchWithTimeout;
|
|
430
432
|
/**
|
|
431
|
-
*
|
|
432
|
-
* @param
|
|
433
|
-
* @returns A promise that resolves to the thread ID
|
|
433
|
+
* Set tenant ID for multi-tenant environments
|
|
434
|
+
* @param tenantId - Tenant identifier
|
|
434
435
|
*/
|
|
435
|
-
|
|
436
|
+
setTenantId(tenantId: string): void;
|
|
436
437
|
/**
|
|
437
|
-
*
|
|
438
|
-
* @param
|
|
439
|
-
* @
|
|
438
|
+
* Implementation of the abstract makeRequest method for web clients
|
|
439
|
+
* @param url - The URL to make the request to
|
|
440
|
+
* @param options - Request options
|
|
441
|
+
* @returns A promise that resolves to the response data
|
|
440
442
|
*/
|
|
441
|
-
|
|
443
|
+
protected makeRequest<T>(url: string, options?: {
|
|
444
|
+
method?: string;
|
|
445
|
+
body?: any;
|
|
446
|
+
headers?: Record<string, string>;
|
|
447
|
+
}): Promise<T>;
|
|
442
448
|
/**
|
|
443
|
-
*
|
|
444
|
-
* @param options - Options for listing threads
|
|
445
|
-
* @returns A promise that resolves to an array of threads
|
|
449
|
+
* Implementation of the abstract streamRequest method for web clients
|
|
446
450
|
*/
|
|
447
|
-
|
|
451
|
+
protected streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
|
|
448
452
|
/**
|
|
449
|
-
*
|
|
450
|
-
* @param
|
|
451
|
-
* @
|
|
453
|
+
* Stream run results
|
|
454
|
+
* @param options - Options for streaming run results
|
|
455
|
+
* @param onEvent - Callback function that receives stream events
|
|
456
|
+
* @param onComplete - Optional callback function called when streaming completes
|
|
457
|
+
* @param onError - Optional callback function called when an error occurs
|
|
458
|
+
* @returns A function that can be called to stop the stream
|
|
452
459
|
*/
|
|
453
|
-
|
|
460
|
+
private streamRun;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* WeChat Mini Program client for interacting with the Axiom Lattice Agent Service API
|
|
465
|
+
*/
|
|
466
|
+
declare class WeChatClient extends AbstractClient {
|
|
454
467
|
/**
|
|
455
|
-
*
|
|
456
|
-
* @param
|
|
457
|
-
* @returns A promise that resolves to an array of messages
|
|
468
|
+
* Creates a new WeChatClient instance
|
|
469
|
+
* @param config - Configuration options for the client
|
|
458
470
|
*/
|
|
459
|
-
|
|
471
|
+
constructor(config: ClientConfig);
|
|
460
472
|
/**
|
|
461
|
-
*
|
|
462
|
-
* @param
|
|
463
|
-
* @returns A promise that resolves to the agent state
|
|
473
|
+
* Set tenant ID for multi-tenant environments
|
|
474
|
+
* @param tenantId - Tenant identifier
|
|
464
475
|
*/
|
|
465
|
-
|
|
476
|
+
setTenantId(tenantId: string): void;
|
|
466
477
|
/**
|
|
467
|
-
*
|
|
468
|
-
* @
|
|
478
|
+
* Implementation of the abstract makeRequest method for WeChat clients
|
|
479
|
+
* @param url - The URL to make the request to
|
|
480
|
+
* @param options - Request options
|
|
481
|
+
* @returns A promise that resolves to the response data
|
|
469
482
|
*/
|
|
470
|
-
|
|
483
|
+
protected makeRequest<T>(url: string, options?: {
|
|
484
|
+
method?: string;
|
|
485
|
+
body?: any;
|
|
486
|
+
headers?: Record<string, string>;
|
|
487
|
+
}): Promise<T>;
|
|
471
488
|
/**
|
|
472
|
-
*
|
|
473
|
-
|
|
474
|
-
|
|
489
|
+
* Implementation of the abstract streamRequest method for WeChat clients
|
|
490
|
+
*/
|
|
491
|
+
protected streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
|
|
492
|
+
/**
|
|
493
|
+
* Helper method to make WeChat HTTP requests
|
|
494
|
+
* @private
|
|
475
495
|
*/
|
|
476
|
-
|
|
496
|
+
private request;
|
|
477
497
|
/**
|
|
478
498
|
* Stream run results using WeChat's downloadFile API
|
|
479
499
|
* @param options - Options for streaming run results
|
|
@@ -483,41 +503,14 @@ declare class WeChatClient {
|
|
|
483
503
|
* @returns A function that can be called to stop the stream
|
|
484
504
|
*/
|
|
485
505
|
private streamRun;
|
|
506
|
+
decodeUint8Array(uint8Array: ArrayBuffer): any;
|
|
507
|
+
buf2hex(arrayBuffer: ArrayBuffer): string;
|
|
486
508
|
/**
|
|
487
|
-
*
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Sends a message to a thread and receives a response
|
|
492
|
-
* @param options - Options for sending a message
|
|
493
|
-
* @returns A promise that resolves to the chat response
|
|
494
|
-
*/
|
|
495
|
-
send: (options: ChatSendOptions) => Promise<ChatResponse>;
|
|
496
|
-
/**
|
|
497
|
-
* Sends a message to a thread and streams the response
|
|
498
|
-
* @param options - Options for streaming a message
|
|
499
|
-
* @param onEvent - Callback function that receives stream events
|
|
500
|
-
* @param onComplete - Optional callback function called when streaming completes
|
|
501
|
-
* @param onError - Optional callback function called when an error occurs
|
|
502
|
-
* @returns A function that can be called to stop the stream
|
|
503
|
-
*/
|
|
504
|
-
stream: (options: ChatStreamOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void) => (() => void);
|
|
505
|
-
};
|
|
506
|
-
/**
|
|
507
|
-
* Tools namespace for registering and unregistering client-side tools
|
|
509
|
+
* 十六进制字符串转中文
|
|
510
|
+
* @param {String} hex 为十六进制字符串
|
|
511
|
+
* @return {String} 包含中文的字符串
|
|
508
512
|
*/
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Registers a client-side tool
|
|
512
|
-
* @param options - Options for registering a tool
|
|
513
|
-
*/
|
|
514
|
-
register: (options: RegisterToolOptions) => void;
|
|
515
|
-
/**
|
|
516
|
-
* Unregisters a client-side tool
|
|
517
|
-
* @param name - Tool name
|
|
518
|
-
*/
|
|
519
|
-
unregister: (name: string) => void;
|
|
520
|
-
};
|
|
513
|
+
hexToStr(hex: string): any;
|
|
521
514
|
}
|
|
522
515
|
|
|
523
516
|
/**
|
|
@@ -538,4 +531,4 @@ declare function createSimpleMessageMerger(): {
|
|
|
538
531
|
reset: () => void;
|
|
539
532
|
};
|
|
540
533
|
|
|
541
|
-
export { AgentState, ApiError, AuthenticationError, ChatResponse, ChatSendOptions, ChatStreamOptions, Client, ClientConfig, CreateThreadOptions, GetMessagesOptions, ListThreadsOptions, NetworkError, RegisterToolOptions, RetryConfig, RunOptions, StreamCallbacks, Thread, Transport, WeChatClient, createSimpleMessageMerger };
|
|
534
|
+
export { AbstractClient, AgentState, ApiError, AuthenticationError, ChatResponse, ChatSendOptions, ChatStreamOptions, Client, ClientConfig, CreateThreadOptions, GetMessagesOptions, ListThreadsOptions, NetworkError, RegisterToolOptions, RetryConfig, RunOptions, StreamCallbacks, Thread, Transport, WeChatClient, createSimpleMessageMerger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC"}
|