@posiwise/shared-components 0.0.158 → 0.0.159

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/shared-components",
3
- "version": "0.0.158",
3
+ "version": "0.0.159",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.2.6",
6
6
  "@angular/core": "^21.2.6",
@@ -11,11 +11,13 @@ import { DomSanitizer } from '@angular/platform-browser';
11
11
  import { AdminService } from '@posiwise/admin-module-utils';
12
12
  import { User, Subscription } from '@posiwise/common-utilities';
13
13
  import { AppConfigService } from '@posiwise/app-config-service';
14
- import { AuthService, McpToolDefinition, McpJsonRpcService, GroupService, SubscriptionService, DataService, NumberPickerService, UserService, PermissionService } from '@posiwise/common-services';
14
+ import { AuthService, MCPFieldDiff, MCPOrchestratorService, LocalStorage, GroupService, SubscriptionService, DataService, NumberPickerService, UserService, PermissionService } from '@posiwise/common-services';
15
15
  import * as rxjs from 'rxjs';
16
16
  import { Observable } from 'rxjs';
17
17
  import * as i24 from '@angular/router';
18
18
  import { Router } from '@angular/router';
19
+ import { AppState } from '@posiwise/app-store';
20
+ import { Store } from '@ngrx/store';
19
21
  import * as i4 from '@angular/forms';
20
22
  import { UntypedFormGroup, UntypedFormBuilder, AbstractControl, ControlContainer } from '@angular/forms';
21
23
  import * as i5 from '@posiwise/app-loader';
@@ -377,34 +379,58 @@ declare class CollapsibleSidebarComponent implements OnInit, AfterViewInit, OnDe
377
379
  static ngAcceptInputType_embedInLayout: unknown;
378
380
  }
379
381
 
382
+ interface DiffRow {
383
+ field: string;
384
+ before: string;
385
+ after: string;
386
+ }
387
+ declare function diffRowsFrom(diff?: MCPFieldDiff | null): DiffRow[];
388
+
389
+ /**
390
+ * PosiWise Brain chat panel. Posts user text to brain-api's MCP
391
+ * orchestrator (/v1/mcp/execute, /confirm). Ticket #4167: thread +
392
+ * `conversation_id` are persisted per-user in localStorage so closing
393
+ * and reopening restores the conversation. Stale confirmation cards are
394
+ * stripped on hydrate (server tokens are TTL-bound).
395
+ */
396
+ type ChatMessageRole = 'user' | 'assistant';
397
+ interface PendingConfirmation {
398
+ confirmation_token: string;
399
+ risk_level?: string | null;
400
+ summary?: string | null;
401
+ target_service?: string | null;
402
+ target_tool?: string | null;
403
+ diff?: MCPFieldDiff | null;
404
+ }
405
+ interface ChatMessage {
406
+ role: ChatMessageRole;
407
+ text: string;
408
+ pending?: PendingConfirmation;
409
+ }
380
410
  declare class PwBrainChatComponent implements OnInit, OnDestroy {
381
- private readonly mcp;
411
+ private readonly orchestrator;
412
+ private readonly localStorage;
382
413
  private readonly router;
383
414
  private readonly cdr;
384
- messages: {
385
- role: 'user' | 'assistant';
386
- text: string;
387
- }[];
415
+ private readonly store;
416
+ messages: ChatMessage[];
388
417
  draft: string;
389
418
  loading: boolean;
390
- tools: McpToolDefinition[];
419
+ private conversationId;
420
+ private storage;
391
421
  private readonly destroy$;
392
- constructor(mcp: McpJsonRpcService, router: Router, cdr: ChangeDetectorRef);
422
+ readonly diffRows: typeof diffRowsFrom;
423
+ constructor(orchestrator: MCPOrchestratorService, localStorage: LocalStorage, router: Router, cdr: ChangeDetectorRef, store: Store<AppState>);
393
424
  ngOnInit(): void;
394
425
  ngOnDestroy(): void;
395
426
  send(): void;
396
- trackByIndex(index: number, _item: {
397
- role: string;
398
- text: string;
399
- }): number;
400
- private buildWelcome;
401
- private buildHelpReply;
402
- private resolveToolName;
403
- private applyToolResult;
404
- /** Mitigate open redirects: only same-origin absolute URLs. */
405
- private isAllowedExternalNavigationUrl;
406
- /** Block protocol-relative and pseudo-scheme paths passed to Router. */
407
- private isSafeAppRelativePath;
427
+ approve(message: ChatMessage): void;
428
+ cancel(message: ChatMessage): void;
429
+ trackByIndex(index: number, _item: ChatMessage): number;
430
+ private handleExecuteResponse;
431
+ private applySuccessResult;
432
+ private handleError;
433
+ private persistConversationId;
408
434
  private pushAssistant;
409
435
  static ɵfac: i0.ɵɵFactoryDeclaration<PwBrainChatComponent, never>;
410
436
  static ɵcmp: i0.ɵɵComponentDeclaration<PwBrainChatComponent, "pw-brain-chat", never, {}, {}, never, never, false, never>;