@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/index.d.ts CHANGED
@@ -283,34 +283,48 @@ declare class AuthenticationError extends Error {
283
283
  }
284
284
 
285
285
  /**
286
- * Main client class for interacting with the Axiom Lattice Agent Service API
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 Client {
289
- private config;
290
- private assistantId;
291
- private tenantId;
292
- private registeredTools;
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 Client instance
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
- * Helper method to handle fetch responses and errors
301
- * @private
300
+ * Set tenant ID for multi-tenant environments
301
+ * @param tenantId - Tenant identifier
302
302
  */
303
- private handleResponse;
303
+ abstract setTenantId(tenantId: string): void;
304
304
  /**
305
- * Helper method to make fetch requests
306
- * @private
305
+ * Abstract method for making API requests
306
+ * To be implemented by concrete client classes
307
307
  */
308
- private fetchWithTimeout;
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
- * Set tenant ID for multi-tenant environments
311
- * @param tenantId - Tenant identifier
314
+ * Abstract method for streaming API requests
315
+ * To be implemented by concrete client classes
312
316
  */
313
- setTenantId(tenantId: string): void;
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
- * WeChat Mini Program client for interacting with the Axiom Lattice Agent Service API
413
+ * Web client class for interacting with the Axiom Lattice Agent Service API
409
414
  */
410
- declare class WeChatClient {
411
- private config;
412
- private assistantId;
413
- private tenantId;
414
- private registeredTools;
415
+ declare class Client extends AbstractClient {
416
+ private headers;
415
417
  /**
416
- * Creates a new WeChatClient instance
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
- * Set tenant ID for multi-tenant environments
422
- * @param tenantId - Tenant identifier
423
+ * Helper method to handle fetch responses and errors
424
+ * @private
423
425
  */
424
- setTenantId(tenantId: string): void;
426
+ private handleResponse;
425
427
  /**
426
- * Helper method to make WeChat HTTP requests
428
+ * Helper method to make fetch requests
427
429
  * @private
428
430
  */
429
- private request;
431
+ private fetchWithTimeout;
430
432
  /**
431
- * Creates a new thread
432
- * @param options - Options for creating a thread
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
- createThread(options: CreateThreadOptions): Promise<string>;
436
+ setTenantId(tenantId: string): void;
436
437
  /**
437
- * Retrieves thread information
438
- * @param threadId - Thread identifier
439
- * @returns A promise that resolves to the thread information
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
- getThread(threadId: string): Promise<Thread>;
443
+ protected makeRequest<T>(url: string, options?: {
444
+ method?: string;
445
+ body?: any;
446
+ headers?: Record<string, string>;
447
+ }): Promise<T>;
442
448
  /**
443
- * Lists all threads
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
- listThreads(options?: ListThreadsOptions): Promise<Thread[]>;
451
+ protected streamRequest(options: RunOptions, onEvent: (event: MessageChunk) => void, onComplete?: (state?: AgentState) => void, onError?: (error: Error) => void): () => void;
448
452
  /**
449
- * Deletes a thread
450
- * @param threadId - Thread identifier
451
- * @returns A promise that resolves when the thread is deleted
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
- deleteThread(threadId: string): Promise<void>;
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
- * Retrieves messages from a thread
456
- * @param options - Options for retrieving messages
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
- getMessages(options: GetMessagesOptions): Promise<Message[]>;
471
+ constructor(config: ClientConfig);
460
472
  /**
461
- * Retrieves agent state
462
- * @param threadId - Thread identifier
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
- getAgentState(threadId: string): Promise<AgentState>;
476
+ setTenantId(tenantId: string): void;
466
477
  /**
467
- * Gets agent graph visualization
468
- * @returns A promise that resolves to the graph visualization data
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
- getAgentGraph(): Promise<string>;
483
+ protected makeRequest<T>(url: string, options?: {
484
+ method?: string;
485
+ body?: any;
486
+ headers?: Record<string, string>;
487
+ }): Promise<T>;
471
488
  /**
472
- * Run agent with options
473
- * @param options - Options for running the agent
474
- * @returns A promise that resolves to the run result
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
- run(options: RunOptions): Promise<any>;
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
- * Chat namespace for sending messages and streaming responses
488
- */
489
- chat: {
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
- tools: {
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"}