@prbe.ai/electron-sdk 0.1.18 → 0.1.21

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.
@@ -9,7 +9,8 @@ import { EventEmitter } from 'events';
9
9
  declare enum InteractionType {
10
10
  ASK_QUESTION = "ask_question",
11
11
  REQUEST_PERMISSION = "request_permission",
12
- REQUEST_PATH_ACCESS = "request_path_access"
12
+ REQUEST_PATH_ACCESS = "request_path_access",
13
+ REVIEW_SANITIZED_OUTPUT = "review_sanitized_output"
13
14
  }
14
15
  interface AskQuestionPayload {
15
16
  type: InteractionType.ASK_QUESTION;
@@ -30,7 +31,19 @@ interface RequestPathAccessPayload {
30
31
  path: string;
31
32
  reason: string;
32
33
  }
33
- type InteractionPayload = AskQuestionPayload | RequestPermissionPayload | RequestPathAccessPayload;
34
+ interface SanitizedFileRef {
35
+ key: string;
36
+ url: string;
37
+ }
38
+ interface ReviewSanitizedOutputPayload {
39
+ type: InteractionType.REVIEW_SANITIZED_OUTPUT;
40
+ interactionId: string;
41
+ sanitizedAnalysis: string;
42
+ files: SanitizedFileRef[];
43
+ summary: string;
44
+ issues: SanitizationIssue[];
45
+ }
46
+ type InteractionPayload = AskQuestionPayload | RequestPermissionPayload | RequestPathAccessPayload | ReviewSanitizedOutputPayload;
34
47
  interface AskQuestionResponse {
35
48
  type: InteractionType.ASK_QUESTION;
36
49
  answer: string;
@@ -43,7 +56,12 @@ interface RequestPathAccessResponse {
43
56
  type: InteractionType.REQUEST_PATH_ACCESS;
44
57
  granted: boolean;
45
58
  }
46
- type InteractionResponse = AskQuestionResponse | RequestPermissionResponse | RequestPathAccessResponse;
59
+ interface ReviewSanitizedOutputResponse {
60
+ type: InteractionType.REVIEW_SANITIZED_OUTPUT;
61
+ approved: boolean;
62
+ editedText?: string;
63
+ }
64
+ type InteractionResponse = AskQuestionResponse | RequestPermissionResponse | RequestPathAccessResponse | ReviewSanitizedOutputResponse;
47
65
  declare enum InvestigationSource {
48
66
  USER = "user",
49
67
  CONTEXT_REQUEST = "context_request",
@@ -51,7 +69,7 @@ declare enum InvestigationSource {
51
69
  }
52
70
  interface PRBEInteractionRequester {
53
71
  requestUserInteraction(payload: InteractionPayload): Promise<InteractionResponse>;
54
- sendConversationMessage(content: string): void;
72
+ sendConversationMessage(content: string, role?: ConversationRole, label?: string): void;
55
73
  readonly investigationSource: InvestigationSource;
56
74
  }
57
75
  interface PRBEInteractionHandler {
@@ -86,7 +104,10 @@ declare enum WSMessageType {
86
104
  CONVERSATION_UPDATE = "conversation_update",
87
105
  COMPLETE = "complete",
88
106
  ERROR = "error",
89
- PING = "ping"
107
+ PING = "ping",
108
+ PRIVACY_SANITIZING = "privacy_sanitizing",
109
+ PRIVACY_REVIEW = "privacy_review",
110
+ PRIVACY_REVIEW_RESPONSE = "privacy_review_response"
90
111
  }
91
112
  declare enum ConversationRole {
92
113
  User = "user",
@@ -135,7 +156,9 @@ declare enum ToolName {
135
156
  CLIENT_FLAG_APP_LOGS = "client_flag_app_logs",
136
157
  CLIENT_ASK_USER = "client_ask_user",
137
158
  CLIENT_BASH_EXECUTE = "client_bash_execute",
138
- CLIENT_MESSAGE_USER = "client_message_user"
159
+ CLIENT_MESSAGE_USER = "client_message_user",
160
+ SDK_MESSAGE_USER = "sdk_message_user",
161
+ SDK_ASK_USER = "sdk_ask_user"
139
162
  }
140
163
  declare enum UserIdentifierType {
141
164
  EMAIL = "email",
@@ -180,6 +203,19 @@ interface PRBEAgentConfig {
180
203
  /** Custom metadata included in every session submission (e.g. user profile, app version). */
181
204
  [PRBEAgentConfigKey.SESSION_METADATA]?: Record<string, unknown>;
182
205
  }
206
+ interface SanitizationIssue {
207
+ type: "pii" | "ngram_overlap" | "incomplete";
208
+ detail: string;
209
+ severity: "high" | "medium" | "low";
210
+ }
211
+ type SanitizedFileResult = {
212
+ isText: true;
213
+ content: string;
214
+ url: string;
215
+ } | {
216
+ isText: false;
217
+ url: string;
218
+ };
183
219
  declare enum PRBEAgentStatusType {
184
220
  STARTED = "started",
185
221
  THINKING = "thinking",
@@ -188,7 +224,8 @@ declare enum PRBEAgentStatusType {
188
224
  OBSERVATION = "observation",
189
225
  COMPLETED = "completed",
190
226
  ERROR = "error",
191
- AWAITING_INTERACTION = "awaiting_interaction"
227
+ AWAITING_INTERACTION = "awaiting_interaction",
228
+ PRIVACY_SANITIZING = "privacy_sanitizing"
192
229
  }
193
230
  type PRBEAgentStatus = {
194
231
  type: PRBEAgentStatusType.STARTED;
@@ -214,6 +251,8 @@ type PRBEAgentStatus = {
214
251
  } | {
215
252
  type: PRBEAgentStatusType.AWAITING_INTERACTION;
216
253
  interactionPayload: InteractionPayload;
254
+ } | {
255
+ type: PRBEAgentStatusType.PRIVACY_SANITIZING;
217
256
  };
218
257
  interface InvestigationResult {
219
258
  report: string;
@@ -372,6 +411,7 @@ declare class PRBEAgentState extends EventEmitter {
372
411
  resolvedInteractions: ResolvedInteraction[];
373
412
  agentMessage?: string;
374
413
  conversationHistory: ConversationEntry[];
414
+ isPrivacySanitizing: boolean;
375
415
  completedInvestigations: PRBECompletedInvestigation[];
376
416
  activeBackgroundInvestigations: Map<string, PRBEBackgroundInvestigation>;
377
417
  completedBackgroundInvestigations: PRBEBackgroundInvestigation[];
@@ -389,6 +429,7 @@ declare class PRBEAgentState extends EventEmitter {
389
429
  attachObservation(text: string): void;
390
430
  completeInvestigation(report: string, ticketId?: string): void;
391
431
  failInvestigation(message: string): void;
432
+ setPrivacySanitizing(value: boolean): void;
392
433
  setPendingInteraction(payload: InteractionPayload): void;
393
434
  clearPendingInteraction(): void;
394
435
  setBackgroundPendingInteraction(backgroundId: string, payload: InteractionPayload): void;
@@ -449,6 +490,7 @@ interface PRBESerializedCompletedInvestigation {
449
490
  }
450
491
  interface PRBESerializedState {
451
492
  isInvestigating: boolean;
493
+ isPrivacySanitizing: boolean;
452
494
  events: PRBEStatusEvent[];
453
495
  report: string;
454
496
  summary?: string;
@@ -468,4 +510,4 @@ interface PRBESerializedState {
468
510
  declare const DEFAULT_PRBE_STATE: PRBESerializedState;
469
511
  declare function serializePRBEState(state: PRBEAgentState): PRBESerializedState;
470
512
 
471
- export { type AgentHistoryResponse as A, type PRBESerializedCompletedInvestigation as B, type ContextRequestOut as C, DEFAULT_PRBE_STATE as D, type ExternalRequestOut as E, type FlaggedFileIn as F, type PRBESerializedState as G, type PRBESerializedTicket as H, InvestigationSource as I, PRBEStateEvent as J, type PRBEStatusEvent as K, type PollRequest as L, MIDDLEWARE_URL as M, type RequestPathAccessResponse as N, type RequestPermissionPayload as O, type PRBEToolDeclaration as P, type RequestPermissionResponse as Q, type RequestPathAccessPayload as R, type ResolvedInteraction as S, type TicketInfoOut as T, UserIdentifierType as U, ToolName as V, ToolParamType as W, type WSMessage as X, WSMessageType as Y, redactPII as Z, serializePRBEState as _, type PRBEToolParameter as a, type PRBEInteractionRequester as b, PRBEAgentState as c, type PRBEAgentConfig as d, type InteractionPayload as e, type InteractionResponse as f, type PollResponse as g, API_URL as h, type AgentHistoryRequest as i, type AgentSessionOut as j, type AgentTicketOut as k, type AskQuestionPayload as l, type AskQuestionResponse as m, type ConversationEntry as n, ConversationRole as o, InteractionType as p, type InvestigationResult as q, PRBEAgentConfigKey as r, PRBEAgentError as s, PRBEAgentErrorType as t, type PRBEAgentStatus as u, PRBEAgentStatusType as v, type PRBEBackgroundInvestigation as w, type PRBECompletedInvestigation as x, type PRBEInteractionHandler as y, type PRBESerializedBackgroundInvestigation as z };
513
+ export { ToolParamType as $, type AgentHistoryResponse as A, type PRBESerializedCompletedInvestigation as B, ConversationRole as C, DEFAULT_PRBE_STATE as D, type ExternalRequestOut as E, type FlaggedFileIn as F, type PRBESerializedState as G, type PRBESerializedTicket as H, InvestigationSource as I, PRBEStateEvent as J, type PRBEStatusEvent as K, type PollRequest as L, MIDDLEWARE_URL as M, type RequestPathAccessResponse as N, type RequestPermissionPayload as O, type PRBEToolDeclaration as P, type RequestPermissionResponse as Q, type RequestPathAccessPayload as R, type SanitizedFileResult as S, type ResolvedInteraction as T, UserIdentifierType as U, type ReviewSanitizedOutputPayload as V, type ReviewSanitizedOutputResponse as W, type SanitizationIssue as X, type SanitizedFileRef as Y, type TicketInfoOut as Z, ToolName as _, type PRBEToolParameter as a, type WSMessage as a0, WSMessageType as a1, redactPII as a2, serializePRBEState as a3, type PRBEInteractionRequester as b, PRBEAgentState as c, type PRBEAgentConfig as d, type InteractionPayload as e, type InteractionResponse as f, type PollResponse as g, API_URL as h, type AgentHistoryRequest as i, type AgentSessionOut as j, type AgentTicketOut as k, type AskQuestionPayload as l, type AskQuestionResponse as m, type ContextRequestOut as n, type ConversationEntry as o, InteractionType as p, type InvestigationResult as q, PRBEAgentConfigKey as r, PRBEAgentError as s, PRBEAgentErrorType as t, type PRBEAgentStatus as u, PRBEAgentStatusType as v, type PRBEBackgroundInvestigation as w, type PRBECompletedInvestigation as x, type PRBEInteractionHandler as y, type PRBESerializedBackgroundInvestigation as z };
@@ -9,7 +9,8 @@ import { EventEmitter } from 'events';
9
9
  declare enum InteractionType {
10
10
  ASK_QUESTION = "ask_question",
11
11
  REQUEST_PERMISSION = "request_permission",
12
- REQUEST_PATH_ACCESS = "request_path_access"
12
+ REQUEST_PATH_ACCESS = "request_path_access",
13
+ REVIEW_SANITIZED_OUTPUT = "review_sanitized_output"
13
14
  }
14
15
  interface AskQuestionPayload {
15
16
  type: InteractionType.ASK_QUESTION;
@@ -30,7 +31,19 @@ interface RequestPathAccessPayload {
30
31
  path: string;
31
32
  reason: string;
32
33
  }
33
- type InteractionPayload = AskQuestionPayload | RequestPermissionPayload | RequestPathAccessPayload;
34
+ interface SanitizedFileRef {
35
+ key: string;
36
+ url: string;
37
+ }
38
+ interface ReviewSanitizedOutputPayload {
39
+ type: InteractionType.REVIEW_SANITIZED_OUTPUT;
40
+ interactionId: string;
41
+ sanitizedAnalysis: string;
42
+ files: SanitizedFileRef[];
43
+ summary: string;
44
+ issues: SanitizationIssue[];
45
+ }
46
+ type InteractionPayload = AskQuestionPayload | RequestPermissionPayload | RequestPathAccessPayload | ReviewSanitizedOutputPayload;
34
47
  interface AskQuestionResponse {
35
48
  type: InteractionType.ASK_QUESTION;
36
49
  answer: string;
@@ -43,7 +56,12 @@ interface RequestPathAccessResponse {
43
56
  type: InteractionType.REQUEST_PATH_ACCESS;
44
57
  granted: boolean;
45
58
  }
46
- type InteractionResponse = AskQuestionResponse | RequestPermissionResponse | RequestPathAccessResponse;
59
+ interface ReviewSanitizedOutputResponse {
60
+ type: InteractionType.REVIEW_SANITIZED_OUTPUT;
61
+ approved: boolean;
62
+ editedText?: string;
63
+ }
64
+ type InteractionResponse = AskQuestionResponse | RequestPermissionResponse | RequestPathAccessResponse | ReviewSanitizedOutputResponse;
47
65
  declare enum InvestigationSource {
48
66
  USER = "user",
49
67
  CONTEXT_REQUEST = "context_request",
@@ -51,7 +69,7 @@ declare enum InvestigationSource {
51
69
  }
52
70
  interface PRBEInteractionRequester {
53
71
  requestUserInteraction(payload: InteractionPayload): Promise<InteractionResponse>;
54
- sendConversationMessage(content: string): void;
72
+ sendConversationMessage(content: string, role?: ConversationRole, label?: string): void;
55
73
  readonly investigationSource: InvestigationSource;
56
74
  }
57
75
  interface PRBEInteractionHandler {
@@ -86,7 +104,10 @@ declare enum WSMessageType {
86
104
  CONVERSATION_UPDATE = "conversation_update",
87
105
  COMPLETE = "complete",
88
106
  ERROR = "error",
89
- PING = "ping"
107
+ PING = "ping",
108
+ PRIVACY_SANITIZING = "privacy_sanitizing",
109
+ PRIVACY_REVIEW = "privacy_review",
110
+ PRIVACY_REVIEW_RESPONSE = "privacy_review_response"
90
111
  }
91
112
  declare enum ConversationRole {
92
113
  User = "user",
@@ -135,7 +156,9 @@ declare enum ToolName {
135
156
  CLIENT_FLAG_APP_LOGS = "client_flag_app_logs",
136
157
  CLIENT_ASK_USER = "client_ask_user",
137
158
  CLIENT_BASH_EXECUTE = "client_bash_execute",
138
- CLIENT_MESSAGE_USER = "client_message_user"
159
+ CLIENT_MESSAGE_USER = "client_message_user",
160
+ SDK_MESSAGE_USER = "sdk_message_user",
161
+ SDK_ASK_USER = "sdk_ask_user"
139
162
  }
140
163
  declare enum UserIdentifierType {
141
164
  EMAIL = "email",
@@ -180,6 +203,19 @@ interface PRBEAgentConfig {
180
203
  /** Custom metadata included in every session submission (e.g. user profile, app version). */
181
204
  [PRBEAgentConfigKey.SESSION_METADATA]?: Record<string, unknown>;
182
205
  }
206
+ interface SanitizationIssue {
207
+ type: "pii" | "ngram_overlap" | "incomplete";
208
+ detail: string;
209
+ severity: "high" | "medium" | "low";
210
+ }
211
+ type SanitizedFileResult = {
212
+ isText: true;
213
+ content: string;
214
+ url: string;
215
+ } | {
216
+ isText: false;
217
+ url: string;
218
+ };
183
219
  declare enum PRBEAgentStatusType {
184
220
  STARTED = "started",
185
221
  THINKING = "thinking",
@@ -188,7 +224,8 @@ declare enum PRBEAgentStatusType {
188
224
  OBSERVATION = "observation",
189
225
  COMPLETED = "completed",
190
226
  ERROR = "error",
191
- AWAITING_INTERACTION = "awaiting_interaction"
227
+ AWAITING_INTERACTION = "awaiting_interaction",
228
+ PRIVACY_SANITIZING = "privacy_sanitizing"
192
229
  }
193
230
  type PRBEAgentStatus = {
194
231
  type: PRBEAgentStatusType.STARTED;
@@ -214,6 +251,8 @@ type PRBEAgentStatus = {
214
251
  } | {
215
252
  type: PRBEAgentStatusType.AWAITING_INTERACTION;
216
253
  interactionPayload: InteractionPayload;
254
+ } | {
255
+ type: PRBEAgentStatusType.PRIVACY_SANITIZING;
217
256
  };
218
257
  interface InvestigationResult {
219
258
  report: string;
@@ -372,6 +411,7 @@ declare class PRBEAgentState extends EventEmitter {
372
411
  resolvedInteractions: ResolvedInteraction[];
373
412
  agentMessage?: string;
374
413
  conversationHistory: ConversationEntry[];
414
+ isPrivacySanitizing: boolean;
375
415
  completedInvestigations: PRBECompletedInvestigation[];
376
416
  activeBackgroundInvestigations: Map<string, PRBEBackgroundInvestigation>;
377
417
  completedBackgroundInvestigations: PRBEBackgroundInvestigation[];
@@ -389,6 +429,7 @@ declare class PRBEAgentState extends EventEmitter {
389
429
  attachObservation(text: string): void;
390
430
  completeInvestigation(report: string, ticketId?: string): void;
391
431
  failInvestigation(message: string): void;
432
+ setPrivacySanitizing(value: boolean): void;
392
433
  setPendingInteraction(payload: InteractionPayload): void;
393
434
  clearPendingInteraction(): void;
394
435
  setBackgroundPendingInteraction(backgroundId: string, payload: InteractionPayload): void;
@@ -449,6 +490,7 @@ interface PRBESerializedCompletedInvestigation {
449
490
  }
450
491
  interface PRBESerializedState {
451
492
  isInvestigating: boolean;
493
+ isPrivacySanitizing: boolean;
452
494
  events: PRBEStatusEvent[];
453
495
  report: string;
454
496
  summary?: string;
@@ -468,4 +510,4 @@ interface PRBESerializedState {
468
510
  declare const DEFAULT_PRBE_STATE: PRBESerializedState;
469
511
  declare function serializePRBEState(state: PRBEAgentState): PRBESerializedState;
470
512
 
471
- export { type AgentHistoryResponse as A, type PRBESerializedCompletedInvestigation as B, type ContextRequestOut as C, DEFAULT_PRBE_STATE as D, type ExternalRequestOut as E, type FlaggedFileIn as F, type PRBESerializedState as G, type PRBESerializedTicket as H, InvestigationSource as I, PRBEStateEvent as J, type PRBEStatusEvent as K, type PollRequest as L, MIDDLEWARE_URL as M, type RequestPathAccessResponse as N, type RequestPermissionPayload as O, type PRBEToolDeclaration as P, type RequestPermissionResponse as Q, type RequestPathAccessPayload as R, type ResolvedInteraction as S, type TicketInfoOut as T, UserIdentifierType as U, ToolName as V, ToolParamType as W, type WSMessage as X, WSMessageType as Y, redactPII as Z, serializePRBEState as _, type PRBEToolParameter as a, type PRBEInteractionRequester as b, PRBEAgentState as c, type PRBEAgentConfig as d, type InteractionPayload as e, type InteractionResponse as f, type PollResponse as g, API_URL as h, type AgentHistoryRequest as i, type AgentSessionOut as j, type AgentTicketOut as k, type AskQuestionPayload as l, type AskQuestionResponse as m, type ConversationEntry as n, ConversationRole as o, InteractionType as p, type InvestigationResult as q, PRBEAgentConfigKey as r, PRBEAgentError as s, PRBEAgentErrorType as t, type PRBEAgentStatus as u, PRBEAgentStatusType as v, type PRBEBackgroundInvestigation as w, type PRBECompletedInvestigation as x, type PRBEInteractionHandler as y, type PRBESerializedBackgroundInvestigation as z };
513
+ export { ToolParamType as $, type AgentHistoryResponse as A, type PRBESerializedCompletedInvestigation as B, ConversationRole as C, DEFAULT_PRBE_STATE as D, type ExternalRequestOut as E, type FlaggedFileIn as F, type PRBESerializedState as G, type PRBESerializedTicket as H, InvestigationSource as I, PRBEStateEvent as J, type PRBEStatusEvent as K, type PollRequest as L, MIDDLEWARE_URL as M, type RequestPathAccessResponse as N, type RequestPermissionPayload as O, type PRBEToolDeclaration as P, type RequestPermissionResponse as Q, type RequestPathAccessPayload as R, type SanitizedFileResult as S, type ResolvedInteraction as T, UserIdentifierType as U, type ReviewSanitizedOutputPayload as V, type ReviewSanitizedOutputResponse as W, type SanitizationIssue as X, type SanitizedFileRef as Y, type TicketInfoOut as Z, ToolName as _, type PRBEToolParameter as a, type WSMessage as a0, WSMessageType as a1, redactPII as a2, serializePRBEState as a3, type PRBEInteractionRequester as b, PRBEAgentState as c, type PRBEAgentConfig as d, type InteractionPayload as e, type InteractionResponse as f, type PollResponse as g, API_URL as h, type AgentHistoryRequest as i, type AgentSessionOut as j, type AgentTicketOut as k, type AskQuestionPayload as l, type AskQuestionResponse as m, type ContextRequestOut as n, type ConversationEntry as o, InteractionType as p, type InvestigationResult as q, PRBEAgentConfigKey as r, PRBEAgentError as s, PRBEAgentErrorType as t, type PRBEAgentStatus as u, PRBEAgentStatusType as v, type PRBEBackgroundInvestigation as w, type PRBECompletedInvestigation as x, type PRBEInteractionHandler as y, type PRBESerializedBackgroundInvestigation as z };
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export { h as API_URL, i as AgentHistoryRequest, A as AgentHistoryResponse, j as AgentSessionOut, k as AgentTicketOut, l as AskQuestionPayload, m as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, E as ExternalRequestOut, F as FlaggedFileIn, e as InteractionPayload, f as InteractionResponse, p as InteractionType, q as InvestigationResult, M as MIDDLEWARE_URL, d as PRBEAgentConfig, r as PRBEAgentConfigKey, t as PRBEAgentErrorType, u as PRBEAgentStatus, v as PRBEAgentStatusType, w as PRBEBackgroundInvestigation, x as PRBECompletedInvestigation, y as PRBEInteractionHandler, b as PRBEInteractionRequester, z as PRBESerializedBackgroundInvestigation, B as PRBESerializedCompletedInvestigation, G as PRBESerializedState, H as PRBESerializedTicket, J as PRBEStateEvent, K as PRBEStatusEvent, P as PRBEToolDeclaration, a as PRBEToolParameter, L as PollRequest, g as PollResponse, R as RequestPathAccessPayload, N as RequestPathAccessResponse, O as RequestPermissionPayload, Q as RequestPermissionResponse, S as ResolvedInteraction, T as TicketInfoOut, V as ToolName, W as ToolParamType, X as WSMessage, Y as WSMessageType } from './types-BeZ2nQ9x.mjs';
1
+ export { h as API_URL, i as AgentHistoryRequest, A as AgentHistoryResponse, j as AgentSessionOut, k as AgentTicketOut, l as AskQuestionPayload, m as AskQuestionResponse, n as ContextRequestOut, D as DEFAULT_PRBE_STATE, E as ExternalRequestOut, F as FlaggedFileIn, e as InteractionPayload, f as InteractionResponse, p as InteractionType, q as InvestigationResult, M as MIDDLEWARE_URL, d as PRBEAgentConfig, r as PRBEAgentConfigKey, t as PRBEAgentErrorType, u as PRBEAgentStatus, v as PRBEAgentStatusType, w as PRBEBackgroundInvestigation, x as PRBECompletedInvestigation, y as PRBEInteractionHandler, b as PRBEInteractionRequester, z as PRBESerializedBackgroundInvestigation, B as PRBESerializedCompletedInvestigation, G as PRBESerializedState, H as PRBESerializedTicket, J as PRBEStateEvent, K as PRBEStatusEvent, P as PRBEToolDeclaration, a as PRBEToolParameter, L as PollRequest, g as PollResponse, R as RequestPathAccessPayload, N as RequestPathAccessResponse, O as RequestPermissionPayload, Q as RequestPermissionResponse, T as ResolvedInteraction, V as ReviewSanitizedOutputPayload, W as ReviewSanitizedOutputResponse, X as SanitizationIssue, Y as SanitizedFileRef, S as SanitizedFileResult, Z as TicketInfoOut, _ as ToolName, $ as ToolParamType, a0 as WSMessage, a1 as WSMessageType } from './types-CtT5RMCX.mjs';
2
2
  import 'events';
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { h as API_URL, i as AgentHistoryRequest, A as AgentHistoryResponse, j as AgentSessionOut, k as AgentTicketOut, l as AskQuestionPayload, m as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, E as ExternalRequestOut, F as FlaggedFileIn, e as InteractionPayload, f as InteractionResponse, p as InteractionType, q as InvestigationResult, M as MIDDLEWARE_URL, d as PRBEAgentConfig, r as PRBEAgentConfigKey, t as PRBEAgentErrorType, u as PRBEAgentStatus, v as PRBEAgentStatusType, w as PRBEBackgroundInvestigation, x as PRBECompletedInvestigation, y as PRBEInteractionHandler, b as PRBEInteractionRequester, z as PRBESerializedBackgroundInvestigation, B as PRBESerializedCompletedInvestigation, G as PRBESerializedState, H as PRBESerializedTicket, J as PRBEStateEvent, K as PRBEStatusEvent, P as PRBEToolDeclaration, a as PRBEToolParameter, L as PollRequest, g as PollResponse, R as RequestPathAccessPayload, N as RequestPathAccessResponse, O as RequestPermissionPayload, Q as RequestPermissionResponse, S as ResolvedInteraction, T as TicketInfoOut, V as ToolName, W as ToolParamType, X as WSMessage, Y as WSMessageType } from './types-BeZ2nQ9x.js';
1
+ export { h as API_URL, i as AgentHistoryRequest, A as AgentHistoryResponse, j as AgentSessionOut, k as AgentTicketOut, l as AskQuestionPayload, m as AskQuestionResponse, n as ContextRequestOut, D as DEFAULT_PRBE_STATE, E as ExternalRequestOut, F as FlaggedFileIn, e as InteractionPayload, f as InteractionResponse, p as InteractionType, q as InvestigationResult, M as MIDDLEWARE_URL, d as PRBEAgentConfig, r as PRBEAgentConfigKey, t as PRBEAgentErrorType, u as PRBEAgentStatus, v as PRBEAgentStatusType, w as PRBEBackgroundInvestigation, x as PRBECompletedInvestigation, y as PRBEInteractionHandler, b as PRBEInteractionRequester, z as PRBESerializedBackgroundInvestigation, B as PRBESerializedCompletedInvestigation, G as PRBESerializedState, H as PRBESerializedTicket, J as PRBEStateEvent, K as PRBEStatusEvent, P as PRBEToolDeclaration, a as PRBEToolParameter, L as PollRequest, g as PollResponse, R as RequestPathAccessPayload, N as RequestPathAccessResponse, O as RequestPermissionPayload, Q as RequestPermissionResponse, T as ResolvedInteraction, V as ReviewSanitizedOutputPayload, W as ReviewSanitizedOutputResponse, X as SanitizationIssue, Y as SanitizedFileRef, S as SanitizedFileResult, Z as TicketInfoOut, _ as ToolName, $ as ToolParamType, a0 as WSMessage, a1 as WSMessageType } from './types-CtT5RMCX.js';
2
2
  import 'events';
package/dist/types.js CHANGED
@@ -39,6 +39,7 @@ var InteractionType = /* @__PURE__ */ ((InteractionType2) => {
39
39
  InteractionType2["ASK_QUESTION"] = "ask_question";
40
40
  InteractionType2["REQUEST_PERMISSION"] = "request_permission";
41
41
  InteractionType2["REQUEST_PATH_ACCESS"] = "request_path_access";
42
+ InteractionType2["REVIEW_SANITIZED_OUTPUT"] = "review_sanitized_output";
42
43
  return InteractionType2;
43
44
  })(InteractionType || {});
44
45
 
@@ -60,6 +61,9 @@ var WSMessageType = /* @__PURE__ */ ((WSMessageType2) => {
60
61
  WSMessageType2["COMPLETE"] = "complete";
61
62
  WSMessageType2["ERROR"] = "error";
62
63
  WSMessageType2["PING"] = "ping";
64
+ WSMessageType2["PRIVACY_SANITIZING"] = "privacy_sanitizing";
65
+ WSMessageType2["PRIVACY_REVIEW"] = "privacy_review";
66
+ WSMessageType2["PRIVACY_REVIEW_RESPONSE"] = "privacy_review_response";
63
67
  return WSMessageType2;
64
68
  })(WSMessageType || {});
65
69
  var ToolParamType = /* @__PURE__ */ ((ToolParamType2) => {
@@ -81,6 +85,8 @@ var ToolName = /* @__PURE__ */ ((ToolName2) => {
81
85
  ToolName2["CLIENT_ASK_USER"] = "client_ask_user";
82
86
  ToolName2["CLIENT_BASH_EXECUTE"] = "client_bash_execute";
83
87
  ToolName2["CLIENT_MESSAGE_USER"] = "client_message_user";
88
+ ToolName2["SDK_MESSAGE_USER"] = "sdk_message_user";
89
+ ToolName2["SDK_ASK_USER"] = "sdk_ask_user";
84
90
  return ToolName2;
85
91
  })(ToolName || {});
86
92
  var PRBEAgentConfigKey = /* @__PURE__ */ ((PRBEAgentConfigKey2) => {
@@ -107,6 +113,7 @@ var PRBEAgentStatusType = /* @__PURE__ */ ((PRBEAgentStatusType2) => {
107
113
  PRBEAgentStatusType2["COMPLETED"] = "completed";
108
114
  PRBEAgentStatusType2["ERROR"] = "error";
109
115
  PRBEAgentStatusType2["AWAITING_INTERACTION"] = "awaiting_interaction";
116
+ PRBEAgentStatusType2["PRIVACY_SANITIZING"] = "privacy_sanitizing";
110
117
  return PRBEAgentStatusType2;
111
118
  })(PRBEAgentStatusType || {});
112
119
  var PRBEAgentErrorType = /* @__PURE__ */ ((PRBEAgentErrorType2) => {
@@ -122,6 +129,7 @@ var MIDDLEWARE_URL = "wss://middleware.prbe.ai";
122
129
  // src/serialization.ts
123
130
  var DEFAULT_PRBE_STATE = {
124
131
  isInvestigating: false,
132
+ isPrivacySanitizing: false,
125
133
  events: [],
126
134
  report: "",
127
135
  summary: "",
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts","../src/interactions.ts","../src/models.ts","../src/serialization.ts","../src/state.ts"],"sourcesContent":["/**\n * types.ts — Renderer-safe exports (no Node.js built-in imports)\n *\n * This entry point exports only interfaces, type aliases, enums, and\n * plain-object constants. It is safe to import from renderer/browser\n * code that cannot access Node.js modules like fs, path, child_process.\n *\n * Usage: import { ... } from \"@prbe/electron-sdk/types\"\n */\n\n// Interactions — enums + interfaces (no Node imports)\nexport {\n InteractionType,\n type AskQuestionPayload,\n type RequestPermissionPayload,\n type RequestPathAccessPayload,\n type InteractionPayload,\n type AskQuestionResponse,\n type RequestPermissionResponse,\n type RequestPathAccessResponse,\n type InteractionResponse,\n type PRBEInteractionRequester,\n type PRBEInteractionHandler,\n type ResolvedInteraction,\n} from \"./interactions\";\n\n// Models — enums + interfaces (no Node imports, no class exports)\nexport {\n WSMessageType,\n type WSMessage,\n ToolParamType,\n ToolName,\n type PRBEToolParameter,\n type PRBEToolDeclaration,\n PRBEAgentConfigKey,\n type PRBEAgentConfig,\n PRBEAgentStatusType,\n type PRBEAgentStatus,\n PRBEAgentErrorType,\n type PRBEStatusEvent,\n type PRBEBackgroundInvestigation,\n type PRBECompletedInvestigation,\n type FlaggedFileIn,\n type InvestigationResult,\n type PollRequest,\n type PollResponse,\n type ContextRequestOut,\n type ExternalRequestOut,\n type TicketInfoOut,\n type AgentHistoryRequest,\n type AgentSessionOut,\n type AgentTicketOut,\n type AgentHistoryResponse,\n API_URL,\n MIDDLEWARE_URL,\n} from \"./models\";\n\n// Serialization — interfaces + plain constants (no Node imports)\nexport {\n type PRBESerializedBackgroundInvestigation,\n type PRBESerializedTicket,\n type PRBESerializedCompletedInvestigation,\n type PRBESerializedState,\n DEFAULT_PRBE_STATE,\n} from \"./serialization\";\n\n// State events enum (no Node imports — just re-export the enum)\nexport { PRBEStateEvent } from \"./state\";\n","/**\n * interactions.ts — Types for user interaction during investigations\n *\n * Defines the contract between tools (which request interactions) and\n * host apps (which present UI and collect responses).\n */\n\n// ---------------------------------------------------------------------------\n// Interaction Types\n// ---------------------------------------------------------------------------\n\nexport enum InteractionType {\n ASK_QUESTION = \"ask_question\",\n REQUEST_PERMISSION = \"request_permission\",\n REQUEST_PATH_ACCESS = \"request_path_access\",\n}\n\n// ---------------------------------------------------------------------------\n// Payloads (tool → host)\n// ---------------------------------------------------------------------------\n\nexport interface AskQuestionPayload {\n type: InteractionType.ASK_QUESTION;\n interactionId: string;\n question: string;\n context?: string;\n}\n\nexport interface RequestPermissionPayload {\n type: InteractionType.REQUEST_PERMISSION;\n interactionId: string;\n action: string;\n command: string;\n reason?: string;\n}\n\nexport interface RequestPathAccessPayload {\n type: InteractionType.REQUEST_PATH_ACCESS;\n interactionId: string;\n path: string;\n reason: string;\n}\n\nexport type InteractionPayload =\n | AskQuestionPayload\n | RequestPermissionPayload\n | RequestPathAccessPayload;\n\n// ---------------------------------------------------------------------------\n// Responses (host → tool)\n// ---------------------------------------------------------------------------\n\nexport interface AskQuestionResponse {\n type: InteractionType.ASK_QUESTION;\n answer: string;\n}\n\nexport interface RequestPermissionResponse {\n type: InteractionType.REQUEST_PERMISSION;\n approved: boolean;\n}\n\nexport interface RequestPathAccessResponse {\n type: InteractionType.REQUEST_PATH_ACCESS;\n granted: boolean;\n}\n\nexport type InteractionResponse =\n | AskQuestionResponse\n | RequestPermissionResponse\n | RequestPathAccessResponse;\n\n// ---------------------------------------------------------------------------\n// Investigation source\n// ---------------------------------------------------------------------------\n\nexport enum InvestigationSource {\n USER = \"user\",\n CONTEXT_REQUEST = \"context_request\",\n EXTERNAL_REQUEST = \"external_request\",\n}\n\n// ---------------------------------------------------------------------------\n// Minimal requester interface (tools depend on this, not on PRBEAgent)\n// ---------------------------------------------------------------------------\n\nexport interface PRBEInteractionRequester {\n requestUserInteraction(payload: InteractionPayload): Promise<InteractionResponse>;\n sendConversationMessage(content: string): void;\n readonly investigationSource: InvestigationSource;\n}\n\n// ---------------------------------------------------------------------------\n// Handler interface (host app implements this)\n// ---------------------------------------------------------------------------\n\nexport interface PRBEInteractionHandler {\n handleInteraction(payload: InteractionPayload): Promise<InteractionResponse>;\n}\n\n// ---------------------------------------------------------------------------\n// Resolved interaction (question + response, for persistence)\n// ---------------------------------------------------------------------------\n\nexport interface ResolvedInteraction {\n interactionId: string;\n payload: InteractionPayload;\n response: InteractionResponse;\n /** Number of events at time of resolution — used to split thinking bubbles */\n eventIndex: number;\n}\n","/**\n * models.ts — WSMessage, WSMessageType, tool types, config, errors\n *\n * All types must match the Swift SDK + middleware protocol exactly.\n */\n\n// ---------------------------------------------------------------------------\n// WebSocket Message Types\n// ---------------------------------------------------------------------------\n\nexport enum WSMessageType {\n // SDK -> Middleware\n START = \"start\",\n TOOL_RESULT = \"tool_result\",\n UPLOAD_REQUEST = \"upload_request\",\n CONVERSATION_MESSAGE = \"conversation_message\",\n CANCEL = \"cancel\",\n PONG = \"pong\",\n // Middleware -> SDK\n THOUGHT = \"thought\",\n TOOL_CALL = \"tool_call\",\n SERVER_TOOL_CALL = \"server_tool_call\",\n SERVER_OBSERVATION = \"server_observation\",\n UPLOAD_URL = \"upload_url\",\n SESSION_CONFIG = \"session_config\",\n CONVERSATION_UPDATE = \"conversation_update\",\n COMPLETE = \"complete\",\n ERROR = \"error\",\n PING = \"ping\",\n}\n\n// ---------------------------------------------------------------------------\n// Conversation\n// ---------------------------------------------------------------------------\n\nexport enum ConversationRole {\n User = \"user\",\n Agent = \"agent\",\n}\n\nexport interface ConversationEntry {\n role: ConversationRole;\n content: string;\n label?: string;\n ts: string;\n}\n\n// ---------------------------------------------------------------------------\n// WebSocket Message\n// ---------------------------------------------------------------------------\n\nexport interface WSMessage {\n type: WSMessageType;\n id?: string;\n name?: string;\n content?: string;\n metadata?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Tool System\n// ---------------------------------------------------------------------------\n\nexport enum ToolParamType {\n STRING = \"STRING\",\n BOOLEAN = \"BOOLEAN\",\n INTEGER = \"INTEGER\",\n}\n\nexport interface PRBEToolParameter {\n name: string;\n type: ToolParamType;\n description: string;\n required: boolean;\n}\n\nexport interface PRBEToolDeclaration {\n name: string;\n description: string;\n parameters: PRBEToolParameter[];\n /** When true, the middleware uses a longer timeout for this tool (user interaction required). */\n interactive?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Tool Names (must match middleware exactly)\n// ---------------------------------------------------------------------------\n\nexport enum ToolName {\n CLIENT_LIST_DIRECTORY = \"client_list_directory\",\n CLIENT_READ_FILE = \"client_read_file\",\n CLIENT_SEARCH_CONTENT = \"client_search_content\",\n CLIENT_FIND_FILES = \"client_find_files\",\n CLIENT_FLAG_FILE = \"client_flag_file\",\n CLIENT_READ_APP_LOGS = \"client_read_app_logs\",\n CLIENT_SEARCH_APP_LOGS = \"client_search_app_logs\",\n CLIENT_CLEAR_APP_LOGS = \"client_clear_app_logs\",\n CLIENT_FLAG_APP_LOGS = \"client_flag_app_logs\",\n CLIENT_ASK_USER = \"client_ask_user\",\n CLIENT_BASH_EXECUTE = \"client_bash_execute\",\n CLIENT_MESSAGE_USER = \"client_message_user\",\n}\n\n// ---------------------------------------------------------------------------\n// User Identifier\n// ---------------------------------------------------------------------------\n\nexport enum UserIdentifierType {\n EMAIL = \"email\",\n ID = \"id\",\n}\n\n// ---------------------------------------------------------------------------\n// Agent Configuration\n// ---------------------------------------------------------------------------\n\nexport enum PRBEAgentConfigKey {\n API_KEY = \"apiKey\",\n AUTO_APPROVED_DIRS = \"autoApprovedDirs\",\n POLLING_INTERVAL = \"pollingInterval\",\n MAX_LOG_ENTRIES = \"maxLogEntries\",\n CAPTURE_CONSOLE = \"captureConsole\",\n BACKGROUND_POLLING = \"backgroundPolling\",\n INTERACTION_HANDLER = \"interactionHandler\",\n ELECTRON_LOG = \"electronLog\",\n IPC_MAIN = \"ipcMain\",\n RENDERER_LOG_CHANNEL = \"rendererLogChannel\",\n APP_DATA_PATH = \"appDataPath\",\n SESSION_METADATA = \"sessionMetadata\",\n}\n\nexport interface PRBEAgentConfig {\n [PRBEAgentConfigKey.API_KEY]: string;\n [PRBEAgentConfigKey.AUTO_APPROVED_DIRS]: string[];\n [PRBEAgentConfigKey.POLLING_INTERVAL]?: number; // ms, default 600_000 (10 min)\n [PRBEAgentConfigKey.MAX_LOG_ENTRIES]?: number; // default 10_000\n [PRBEAgentConfigKey.CAPTURE_CONSOLE]?: boolean; // default true\n [PRBEAgentConfigKey.BACKGROUND_POLLING]?: boolean; // default true\n [PRBEAgentConfigKey.INTERACTION_HANDLER]?: import(\"./interactions\").PRBEInteractionHandler;\n /** electron-log instance (v5) — SDK hooks into its transports to capture main-process logs */\n [PRBEAgentConfigKey.ELECTRON_LOG]?: { hooks: { push: (hook: (...args: any[]) => any) => void } };\n /** Electron ipcMain instance — SDK listens for renderer log forwarding */\n [PRBEAgentConfigKey.IPC_MAIN]?: { on: (channel: string, listener: (event: any, ...args: any[]) => void) => void };\n /** IPC channel name for renderer log forwarding (default: \"prbe-renderer-log\") */\n [PRBEAgentConfigKey.RENDERER_LOG_CHANNEL]?: string;\n /** Path to the application's data directory (e.g. Electron userData). Sent to the agent so it explores this directory first. */\n [PRBEAgentConfigKey.APP_DATA_PATH]?: string;\n /** Custom metadata included in every session submission (e.g. user profile, app version). */\n [PRBEAgentConfigKey.SESSION_METADATA]?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Agent Status\n// ---------------------------------------------------------------------------\n\nexport enum PRBEAgentStatusType {\n STARTED = \"started\",\n THINKING = \"thinking\",\n TOOL_CALL = \"tool_call\",\n THOUGHT = \"thought\",\n OBSERVATION = \"observation\",\n COMPLETED = \"completed\",\n ERROR = \"error\",\n AWAITING_INTERACTION = \"awaiting_interaction\",\n}\n\nexport type PRBEAgentStatus =\n | { type: PRBEAgentStatusType.STARTED }\n | { type: PRBEAgentStatusType.THINKING }\n | { type: PRBEAgentStatusType.TOOL_CALL; name: string; label: string }\n | { type: PRBEAgentStatusType.THOUGHT; text: string }\n | { type: PRBEAgentStatusType.OBSERVATION; text: string }\n | { type: PRBEAgentStatusType.COMPLETED; report: string; ticketId?: string }\n | { type: PRBEAgentStatusType.ERROR; message: string }\n | { type: PRBEAgentStatusType.AWAITING_INTERACTION; interactionPayload: import(\"./interactions\").InteractionPayload };\n\n// ---------------------------------------------------------------------------\n// Investigation Result (internal)\n// ---------------------------------------------------------------------------\n\nexport interface InvestigationResult {\n report: string;\n ticketId?: string;\n sessionId?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Flagged File (internal)\n// ---------------------------------------------------------------------------\n\nexport interface FlaggedFileIn {\n originalPath: string;\n reason?: string;\n data: Buffer;\n isText: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Poll Endpoint\n// ---------------------------------------------------------------------------\n\nexport interface PollRequest {\n agent_id: string;\n}\n\nexport interface ContextRequestOut {\n id: string;\n query: string;\n slug?: string;\n ticket_id: string;\n is_active: boolean;\n created_at: string;\n}\n\nexport interface ExternalRequestOut {\n id: string;\n query: string;\n source: string;\n source_detail?: string;\n is_active: boolean;\n created_at: string;\n}\n\nexport interface PollResponse {\n context_requests: ContextRequestOut[];\n external_requests: ExternalRequestOut[];\n}\n\n// ---------------------------------------------------------------------------\n// Ticket Info (used by state for UI display)\n// ---------------------------------------------------------------------------\n\nexport interface TicketInfoOut {\n ticket_id: string;\n title: string;\n status: string;\n priority?: string;\n description?: string;\n session_count: number;\n}\n\n// ---------------------------------------------------------------------------\n// Agent History\n// ---------------------------------------------------------------------------\n\nexport interface AgentHistoryRequest {\n agent_id: string;\n}\n\nexport interface AgentSessionOut {\n session_id: string;\n title: string;\n status: string;\n context_summary?: string;\n created_at: string;\n}\n\nexport interface AgentTicketOut {\n ticket_id: string;\n title: string;\n status: string;\n priority?: string;\n sessions: AgentSessionOut[];\n}\n\nexport interface AgentHistoryResponse {\n tickets: AgentTicketOut[];\n}\n\n// ---------------------------------------------------------------------------\n// Status Events (for state tracking)\n// ---------------------------------------------------------------------------\n\nexport interface PRBEStatusEvent {\n id: string;\n label: string;\n detail?: string;\n isCompleted: boolean;\n isExpanded: boolean;\n}\n\nexport interface PRBEBackgroundInvestigation {\n id: string;\n query: string;\n slug?: string;\n ticketId?: string;\n source?: string;\n sourceDetail?: string;\n events: PRBEStatusEvent[];\n isRunning: boolean;\n isCompleted: boolean;\n isFailed: boolean;\n report: string;\n summary?: string;\n errorMessage?: string;\n agentMessage?: string;\n startedAt: Date;\n pendingInteraction?: import(\"./interactions\").InteractionPayload;\n resolvedInteractions?: import(\"./interactions\").ResolvedInteraction[];\n conversationHistory: ConversationEntry[];\n}\n\n// ---------------------------------------------------------------------------\n// Completed Investigation (persisted in state for history)\n// ---------------------------------------------------------------------------\n\nexport interface PRBECompletedInvestigation {\n id: string;\n query: string;\n report: string;\n summary?: string;\n ticketId?: string;\n events: PRBEStatusEvent[];\n resolvedInteractions: import(\"./interactions\").ResolvedInteraction[];\n conversationHistory?: ConversationEntry[];\n completedAt: Date;\n}\n\n// ---------------------------------------------------------------------------\n// Errors\n// ---------------------------------------------------------------------------\n\nexport enum PRBEAgentErrorType {\n SERVER_ERROR = \"server_error\",\n NETWORK_ERROR = \"network_error\",\n CANCELLED = \"cancelled\",\n MAX_ITERATIONS = \"max_iterations\",\n}\n\nexport class PRBEAgentError extends Error {\n public readonly errorType: PRBEAgentErrorType;\n public readonly statusCode?: number;\n\n constructor(errorType: PRBEAgentErrorType, message: string, statusCode?: number) {\n super(message);\n this.name = \"PRBEAgentError\";\n this.errorType = errorType;\n this.statusCode = statusCode;\n }\n}\n\n// ---------------------------------------------------------------------------\n// PII Redactor (pass-through stub, matches Swift SDK)\n// ---------------------------------------------------------------------------\n\nexport function redactPII(text: string): string {\n return text;\n}\n\n// ---------------------------------------------------------------------------\n// Static URLs\n// ---------------------------------------------------------------------------\n\nexport const API_URL = \"https://api.prbe.ai\";\nexport const MIDDLEWARE_URL = \"wss://middleware.prbe.ai\";\n","/**\n * serialization.ts — IPC-safe serialization of agent state\n *\n * Converts live PRBEAgentState (with Map, Date, EventEmitter) into\n * plain JSON-safe objects suitable for IPC or structured clone.\n */\n\nimport type { PRBEAgentState } from \"./state\";\nimport type {\n PRBEStatusEvent,\n PRBEBackgroundInvestigation,\n TicketInfoOut,\n AgentTicketOut,\n ConversationEntry,\n} from \"./models\";\nimport type { InteractionPayload, ResolvedInteraction } from \"./interactions\";\n\n// ---------------------------------------------------------------------------\n// Serialized Background Investigation (Date → ISO string, safe for IPC)\n// ---------------------------------------------------------------------------\n\nexport interface PRBESerializedBackgroundInvestigation {\n id: string;\n query: string;\n slug?: string;\n ticketId?: string;\n source?: string;\n sourceDetail?: string;\n events: PRBEStatusEvent[];\n isRunning: boolean;\n isCompleted: boolean;\n isFailed: boolean;\n report: string;\n summary?: string;\n errorMessage?: string;\n agentMessage?: string;\n startedAt: string; // ISO string\n pendingInteraction?: InteractionPayload;\n resolvedInteractions?: ResolvedInteraction[];\n conversationHistory: ConversationEntry[];\n}\n\n// ---------------------------------------------------------------------------\n// Serialized Ticket (pass-through — already plain)\n// ---------------------------------------------------------------------------\n\nexport type PRBESerializedTicket = TicketInfoOut;\n\n// ---------------------------------------------------------------------------\n// Serialized Completed Investigation (Date → ISO string)\n// ---------------------------------------------------------------------------\n\nexport interface PRBESerializedCompletedInvestigation {\n id: string;\n query: string;\n report: string;\n summary?: string;\n ticketId?: string;\n events: PRBEStatusEvent[];\n resolvedInteractions: ResolvedInteraction[];\n conversationHistory?: ConversationEntry[];\n completedAt: string; // ISO string\n}\n\n// ---------------------------------------------------------------------------\n// Full serialized state (no Map, Date, or EventEmitter)\n// ---------------------------------------------------------------------------\n\nexport interface PRBESerializedState {\n isInvestigating: boolean;\n events: PRBEStatusEvent[];\n report: string;\n summary?: string;\n currentQuery: string;\n investigationError?: string;\n pendingInteraction?: InteractionPayload;\n resolvedInteractions: ResolvedInteraction[];\n agentMessage?: string;\n conversationHistory: ConversationEntry[];\n completedInvestigations: PRBESerializedCompletedInvestigation[];\n activeBackgroundInvestigations: PRBESerializedBackgroundInvestigation[];\n completedBackgroundInvestigations: PRBESerializedBackgroundInvestigation[];\n ticketInfo: PRBESerializedTicket[];\n agentHistory: AgentTicketOut[];\n hasActiveWork: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Default state (used before agent initializes)\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_PRBE_STATE: PRBESerializedState = {\n isInvestigating: false,\n events: [],\n report: \"\",\n summary: \"\",\n currentQuery: \"\",\n resolvedInteractions: [],\n conversationHistory: [],\n completedInvestigations: [],\n activeBackgroundInvestigations: [],\n completedBackgroundInvestigations: [],\n ticketInfo: [],\n agentHistory: [],\n hasActiveWork: false,\n};\n\n// ---------------------------------------------------------------------------\n// Converter: live state → IPC-safe plain object\n// ---------------------------------------------------------------------------\n\nfunction serializeBackgroundInvestigation(bg: PRBEBackgroundInvestigation): PRBESerializedBackgroundInvestigation {\n return {\n id: bg.id,\n query: bg.query,\n slug: bg.slug,\n ticketId: bg.ticketId,\n source: bg.source,\n sourceDetail: bg.sourceDetail,\n events: bg.events,\n isRunning: bg.isRunning,\n isCompleted: bg.isCompleted,\n isFailed: bg.isFailed,\n report: bg.report,\n summary: bg.summary,\n errorMessage: bg.errorMessage,\n agentMessage: bg.agentMessage,\n startedAt: bg.startedAt.toISOString(),\n pendingInteraction: bg.pendingInteraction,\n resolvedInteractions: bg.resolvedInteractions ?? [],\n conversationHistory: bg.conversationHistory ?? [],\n };\n}\n\nexport function serializePRBEState(state: PRBEAgentState): PRBESerializedState {\n return {\n isInvestigating: state.isInvestigating,\n events: state.events,\n report: state.report,\n summary: state.summary,\n currentQuery: state.currentQuery,\n investigationError: state.investigationError,\n pendingInteraction: state.pendingInteraction,\n resolvedInteractions: state.resolvedInteractions,\n agentMessage: state.agentMessage,\n conversationHistory: state.conversationHistory,\n completedInvestigations: state.completedInvestigations.map((inv) => ({\n id: inv.id,\n query: inv.query,\n report: inv.report,\n summary: inv.summary,\n ticketId: inv.ticketId,\n events: inv.events,\n resolvedInteractions: inv.resolvedInteractions,\n conversationHistory: inv.conversationHistory,\n completedAt: inv.completedAt.toISOString(),\n })),\n activeBackgroundInvestigations: Array.from(state.activeBackgroundInvestigations.values()).map(serializeBackgroundInvestigation),\n completedBackgroundInvestigations: state.completedBackgroundInvestigations.map(serializeBackgroundInvestigation),\n ticketInfo: state.ticketInfo,\n agentHistory: state.agentHistory,\n hasActiveWork: state.hasActiveWork,\n };\n}\n","/**\n * state.ts — PRBEAgentState: EventEmitter-based observable investigation state\n *\n * Mirrors PRBEAgentState.swift but uses Node.js EventEmitter instead of Combine/@Published.\n * Host apps subscribe to events for UI updates.\n */\n\nimport { EventEmitter } from \"events\";\nimport { randomUUID } from \"crypto\";\nimport type {\n PRBEStatusEvent,\n PRBEBackgroundInvestigation,\n PRBECompletedInvestigation,\n TicketInfoOut,\n AgentTicketOut,\n ConversationEntry,\n} from \"./models\";\nimport type { InteractionPayload, InteractionResponse, ResolvedInteraction } from \"./interactions\";\n\n// ---------------------------------------------------------------------------\n// Event types emitted by PRBEAgentState\n// ---------------------------------------------------------------------------\n\nexport enum PRBEStateEvent {\n /** Emitted on any state change. Payload: void */\n STATUS = \"status\",\n /** Emitted when a new event is appended. Payload: PRBEStatusEvent */\n EVENT = \"event\",\n /** Emitted when investigation completes. Payload: { report: string } */\n COMPLETE = \"complete\",\n /** Emitted on error. Payload: { message: string } */\n ERROR = \"error\",\n /** Emitted when a background investigation starts. Payload: PRBEBackgroundInvestigation */\n BACKGROUND_START = \"background-start\",\n /** Emitted when a background investigation completes/fails. Payload: PRBEBackgroundInvestigation */\n BACKGROUND_COMPLETE = \"background-complete\",\n /** Emitted when tracked ticket IDs change. Payload: string[] */\n TICKETS_CHANGED = \"tickets-changed\",\n /** Emitted when ticket info is updated. Payload: TicketInfoOut[] */\n TICKET_INFO = \"ticket-info\",\n /** Emitted when an interaction is requested. Payload: InteractionPayload */\n INTERACTION_REQUESTED = \"interaction-requested\",\n /** Emitted when an interaction is resolved. Payload: void */\n INTERACTION_RESOLVED = \"interaction-resolved\",\n /** Emitted when the agent sends a message to the user. Payload: { message: string } */\n AGENT_MESSAGE = \"agent-message\",\n}\n\n// ---------------------------------------------------------------------------\n// PRBEAgentState\n// ---------------------------------------------------------------------------\n\nexport class PRBEAgentState extends EventEmitter {\n // User-initiated investigation\n public isInvestigating = false;\n public events: PRBEStatusEvent[] = [];\n public report = \"\";\n public summary = \"\";\n public currentQuery = \"\";\n public investigationError?: string;\n public pendingInteraction?: InteractionPayload;\n public resolvedInteractions: ResolvedInteraction[] = [];\n public agentMessage?: string;\n public conversationHistory: ConversationEntry[] = [];\n\n // Completed user investigations (history)\n public completedInvestigations: PRBECompletedInvestigation[] = [];\n\n // Background investigations (context requests, external requests, etc.)\n public activeBackgroundInvestigations: Map<string, PRBEBackgroundInvestigation> = new Map();\n public completedBackgroundInvestigations: PRBEBackgroundInvestigation[] = [];\n\n // Tracked tickets\n public trackedSessionIDs: string[] = [];\n public ticketInfo: TicketInfoOut[] = [];\n\n // Agent history\n public agentHistory: AgentTicketOut[] = [];\n\n // Computed\n get hasActiveWork(): boolean {\n return this.isInvestigating || this.activeBackgroundInvestigations.size > 0;\n }\n\n get activeBackgroundCount(): number {\n return this.activeBackgroundInvestigations.size;\n }\n\n get isActive(): boolean {\n return this.isInvestigating || this.report.length > 0 || this.investigationError != null;\n }\n\n // ---------- User investigation mutations ----------\n\n beginInvestigation(query: string): void {\n this.isInvestigating = true;\n this.events = [];\n this.resolvedInteractions = [];\n this.conversationHistory = [];\n this.report = \"\";\n this.summary = \"\";\n this.currentQuery = query;\n this.investigationError = undefined;\n this.agentMessage = undefined;\n this.emit(PRBEStateEvent.STATUS);\n }\n\n appendConversation(entry: ConversationEntry): void {\n this.conversationHistory.push(entry);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n appendBackgroundConversation(backgroundId: string, entry: ConversationEntry): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n bg.conversationHistory.push(entry);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n resetInvestigation(): void {\n this.isInvestigating = false;\n this.events = [];\n this.resolvedInteractions = [];\n this.conversationHistory = [];\n this.report = \"\";\n this.summary = \"\";\n this.currentQuery = \"\";\n this.investigationError = undefined;\n this.pendingInteraction = undefined;\n this.agentMessage = undefined;\n this.emit(PRBEStateEvent.STATUS);\n }\n\n appendEvent(label: string, detail?: string, completed = false): void {\n // Mark previous event as completed before adding new one\n if (this.events.length > 0) {\n const last = this.events[this.events.length - 1];\n if (!last.isCompleted && !completed) {\n last.isCompleted = true;\n }\n }\n const event: PRBEStatusEvent = {\n id: randomUUID(),\n label,\n detail,\n isCompleted: completed,\n isExpanded: false,\n };\n this.events.push(event);\n this.emit(PRBEStateEvent.EVENT, event);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n attachObservation(text: string): void {\n if (this.events.length > 0) {\n this.events[this.events.length - 1].detail = text;\n this.emit(PRBEStateEvent.STATUS);\n }\n }\n\n completeInvestigation(report: string, ticketId?: string): void {\n if (this.events.length > 0) {\n this.events[this.events.length - 1].isCompleted = true;\n }\n this.appendEvent(\"Done\", undefined, true);\n\n // Save to history (snapshot events + interactions before reset)\n this.completedInvestigations.unshift({\n id: randomUUID(),\n query: this.currentQuery,\n report,\n ticketId,\n events: [...this.events],\n resolvedInteractions: [...this.resolvedInteractions],\n conversationHistory: [...this.conversationHistory],\n completedAt: new Date(),\n });\n\n this.report = report;\n this.isInvestigating = false;\n this.emit(PRBEStateEvent.COMPLETE, { report });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n failInvestigation(message: string): void {\n this.appendEvent(`Error: ${message}`);\n this.investigationError = message;\n this.isInvestigating = false;\n this.emit(PRBEStateEvent.ERROR, { message });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n // ---------- Interaction state mutations ----------\n\n setPendingInteraction(payload: InteractionPayload): void {\n this.pendingInteraction = payload;\n this.emit(PRBEStateEvent.INTERACTION_REQUESTED, payload);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n clearPendingInteraction(): void {\n this.pendingInteraction = undefined;\n this.emit(PRBEStateEvent.INTERACTION_RESOLVED);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n setBackgroundPendingInteraction(backgroundId: string, payload: InteractionPayload): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n bg.pendingInteraction = payload;\n this.emit(PRBEStateEvent.INTERACTION_REQUESTED, payload);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n clearBackgroundPendingInteraction(backgroundId: string): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n bg.pendingInteraction = undefined;\n this.emit(PRBEStateEvent.INTERACTION_RESOLVED);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n resolveInteraction(response: InteractionResponse): void {\n if (!this.pendingInteraction) return;\n this.resolvedInteractions.push({\n interactionId: this.pendingInteraction.interactionId,\n payload: this.pendingInteraction,\n response,\n eventIndex: this.events.length,\n });\n this.pendingInteraction = undefined;\n this.emit(PRBEStateEvent.INTERACTION_RESOLVED);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n resolveBackgroundInteraction(backgroundId: string, response: InteractionResponse): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg || !bg.pendingInteraction) return;\n const resolved = bg.resolvedInteractions ?? [];\n resolved.push({\n interactionId: bg.pendingInteraction.interactionId,\n payload: bg.pendingInteraction,\n response,\n eventIndex: bg.events.length,\n });\n bg.resolvedInteractions = resolved;\n bg.pendingInteraction = undefined;\n this.emit(PRBEStateEvent.INTERACTION_RESOLVED);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n setAgentMessage(message: string): void {\n this.agentMessage = message;\n this.emit(PRBEStateEvent.AGENT_MESSAGE, { message });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n setBackgroundAgentMessage(backgroundId: string, message: string): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n bg.agentMessage = message;\n this.emit(PRBEStateEvent.AGENT_MESSAGE, { message });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n toggleExpansion(eventId: string): void {\n const event = this.events.find((e) => e.id === eventId);\n if (event) {\n event.isExpanded = !event.isExpanded;\n this.emit(PRBEStateEvent.STATUS);\n }\n }\n\n // ---------- Background investigation state mutations ----------\n\n beginBackgroundInvestigation(id: string, query: string, slug?: string, ticketId?: string, source?: string, sourceDetail?: string): void {\n const bg: PRBEBackgroundInvestigation = {\n id,\n query,\n slug,\n ticketId,\n source,\n sourceDetail,\n events: [],\n conversationHistory: [],\n resolvedInteractions: [],\n isRunning: true,\n isCompleted: false,\n isFailed: false,\n report: \"\",\n summary: \"\",\n startedAt: new Date(),\n };\n this.activeBackgroundInvestigations.set(id, bg);\n this.emit(PRBEStateEvent.BACKGROUND_START, bg);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n appendBackgroundEvent(backgroundId: string, label: string, detail?: string, completed = false): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n\n if (bg.events.length > 0) {\n const last = bg.events[bg.events.length - 1];\n if (!last.isCompleted && !completed) {\n last.isCompleted = true;\n }\n }\n bg.events.push({\n id: randomUUID(),\n label,\n detail,\n isCompleted: completed,\n isExpanded: false,\n });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n attachBackgroundObservation(backgroundId: string, text: string): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg || bg.events.length === 0) return;\n bg.events[bg.events.length - 1].detail = text;\n this.emit(PRBEStateEvent.STATUS);\n }\n\n completeBackgroundInvestigation(id: string, report: string): void {\n const bg = this.activeBackgroundInvestigations.get(id);\n if (!bg) return;\n\n this.activeBackgroundInvestigations.delete(id);\n if (bg.events.length > 0) {\n bg.events[bg.events.length - 1].isCompleted = true;\n }\n bg.events.push({\n id: randomUUID(),\n label: \"Done\",\n isCompleted: true,\n isExpanded: false,\n });\n bg.isRunning = false;\n bg.isCompleted = true;\n bg.report = report;\n this.completedBackgroundInvestigations.unshift(bg);\n this.emit(PRBEStateEvent.BACKGROUND_COMPLETE, bg);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n failBackgroundInvestigation(id: string, message: string): void {\n const bg = this.activeBackgroundInvestigations.get(id);\n if (!bg) return;\n\n this.activeBackgroundInvestigations.delete(id);\n bg.events.push({\n id: randomUUID(),\n label: `Error: ${message}`,\n isCompleted: false,\n isExpanded: false,\n });\n bg.isRunning = false;\n bg.isFailed = true;\n bg.errorMessage = message;\n this.completedBackgroundInvestigations.unshift(bg);\n this.emit(PRBEStateEvent.BACKGROUND_COMPLETE, bg);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n // ---------- Tickets ----------\n\n updateTrackedSessionIDs(ids: string[]): void {\n this.trackedSessionIDs = ids;\n this.emit(PRBEStateEvent.TICKETS_CHANGED, ids);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n updateTicketInfo(info: TicketInfoOut[]): void {\n this.ticketInfo = info;\n this.emit(PRBEStateEvent.TICKET_INFO, info);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n updateAgentHistory(tickets: AgentTicketOut[]): void {\n this.agentHistory = tickets;\n this.emit(PRBEStateEvent.STATUS);\n }\n}\n"],"mappings":"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","names":["InteractionType","WSMessageType","ToolParamType","ToolName","PRBEAgentConfigKey","PRBEAgentStatusType","PRBEAgentErrorType","PRBEStateEvent"]}
1
+ {"version":3,"sources":["../src/types.ts","../src/interactions.ts","../src/models.ts","../src/serialization.ts","../src/state.ts"],"sourcesContent":["/**\n * types.ts — Renderer-safe exports (no Node.js built-in imports)\n *\n * This entry point exports only interfaces, type aliases, enums, and\n * plain-object constants. It is safe to import from renderer/browser\n * code that cannot access Node.js modules like fs, path, child_process.\n *\n * Usage: import { ... } from \"@prbe/electron-sdk/types\"\n */\n\n// Interactions — enums + interfaces (no Node imports)\nexport {\n InteractionType,\n type AskQuestionPayload,\n type RequestPermissionPayload,\n type RequestPathAccessPayload,\n type InteractionPayload,\n type AskQuestionResponse,\n type RequestPermissionResponse,\n type RequestPathAccessResponse,\n type InteractionResponse,\n type SanitizedFileRef,\n type ReviewSanitizedOutputPayload,\n type ReviewSanitizedOutputResponse,\n type PRBEInteractionRequester,\n type PRBEInteractionHandler,\n type ResolvedInteraction,\n} from \"./interactions\";\n\n// Models — sanitization types (no Node imports)\nexport {\n type SanitizationIssue,\n type SanitizedFileResult,\n} from \"./models\";\n\n// Models — enums + interfaces (no Node imports, no class exports)\nexport {\n WSMessageType,\n type WSMessage,\n ToolParamType,\n ToolName,\n type PRBEToolParameter,\n type PRBEToolDeclaration,\n PRBEAgentConfigKey,\n type PRBEAgentConfig,\n PRBEAgentStatusType,\n type PRBEAgentStatus,\n PRBEAgentErrorType,\n type PRBEStatusEvent,\n type PRBEBackgroundInvestigation,\n type PRBECompletedInvestigation,\n type FlaggedFileIn,\n type InvestigationResult,\n type PollRequest,\n type PollResponse,\n type ContextRequestOut,\n type ExternalRequestOut,\n type TicketInfoOut,\n type AgentHistoryRequest,\n type AgentSessionOut,\n type AgentTicketOut,\n type AgentHistoryResponse,\n API_URL,\n MIDDLEWARE_URL,\n} from \"./models\";\n\n// Serialization — interfaces + plain constants (no Node imports)\nexport {\n type PRBESerializedBackgroundInvestigation,\n type PRBESerializedTicket,\n type PRBESerializedCompletedInvestigation,\n type PRBESerializedState,\n DEFAULT_PRBE_STATE,\n} from \"./serialization\";\n\n// State events enum (no Node imports — just re-export the enum)\nexport { PRBEStateEvent } from \"./state\";\n","/**\n * interactions.ts — Types for user interaction during investigations\n *\n * Defines the contract between tools (which request interactions) and\n * host apps (which present UI and collect responses).\n */\n\n// ---------------------------------------------------------------------------\n// Interaction Types\n// ---------------------------------------------------------------------------\n\nexport enum InteractionType {\n ASK_QUESTION = \"ask_question\",\n REQUEST_PERMISSION = \"request_permission\",\n REQUEST_PATH_ACCESS = \"request_path_access\",\n REVIEW_SANITIZED_OUTPUT = \"review_sanitized_output\",\n}\n\n// ---------------------------------------------------------------------------\n// Payloads (tool → host)\n// ---------------------------------------------------------------------------\n\nexport interface AskQuestionPayload {\n type: InteractionType.ASK_QUESTION;\n interactionId: string;\n question: string;\n context?: string;\n}\n\nexport interface RequestPermissionPayload {\n type: InteractionType.REQUEST_PERMISSION;\n interactionId: string;\n action: string;\n command: string;\n reason?: string;\n}\n\nexport interface RequestPathAccessPayload {\n type: InteractionType.REQUEST_PATH_ACCESS;\n interactionId: string;\n path: string;\n reason: string;\n}\n\nexport interface SanitizedFileRef {\n key: string;\n url: string;\n}\n\nexport interface ReviewSanitizedOutputPayload {\n type: InteractionType.REVIEW_SANITIZED_OUTPUT;\n interactionId: string;\n sanitizedAnalysis: string;\n files: SanitizedFileRef[];\n summary: string;\n issues: import(\"./models\").SanitizationIssue[];\n}\n\nexport type InteractionPayload =\n | AskQuestionPayload\n | RequestPermissionPayload\n | RequestPathAccessPayload\n | ReviewSanitizedOutputPayload;\n\n// ---------------------------------------------------------------------------\n// Responses (host → tool)\n// ---------------------------------------------------------------------------\n\nexport interface AskQuestionResponse {\n type: InteractionType.ASK_QUESTION;\n answer: string;\n}\n\nexport interface RequestPermissionResponse {\n type: InteractionType.REQUEST_PERMISSION;\n approved: boolean;\n}\n\nexport interface RequestPathAccessResponse {\n type: InteractionType.REQUEST_PATH_ACCESS;\n granted: boolean;\n}\n\nexport interface ReviewSanitizedOutputResponse {\n type: InteractionType.REVIEW_SANITIZED_OUTPUT;\n approved: boolean;\n editedText?: string;\n}\n\nexport type InteractionResponse =\n | AskQuestionResponse\n | RequestPermissionResponse\n | RequestPathAccessResponse\n | ReviewSanitizedOutputResponse;\n\n// ---------------------------------------------------------------------------\n// Investigation source\n// ---------------------------------------------------------------------------\n\nexport enum InvestigationSource {\n USER = \"user\",\n CONTEXT_REQUEST = \"context_request\",\n EXTERNAL_REQUEST = \"external_request\",\n}\n\n// ---------------------------------------------------------------------------\n// Minimal requester interface (tools depend on this, not on PRBEAgent)\n// ---------------------------------------------------------------------------\n\nexport interface PRBEInteractionRequester {\n requestUserInteraction(payload: InteractionPayload): Promise<InteractionResponse>;\n sendConversationMessage(content: string, role?: import(\"./models\").ConversationRole, label?: string): void;\n readonly investigationSource: InvestigationSource;\n}\n\n// ---------------------------------------------------------------------------\n// Handler interface (host app implements this)\n// ---------------------------------------------------------------------------\n\nexport interface PRBEInteractionHandler {\n handleInteraction(payload: InteractionPayload): Promise<InteractionResponse>;\n}\n\n// ---------------------------------------------------------------------------\n// Resolved interaction (question + response, for persistence)\n// ---------------------------------------------------------------------------\n\nexport interface ResolvedInteraction {\n interactionId: string;\n payload: InteractionPayload;\n response: InteractionResponse;\n /** Number of events at time of resolution — used to split thinking bubbles */\n eventIndex: number;\n}\n","/**\n * models.ts — WSMessage, WSMessageType, tool types, config, errors\n *\n * All types must match the Swift SDK + middleware protocol exactly.\n */\n\n// ---------------------------------------------------------------------------\n// WebSocket Message Types\n// ---------------------------------------------------------------------------\n\nexport enum WSMessageType {\n // SDK -> Middleware\n START = \"start\",\n TOOL_RESULT = \"tool_result\",\n UPLOAD_REQUEST = \"upload_request\",\n CONVERSATION_MESSAGE = \"conversation_message\",\n CANCEL = \"cancel\",\n PONG = \"pong\",\n // Middleware -> SDK\n THOUGHT = \"thought\",\n TOOL_CALL = \"tool_call\",\n SERVER_TOOL_CALL = \"server_tool_call\",\n SERVER_OBSERVATION = \"server_observation\",\n UPLOAD_URL = \"upload_url\",\n SESSION_CONFIG = \"session_config\",\n CONVERSATION_UPDATE = \"conversation_update\",\n COMPLETE = \"complete\",\n ERROR = \"error\",\n PING = \"ping\",\n // Privacy mode\n PRIVACY_SANITIZING = \"privacy_sanitizing\",\n PRIVACY_REVIEW = \"privacy_review\",\n PRIVACY_REVIEW_RESPONSE = \"privacy_review_response\",\n}\n\n// ---------------------------------------------------------------------------\n// Conversation\n// ---------------------------------------------------------------------------\n\nexport enum ConversationRole {\n User = \"user\",\n Agent = \"agent\",\n}\n\nexport interface ConversationEntry {\n role: ConversationRole;\n content: string;\n label?: string;\n ts: string;\n}\n\n// ---------------------------------------------------------------------------\n// WebSocket Message\n// ---------------------------------------------------------------------------\n\nexport interface WSMessage {\n type: WSMessageType;\n id?: string;\n name?: string;\n content?: string;\n metadata?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Tool System\n// ---------------------------------------------------------------------------\n\nexport enum ToolParamType {\n STRING = \"STRING\",\n BOOLEAN = \"BOOLEAN\",\n INTEGER = \"INTEGER\",\n}\n\nexport interface PRBEToolParameter {\n name: string;\n type: ToolParamType;\n description: string;\n required: boolean;\n}\n\nexport interface PRBEToolDeclaration {\n name: string;\n description: string;\n parameters: PRBEToolParameter[];\n /** When true, the middleware uses a longer timeout for this tool (user interaction required). */\n interactive?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Tool Names (must match middleware exactly)\n// ---------------------------------------------------------------------------\n\nexport enum ToolName {\n CLIENT_LIST_DIRECTORY = \"client_list_directory\",\n CLIENT_READ_FILE = \"client_read_file\",\n CLIENT_SEARCH_CONTENT = \"client_search_content\",\n CLIENT_FIND_FILES = \"client_find_files\",\n CLIENT_FLAG_FILE = \"client_flag_file\",\n CLIENT_READ_APP_LOGS = \"client_read_app_logs\",\n CLIENT_SEARCH_APP_LOGS = \"client_search_app_logs\",\n CLIENT_CLEAR_APP_LOGS = \"client_clear_app_logs\",\n CLIENT_FLAG_APP_LOGS = \"client_flag_app_logs\",\n CLIENT_ASK_USER = \"client_ask_user\",\n CLIENT_BASH_EXECUTE = \"client_bash_execute\",\n CLIENT_MESSAGE_USER = \"client_message_user\",\n // SDK-side chat tools (proxied by middleware when supports_chat is true)\n SDK_MESSAGE_USER = \"sdk_message_user\",\n SDK_ASK_USER = \"sdk_ask_user\",\n}\n\n// ---------------------------------------------------------------------------\n// User Identifier\n// ---------------------------------------------------------------------------\n\nexport enum UserIdentifierType {\n EMAIL = \"email\",\n ID = \"id\",\n}\n\n// ---------------------------------------------------------------------------\n// Agent Configuration\n// ---------------------------------------------------------------------------\n\nexport enum PRBEAgentConfigKey {\n API_KEY = \"apiKey\",\n AUTO_APPROVED_DIRS = \"autoApprovedDirs\",\n POLLING_INTERVAL = \"pollingInterval\",\n MAX_LOG_ENTRIES = \"maxLogEntries\",\n CAPTURE_CONSOLE = \"captureConsole\",\n BACKGROUND_POLLING = \"backgroundPolling\",\n INTERACTION_HANDLER = \"interactionHandler\",\n ELECTRON_LOG = \"electronLog\",\n IPC_MAIN = \"ipcMain\",\n RENDERER_LOG_CHANNEL = \"rendererLogChannel\",\n APP_DATA_PATH = \"appDataPath\",\n SESSION_METADATA = \"sessionMetadata\",\n}\n\nexport interface PRBEAgentConfig {\n [PRBEAgentConfigKey.API_KEY]: string;\n [PRBEAgentConfigKey.AUTO_APPROVED_DIRS]: string[];\n [PRBEAgentConfigKey.POLLING_INTERVAL]?: number; // ms, default 600_000 (10 min)\n [PRBEAgentConfigKey.MAX_LOG_ENTRIES]?: number; // default 10_000\n [PRBEAgentConfigKey.CAPTURE_CONSOLE]?: boolean; // default true\n [PRBEAgentConfigKey.BACKGROUND_POLLING]?: boolean; // default true\n [PRBEAgentConfigKey.INTERACTION_HANDLER]?: import(\"./interactions\").PRBEInteractionHandler;\n /** electron-log instance (v5) — SDK hooks into its transports to capture main-process logs */\n [PRBEAgentConfigKey.ELECTRON_LOG]?: { hooks: { push: (hook: (...args: any[]) => any) => void } };\n /** Electron ipcMain instance — SDK listens for renderer log forwarding */\n [PRBEAgentConfigKey.IPC_MAIN]?: { on: (channel: string, listener: (event: any, ...args: any[]) => void) => void };\n /** IPC channel name for renderer log forwarding (default: \"prbe-renderer-log\") */\n [PRBEAgentConfigKey.RENDERER_LOG_CHANNEL]?: string;\n /** Path to the application's data directory (e.g. Electron userData). Sent to the agent so it explores this directory first. */\n [PRBEAgentConfigKey.APP_DATA_PATH]?: string;\n /** Custom metadata included in every session submission (e.g. user profile, app version). */\n [PRBEAgentConfigKey.SESSION_METADATA]?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Sanitization Issue (received from middleware during privacy review)\n// ---------------------------------------------------------------------------\n\nexport interface SanitizationIssue {\n type: \"pii\" | \"ngram_overlap\" | \"incomplete\";\n detail: string;\n severity: \"high\" | \"medium\" | \"low\";\n}\n\nexport type SanitizedFileResult =\n | { isText: true; content: string; url: string }\n | { isText: false; url: string };\n\n// ---------------------------------------------------------------------------\n// Agent Status\n// ---------------------------------------------------------------------------\n\nexport enum PRBEAgentStatusType {\n STARTED = \"started\",\n THINKING = \"thinking\",\n TOOL_CALL = \"tool_call\",\n THOUGHT = \"thought\",\n OBSERVATION = \"observation\",\n COMPLETED = \"completed\",\n ERROR = \"error\",\n AWAITING_INTERACTION = \"awaiting_interaction\",\n PRIVACY_SANITIZING = \"privacy_sanitizing\",\n}\n\nexport type PRBEAgentStatus =\n | { type: PRBEAgentStatusType.STARTED }\n | { type: PRBEAgentStatusType.THINKING }\n | { type: PRBEAgentStatusType.TOOL_CALL; name: string; label: string }\n | { type: PRBEAgentStatusType.THOUGHT; text: string }\n | { type: PRBEAgentStatusType.OBSERVATION; text: string }\n | { type: PRBEAgentStatusType.COMPLETED; report: string; ticketId?: string }\n | { type: PRBEAgentStatusType.ERROR; message: string }\n | { type: PRBEAgentStatusType.AWAITING_INTERACTION; interactionPayload: import(\"./interactions\").InteractionPayload }\n | { type: PRBEAgentStatusType.PRIVACY_SANITIZING };\n\n// ---------------------------------------------------------------------------\n// Investigation Result (internal)\n// ---------------------------------------------------------------------------\n\nexport interface InvestigationResult {\n report: string;\n ticketId?: string;\n sessionId?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Flagged File (internal)\n// ---------------------------------------------------------------------------\n\nexport interface FlaggedFileIn {\n originalPath: string;\n reason?: string;\n data: Buffer;\n isText: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Poll Endpoint\n// ---------------------------------------------------------------------------\n\nexport interface PollRequest {\n agent_id: string;\n}\n\nexport interface ContextRequestOut {\n id: string;\n query: string;\n slug?: string;\n ticket_id: string;\n is_active: boolean;\n created_at: string;\n}\n\nexport interface ExternalRequestOut {\n id: string;\n query: string;\n source: string;\n source_detail?: string;\n is_active: boolean;\n created_at: string;\n}\n\nexport interface PollResponse {\n context_requests: ContextRequestOut[];\n external_requests: ExternalRequestOut[];\n}\n\n// ---------------------------------------------------------------------------\n// Ticket Info (used by state for UI display)\n// ---------------------------------------------------------------------------\n\nexport interface TicketInfoOut {\n ticket_id: string;\n title: string;\n status: string;\n priority?: string;\n description?: string;\n session_count: number;\n}\n\n// ---------------------------------------------------------------------------\n// Agent History\n// ---------------------------------------------------------------------------\n\nexport interface AgentHistoryRequest {\n agent_id: string;\n}\n\nexport interface AgentSessionOut {\n session_id: string;\n title: string;\n status: string;\n context_summary?: string;\n created_at: string;\n}\n\nexport interface AgentTicketOut {\n ticket_id: string;\n title: string;\n status: string;\n priority?: string;\n sessions: AgentSessionOut[];\n}\n\nexport interface AgentHistoryResponse {\n tickets: AgentTicketOut[];\n}\n\n// ---------------------------------------------------------------------------\n// Status Events (for state tracking)\n// ---------------------------------------------------------------------------\n\nexport interface PRBEStatusEvent {\n id: string;\n label: string;\n detail?: string;\n isCompleted: boolean;\n isExpanded: boolean;\n}\n\nexport interface PRBEBackgroundInvestigation {\n id: string;\n query: string;\n slug?: string;\n ticketId?: string;\n source?: string;\n sourceDetail?: string;\n events: PRBEStatusEvent[];\n isRunning: boolean;\n isCompleted: boolean;\n isFailed: boolean;\n report: string;\n summary?: string;\n errorMessage?: string;\n agentMessage?: string;\n startedAt: Date;\n pendingInteraction?: import(\"./interactions\").InteractionPayload;\n resolvedInteractions?: import(\"./interactions\").ResolvedInteraction[];\n conversationHistory: ConversationEntry[];\n}\n\n// ---------------------------------------------------------------------------\n// Completed Investigation (persisted in state for history)\n// ---------------------------------------------------------------------------\n\nexport interface PRBECompletedInvestigation {\n id: string;\n query: string;\n report: string;\n summary?: string;\n ticketId?: string;\n events: PRBEStatusEvent[];\n resolvedInteractions: import(\"./interactions\").ResolvedInteraction[];\n conversationHistory?: ConversationEntry[];\n completedAt: Date;\n}\n\n// ---------------------------------------------------------------------------\n// Errors\n// ---------------------------------------------------------------------------\n\nexport enum PRBEAgentErrorType {\n SERVER_ERROR = \"server_error\",\n NETWORK_ERROR = \"network_error\",\n CANCELLED = \"cancelled\",\n MAX_ITERATIONS = \"max_iterations\",\n}\n\nexport class PRBEAgentError extends Error {\n public readonly errorType: PRBEAgentErrorType;\n public readonly statusCode?: number;\n\n constructor(errorType: PRBEAgentErrorType, message: string, statusCode?: number) {\n super(message);\n this.name = \"PRBEAgentError\";\n this.errorType = errorType;\n this.statusCode = statusCode;\n }\n}\n\n// ---------------------------------------------------------------------------\n// PII Redactor (pass-through stub, matches Swift SDK)\n// ---------------------------------------------------------------------------\n\nexport function redactPII(text: string): string {\n return text;\n}\n\n// ---------------------------------------------------------------------------\n// Static URLs\n// ---------------------------------------------------------------------------\n\nexport const API_URL = \"https://api.prbe.ai\";\nexport const MIDDLEWARE_URL = \"wss://middleware.prbe.ai\";\n","/**\n * serialization.ts — IPC-safe serialization of agent state\n *\n * Converts live PRBEAgentState (with Map, Date, EventEmitter) into\n * plain JSON-safe objects suitable for IPC or structured clone.\n */\n\nimport type { PRBEAgentState } from \"./state\";\nimport type {\n PRBEStatusEvent,\n PRBEBackgroundInvestigation,\n TicketInfoOut,\n AgentTicketOut,\n ConversationEntry,\n} from \"./models\";\nimport type { InteractionPayload, ResolvedInteraction } from \"./interactions\";\n\n// ---------------------------------------------------------------------------\n// Serialized Background Investigation (Date → ISO string, safe for IPC)\n// ---------------------------------------------------------------------------\n\nexport interface PRBESerializedBackgroundInvestigation {\n id: string;\n query: string;\n slug?: string;\n ticketId?: string;\n source?: string;\n sourceDetail?: string;\n events: PRBEStatusEvent[];\n isRunning: boolean;\n isCompleted: boolean;\n isFailed: boolean;\n report: string;\n summary?: string;\n errorMessage?: string;\n agentMessage?: string;\n startedAt: string; // ISO string\n pendingInteraction?: InteractionPayload;\n resolvedInteractions?: ResolvedInteraction[];\n conversationHistory: ConversationEntry[];\n}\n\n// ---------------------------------------------------------------------------\n// Serialized Ticket (pass-through — already plain)\n// ---------------------------------------------------------------------------\n\nexport type PRBESerializedTicket = TicketInfoOut;\n\n// ---------------------------------------------------------------------------\n// Serialized Completed Investigation (Date → ISO string)\n// ---------------------------------------------------------------------------\n\nexport interface PRBESerializedCompletedInvestigation {\n id: string;\n query: string;\n report: string;\n summary?: string;\n ticketId?: string;\n events: PRBEStatusEvent[];\n resolvedInteractions: ResolvedInteraction[];\n conversationHistory?: ConversationEntry[];\n completedAt: string; // ISO string\n}\n\n// ---------------------------------------------------------------------------\n// Full serialized state (no Map, Date, or EventEmitter)\n// ---------------------------------------------------------------------------\n\nexport interface PRBESerializedState {\n isInvestigating: boolean;\n isPrivacySanitizing: boolean;\n events: PRBEStatusEvent[];\n report: string;\n summary?: string;\n currentQuery: string;\n investigationError?: string;\n pendingInteraction?: InteractionPayload;\n resolvedInteractions: ResolvedInteraction[];\n agentMessage?: string;\n conversationHistory: ConversationEntry[];\n completedInvestigations: PRBESerializedCompletedInvestigation[];\n activeBackgroundInvestigations: PRBESerializedBackgroundInvestigation[];\n completedBackgroundInvestigations: PRBESerializedBackgroundInvestigation[];\n ticketInfo: PRBESerializedTicket[];\n agentHistory: AgentTicketOut[];\n hasActiveWork: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Default state (used before agent initializes)\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_PRBE_STATE: PRBESerializedState = {\n isInvestigating: false,\n isPrivacySanitizing: false,\n events: [],\n report: \"\",\n summary: \"\",\n currentQuery: \"\",\n resolvedInteractions: [],\n conversationHistory: [],\n completedInvestigations: [],\n activeBackgroundInvestigations: [],\n completedBackgroundInvestigations: [],\n ticketInfo: [],\n agentHistory: [],\n hasActiveWork: false,\n};\n\n// ---------------------------------------------------------------------------\n// Converter: live state → IPC-safe plain object\n// ---------------------------------------------------------------------------\n\nfunction serializeBackgroundInvestigation(bg: PRBEBackgroundInvestigation): PRBESerializedBackgroundInvestigation {\n return {\n id: bg.id,\n query: bg.query,\n slug: bg.slug,\n ticketId: bg.ticketId,\n source: bg.source,\n sourceDetail: bg.sourceDetail,\n events: bg.events,\n isRunning: bg.isRunning,\n isCompleted: bg.isCompleted,\n isFailed: bg.isFailed,\n report: bg.report,\n summary: bg.summary,\n errorMessage: bg.errorMessage,\n agentMessage: bg.agentMessage,\n startedAt: bg.startedAt.toISOString(),\n pendingInteraction: bg.pendingInteraction,\n resolvedInteractions: bg.resolvedInteractions ?? [],\n conversationHistory: bg.conversationHistory ?? [],\n };\n}\n\nexport function serializePRBEState(state: PRBEAgentState): PRBESerializedState {\n return {\n isInvestigating: state.isInvestigating,\n isPrivacySanitizing: state.isPrivacySanitizing,\n events: state.events,\n report: state.report,\n summary: state.summary,\n currentQuery: state.currentQuery,\n investigationError: state.investigationError,\n pendingInteraction: state.pendingInteraction,\n resolvedInteractions: state.resolvedInteractions,\n agentMessage: state.agentMessage,\n conversationHistory: state.conversationHistory,\n completedInvestigations: state.completedInvestigations.map((inv) => ({\n id: inv.id,\n query: inv.query,\n report: inv.report,\n summary: inv.summary,\n ticketId: inv.ticketId,\n events: inv.events,\n resolvedInteractions: inv.resolvedInteractions,\n conversationHistory: inv.conversationHistory,\n completedAt: inv.completedAt.toISOString(),\n })),\n activeBackgroundInvestigations: Array.from(state.activeBackgroundInvestigations.values()).map(serializeBackgroundInvestigation),\n completedBackgroundInvestigations: state.completedBackgroundInvestigations.map(serializeBackgroundInvestigation),\n ticketInfo: state.ticketInfo,\n agentHistory: state.agentHistory,\n hasActiveWork: state.hasActiveWork,\n };\n}\n","/**\n * state.ts — PRBEAgentState: EventEmitter-based observable investigation state\n *\n * Mirrors PRBEAgentState.swift but uses Node.js EventEmitter instead of Combine/@Published.\n * Host apps subscribe to events for UI updates.\n */\n\nimport { EventEmitter } from \"events\";\nimport { randomUUID } from \"crypto\";\nimport type {\n PRBEStatusEvent,\n PRBEBackgroundInvestigation,\n PRBECompletedInvestigation,\n TicketInfoOut,\n AgentTicketOut,\n ConversationEntry,\n} from \"./models\";\nimport type { InteractionPayload, InteractionResponse, ResolvedInteraction } from \"./interactions\";\n\n// ---------------------------------------------------------------------------\n// Event types emitted by PRBEAgentState\n// ---------------------------------------------------------------------------\n\nexport enum PRBEStateEvent {\n /** Emitted on any state change. Payload: void */\n STATUS = \"status\",\n /** Emitted when a new event is appended. Payload: PRBEStatusEvent */\n EVENT = \"event\",\n /** Emitted when investigation completes. Payload: { report: string } */\n COMPLETE = \"complete\",\n /** Emitted on error. Payload: { message: string } */\n ERROR = \"error\",\n /** Emitted when a background investigation starts. Payload: PRBEBackgroundInvestigation */\n BACKGROUND_START = \"background-start\",\n /** Emitted when a background investigation completes/fails. Payload: PRBEBackgroundInvestigation */\n BACKGROUND_COMPLETE = \"background-complete\",\n /** Emitted when tracked ticket IDs change. Payload: string[] */\n TICKETS_CHANGED = \"tickets-changed\",\n /** Emitted when ticket info is updated. Payload: TicketInfoOut[] */\n TICKET_INFO = \"ticket-info\",\n /** Emitted when an interaction is requested. Payload: InteractionPayload */\n INTERACTION_REQUESTED = \"interaction-requested\",\n /** Emitted when an interaction is resolved. Payload: void */\n INTERACTION_RESOLVED = \"interaction-resolved\",\n /** Emitted when the agent sends a message to the user. Payload: { message: string } */\n AGENT_MESSAGE = \"agent-message\",\n}\n\n// ---------------------------------------------------------------------------\n// PRBEAgentState\n// ---------------------------------------------------------------------------\n\nexport class PRBEAgentState extends EventEmitter {\n // User-initiated investigation\n public isInvestigating = false;\n public events: PRBEStatusEvent[] = [];\n public report = \"\";\n public summary = \"\";\n public currentQuery = \"\";\n public investigationError?: string;\n public pendingInteraction?: InteractionPayload;\n public resolvedInteractions: ResolvedInteraction[] = [];\n public agentMessage?: string;\n public conversationHistory: ConversationEntry[] = [];\n public isPrivacySanitizing = false;\n\n // Completed user investigations (history)\n public completedInvestigations: PRBECompletedInvestigation[] = [];\n\n // Background investigations (context requests, external requests, etc.)\n public activeBackgroundInvestigations: Map<string, PRBEBackgroundInvestigation> = new Map();\n public completedBackgroundInvestigations: PRBEBackgroundInvestigation[] = [];\n\n // Tracked tickets\n public trackedSessionIDs: string[] = [];\n public ticketInfo: TicketInfoOut[] = [];\n\n // Agent history\n public agentHistory: AgentTicketOut[] = [];\n\n // Computed\n get hasActiveWork(): boolean {\n return this.isInvestigating || this.activeBackgroundInvestigations.size > 0;\n }\n\n get activeBackgroundCount(): number {\n return this.activeBackgroundInvestigations.size;\n }\n\n get isActive(): boolean {\n return this.isInvestigating || this.report.length > 0 || this.investigationError != null;\n }\n\n // ---------- User investigation mutations ----------\n\n beginInvestigation(query: string): void {\n this.isInvestigating = true;\n this.events = [];\n this.resolvedInteractions = [];\n this.conversationHistory = [];\n this.report = \"\";\n this.summary = \"\";\n this.currentQuery = query;\n this.investigationError = undefined;\n this.agentMessage = undefined;\n this.emit(PRBEStateEvent.STATUS);\n }\n\n appendConversation(entry: ConversationEntry): void {\n this.conversationHistory.push(entry);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n appendBackgroundConversation(backgroundId: string, entry: ConversationEntry): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n bg.conversationHistory.push(entry);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n resetInvestigation(): void {\n this.isInvestigating = false;\n this.events = [];\n this.resolvedInteractions = [];\n this.conversationHistory = [];\n this.report = \"\";\n this.summary = \"\";\n this.currentQuery = \"\";\n this.investigationError = undefined;\n this.pendingInteraction = undefined;\n this.agentMessage = undefined;\n this.emit(PRBEStateEvent.STATUS);\n }\n\n appendEvent(label: string, detail?: string, completed = false): void {\n // Mark previous event as completed before adding new one\n if (this.events.length > 0) {\n const last = this.events[this.events.length - 1];\n if (!last.isCompleted && !completed) {\n last.isCompleted = true;\n }\n }\n const event: PRBEStatusEvent = {\n id: randomUUID(),\n label,\n detail,\n isCompleted: completed,\n isExpanded: false,\n };\n this.events.push(event);\n this.emit(PRBEStateEvent.EVENT, event);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n attachObservation(text: string): void {\n if (this.events.length > 0) {\n this.events[this.events.length - 1].detail = text;\n this.emit(PRBEStateEvent.STATUS);\n }\n }\n\n completeInvestigation(report: string, ticketId?: string): void {\n if (this.events.length > 0) {\n this.events[this.events.length - 1].isCompleted = true;\n }\n this.appendEvent(\"Done\", undefined, true);\n\n // Save to history (snapshot events + interactions before reset)\n this.completedInvestigations.unshift({\n id: randomUUID(),\n query: this.currentQuery,\n report,\n ticketId,\n events: [...this.events],\n resolvedInteractions: [...this.resolvedInteractions],\n conversationHistory: [...this.conversationHistory],\n completedAt: new Date(),\n });\n\n this.report = report;\n this.isInvestigating = false;\n this.isPrivacySanitizing = false;\n this.emit(PRBEStateEvent.COMPLETE, { report });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n failInvestigation(message: string): void {\n this.appendEvent(`Error: ${message}`);\n this.investigationError = message;\n this.isInvestigating = false;\n this.isPrivacySanitizing = false;\n this.emit(PRBEStateEvent.ERROR, { message });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n setPrivacySanitizing(value: boolean): void {\n this.isPrivacySanitizing = value;\n this.emit(PRBEStateEvent.STATUS);\n }\n\n // ---------- Interaction state mutations ----------\n\n setPendingInteraction(payload: InteractionPayload): void {\n this.pendingInteraction = payload;\n this.emit(PRBEStateEvent.INTERACTION_REQUESTED, payload);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n clearPendingInteraction(): void {\n this.pendingInteraction = undefined;\n this.emit(PRBEStateEvent.INTERACTION_RESOLVED);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n setBackgroundPendingInteraction(backgroundId: string, payload: InteractionPayload): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n bg.pendingInteraction = payload;\n this.emit(PRBEStateEvent.INTERACTION_REQUESTED, payload);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n clearBackgroundPendingInteraction(backgroundId: string): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n bg.pendingInteraction = undefined;\n this.emit(PRBEStateEvent.INTERACTION_RESOLVED);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n resolveInteraction(response: InteractionResponse): void {\n if (!this.pendingInteraction) return;\n this.resolvedInteractions.push({\n interactionId: this.pendingInteraction.interactionId,\n payload: this.pendingInteraction,\n response,\n eventIndex: this.events.length,\n });\n this.pendingInteraction = undefined;\n this.emit(PRBEStateEvent.INTERACTION_RESOLVED);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n resolveBackgroundInteraction(backgroundId: string, response: InteractionResponse): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg || !bg.pendingInteraction) return;\n const resolved = bg.resolvedInteractions ?? [];\n resolved.push({\n interactionId: bg.pendingInteraction.interactionId,\n payload: bg.pendingInteraction,\n response,\n eventIndex: bg.events.length,\n });\n bg.resolvedInteractions = resolved;\n bg.pendingInteraction = undefined;\n this.emit(PRBEStateEvent.INTERACTION_RESOLVED);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n setAgentMessage(message: string): void {\n this.agentMessage = message;\n this.emit(PRBEStateEvent.AGENT_MESSAGE, { message });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n setBackgroundAgentMessage(backgroundId: string, message: string): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n bg.agentMessage = message;\n this.emit(PRBEStateEvent.AGENT_MESSAGE, { message });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n toggleExpansion(eventId: string): void {\n const event = this.events.find((e) => e.id === eventId);\n if (event) {\n event.isExpanded = !event.isExpanded;\n this.emit(PRBEStateEvent.STATUS);\n }\n }\n\n // ---------- Background investigation state mutations ----------\n\n beginBackgroundInvestigation(id: string, query: string, slug?: string, ticketId?: string, source?: string, sourceDetail?: string): void {\n const bg: PRBEBackgroundInvestigation = {\n id,\n query,\n slug,\n ticketId,\n source,\n sourceDetail,\n events: [],\n conversationHistory: [],\n resolvedInteractions: [],\n isRunning: true,\n isCompleted: false,\n isFailed: false,\n report: \"\",\n summary: \"\",\n startedAt: new Date(),\n };\n this.activeBackgroundInvestigations.set(id, bg);\n this.emit(PRBEStateEvent.BACKGROUND_START, bg);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n appendBackgroundEvent(backgroundId: string, label: string, detail?: string, completed = false): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg) return;\n\n if (bg.events.length > 0) {\n const last = bg.events[bg.events.length - 1];\n if (!last.isCompleted && !completed) {\n last.isCompleted = true;\n }\n }\n bg.events.push({\n id: randomUUID(),\n label,\n detail,\n isCompleted: completed,\n isExpanded: false,\n });\n this.emit(PRBEStateEvent.STATUS);\n }\n\n attachBackgroundObservation(backgroundId: string, text: string): void {\n const bg = this.activeBackgroundInvestigations.get(backgroundId);\n if (!bg || bg.events.length === 0) return;\n bg.events[bg.events.length - 1].detail = text;\n this.emit(PRBEStateEvent.STATUS);\n }\n\n completeBackgroundInvestigation(id: string, report: string): void {\n const bg = this.activeBackgroundInvestigations.get(id);\n if (!bg) return;\n\n this.activeBackgroundInvestigations.delete(id);\n if (bg.events.length > 0) {\n bg.events[bg.events.length - 1].isCompleted = true;\n }\n bg.events.push({\n id: randomUUID(),\n label: \"Done\",\n isCompleted: true,\n isExpanded: false,\n });\n bg.isRunning = false;\n bg.isCompleted = true;\n bg.report = report;\n this.completedBackgroundInvestigations.unshift(bg);\n this.emit(PRBEStateEvent.BACKGROUND_COMPLETE, bg);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n failBackgroundInvestigation(id: string, message: string): void {\n const bg = this.activeBackgroundInvestigations.get(id);\n if (!bg) return;\n\n this.activeBackgroundInvestigations.delete(id);\n bg.events.push({\n id: randomUUID(),\n label: `Error: ${message}`,\n isCompleted: false,\n isExpanded: false,\n });\n bg.isRunning = false;\n bg.isFailed = true;\n bg.errorMessage = message;\n this.completedBackgroundInvestigations.unshift(bg);\n this.emit(PRBEStateEvent.BACKGROUND_COMPLETE, bg);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n // ---------- Tickets ----------\n\n updateTrackedSessionIDs(ids: string[]): void {\n this.trackedSessionIDs = ids;\n this.emit(PRBEStateEvent.TICKETS_CHANGED, ids);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n updateTicketInfo(info: TicketInfoOut[]): void {\n this.ticketInfo = info;\n this.emit(PRBEStateEvent.TICKET_INFO, info);\n this.emit(PRBEStateEvent.STATUS);\n }\n\n updateAgentHistory(tickets: AgentTicketOut[]): void {\n this.agentHistory = tickets;\n this.emit(PRBEStateEvent.STATUS);\n }\n}\n"],"mappings":"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","names":["InteractionType","WSMessageType","ToolParamType","ToolName","PRBEAgentConfigKey","PRBEAgentStatusType","PRBEAgentErrorType","PRBEStateEvent"]}
package/dist/types.mjs CHANGED
@@ -3,6 +3,7 @@ var InteractionType = /* @__PURE__ */ ((InteractionType2) => {
3
3
  InteractionType2["ASK_QUESTION"] = "ask_question";
4
4
  InteractionType2["REQUEST_PERMISSION"] = "request_permission";
5
5
  InteractionType2["REQUEST_PATH_ACCESS"] = "request_path_access";
6
+ InteractionType2["REVIEW_SANITIZED_OUTPUT"] = "review_sanitized_output";
6
7
  return InteractionType2;
7
8
  })(InteractionType || {});
8
9
 
@@ -24,6 +25,9 @@ var WSMessageType = /* @__PURE__ */ ((WSMessageType2) => {
24
25
  WSMessageType2["COMPLETE"] = "complete";
25
26
  WSMessageType2["ERROR"] = "error";
26
27
  WSMessageType2["PING"] = "ping";
28
+ WSMessageType2["PRIVACY_SANITIZING"] = "privacy_sanitizing";
29
+ WSMessageType2["PRIVACY_REVIEW"] = "privacy_review";
30
+ WSMessageType2["PRIVACY_REVIEW_RESPONSE"] = "privacy_review_response";
27
31
  return WSMessageType2;
28
32
  })(WSMessageType || {});
29
33
  var ToolParamType = /* @__PURE__ */ ((ToolParamType2) => {
@@ -45,6 +49,8 @@ var ToolName = /* @__PURE__ */ ((ToolName2) => {
45
49
  ToolName2["CLIENT_ASK_USER"] = "client_ask_user";
46
50
  ToolName2["CLIENT_BASH_EXECUTE"] = "client_bash_execute";
47
51
  ToolName2["CLIENT_MESSAGE_USER"] = "client_message_user";
52
+ ToolName2["SDK_MESSAGE_USER"] = "sdk_message_user";
53
+ ToolName2["SDK_ASK_USER"] = "sdk_ask_user";
48
54
  return ToolName2;
49
55
  })(ToolName || {});
50
56
  var PRBEAgentConfigKey = /* @__PURE__ */ ((PRBEAgentConfigKey2) => {
@@ -71,6 +77,7 @@ var PRBEAgentStatusType = /* @__PURE__ */ ((PRBEAgentStatusType2) => {
71
77
  PRBEAgentStatusType2["COMPLETED"] = "completed";
72
78
  PRBEAgentStatusType2["ERROR"] = "error";
73
79
  PRBEAgentStatusType2["AWAITING_INTERACTION"] = "awaiting_interaction";
80
+ PRBEAgentStatusType2["PRIVACY_SANITIZING"] = "privacy_sanitizing";
74
81
  return PRBEAgentStatusType2;
75
82
  })(PRBEAgentStatusType || {});
76
83
  var PRBEAgentErrorType = /* @__PURE__ */ ((PRBEAgentErrorType2) => {
@@ -86,6 +93,7 @@ var MIDDLEWARE_URL = "wss://middleware.prbe.ai";
86
93
  // src/serialization.ts
87
94
  var DEFAULT_PRBE_STATE = {
88
95
  isInvestigating: false,
96
+ isPrivacySanitizing: false,
89
97
  events: [],
90
98
  report: "",
91
99
  summary: "",