mesauth-angular 1.18.0 → 1.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mesauth-angular",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Angular helper library to connect to a backend API and SignalR hub to surface the current logged-in user and incoming notifications with dark/light theme support",
5
5
  "keywords": [
6
6
  "angular",
@@ -1,10 +1,10 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { InjectionToken, EnvironmentProviders, OnDestroy, AfterViewInit, ElementRef } from '@angular/core';
2
+ import { InjectionToken, EnvironmentProviders, AfterViewInit, OnDestroy, ElementRef } from '@angular/core';
3
3
  import { HttpClient, HttpInterceptorFn, HttpResponse, HttpParams } from '@angular/common/http';
4
4
  import { Observable, OperatorFunction } from 'rxjs';
5
5
  import { Router } from '@angular/router';
6
- import { SafeHtml } from '@angular/platform-browser';
7
6
  import * as mesauth_angular from 'mesauth-angular';
7
+ import { SafeHtml } from '@angular/platform-browser';
8
8
 
9
9
  interface MesAuthConfig {
10
10
  apiBaseUrl: string;
@@ -291,10 +291,12 @@ declare class UserProfileComponent {
291
291
  showBell: _angular_core.InputSignal<boolean>;
292
292
  showApproval: _angular_core.InputSignal<boolean>;
293
293
  showName: _angular_core.InputSignal<boolean>;
294
+ showAi: _angular_core.InputSignal<boolean>;
294
295
  showSignature: _angular_core.InputSignal<boolean[]>;
295
296
  signatureHeight: _angular_core.InputSignal<number>;
296
297
  notificationClick: _angular_core.OutputEmitterRef<void>;
297
298
  approvalClick: _angular_core.OutputEmitterRef<void>;
299
+ aiClick: _angular_core.OutputEmitterRef<void>;
298
300
  get themeClass(): string;
299
301
  readonly currentUser: _angular_core.WritableSignal<IUser>;
300
302
  readonly unreadCount: _angular_core.WritableSignal<number>;
@@ -317,6 +319,7 @@ declare class UserProfileComponent {
317
319
  loadUnreadCount(): void;
318
320
  loadPendingApprovalCount(): void;
319
321
  onApprovalClick(): void;
322
+ onAiClick(): void;
320
323
  getAvatarUrl(user: IUser): string;
321
324
  getLastNameInitial(user: IUser): string;
322
325
  toggleDropdown(): void;
@@ -329,7 +332,7 @@ declare class UserProfileComponent {
329
332
  onNotificationClick(): void;
330
333
  onSigErr(_ev: Event): void;
331
334
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<UserProfileComponent, never>;
332
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserProfileComponent, "ma-user-profile", never, { "inputAvatarShape": { "alias": "inputAvatarShape"; "required": false; "isSignal": true; }; "showBell": { "alias": "showBell"; "required": false; "isSignal": true; }; "showApproval": { "alias": "showApproval"; "required": false; "isSignal": true; }; "showName": { "alias": "showName"; "required": false; "isSignal": true; }; "showSignature": { "alias": "showSignature"; "required": false; "isSignal": true; }; "signatureHeight": { "alias": "signatureHeight"; "required": false; "isSignal": true; }; }, { "notificationClick": "notificationClick"; "approvalClick": "approvalClick"; }, never, ["*"], true, never>;
335
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<UserProfileComponent, "ma-user-profile", never, { "inputAvatarShape": { "alias": "inputAvatarShape"; "required": false; "isSignal": true; }; "showBell": { "alias": "showBell"; "required": false; "isSignal": true; }; "showApproval": { "alias": "showApproval"; "required": false; "isSignal": true; }; "showName": { "alias": "showName"; "required": false; "isSignal": true; }; "showAi": { "alias": "showAi"; "required": false; "isSignal": true; }; "showSignature": { "alias": "showSignature"; "required": false; "isSignal": true; }; "signatureHeight": { "alias": "signatureHeight"; "required": false; "isSignal": true; }; }, { "notificationClick": "notificationClick"; "approvalClick": "approvalClick"; "aiClick": "aiClick"; }, never, ["*"], true, never>;
333
336
  }
334
337
 
335
338
  declare enum ApprovalStepMode {
@@ -556,6 +559,192 @@ declare class MaApprovalPanelComponent {
556
559
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<MaApprovalPanelComponent, "ma-approval-panel", never, {}, { "approvalActioned": "approvalActioned"; }, never, never, true, never>;
557
560
  }
558
561
 
562
+ /**
563
+ * Public AI types exported from mesauth-angular.
564
+ *
565
+ * The library ships a chat panel that talks to MesAuth.Api's /ai/chat SSE endpoint.
566
+ * Consumer apps may register additional client-side tools that the AI can invoke
567
+ * to drive their UI (navigation, dialogs, etc.) via provideMesAuthAi().
568
+ */
569
+ /**
570
+ * A tool the host app registers. The AI may call it; the handler runs in the browser
571
+ * with the application's DI container available via Angular's inject() in the handler.
572
+ *
573
+ * `parameters` is a JSON schema (object type). Use `readOnly: true` to skip the
574
+ * confirm card for safe operations like navigation. Anything that mutates server state
575
+ * or is hard to undo should have readOnly: false (default).
576
+ */
577
+ interface ClientTool {
578
+ name: string;
579
+ description: string;
580
+ parameters: ClientToolSchema;
581
+ readOnly?: boolean;
582
+ /**
583
+ * Handler executed when the AI calls this tool.
584
+ * Return a string (or anything JSON-serializable) describing the outcome; this is
585
+ * fed back to the AI as the tool result. Throw to signal failure.
586
+ */
587
+ handler: (args: any) => Promise<unknown> | unknown;
588
+ }
589
+ interface ClientToolSchema {
590
+ type: 'object';
591
+ properties?: Record<string, unknown>;
592
+ required?: string[];
593
+ [k: string]: unknown;
594
+ }
595
+ /** A single message in the chat panel UI (different from the on-wire format). */
596
+ interface ChatBubble {
597
+ id: string;
598
+ role: 'user' | 'assistant' | 'tool';
599
+ /** Plain-text content (assistant + user). For tool: short summary. */
600
+ text: string;
601
+ /** Server tool calls that ran in this assistant turn (rendered as chips). */
602
+ toolEvents?: ChatToolEvent[];
603
+ pending?: boolean;
604
+ }
605
+ interface ChatToolEvent {
606
+ id: string;
607
+ name: string;
608
+ side: 'server' | 'client';
609
+ status: 'running' | 'ok' | 'error' | 'awaiting-approval' | 'declined';
610
+ summary?: string;
611
+ args?: any;
612
+ readOnly?: boolean;
613
+ }
614
+ /** Stream event types matching MesAuth.Api's AiStreamEvent JSON. */
615
+ type AiSseEvent = {
616
+ type: 'session';
617
+ sessionId: string;
618
+ } | {
619
+ type: 'token';
620
+ text: string;
621
+ } | {
622
+ type: 'tool_call_started';
623
+ id: string;
624
+ name: string;
625
+ args: any;
626
+ side: 'server' | 'client';
627
+ readOnly?: boolean;
628
+ } | {
629
+ type: 'tool_call_completed';
630
+ id: string;
631
+ ok: boolean;
632
+ summary?: string;
633
+ } | {
634
+ type: 'client_tool_call';
635
+ id: string;
636
+ name: string;
637
+ args: any;
638
+ side: 'client';
639
+ readOnly?: boolean;
640
+ } | {
641
+ type: 'error';
642
+ message: string;
643
+ } | {
644
+ type: 'done';
645
+ };
646
+
647
+ interface PendingApproval {
648
+ callId: string;
649
+ name: string;
650
+ args: any;
651
+ side: 'client';
652
+ }
653
+ /**
654
+ * Drives the chat panel.
655
+ *
656
+ * Uses `fetch` + `ReadableStream` (not `EventSource`, which can't POST a body) to talk to
657
+ * `/ai/chat` SSE. State lives in signals so the panel can re-render reactively.
658
+ */
659
+ declare class MaAiService {
660
+ private readonly auth;
661
+ private readonly aiConfig;
662
+ private readonly tools;
663
+ readonly messages: _angular_core.WritableSignal<ChatBubble[]>;
664
+ readonly streaming: _angular_core.WritableSignal<boolean>;
665
+ /** When non-null, a write-class client tool is awaiting user confirmation. */
666
+ readonly pendingApproval: _angular_core.WritableSignal<PendingApproval>;
667
+ readonly lastError: _angular_core.WritableSignal<string>;
668
+ private sessionId;
669
+ /** Verbs the user already chose "always approve" for in this session. */
670
+ private alwaysApproved;
671
+ private abortController;
672
+ /** ID of the current assistant bubble we're streaming tokens into. */
673
+ private currentAssistantId;
674
+ get enabled(): boolean;
675
+ /** Start a brand-new conversation. */
676
+ resetSession(): void;
677
+ /** Cancel the in-flight stream (if any). The session id is preserved so the user can resume. */
678
+ cancel(): void;
679
+ /** User typed and submitted a message. */
680
+ send(text: string, currentRoute?: string): Promise<void>;
681
+ /**
682
+ * Approve (or decline) a pending client tool call. If approved (and alwaysApprove),
683
+ * remember the verb so we skip the prompt next time in this session.
684
+ */
685
+ resolvePendingApproval(decision: 'approve' | 'always' | 'decline'): Promise<void>;
686
+ private runStream;
687
+ private readSse;
688
+ private handleEvent;
689
+ private executeClientTool;
690
+ private continueWithToolResult;
691
+ private appendBubble;
692
+ private appendToken;
693
+ private appendToolEvent;
694
+ private markToolStatus;
695
+ private finalizeAssistant;
696
+ private verbOf;
697
+ private summarize;
698
+ private uid;
699
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<MaAiService, never>;
700
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<MaAiService>;
701
+ }
702
+
703
+ /**
704
+ * Right-side, resizable chat drawer. Open/close via the public open/close/toggle methods.
705
+ * Uses panel-shared.css for the header/empty-state styling so it looks like the approval
706
+ * and notification panels.
707
+ */
708
+ declare class MaAiChatPanelComponent implements AfterViewInit {
709
+ readonly isOpen: _angular_core.WritableSignal<boolean>;
710
+ readonly width: _angular_core.WritableSignal<number>;
711
+ readonly draft: _angular_core.WritableSignal<string>;
712
+ readonly ai: MaAiService;
713
+ private readonly router;
714
+ private readonly themeService;
715
+ private readonly scrollContainer;
716
+ private readonly textArea;
717
+ get themeClass(): string;
718
+ readonly messages: _angular_core.WritableSignal<mesauth_angular.ChatBubble[]>;
719
+ readonly streaming: _angular_core.WritableSignal<boolean>;
720
+ readonly pendingApproval: _angular_core.WritableSignal<mesauth_angular.PendingApproval>;
721
+ readonly lastError: _angular_core.WritableSignal<string>;
722
+ readonly hasMessages: _angular_core.Signal<boolean>;
723
+ private isDragging;
724
+ private dragStartX;
725
+ private dragStartWidth;
726
+ constructor();
727
+ ngAfterViewInit(): void;
728
+ open(): void;
729
+ close(): void;
730
+ toggle(): void;
731
+ newConversation(): void;
732
+ send(): void;
733
+ cancel(): void;
734
+ onTextareaKey(ev: KeyboardEvent): void;
735
+ onTextareaInput(ev: Event): void;
736
+ approve(): void;
737
+ alwaysApprove(): void;
738
+ decline(): void;
739
+ startResize(ev: PointerEvent): void;
740
+ onResizeMove(ev: PointerEvent): void;
741
+ endResize(ev: PointerEvent): void;
742
+ private loadWidth;
743
+ private scrollToBottom;
744
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<MaAiChatPanelComponent, never>;
745
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<MaAiChatPanelComponent, "ma-ai-chat-panel", never, {}, {}, never, never, true, never>;
746
+ }
747
+
559
748
  type Theme = 'light' | 'dark';
560
749
  declare class ThemeService implements OnDestroy {
561
750
  private readonly _currentTheme;
@@ -580,9 +769,11 @@ declare class ThemeService implements OnDestroy {
580
769
  declare class MaUserComponent implements AfterViewInit {
581
770
  userProfile?: UserProfileComponent;
582
771
  approvalPanel: MaApprovalPanelComponent;
772
+ aiPanel?: MaAiChatPanelComponent;
583
773
  avatarShape: _angular_core.InputSignal<"circle" | "rounded" | "rectangle">;
584
774
  showBell: _angular_core.InputSignal<boolean>;
585
775
  showApproval: _angular_core.InputSignal<boolean>;
776
+ showAi: _angular_core.InputSignal<boolean>;
586
777
  showName: _angular_core.InputSignal<boolean>;
587
778
  showSignature: _angular_core.InputSignal<boolean[]>;
588
779
  theme: _angular_core.InputSignal<"light" | "dark">;
@@ -592,7 +783,7 @@ declare class MaUserComponent implements AfterViewInit {
592
783
  onNotificationRead(): void;
593
784
  onApprovalActioned(): void;
594
785
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<MaUserComponent, never>;
595
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<MaUserComponent, "ma-user", never, { "avatarShape": { "alias": "avatarShape"; "required": false; "isSignal": true; }; "showBell": { "alias": "showBell"; "required": false; "isSignal": true; }; "showApproval": { "alias": "showApproval"; "required": false; "isSignal": true; }; "showName": { "alias": "showName"; "required": false; "isSignal": true; }; "showSignature": { "alias": "showSignature"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
786
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<MaUserComponent, "ma-user", never, { "avatarShape": { "alias": "avatarShape"; "required": false; "isSignal": true; }; "showBell": { "alias": "showBell"; "required": false; "isSignal": true; }; "showApproval": { "alias": "showApproval"; "required": false; "isSignal": true; }; "showAi": { "alias": "showAi"; "required": false; "isSignal": true; }; "showName": { "alias": "showName"; "required": false; "isSignal": true; }; "showSignature": { "alias": "showSignature"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
596
787
  }
597
788
 
598
789
  declare class MaUserXComponent {
@@ -855,7 +1046,7 @@ interface MaUiManifest {
855
1046
  features?: Record<string, boolean>;
856
1047
  }
857
1048
  /** Current installed package version — keep in sync with package.json. */
858
- declare const PACKAGE_VERSION = "1.18.0";
1049
+ declare const PACKAGE_VERSION = "1.19.0";
859
1050
  /**
860
1051
  * Provides server-driven UI configuration loaded from the hosted manifest.
861
1052
  * Components read `labels()` and `features()` signals instead of hardcoded strings.
@@ -983,5 +1174,86 @@ declare function runSsoCheckHandshake(authService: MesAuthService): Promise<void
983
1174
  */
984
1175
  declare function runReturnViaPostMessageIfRequested(authService: MesAuthService): Promise<boolean>;
985
1176
 
986
- export { ALL_ACTIONS, AVATAR_FRAMES, ApprovalActionType, ApprovalDocumentStatus, ApprovalStepMode, ApprovalStepStatus, MES_AUTH_CONFIG, MaApprovalPanelComponent, MaApprovalService, MaArvContainerComponent, MaAvatarComponent, MaIconComponent, MaThemeDirective, MaUiConfigService, MaUserComponent, MaUserMenuColor, MaUserMenuComponent, MaUserXComponent, MesAuthModule, MesAuthService, NotificationBadgeComponent, NotificationPanelComponent, NotificationType, PACKAGE_VERSION, ThemeService, ToastContainerComponent, ToastService, UserProfileComponent, extractXMaPerm, mesAuthInterceptor, provideMesAuth, runReturnViaPostMessageIfRequested, runSsoCheckHandshake, withXMaPerm, xMaResource };
987
- export type { ApprovalDashboardDto, ApprovalDocumentDto, ApprovalDocumentSummaryDto, ApprovalHistoryDto, ApprovalReferenceDto, ApprovalStepDto, ApprovalStepRequest, ApprovalSubmitResult, ApprovalTemplateDto, ApprovalTemplateStepDto, ApprovalTemplateSummaryDto, ApproveRejectRequest, AvatarFrameDef, AvatarShape, AvatarSize, CreateApprovalRequest, CreateApprovalResponseDto, CreateApprovalTemplateRequest, DelegateRequest, FrontEndRoute, IUser, MaUiManifest, MesAuthConfig, NotificationDto, PagedList, PermissionHeader, RealTimeNotificationDto, RequestConfig, RolePreviewUserDto, StepRoleDto, Theme, Toast, UpdateApprovalTemplateRequest, UserFrontEndRoutesGrouped };
1177
+ interface MesAuthAiConfig {
1178
+ /** Master switch when false the Ask-AI button hides and the panel never opens. */
1179
+ enabled?: boolean;
1180
+ /**
1181
+ * Extra client-side tools the AI can invoke. The handler runs in the browser.
1182
+ * The library always exposes a set of built-in client tools (navigate, toggle theme, etc.)
1183
+ * — these are merged in addition.
1184
+ */
1185
+ tools?: ClientTool[];
1186
+ /**
1187
+ * Optional extra paragraphs appended to the backend system prompt for this app.
1188
+ * Use to tell the AI what domain the consumer app handles (e.g. "You are inside the SPC app").
1189
+ */
1190
+ systemPromptExtensions?: string[];
1191
+ /**
1192
+ * Optional friendly name of the host app; sent to the backend each turn.
1193
+ */
1194
+ appName?: string;
1195
+ }
1196
+ declare const MES_AUTH_AI_CONFIG: InjectionToken<MesAuthAiConfig>;
1197
+ /** Default configuration when the consumer doesn't call provideMesAuthAi(). */
1198
+ declare const DEFAULT_AI_CONFIG: MesAuthAiConfig;
1199
+ /**
1200
+ * Provide AI assistant configuration to mesauth-angular.
1201
+ *
1202
+ * @example
1203
+ * ```ts
1204
+ * providers: [
1205
+ * provideMesAuth(...),
1206
+ * provideMesAuthAi({
1207
+ * enabled: true,
1208
+ * appName: 'MesExtensionSite',
1209
+ * tools: [
1210
+ * {
1211
+ * name: 'spc_open_chart',
1212
+ * description: 'Open the SPC chart for a given product line',
1213
+ * parameters: {
1214
+ * type: 'object',
1215
+ * properties: { lineId: { type: 'string' } },
1216
+ * required: ['lineId']
1217
+ * },
1218
+ * readOnly: true,
1219
+ * handler: (args) => inject(Router).navigateByUrl(`/spc/${args.lineId}`)
1220
+ * }
1221
+ * ]
1222
+ * })
1223
+ * ]
1224
+ * ```
1225
+ */
1226
+ declare function provideMesAuthAi(config: MesAuthAiConfig): EnvironmentProviders;
1227
+
1228
+ /**
1229
+ * Resolves the full set of client tools available to the AI: built-ins + consumer-registered.
1230
+ * Handlers are invoked through `runTool(name, args)` which automatically threads the Injector
1231
+ * so consumer handlers can use inject() patterns.
1232
+ */
1233
+ declare class MaAiToolsRegistry {
1234
+ private readonly config;
1235
+ private readonly injector;
1236
+ /** Built-in client tools shipped by the library. */
1237
+ private readonly builtIn;
1238
+ /** All tools, deduplicated by name (consumer wins on conflict). */
1239
+ list(): ClientTool[];
1240
+ resolve(name: string): ClientTool | undefined;
1241
+ /** Run a registered client tool and serialize its result for posting back to the agent loop. */
1242
+ runTool(name: string, args: any): Promise<{
1243
+ ok: boolean;
1244
+ result: string;
1245
+ }>;
1246
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<MaAiToolsRegistry, never>;
1247
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<MaAiToolsRegistry>;
1248
+ }
1249
+
1250
+ declare class MaAiButtonComponent {
1251
+ private readonly config;
1252
+ readonly enabled: _angular_core.Signal<boolean>;
1253
+ clicked: _angular_core.OutputEmitterRef<void>;
1254
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<MaAiButtonComponent, never>;
1255
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<MaAiButtonComponent, "ma-ai-button", never, {}, { "clicked": "clicked"; }, never, never, true, never>;
1256
+ }
1257
+
1258
+ export { ALL_ACTIONS, AVATAR_FRAMES, ApprovalActionType, ApprovalDocumentStatus, ApprovalStepMode, ApprovalStepStatus, DEFAULT_AI_CONFIG, MES_AUTH_AI_CONFIG, MES_AUTH_CONFIG, MaAiButtonComponent, MaAiChatPanelComponent, MaAiService, MaAiToolsRegistry, MaApprovalPanelComponent, MaApprovalService, MaArvContainerComponent, MaAvatarComponent, MaIconComponent, MaThemeDirective, MaUiConfigService, MaUserComponent, MaUserMenuColor, MaUserMenuComponent, MaUserXComponent, MesAuthModule, MesAuthService, NotificationBadgeComponent, NotificationPanelComponent, NotificationType, PACKAGE_VERSION, ThemeService, ToastContainerComponent, ToastService, UserProfileComponent, extractXMaPerm, mesAuthInterceptor, provideMesAuth, provideMesAuthAi, runReturnViaPostMessageIfRequested, runSsoCheckHandshake, withXMaPerm, xMaResource };
1259
+ export type { AiSseEvent, ApprovalDashboardDto, ApprovalDocumentDto, ApprovalDocumentSummaryDto, ApprovalHistoryDto, ApprovalReferenceDto, ApprovalStepDto, ApprovalStepRequest, ApprovalSubmitResult, ApprovalTemplateDto, ApprovalTemplateStepDto, ApprovalTemplateSummaryDto, ApproveRejectRequest, AvatarFrameDef, AvatarShape, AvatarSize, ChatBubble, ChatToolEvent, ClientTool, ClientToolSchema, CreateApprovalRequest, CreateApprovalResponseDto, CreateApprovalTemplateRequest, DelegateRequest, FrontEndRoute, IUser, MaUiManifest, MesAuthAiConfig, MesAuthConfig, NotificationDto, PagedList, PendingApproval, PermissionHeader, RealTimeNotificationDto, RequestConfig, RolePreviewUserDto, StepRoleDto, Theme, Toast, UpdateApprovalTemplateRequest, UserFrontEndRoutesGrouped };