@redhat-cloud-services/ai-client-common 0.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ## 0.1.0 (2025-07-23)
6
+
7
+
8
+ ### Features
9
+
10
+ * allow additional properties on message response ([c8b4878](https://github.com/Hyperkid123/ai-web-clients/commit/c8b48783e62706f4463f7091805f79a02fab0fab))
11
+ * create common client package ([584467d](https://github.com/Hyperkid123/ai-web-clients/commit/584467d774a45dd8a5f83fce73a8d00766200934))
12
+ * **manager:** initialize conversation from history ([99f46de](https://github.com/Hyperkid123/ai-web-clients/commit/99f46dedbae10c42c6b275ce93364ffeea6b8006))
13
+ * setup simple react arh integration ([456d10a](https://github.com/Hyperkid123/ai-web-clients/commit/456d10a059d8da36c4b3275926b7a7d908229d10))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * move metadata to additionalAttributes field ([de42be2](https://github.com/Hyperkid123/ai-web-clients/commit/de42be2368619a9e89c87d7dd034991169dffafa))
package/README.md ADDED
@@ -0,0 +1,208 @@
1
+ # @redhat-cloud-services/ai-client-common
2
+
3
+ Common interfaces and utilities for AI client packages in the Red Hat Cloud Services ecosystem.
4
+
5
+ ## Features
6
+
7
+ - **Standardized AI Client Interface** - Common `IAIClient` interface for all AI services
8
+ - **Dependency Injection** - Interfaces for custom fetch implementations and streaming handlers
9
+ - **TypeScript Support** - Comprehensive type definitions for AI client development
10
+ - **Error Handling** - Base error classes with validation error support
11
+ - **Streaming Support** - Generic streaming handler interface for real-time responses
12
+ - **Zero Dependencies** - Pure TypeScript interfaces with no runtime dependencies
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @redhat-cloud-services/ai-client-common
18
+ ```
19
+
20
+ ## Core Interfaces
21
+
22
+ ### IAIClient Interface
23
+
24
+ All AI clients in this workspace implement the `IAIClient` interface:
25
+
26
+ ```typescript
27
+ import { IAIClient } from '@redhat-cloud-services/ai-client-common';
28
+
29
+ interface IAIClient {
30
+ init(): Promise<string>;
31
+ sendMessage<TChunk = unknown>(
32
+ conversationId: string,
33
+ message: string,
34
+ options?: ISendMessageOptions<TChunk>
35
+ ): Promise<TChunk | IMessageResponse | void>;
36
+ getDefaultStreamingHandler?<TChunk = unknown>(): IStreamingHandler<TChunk> | undefined;
37
+ getConversationHistory(conversationId: string, options?: IRequestOptions): Promise<IConversationHistoryResponse>;
38
+ healthCheck(options?: IRequestOptions): Promise<unknown>;
39
+ getServiceStatus?(options?: IRequestOptions): Promise<unknown>;
40
+ }
41
+ ```
42
+
43
+ ### Dependency Injection
44
+
45
+ #### Custom Fetch Implementation
46
+
47
+ **Important**: Do NOT set `'Content-Type'` headers in your fetchFunction - AI clients manage these internally based on endpoint requirements.
48
+
49
+ ```typescript
50
+ import { IFetchFunction } from '@redhat-cloud-services/ai-client-common';
51
+
52
+ const customFetch: IFetchFunction = async (input, init) => {
53
+ // Add authentication headers
54
+ const token = await getAuthToken();
55
+
56
+ return fetch(input, {
57
+ ...init,
58
+ headers: {
59
+ ...init?.headers,
60
+ 'Authorization': `Bearer ${token}`,
61
+ // DO NOT set 'Content-Type' - AI clients handle this internally
62
+ },
63
+ });
64
+ };
65
+ ```
66
+
67
+ #### Base Client Configuration
68
+
69
+ ```typescript
70
+ import { IBaseClientConfig } from '@redhat-cloud-services/ai-client-common';
71
+
72
+ const config: IBaseClientConfig = {
73
+ baseUrl: 'https://your-ai-service.com',
74
+ fetchFunction: customFetch,
75
+ defaultStreamingHandler: new CustomStreamingHandler()
76
+ };
77
+ ```
78
+
79
+ ### Streaming Support
80
+
81
+ #### Implementing a Custom Streaming Handler
82
+
83
+ ```typescript
84
+ import { IStreamingHandler } from '@redhat-cloud-services/ai-client-common';
85
+
86
+ class CustomStreamingHandler implements IStreamingHandler<string> {
87
+ onChunk(chunk: string, afterChunk?: (chunk: string) => void): void {
88
+ console.log('Received chunk:', chunk);
89
+ // Process the chunk
90
+ if (afterChunk) {
91
+ afterChunk(chunk);
92
+ }
93
+ }
94
+
95
+ onStart?(conversationId?: string, messageId?: string): void {
96
+ console.log('Stream started', { conversationId, messageId });
97
+ }
98
+
99
+ onComplete?(finalChunk: string): void {
100
+ console.log('Stream completed:', finalChunk);
101
+ }
102
+
103
+ onError?(error: Error): void {
104
+ console.error('Stream error:', error);
105
+ }
106
+
107
+ onAbort?(): void {
108
+ console.log('Stream aborted');
109
+ }
110
+ }
111
+ ```
112
+
113
+ #### Streaming Request Options
114
+
115
+ ```typescript
116
+ import { ISendMessageOptions } from '@redhat-cloud-services/ai-client-common';
117
+
118
+ const streamingOptions: ISendMessageOptions<string> = {
119
+ stream: true,
120
+ headers: { 'Custom-Header': 'value' },
121
+ signal: abortController.signal,
122
+ afterChunk: (chunk) => {
123
+ // Process each chunk as it arrives
124
+ updateUI(chunk);
125
+ }
126
+ };
127
+ ```
128
+
129
+ ## Error Handling
130
+
131
+ ### Base Error Classes
132
+
133
+ ```typescript
134
+ import {
135
+ AIClientError,
136
+ AIClientValidationError
137
+ } from '@redhat-cloud-services/ai-client-common';
138
+
139
+ try {
140
+ const response = await client.sendMessage(conversationId, message);
141
+ } catch (error) {
142
+ if (error instanceof AIClientValidationError) {
143
+ console.error('Validation errors:', error.validationErrors);
144
+ error.validationErrors.forEach(validationError => {
145
+ console.log(`Field: ${validationError.loc.join('.')}`);
146
+ console.log(`Message: ${validationError.msg}`);
147
+ console.log(`Type: ${validationError.type}`);
148
+ });
149
+ } else if (error instanceof AIClientError) {
150
+ console.error(`API Error ${error.status}: ${error.message}`);
151
+ console.error('Response data:', error.data);
152
+ } else {
153
+ console.error('Unexpected error:', error);
154
+ }
155
+ }
156
+ ```
157
+
158
+ ## Type Definitions
159
+
160
+ ### Request and Response Types
161
+
162
+ ```typescript
163
+ import {
164
+ IRequestOptions,
165
+ IMessageResponse,
166
+ IConversationHistoryResponse,
167
+ IAPIResponse
168
+ } from '@redhat-cloud-services/ai-client-common';
169
+
170
+ // Standard request options
171
+ const options: IRequestOptions = {
172
+ headers: { 'Custom-Header': 'value' },
173
+ signal: new AbortController().signal
174
+ };
175
+
176
+ // Message response structure
177
+ interface IMessageResponse {
178
+ messageId: string;
179
+ answer: string;
180
+ conversationId: string;
181
+ createdAt?: string;
182
+ metadata?: unknown;
183
+ }
184
+ ```
185
+
186
+ ## Compatible Packages
187
+
188
+ This package provides the foundation for:
189
+
190
+ - **[@redhat-cloud-services/arh-client](../arh-client)** - Intelligent Front Door (IFD) API client
191
+ - **[@redhat-cloud-services/lightspeed-client](../lightspeed-client)** - OpenShift Lightspeed API client
192
+ - **[@redhat-cloud-services/ai-client-state](../ai-client-state)** - State management for AI conversations
193
+ - **[@redhat-cloud-services/ai-react-state](../ai-react-state)** - React hooks and context for AI state
194
+
195
+ ## Building
196
+
197
+ Run `nx build ai-client-common` to build the library.
198
+
199
+ ## Running unit tests
200
+
201
+ Run `nx test ai-client-common` to execute the unit tests via [Jest](https://jestjs.io).
202
+
203
+ ## Development
204
+
205
+ This package follows the workspace standards:
206
+ - Strict TypeScript with no `any` types
207
+ - Zero runtime dependencies
208
+ - Comprehensive interface definitions
package/package.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@redhat-cloud-services/ai-client-common",
3
+ "version": "0.1.0",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {}
8
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/ai-client-common';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/ai-client-common/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
package/src/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./lib/ai-client-common"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ai-client-common/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Generic interface for custom fetch implementation that must be injected into AI clients.
3
+ * Mirrors exactly the native browser fetch interface for maximum compatibility.
4
+ */
5
+ export interface IFetchFunction {
6
+ (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
7
+ }
8
+ /**
9
+ * Base configuration interface for all AI clients
10
+ */
11
+ export interface IBaseClientConfig<TChunk = unknown> {
12
+ /**
13
+ * The base URL for the API
14
+ */
15
+ baseUrl: string;
16
+ /**
17
+ * Custom fetch implementation for making HTTP requests
18
+ * Must include authentication headers (Bearer token) if needed
19
+ */
20
+ fetchFunction: IFetchFunction;
21
+ /**
22
+ * Default streaming handler for the client
23
+ * Used when sendMessage is called with stream=true but no streamingHandler provided
24
+ * Individual requests can override this by providing their own streamingHandler
25
+ */
26
+ defaultStreamingHandler?: IStreamingHandler<TChunk>;
27
+ }
28
+ /**
29
+ * Standard request options that can be passed to individual client methods
30
+ */
31
+ export interface IRequestOptions {
32
+ /**
33
+ * Custom headers for this specific request
34
+ */
35
+ headers?: Record<string, string>;
36
+ /**
37
+ * AbortSignal to cancel the request
38
+ */
39
+ signal?: AbortSignal;
40
+ }
41
+ /**
42
+ * Common interface that all AI clients must implement
43
+ * Provides a standardized way to interact with different AI services
44
+ */
45
+ export interface IAIClient<AP extends Record<string, unknown> = Record<string, unknown>> {
46
+ /**
47
+ * Initialize the client and return the initial conversation ID
48
+ * This method is called once when the client is first used by a state manager
49
+ * @returns Promise that resolves to the initial conversation ID
50
+ */
51
+ init(): Promise<string>;
52
+ /**
53
+ * Send a message to the AI service
54
+ * @param conversationId - The conversation ID to send the message to
55
+ * @param message - The message content to send
56
+ * @param options - Optional configuration for the request
57
+ * @returns Promise that resolves to the AI's response
58
+ */
59
+ sendMessage<TChunk = unknown>(conversationId: string, message: string, options?: ISendMessageOptions<TChunk>): Promise<TChunk | IMessageResponse<AP> | void>;
60
+ /**
61
+ * Get the default streaming handler for this client (if any)
62
+ * @returns The default streaming handler or undefined if not configured
63
+ */
64
+ getDefaultStreamingHandler?<TChunk = unknown>(): IStreamingHandler<TChunk> | undefined;
65
+ /**
66
+ * Get the conversation history for a specific conversation
67
+ * @param conversationId - The conversation ID to retrieve history for
68
+ * @param options - Optional request configuration
69
+ * @returns Promise that resolves to the conversation history
70
+ */
71
+ getConversationHistory(conversationId: string, options?: IRequestOptions): Promise<IConversationHistoryResponse<AP>>;
72
+ /**
73
+ * Perform a health check on the AI service
74
+ * @param options - Optional request configuration
75
+ * @returns Promise that resolves to health status information
76
+ */
77
+ healthCheck(options?: IRequestOptions): Promise<unknown>;
78
+ /**
79
+ * Get the current status of the AI service
80
+ * @param options - Optional request configuration
81
+ * @returns Promise that resolves to service status information
82
+ */
83
+ getServiceStatus?(options?: IRequestOptions): Promise<unknown>;
84
+ }
85
+ /**
86
+ * Base error class for all AI client errors
87
+ */
88
+ export declare class AIClientError extends Error {
89
+ status: number;
90
+ statusText: string;
91
+ data?: unknown | undefined;
92
+ constructor(status: number, statusText: string, message: string, data?: unknown | undefined);
93
+ }
94
+ /**
95
+ * Validation error class for 422 responses
96
+ */
97
+ export interface IValidationError {
98
+ loc: (string | number)[];
99
+ msg: string;
100
+ type: string;
101
+ }
102
+ export declare class AIClientValidationError extends AIClientError {
103
+ validationErrors: IValidationError[];
104
+ constructor(validationErrors: IValidationError[]);
105
+ }
106
+ /**
107
+ * Common utility types used across AI clients
108
+ */
109
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
110
+ /**
111
+ * Standard API response wrapper that many AI services use
112
+ */
113
+ export interface IAPIResponse<T = unknown> {
114
+ data?: T;
115
+ error?: string;
116
+ status?: number;
117
+ }
118
+ /**
119
+ * Generic streaming handler interface for AI clients that support streaming
120
+ */
121
+ export interface IStreamingHandler<TChunk = unknown> {
122
+ /**
123
+ * Handle a single chunk of streaming data
124
+ */
125
+ onChunk(chunk: TChunk, afterChunk?: (chunk: TChunk) => void): void;
126
+ /**
127
+ * Called when the stream starts
128
+ */
129
+ onStart?(conversationId?: string, messageId?: string): void;
130
+ /**
131
+ * Called when the stream completes successfully
132
+ */
133
+ onComplete?(finalChunk: TChunk): void;
134
+ /**
135
+ * Called when an error occurs during streaming
136
+ */
137
+ onError?(error: Error): void;
138
+ /**
139
+ * Called when the stream is aborted
140
+ */
141
+ onAbort?(): void;
142
+ }
143
+ /**
144
+ * Streaming request options for clients that support streaming
145
+ */
146
+ export interface IStreamingRequestOptions<TChunk = unknown> extends IRequestOptions {
147
+ /**
148
+ * The streaming handler to process the response
149
+ */
150
+ streamingHandler: IStreamingHandler<TChunk>;
151
+ }
152
+ /**
153
+ * Standard message response for non-streaming requests
154
+ */
155
+ export interface IMessageResponse<AP extends Record<string, unknown> = Record<string, unknown>> {
156
+ /**
157
+ * Unique identifier for the message
158
+ */
159
+ messageId: string;
160
+ /**
161
+ * The response answer/text
162
+ */
163
+ answer: string;
164
+ /**
165
+ * Conversation identifier this message belongs to
166
+ */
167
+ conversationId: string;
168
+ /**
169
+ * Timestamp when the message was created
170
+ */
171
+ createdAt?: string;
172
+ /**
173
+ * Additional attributes specific to the AI client
174
+ */
175
+ additionalAttributes?: AP;
176
+ }
177
+ /**
178
+ * Source citation information for AI responses
179
+ */
180
+ export interface IAnswerSource {
181
+ /**
182
+ * URL to the source content
183
+ */
184
+ link?: string | null;
185
+ /**
186
+ * Title of the source content
187
+ */
188
+ title?: string | null;
189
+ /**
190
+ * Relevance score of the source
191
+ */
192
+ score?: number | null;
193
+ /**
194
+ * Text snippet from the source
195
+ */
196
+ snippet?: string | null;
197
+ }
198
+ /**
199
+ * Single message in conversation history
200
+ */
201
+ export interface IConversationHistoryMessage<T extends Record<string, unknown> = Record<string, unknown>> {
202
+ /**
203
+ * Unique identifier for the message
204
+ */
205
+ message_id: string;
206
+ /**
207
+ * When the message was received
208
+ */
209
+ received_at: string;
210
+ /**
211
+ * The user's input/question
212
+ */
213
+ input: string;
214
+ /**
215
+ * When the AI response was created
216
+ */
217
+ created_at: string;
218
+ /**
219
+ * The AI's answer
220
+ */
221
+ answer: string;
222
+ /**
223
+ * Sources used to generate the answer
224
+ */
225
+ sources: IAnswerSource[];
226
+ /**
227
+ * Additional data associated with the message
228
+ */
229
+ additionalData?: T;
230
+ }
231
+ /**
232
+ * Response type for conversation history requests
233
+ */
234
+ export type IConversationHistoryResponse<T extends Record<string, unknown> = Record<string, unknown>> = IConversationHistoryMessage<T>[] | null;
235
+ export interface IErrorMessageResponse {
236
+ error: any;
237
+ }
238
+ /**
239
+ * Options for sending messages, supporting both streaming and non-streaming modes
240
+ */
241
+ export interface ISendMessageOptions<TChunk = unknown> extends IRequestOptions {
242
+ /**
243
+ * Whether to use streaming mode for the response
244
+ * When true, the client's default streaming handler will be used
245
+ */
246
+ stream?: boolean;
247
+ afterChunk?: (chunk: TChunk) => void;
248
+ }
249
+ //# sourceMappingURL=ai-client-common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-client-common.d.ts","sourceRoot":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,EAAE,OAAO,CAAC;IACtG;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,2BAA2B,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC;AAEhJ,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,GAAG,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,MAAM,GAAG,OAAO,CAAE,SAAQ,eAAe;IAC5E;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AIClientValidationError = exports.AIClientError = void 0;
4
+ /**
5
+ * Base error class for all AI client errors
6
+ */
7
+ class AIClientError extends Error {
8
+ constructor(status, statusText, message, data) {
9
+ super(message);
10
+ this.status = status;
11
+ this.statusText = statusText;
12
+ this.data = data;
13
+ this.name = 'AIClientError';
14
+ }
15
+ }
16
+ exports.AIClientError = AIClientError;
17
+ class AIClientValidationError extends AIClientError {
18
+ constructor(validationErrors) {
19
+ super(422, 'Validation Error', 'Request validation failed', validationErrors);
20
+ this.validationErrors = validationErrors;
21
+ this.name = 'AIClientValidationError';
22
+ }
23
+ }
24
+ exports.AIClientValidationError = AIClientValidationError;
25
+ //# sourceMappingURL=ai-client-common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-client-common.js","sourceRoot":"","sources":["../../../../../packages/ai-client-common/src/lib/ai-client-common.ts"],"names":[],"mappings":";;;AAuGA;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,YACS,MAAc,EACd,UAAkB,EACzB,OAAe,EACR,IAAc;QAErB,KAAK,CAAC,OAAO,CAAC,CAAC;QALR,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAElB,SAAI,GAAJ,IAAI,CAAU;QAGrB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAVD,sCAUC;AAWD,MAAa,uBAAwB,SAAQ,aAAa;IACxD,YAAmB,gBAAoC;QACrD,KAAK,CAAC,GAAG,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,gBAAgB,CAAC,CAAC;QAD7D,qBAAgB,GAAhB,gBAAgB,CAAoB;QAErD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AALD,0DAKC"}