@hahnpro/ai-sdk 0.10.0 → 0.11.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { OnInit, ElementRef, Provider, EnvironmentProviders } from '@angular/core';
2
+ import { OnInit, ElementRef, InjectionToken, Provider, EnvironmentProviders } from '@angular/core';
3
3
  import * as _hahnpro_hpc_api from '@hahnpro/hpc-api';
4
4
  import { Message, AiAssistant, ThreadPopulated, AssistantMessage as AssistantMessage$1, SystemMessage, ToolMessage, UserMessage as UserMessage$1, Paginated, Thread, SpeechToken, RequestParameter, Asset, AssetType, Content, Event } from '@hahnpro/hpc-api';
5
5
  import { Subject, Observable } from 'rxjs';
@@ -148,6 +148,7 @@ interface ChatDialogData {
148
148
  declare class AiChatDialogComponent implements OnInit {
149
149
  data: ChatDialogData;
150
150
  private readonly matDialogRef;
151
+ private auth;
151
152
  readonly chatService: ChatService;
152
153
  private readonly asset;
153
154
  private readonly event;
@@ -156,100 +157,30 @@ declare class AiChatDialogComponent implements OnInit {
156
157
  private readonly type;
157
158
  private readonly translocoService;
158
159
  constructor();
159
- ngOnInit(): void;
160
+ ngOnInit(): Promise<void>;
160
161
  close(message?: string): void;
161
162
  static ɵfac: i0.ɵɵFactoryDeclaration<AiChatDialogComponent, never>;
162
163
  static ɵcmp: i0.ɵɵComponentDeclaration<AiChatDialogComponent, "ng-component", never, {}, {}, never, never, true, never>;
163
164
  }
164
165
 
165
- declare class ApiService {
166
- private _baseUrl;
167
- private apiPath;
168
- private realm;
169
- private httpClient;
170
- get baseUrl(): string;
171
- get apiUrl(): string;
172
- get user(): User | null;
173
- init(clientId: string, clientSecret: string, baseUrl?: string, realm?: string): Promise<void>;
174
- addMessage(message: string, threadId?: string, assistantId?: string, context?: Record<string, unknown>): Promise<Message>;
175
- getAccessToken(): Promise<string>;
176
- createThread(assistantId: string, isEphemeral?: boolean): Promise<ThreadPopulated>;
177
- getThread(threadId: string): Promise<ThreadPopulated>;
178
- getThreadMessages(threadId: string): Promise<Paginated<Message[]>>;
179
- deleteThread(threadId: string): Promise<Thread>;
180
- getAssistants(): Promise<AiAssistant[]>;
181
- getSpeechToken(): Promise<SpeechToken>;
182
- getAssets(params?: RequestParameter): Promise<Paginated<Asset[]>>;
183
- getAssetTypes(params?: RequestParameter): Promise<Paginated<AssetType[]>>;
184
- getContents(params?: RequestParameter): Promise<Paginated<Content[]>>;
185
- getEvents(params?: RequestParameter): Promise<Paginated<Event[]>>;
186
- downloadContent(id: string, type?: FileType): Promise<Blob>;
187
- loadUsersAsPermissions(): Promise<Permission[]>;
188
- static ɵfac: i0.ɵɵFactoryDeclaration<ApiService, never>;
189
- static ɵprov: i0.ɵɵInjectableDeclaration<ApiService>;
190
- }
191
- type TokenOption = {
192
- token?: string;
193
- };
194
- type Config = TokenOption & {
195
- headers?: Record<string, string>;
196
- params?: any;
197
- };
198
- declare class HttpClient {
199
- private config;
200
- private token;
201
- private expiresAt;
202
- private _user;
203
- init(serverUrl: string, clientId: string, clientSecret: string): Promise<void>;
204
- delete: <T>(url: string, config?: Config) => Promise<T>;
205
- get: <T>(url: string, config?: Config) => Promise<T>;
206
- post: <T>(url: string, data: any, config?: Config) => Promise<T>;
207
- put: <T>(url: string, data: any, config?: Config) => Promise<T>;
208
- get user(): User | null;
209
- protected request: <T>(method: Method, url: string, config?: Config, data?: BodyInit | null | undefined) => Promise<T>;
210
- getAccessToken(): Promise<string>;
211
- private resolveUser;
212
- }
213
- type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
214
- type FileType = 'original' | 'preview-sm' | 'preview-md' | 'preview-lg' | 'preview-xl';
215
- interface Permission {
216
- label: string;
217
- value: string;
218
- }
219
- interface User {
220
- id: string;
221
- username: string;
222
- activeOrg?: {
223
- id: string;
224
- name: string;
225
- };
226
- roles: string[];
227
- }
228
-
229
166
  interface AssetData {
230
167
  id?: string;
231
168
  name?: string;
232
169
  externalKey?: string;
233
170
  }
234
- interface AuthData {
235
- clientId: string;
236
- clientSecret: string;
237
- baseUrl?: string;
238
- realm?: string;
239
- }
240
171
  declare class AiChatComponent implements OnInit {
241
- readonly apiService: ApiService;
242
172
  readonly chatService: ChatService;
243
173
  readonly translocoService: TranslocoService;
244
174
  readonly logger: NGXLogger;
245
175
  readonly elementRef: ElementRef<any>;
176
+ private auth;
246
177
  asset: AssetData;
247
- authData: AuthData;
248
178
  assistant: ChatAssistantType;
249
179
  initialMessage?: string;
250
- ngOnInit(): void;
180
+ context?: Record<string, unknown>;
181
+ ngOnInit(): Promise<void>;
251
182
  static ɵfac: i0.ɵɵFactoryDeclaration<AiChatComponent, never>;
252
- static ɵcmp: i0.ɵɵComponentDeclaration<AiChatComponent, "ai-chat", never, { "asset": { "alias": "asset"; "required": false; }; "authData": { "alias": "authData"; "required": false; }; "assistant": { "alias": "assistant"; "required": false; }; "initialMessage": { "alias": "initialMessage"; "required": false; }; }, {}, never, never, true, never>;
183
+ static ɵcmp: i0.ɵɵComponentDeclaration<AiChatComponent, "ai-chat", never, { "asset": { "alias": "asset"; "required": false; }; "assistant": { "alias": "assistant"; "required": false; }; "initialMessage": { "alias": "initialMessage"; "required": false; }; "context": { "alias": "context"; "required": false; }; }, {}, never, never, true, never>;
253
184
  }
254
185
 
255
186
  declare const translations: {
@@ -1527,6 +1458,79 @@ declare class AiModule {
1527
1458
  static ɵinj: i0.ɵɵInjectorDeclaration<AiModule>;
1528
1459
  }
1529
1460
 
1461
+ interface AuthAdapter {
1462
+ init(): Promise<void>;
1463
+ isAuthenticated(): Promise<boolean>;
1464
+ getAccessToken(): Promise<string>;
1465
+ loginRedirect(options?: {
1466
+ redirectUri?: string;
1467
+ }): Promise<void>;
1468
+ loginPopup?(): Promise<void>;
1469
+ logout?(): Promise<void>;
1470
+ }
1471
+ declare const AUTH_ADAPTER: InjectionToken<AuthAdapter>;
1472
+
1473
+ declare class ApiService {
1474
+ private _baseUrl;
1475
+ private apiPath;
1476
+ private auth;
1477
+ private httpClient;
1478
+ get baseUrl(): string;
1479
+ get apiUrl(): string;
1480
+ get user(): User | null;
1481
+ addMessage(message: string, threadId?: string, assistantId?: string, context?: Record<string, unknown>): Promise<Message>;
1482
+ getAccessToken(): Promise<string>;
1483
+ createThread(assistantId: string, isEphemeral?: boolean): Promise<ThreadPopulated>;
1484
+ getThread(threadId: string): Promise<ThreadPopulated>;
1485
+ getThreadMessages(threadId: string): Promise<Paginated<Message[]>>;
1486
+ deleteThread(threadId: string): Promise<Thread>;
1487
+ getAssistants(): Promise<AiAssistant[]>;
1488
+ getSpeechToken(): Promise<SpeechToken>;
1489
+ getAssets(params?: RequestParameter): Promise<Paginated<Asset[]>>;
1490
+ getAssetTypes(params?: RequestParameter): Promise<Paginated<AssetType[]>>;
1491
+ getContents(params?: RequestParameter): Promise<Paginated<Content[]>>;
1492
+ getEvents(params?: RequestParameter): Promise<Paginated<Event[]>>;
1493
+ downloadContent(id: string, type?: FileType): Promise<Blob>;
1494
+ loadUsersAsPermissions(): Promise<Permission[]>;
1495
+ static ɵfac: i0.ɵɵFactoryDeclaration<ApiService, never>;
1496
+ static ɵprov: i0.ɵɵInjectableDeclaration<ApiService>;
1497
+ }
1498
+ type TokenOption = {
1499
+ token?: string;
1500
+ };
1501
+ type Config = TokenOption & {
1502
+ headers?: Record<string, string>;
1503
+ params?: any;
1504
+ };
1505
+ declare class HttpClient {
1506
+ private auth;
1507
+ private _user;
1508
+ constructor(auth: AuthAdapter);
1509
+ delete: <T>(url: string, config?: Config) => Promise<T>;
1510
+ get: <T>(url: string, config?: Config) => Promise<T>;
1511
+ post: <T>(url: string, data: any, config?: Config) => Promise<T>;
1512
+ put: <T>(url: string, data: any, config?: Config) => Promise<T>;
1513
+ get user(): User | null;
1514
+ protected request: <T>(method: Method, url: string, config?: Config, data?: BodyInit | null | undefined) => Promise<T>;
1515
+ getAccessToken(): Promise<string>;
1516
+ private resolveUser;
1517
+ }
1518
+ type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
1519
+ type FileType = 'original' | 'preview-sm' | 'preview-md' | 'preview-lg' | 'preview-xl';
1520
+ interface Permission {
1521
+ label: string;
1522
+ value: string;
1523
+ }
1524
+ interface User {
1525
+ id: string;
1526
+ username: string;
1527
+ activeOrg?: {
1528
+ id: string;
1529
+ name: string;
1530
+ };
1531
+ roles: string[];
1532
+ }
1533
+
1530
1534
  /**
1531
1535
  * Provides Markdown configuration for AI SDK
1532
1536
  * This allows consuming applications to not have to set up Markdown themselves
@@ -1539,5 +1543,5 @@ declare function provideAiMarkdown(): Provider;
1539
1543
  */
1540
1544
  declare function provideAiSdk(): (Provider | EnvironmentProviders)[];
1541
1545
 
1542
- export { AiChatComponent, AiChatDialogComponent, AiModule, AiTranslocoLoader, AiTranslocoModule, ApiService, HttpClient, WebSocketMessageType, provideAiMarkdown, provideAiSdk, translations };
1543
- export type { AssetData, AuthData, ChatAssistantType, ChatDialogData, Config, FileType, Method, Permission, TokenOption, User };
1546
+ export { AUTH_ADAPTER, AiChatComponent, AiChatDialogComponent, AiModule, AiTranslocoLoader, AiTranslocoModule, ApiService, HttpClient, WebSocketMessageType, provideAiMarkdown, provideAiSdk, translations };
1547
+ export type { AssetData, AuthAdapter, ChatAssistantType, ChatDialogData, Config, FileType, Method, Permission, TokenOption, User };
package/package.json CHANGED
@@ -1,29 +1,28 @@
1
1
  {
2
2
  "name": "@hahnpro/ai-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "dependencies": {
8
8
  "@hahnpro/hpc-api": "2025.2.13",
9
9
  "@hahnpro/ms-speech-sdk": "1.45.0",
10
- "openid-client": "6.5.1",
11
10
  "pretty-bytes": "6.1.1",
12
11
  "tslib": "^2.3.0"
13
12
  },
14
13
  "peerDependencies": {
15
- "@angular/cdk": "^18.0.0 || ^19.0.0 || ^20.0.0",
16
- "@angular/common": "^18.0.0 || ^19.0.0 || ^20.0.0",
17
- "@angular/core": "^18.0.0 || ^19.0.0 || ^20.0.0",
18
- "@angular/forms": "^18.0.0 || ^19.0.0 || ^20.0.0",
19
- "@angular/material": "^18.0.0 || ^19.0.0 || ^20.0.0",
20
- "@angular/platform-browser": "^18.0.0 || ^19.0.0 || ^20.0.0",
21
- "@angular/router": "^18.0.0 || ^19.0.0 || ^20.0.0",
14
+ "@angular/cdk": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
15
+ "@angular/common": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
16
+ "@angular/core": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
17
+ "@angular/forms": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
18
+ "@angular/material": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
19
+ "@angular/platform-browser": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
20
+ "@angular/router": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
22
21
  "@jsverse/transloco": "^7.6.0",
23
22
  "date-fns": "^4.0.0",
24
23
  "ngx-extended-pdf-viewer": "^23.0.0",
25
24
  "ngx-logger": "^5.0.0",
26
- "ngx-markdown": "^18.0.0 || ^19.0.0 || ^20.0.0",
25
+ "ngx-markdown": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
27
26
  "rxjs": "~7.8.0",
28
27
  "socket.io-client": "^4.8.0"
29
28
  },