@posiwise/common-services 0.2.24 → 0.2.26

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": "@posiwise/common-services",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.2.6",
6
6
  "@angular/core": "^21.2.6",
@@ -74,6 +74,7 @@ declare abstract class BaseHttpService {
74
74
  private readonly toast;
75
75
  abstract getConfig(): void;
76
76
  constructor(http: HttpClient, injector: Injector);
77
+ private buildUrl;
77
78
  get<T>(url: any): Observable<any>;
78
79
  getWithParams<T>(url: any, params: any): Observable<any>;
79
80
  post<T>(url: any, params?: {}): Observable<any>;
@@ -448,9 +449,6 @@ declare class SecureTokenStorageService {
448
449
  * Get cookie value
449
450
  */
450
451
  private getCookieValue;
451
- /**
452
- * Delete cookie
453
- */
454
452
  private deleteCookie;
455
453
  /**
456
454
  * Initialize tokens from storage on service startup
@@ -590,6 +588,13 @@ declare class AuthService {
590
588
  storeToken(token: string): rxjs.Observable<boolean>;
591
589
  storePlatform(plat: string): rxjs.Observable<void>;
592
590
  logout(): rxjs.Observable<any>;
591
+ /**
592
+ * Wipe every `pw-brain.*` localStorage key on logout so the next user
593
+ * on a shared browser doesn't inherit the previous user's chat thread
594
+ * (ticket #4167). Best-effort: private-browsing / quota throws are
595
+ * swallowed so logout never breaks.
596
+ */
597
+ private clearBrainChatStorage;
593
598
  /**
594
599
  * Clear all authentication tokens
595
600
  */
@@ -738,7 +743,7 @@ declare class SubscriptionService {
738
743
  getEnrolledSubscription(id: number, paging?: Paging): rxjs.Observable<any>;
739
744
  removeEnrolledSubscription(id: number, user_id: number): rxjs.Observable<any>;
740
745
  toggleAdmin(id: number, data: any): rxjs.Observable<any>;
741
- updateSubscriptionAPIKey(id: number): rxjs.Observable<any>;
746
+ updateSubscriptionAPIKey(id: number, productId: number): rxjs.Observable<any>;
742
747
  refreshApiTokens(id: number): rxjs.Observable<any>;
743
748
  addFullLogo(id: number, data: any): rxjs.Observable<any>;
744
749
  addSquaredLogo(id: number, data: any): rxjs.Observable<any>;
@@ -808,6 +813,7 @@ declare class AhoyService {
808
813
  private readonly ahoy;
809
814
  private readonly toast;
810
815
  constructor(http: HttpClient, injector: Injector);
816
+ private buildUrl;
811
817
  getAhoyEvents(params: RequestParams, service: any, paging: Paging): Observable<AhoyEventResponse>;
812
818
  getAhoyMessages(params: RequestParams, service: any, paging: Paging): Observable<AhoyMessageResponse>;
813
819
  getAhoyVisits(params: RequestParams, service: any, paging: Paging): Observable<AhoyVisitResponse>;
@@ -1027,6 +1033,116 @@ declare class McpJsonRpcService {
1027
1033
  static ɵprov: i0.ɵɵInjectableDeclaration<McpJsonRpcService>;
1028
1034
  }
1029
1035
 
1036
+ /**
1037
+ * Posiwise Brain MCP orchestrator client (ticket #36).
1038
+ *
1039
+ * Wraps `POST /brain-api/v1/mcp/{execute,interpret,confirm}`. Frees the chat
1040
+ * UI from JSON-RPC plumbing and the `McpJsonRpcService` direct-to-main-api
1041
+ * pattern, which bypasses Bedrock interpretation + the per-user allowlist.
1042
+ *
1043
+ * Auth: the orchestrator authenticates user requests by calling main-api's
1044
+ * `/api/auth/token` from server side. The frontend MUST forward the three
1045
+ * user-token headers (`x-api-user-token`, `x-api-user-id`, `x-api-client-id`)
1046
+ * so the orchestrator can identify the caller. The platform's
1047
+ * `CustomAuthInterceptor` does NOT set these — it sets `Authorization:
1048
+ * pw-gateway` + `x-auth-token` — so we attach them explicitly per request,
1049
+ * mirroring `McpJsonRpcService.pickApiCredentials`.
1050
+ *
1051
+ * Conversation continuity: every response echoes a `conversation_id`. The
1052
+ * UI persists it in localStorage and replays it on subsequent calls so
1053
+ * Bedrock keeps chat context across the three endpoints.
1054
+ */
1055
+ interface MCPExecuteRequest {
1056
+ message: string;
1057
+ workspace_context?: Record<string, unknown>;
1058
+ conversation_id?: string;
1059
+ }
1060
+ type MCPInterpretRequest = MCPExecuteRequest;
1061
+ interface MCPConfirmRequest {
1062
+ confirmation_token: string;
1063
+ idempotency_key?: string;
1064
+ tool_arguments?: Record<string, unknown>;
1065
+ conversation_id?: string;
1066
+ }
1067
+ type MCPRiskLevel = 'low' | 'medium' | 'high' | 'critical';
1068
+ type MCPResultStatus = 'success' | 'error' | 'blocked';
1069
+ interface MCPActionPlan {
1070
+ intent: string;
1071
+ target_service: string;
1072
+ target_tool: string;
1073
+ tool_arguments: Record<string, unknown>;
1074
+ risk_level: MCPRiskLevel;
1075
+ needs_confirmation: boolean;
1076
+ summary?: string | null;
1077
+ }
1078
+ interface MCPFieldDiff {
1079
+ [field: string]: {
1080
+ before: unknown;
1081
+ after: unknown;
1082
+ };
1083
+ }
1084
+ interface MCPExecuteResponse {
1085
+ request_id: string;
1086
+ result_status: MCPResultStatus;
1087
+ needs_confirmation: boolean;
1088
+ confirmation_token?: string | null;
1089
+ risk_level?: MCPRiskLevel | null;
1090
+ summary?: string | null;
1091
+ response?: string | null;
1092
+ tool_result?: Record<string, unknown> | null;
1093
+ interpreted_intent?: string | null;
1094
+ target_service?: string | null;
1095
+ target_tool?: string | null;
1096
+ reason?: string | null;
1097
+ conversation_id?: string | null;
1098
+ diff?: MCPFieldDiff | null;
1099
+ }
1100
+ interface MCPInterpretResponse {
1101
+ request_id: string;
1102
+ plan: MCPActionPlan | null;
1103
+ allowlist_match: boolean;
1104
+ reason_blocked?: string | null;
1105
+ conversation_id?: string | null;
1106
+ }
1107
+ declare class MCPOrchestratorService {
1108
+ private readonly http;
1109
+ private readonly appConfigService;
1110
+ private readonly store;
1111
+ /**
1112
+ * Dev base — `BRAIN_API_PREFIX` = '/brain-api/v1/'. In prod the
1113
+ * orchestrator is reached via the API-gateway public hostname; we read
1114
+ * it from `links.brain_api` in app config (same convention as
1115
+ * `BrainApiHttpService`).
1116
+ */
1117
+ constructor(http: HttpClient, appConfigService: AppConfigService, store: Store<AppState>);
1118
+ execute(body: MCPExecuteRequest): Observable<MCPExecuteResponse>;
1119
+ interpret(body: MCPInterpretRequest): Observable<MCPInterpretResponse>;
1120
+ confirm(body: MCPConfirmRequest): Observable<MCPExecuteResponse>;
1121
+ private post;
1122
+ /**
1123
+ * Pull `(token, userId, clientId?)` for the active session.
1124
+ *
1125
+ * `clientId` comes from `PermissionService.selectedSubscription` — the
1126
+ * canonical "currently-active subscription" on this frontend, set when
1127
+ * the user picks/lands on a subscription. Every other place in the
1128
+ * codebase that needs subscription context (mailbox, chatbox, search,
1129
+ * dashboard, admin lists) reads from the same static. Without it,
1130
+ * downstream MCP tools that require subscription scope (e.g.
1131
+ * `cloudolive-api.count_reconciled_account_inputs`) reject the call
1132
+ * with `McpError: This tool requires subscription context. Please
1133
+ * provide api_client_id parameter`.
1134
+ *
1135
+ * `api_client_id` does NOT live on the `User` interface — it's a
1136
+ * property of `Subscription` (`subscription.interface.ts`). Reading
1137
+ * from the user object would always return `undefined` and silently
1138
+ * drop the header.
1139
+ */
1140
+ private pickApiCredentials;
1141
+ private buildHeaders;
1142
+ static ɵfac: i0.ɵɵFactoryDeclaration<MCPOrchestratorService, never>;
1143
+ static ɵprov: i0.ɵɵInjectableDeclaration<MCPOrchestratorService>;
1144
+ }
1145
+
1030
1146
  declare class WebsocketService {
1031
1147
  private readonly appConfigService;
1032
1148
  private readonly authService;
@@ -1217,5 +1333,5 @@ declare class BrainApiService {
1217
1333
  static ɵprov: i0.ɵɵInjectableDeclaration<BrainApiService>;
1218
1334
  }
1219
1335
 
1220
- export { AbTestService, AhoyService, AuthService, BaseHttpService, BrainApiHttpService, BrainApiService, CommonService, CommonServicesModule, CustomPreloadingStrategy, CustomToastService, DashboardService, DataService, FeatureFlagService, FormHelperService, GeoService, GoogleAnalyticsService, GroupService, HopscotchService, IntegrationsApiHttpService, LinkService, LocalStorage, LogoCacheService, MailBoxService, MainApiHttpService, McpJsonRpcService, NgbDateCustomParserFormatter, NotificationService, NumberPickerService, PermissionService, PrimeNgHelper, ProductService, ProfileService, QualificationService, ScriptLoaderService, SecureTokenStorageService, SentryErrorHandler, SeoService, SubscriptionService, TagService, TipsService, UserEffects, UserService, ValidationService, WebsocketService, WindowService };
1221
- export type { McpJsonRpcError, McpJsonRpcRequest, McpJsonRpcResponse, McpToolDefinition, McpToolsListResult };
1336
+ export { AbTestService, AhoyService, AuthService, BaseHttpService, BrainApiHttpService, BrainApiService, CommonService, CommonServicesModule, CustomPreloadingStrategy, CustomToastService, DashboardService, DataService, FeatureFlagService, FormHelperService, GeoService, GoogleAnalyticsService, GroupService, HopscotchService, IntegrationsApiHttpService, LinkService, LocalStorage, LogoCacheService, MCPOrchestratorService, MailBoxService, MainApiHttpService, McpJsonRpcService, NgbDateCustomParserFormatter, NotificationService, NumberPickerService, PermissionService, PrimeNgHelper, ProductService, ProfileService, QualificationService, ScriptLoaderService, SecureTokenStorageService, SentryErrorHandler, SeoService, SubscriptionService, TagService, TipsService, UserEffects, UserService, ValidationService, WebsocketService, WindowService };
1337
+ export type { MCPActionPlan, MCPConfirmRequest, MCPExecuteRequest, MCPExecuteResponse, MCPFieldDiff, MCPInterpretRequest, MCPInterpretResponse, MCPResultStatus, MCPRiskLevel, McpJsonRpcError, McpJsonRpcRequest, McpJsonRpcResponse, McpToolDefinition, McpToolsListResult };