@hahnpro/ai-sdk 0.9.0 → 0.11.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/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
- import { OnInit, 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
- import { AiAssistant, ThreadPopulated, AssistantMessage as AssistantMessage$1, SystemMessage, ToolMessage, UserMessage as UserMessage$1, Message, Paginated, Thread, SpeechToken, RequestParameter, Asset, AssetType, Content, Event } from '@hahnpro/hpc-api';
5
- import * as i1$1 from '@angular/common';
6
- import * as i2 from 'ngx-logger';
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
+ import { Subject, Observable } from 'rxjs';
7
6
  import * as i1 from '@jsverse/transloco';
8
- import { TranslocoLoader } from '@jsverse/transloco';
9
- import { Observable } from 'rxjs';
7
+ import { TranslocoService, TranslocoLoader } from '@jsverse/transloco';
8
+ import * as i2 from 'ngx-logger';
9
+ import { NGXLogger } from 'ngx-logger';
10
+ import * as i1$1 from '@angular/common';
10
11
 
11
12
  interface ContextReference {
12
13
  reference_id: number;
@@ -30,6 +31,10 @@ declare class ChatService {
30
31
  model: string | null;
31
32
  locale: string;
32
33
  isProcessing: boolean;
34
+ threadEventSubject: Subject<{
35
+ type: WebSocketMessageType;
36
+ data: Message;
37
+ }>;
33
38
  private readonly apiService;
34
39
  private readonly contextService;
35
40
  private readonly destroy$;
@@ -104,8 +109,18 @@ interface UserMessage extends UserMessage$1 {
104
109
  parsedContent?: MessageContent;
105
110
  }
106
111
  type ChatMessage = AssistantMessage | SystemMessage | ToolMessage | UserMessage;
112
+ declare enum WebSocketMessageType {
113
+ AI_ABORTED = "ai_aborted",
114
+ AI_ABORT_FAILED = "ai_abort_failed",
115
+ AI_COMPLETE = "ai_complete",
116
+ AI_FAILED_TO_PROCESS = "ai_failed_to_process",
117
+ AI_INVALID_MESSAGE = "ai_invalid_message",
118
+ AI_MESSAGE = "ai_message",
119
+ AI_PARTIAL_MESSAGE = "ai_partial_message",
120
+ AI_PROCESSING = "ai_processing"
121
+ }
107
122
 
108
- interface AssetData {
123
+ interface AssetData$1 {
109
124
  id?: string;
110
125
  name?: string;
111
126
  externalKey?: string;
@@ -119,15 +134,21 @@ interface EventData {
119
134
  }
120
135
  type ChatAssistantType = 'asset' | 'help' | 'report' | 'incident';
121
136
  interface ChatDialogData {
122
- asset?: AssetData;
137
+ asset?: AssetData$1;
123
138
  event?: EventData;
124
139
  assistant?: ChatAssistantType;
125
140
  initialMessage?: string;
126
141
  context?: Record<string, unknown>;
142
+ messageHandler?: (message: {
143
+ type: WebSocketMessageType;
144
+ data: Message;
145
+ }) => void;
146
+ messageFilter?: WebSocketMessageType[];
127
147
  }
128
148
  declare class AiChatDialogComponent implements OnInit {
129
149
  data: ChatDialogData;
130
150
  private readonly matDialogRef;
151
+ private auth;
131
152
  readonly chatService: ChatService;
132
153
  private readonly asset;
133
154
  private readonly event;
@@ -136,12 +157,32 @@ declare class AiChatDialogComponent implements OnInit {
136
157
  private readonly type;
137
158
  private readonly translocoService;
138
159
  constructor();
139
- ngOnInit(): void;
160
+ ngOnInit(): Promise<void>;
140
161
  close(message?: string): void;
141
162
  static ɵfac: i0.ɵɵFactoryDeclaration<AiChatDialogComponent, never>;
142
163
  static ɵcmp: i0.ɵɵComponentDeclaration<AiChatDialogComponent, "ng-component", never, {}, {}, never, never, true, never>;
143
164
  }
144
165
 
166
+ interface AssetData {
167
+ id?: string;
168
+ name?: string;
169
+ externalKey?: string;
170
+ }
171
+ declare class AiChatComponent implements OnInit {
172
+ readonly chatService: ChatService;
173
+ readonly translocoService: TranslocoService;
174
+ readonly logger: NGXLogger;
175
+ readonly elementRef: ElementRef<any>;
176
+ private auth;
177
+ asset: AssetData;
178
+ assistant: ChatAssistantType;
179
+ initialMessage?: string;
180
+ context?: Record<string, unknown>;
181
+ ngOnInit(): Promise<void>;
182
+ static ɵfac: i0.ɵɵFactoryDeclaration<AiChatComponent, 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>;
184
+ }
185
+
145
186
  declare const translations: {
146
187
  en: {
147
188
  accepted: string;
@@ -1417,15 +1458,26 @@ declare class AiModule {
1417
1458
  static ɵinj: i0.ɵɵInjectorDeclaration<AiModule>;
1418
1459
  }
1419
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
+
1420
1473
  declare class ApiService {
1421
1474
  private _baseUrl;
1422
1475
  private apiPath;
1423
- private realm;
1476
+ private auth;
1424
1477
  private httpClient;
1425
1478
  get baseUrl(): string;
1426
1479
  get apiUrl(): string;
1427
1480
  get user(): User | null;
1428
- init(clientId: string, clientSecret: string, baseUrl?: string, realm?: string): Promise<void>;
1429
1481
  addMessage(message: string, threadId?: string, assistantId?: string, context?: Record<string, unknown>): Promise<Message>;
1430
1482
  getAccessToken(): Promise<string>;
1431
1483
  createThread(assistantId: string, isEphemeral?: boolean): Promise<ThreadPopulated>;
@@ -1451,11 +1503,9 @@ type Config = TokenOption & {
1451
1503
  params?: any;
1452
1504
  };
1453
1505
  declare class HttpClient {
1454
- private config;
1455
- private token;
1456
- private expiresAt;
1506
+ private auth;
1457
1507
  private _user;
1458
- init(serverUrl: string, clientId: string, clientSecret: string): Promise<void>;
1508
+ constructor(auth: AuthAdapter);
1459
1509
  delete: <T>(url: string, config?: Config) => Promise<T>;
1460
1510
  get: <T>(url: string, config?: Config) => Promise<T>;
1461
1511
  post: <T>(url: string, data: any, config?: Config) => Promise<T>;
@@ -1493,5 +1543,5 @@ declare function provideAiMarkdown(): Provider;
1493
1543
  */
1494
1544
  declare function provideAiSdk(): (Provider | EnvironmentProviders)[];
1495
1545
 
1496
- export { AiChatDialogComponent, AiModule, AiTranslocoLoader, AiTranslocoModule, ApiService, HttpClient, provideAiMarkdown, provideAiSdk, translations };
1497
- export type { 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/ai-sdk",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },