@prbe.ai/electron-sdk 0.1.18 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { P as PRBEToolDeclaration, a as PRBEToolParameter, b as PRBEInteractionRequester, F as FlaggedFileIn, c as PRBEAgentState, d as PRBEAgentConfig, I as InvestigationSource, e as InteractionPayload, f as InteractionResponse, U as UserIdentifierType, g as PollResponse, A as AgentHistoryResponse } from './types-BeZ2nQ9x.mjs';
2
- export { h as API_URL, i as AgentHistoryRequest, j as AgentSessionOut, k as AgentTicketOut, l as AskQuestionPayload, m as AskQuestionResponse, C as ContextRequestOut, n as ConversationEntry, o as ConversationRole, D as DEFAULT_PRBE_STATE, E as ExternalRequestOut, p as InteractionType, q as InvestigationResult, M as MIDDLEWARE_URL, r as PRBEAgentConfigKey, s as PRBEAgentError, t as PRBEAgentErrorType, u as PRBEAgentStatus, v as PRBEAgentStatusType, w as PRBEBackgroundInvestigation, x as PRBECompletedInvestigation, y as PRBEInteractionHandler, z as PRBESerializedBackgroundInvestigation, B as PRBESerializedCompletedInvestigation, G as PRBESerializedState, H as PRBESerializedTicket, J as PRBEStateEvent, K as PRBEStatusEvent, L as PollRequest, 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, Z as redactPII, _ as serializePRBEState } from './types-BeZ2nQ9x.mjs';
1
+ import { P as PRBEToolDeclaration, a as PRBEToolParameter, b as PRBEInteractionRequester, F as FlaggedFileIn, c as PRBEAgentState, d as PRBEAgentConfig, I as InvestigationSource, C as ConversationRole, e as InteractionPayload, f as InteractionResponse, U as UserIdentifierType, g as PollResponse, A as AgentHistoryResponse, S as SanitizedFileResult } from './types-9iQH0zmA.mjs';
2
+ export { h as API_URL, i as AgentHistoryRequest, j as AgentSessionOut, k as AgentTicketOut, l as AskQuestionPayload, m as AskQuestionResponse, n as ContextRequestOut, o as ConversationEntry, D as DEFAULT_PRBE_STATE, E as ExternalRequestOut, p as InteractionType, q as InvestigationResult, M as MIDDLEWARE_URL, r as PRBEAgentConfigKey, s as PRBEAgentError, t as PRBEAgentErrorType, u as PRBEAgentStatus, v as PRBEAgentStatusType, w as PRBEBackgroundInvestigation, x as PRBECompletedInvestigation, y as PRBEInteractionHandler, z as PRBESerializedBackgroundInvestigation, B as PRBESerializedCompletedInvestigation, G as PRBESerializedState, H as PRBESerializedTicket, J as PRBEStateEvent, K as PRBEStatusEvent, L as PollRequest, 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, Z as TicketInfoOut, _ as ToolName, $ as ToolParamType, a0 as WSMessage, a1 as WSMessageType, a2 as redactPII, a3 as serializePRBEState } from './types-9iQH0zmA.mjs';
3
3
  import 'events';
4
4
 
5
- var version = "0.1.18";
5
+ var version = "0.1.19";
6
6
 
7
7
  /**
8
8
  * tools/index.ts — Tool interface, registry, and closure tool
@@ -159,7 +159,7 @@ declare class PRBEAgent implements PRBEInteractionRequester {
159
159
  private hookRendererLogs;
160
160
  private static mapElectronLogLevel;
161
161
  get investigationSource(): InvestigationSource;
162
- sendConversationMessage(content: string): void;
162
+ sendConversationMessage(content: string, role?: ConversationRole, label?: string): void;
163
163
  requestUserInteraction(payload: InteractionPayload): Promise<InteractionResponse>;
164
164
  /**
165
165
  * Add an additional root directory to the runtime allowed roots.
@@ -209,6 +209,12 @@ declare class PRBEAgent implements PRBEInteractionRequester {
209
209
  * Fetch agent history (tickets + sessions) from the backend.
210
210
  */
211
211
  fetchHistory(): Promise<AgentHistoryResponse | null>;
212
+ fetchSanitizedFile(url: string): Promise<SanitizedFileResult>;
213
+ /**
214
+ * Detect whether a buffer contains text by checking for null bytes
215
+ * and verifying the content is valid UTF-8.
216
+ */
217
+ private static isTextContent;
212
218
  stopPolling(): void;
213
219
  resumePolling(): void;
214
220
  /**
@@ -354,4 +360,4 @@ declare class BashExecuteTool implements PRBETool {
354
360
  */
355
361
  declare const PROBE_MARK_SVG = "<svg width=\"256\" height=\"256\" viewBox=\"0 0 256 256\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M50 112 L114 148 L50 184 Z\" fill=\"#111111\" opacity=\"0.07\"/>\n <path d=\"M70 86 L148 134 L70 182 Z\" fill=\"#111111\" opacity=\"0.18\"/>\n <path d=\"M92 56 L192 118 L92 180 Z\" fill=\"#111111\"/>\n</svg>";
356
362
 
357
- export { AgentHistoryResponse, AskUserTool, BashExecuteTool, ClearAppLogsTool, FindFilesTool, FlagAppLogsTool, FlagFileTool, FlaggedFileIn, InteractionPayload, InteractionResponse, InvestigationSource, ListDirectoryTool, type LogEntry, PRBEAgent, PRBEAgentConfig, PRBEAgentState, PRBEClosureTool, PRBEInteractionRequester, PRBELogCapture, type PRBETool, PRBEToolDeclaration, PRBEToolParameter, PRBEToolRegistry, PROBE_MARK_SVG, PollResponse, ReadAppLogsTool, ReadFileTool, version as SDK_VERSION, SearchAppLogsTool, SearchContentTool, UserIdentifierType, humanReadableSize, resolveAndValidate, resolveWithAccessRequest };
363
+ export { AgentHistoryResponse, AskUserTool, BashExecuteTool, ClearAppLogsTool, ConversationRole, FindFilesTool, FlagAppLogsTool, FlagFileTool, FlaggedFileIn, InteractionPayload, InteractionResponse, InvestigationSource, ListDirectoryTool, type LogEntry, PRBEAgent, PRBEAgentConfig, PRBEAgentState, PRBEClosureTool, PRBEInteractionRequester, PRBELogCapture, type PRBETool, PRBEToolDeclaration, PRBEToolParameter, PRBEToolRegistry, PROBE_MARK_SVG, PollResponse, ReadAppLogsTool, ReadFileTool, version as SDK_VERSION, SanitizedFileResult, SearchAppLogsTool, SearchContentTool, UserIdentifierType, humanReadableSize, resolveAndValidate, resolveWithAccessRequest };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { P as PRBEToolDeclaration, a as PRBEToolParameter, b as PRBEInteractionRequester, F as FlaggedFileIn, c as PRBEAgentState, d as PRBEAgentConfig, I as InvestigationSource, e as InteractionPayload, f as InteractionResponse, U as UserIdentifierType, g as PollResponse, A as AgentHistoryResponse } from './types-BeZ2nQ9x.js';
2
- export { h as API_URL, i as AgentHistoryRequest, j as AgentSessionOut, k as AgentTicketOut, l as AskQuestionPayload, m as AskQuestionResponse, C as ContextRequestOut, n as ConversationEntry, o as ConversationRole, D as DEFAULT_PRBE_STATE, E as ExternalRequestOut, p as InteractionType, q as InvestigationResult, M as MIDDLEWARE_URL, r as PRBEAgentConfigKey, s as PRBEAgentError, t as PRBEAgentErrorType, u as PRBEAgentStatus, v as PRBEAgentStatusType, w as PRBEBackgroundInvestigation, x as PRBECompletedInvestigation, y as PRBEInteractionHandler, z as PRBESerializedBackgroundInvestigation, B as PRBESerializedCompletedInvestigation, G as PRBESerializedState, H as PRBESerializedTicket, J as PRBEStateEvent, K as PRBEStatusEvent, L as PollRequest, 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, Z as redactPII, _ as serializePRBEState } from './types-BeZ2nQ9x.js';
1
+ import { P as PRBEToolDeclaration, a as PRBEToolParameter, b as PRBEInteractionRequester, F as FlaggedFileIn, c as PRBEAgentState, d as PRBEAgentConfig, I as InvestigationSource, C as ConversationRole, e as InteractionPayload, f as InteractionResponse, U as UserIdentifierType, g as PollResponse, A as AgentHistoryResponse, S as SanitizedFileResult } from './types-9iQH0zmA.js';
2
+ export { h as API_URL, i as AgentHistoryRequest, j as AgentSessionOut, k as AgentTicketOut, l as AskQuestionPayload, m as AskQuestionResponse, n as ContextRequestOut, o as ConversationEntry, D as DEFAULT_PRBE_STATE, E as ExternalRequestOut, p as InteractionType, q as InvestigationResult, M as MIDDLEWARE_URL, r as PRBEAgentConfigKey, s as PRBEAgentError, t as PRBEAgentErrorType, u as PRBEAgentStatus, v as PRBEAgentStatusType, w as PRBEBackgroundInvestigation, x as PRBECompletedInvestigation, y as PRBEInteractionHandler, z as PRBESerializedBackgroundInvestigation, B as PRBESerializedCompletedInvestigation, G as PRBESerializedState, H as PRBESerializedTicket, J as PRBEStateEvent, K as PRBEStatusEvent, L as PollRequest, 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, Z as TicketInfoOut, _ as ToolName, $ as ToolParamType, a0 as WSMessage, a1 as WSMessageType, a2 as redactPII, a3 as serializePRBEState } from './types-9iQH0zmA.js';
3
3
  import 'events';
4
4
 
5
- var version = "0.1.18";
5
+ var version = "0.1.19";
6
6
 
7
7
  /**
8
8
  * tools/index.ts — Tool interface, registry, and closure tool
@@ -159,7 +159,7 @@ declare class PRBEAgent implements PRBEInteractionRequester {
159
159
  private hookRendererLogs;
160
160
  private static mapElectronLogLevel;
161
161
  get investigationSource(): InvestigationSource;
162
- sendConversationMessage(content: string): void;
162
+ sendConversationMessage(content: string, role?: ConversationRole, label?: string): void;
163
163
  requestUserInteraction(payload: InteractionPayload): Promise<InteractionResponse>;
164
164
  /**
165
165
  * Add an additional root directory to the runtime allowed roots.
@@ -209,6 +209,12 @@ declare class PRBEAgent implements PRBEInteractionRequester {
209
209
  * Fetch agent history (tickets + sessions) from the backend.
210
210
  */
211
211
  fetchHistory(): Promise<AgentHistoryResponse | null>;
212
+ fetchSanitizedFile(url: string): Promise<SanitizedFileResult>;
213
+ /**
214
+ * Detect whether a buffer contains text by checking for null bytes
215
+ * and verifying the content is valid UTF-8.
216
+ */
217
+ private static isTextContent;
212
218
  stopPolling(): void;
213
219
  resumePolling(): void;
214
220
  /**
@@ -354,4 +360,4 @@ declare class BashExecuteTool implements PRBETool {
354
360
  */
355
361
  declare const PROBE_MARK_SVG = "<svg width=\"256\" height=\"256\" viewBox=\"0 0 256 256\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M50 112 L114 148 L50 184 Z\" fill=\"#111111\" opacity=\"0.07\"/>\n <path d=\"M70 86 L148 134 L70 182 Z\" fill=\"#111111\" opacity=\"0.18\"/>\n <path d=\"M92 56 L192 118 L92 180 Z\" fill=\"#111111\"/>\n</svg>";
356
362
 
357
- export { AgentHistoryResponse, AskUserTool, BashExecuteTool, ClearAppLogsTool, FindFilesTool, FlagAppLogsTool, FlagFileTool, FlaggedFileIn, InteractionPayload, InteractionResponse, InvestigationSource, ListDirectoryTool, type LogEntry, PRBEAgent, PRBEAgentConfig, PRBEAgentState, PRBEClosureTool, PRBEInteractionRequester, PRBELogCapture, type PRBETool, PRBEToolDeclaration, PRBEToolParameter, PRBEToolRegistry, PROBE_MARK_SVG, PollResponse, ReadAppLogsTool, ReadFileTool, version as SDK_VERSION, SearchAppLogsTool, SearchContentTool, UserIdentifierType, humanReadableSize, resolveAndValidate, resolveWithAccessRequest };
363
+ export { AgentHistoryResponse, AskUserTool, BashExecuteTool, ClearAppLogsTool, ConversationRole, FindFilesTool, FlagAppLogsTool, FlagFileTool, FlaggedFileIn, InteractionPayload, InteractionResponse, InvestigationSource, ListDirectoryTool, type LogEntry, PRBEAgent, PRBEAgentConfig, PRBEAgentState, PRBEClosureTool, PRBEInteractionRequester, PRBELogCapture, type PRBETool, PRBEToolDeclaration, PRBEToolParameter, PRBEToolRegistry, PROBE_MARK_SVG, PollResponse, ReadAppLogsTool, ReadFileTool, version as SDK_VERSION, SanitizedFileResult, SearchAppLogsTool, SearchContentTool, UserIdentifierType, humanReadableSize, resolveAndValidate, resolveWithAccessRequest };
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ __export(src_exports, {
72
72
  module.exports = __toCommonJS(src_exports);
73
73
 
74
74
  // package.json
75
- var version = "0.1.18";
75
+ var version = "0.1.19";
76
76
 
77
77
  // src/agent.ts
78
78
  var fs2 = __toESM(require("fs"));
@@ -98,6 +98,9 @@ var WSMessageType = /* @__PURE__ */ ((WSMessageType2) => {
98
98
  WSMessageType2["COMPLETE"] = "complete";
99
99
  WSMessageType2["ERROR"] = "error";
100
100
  WSMessageType2["PING"] = "ping";
101
+ WSMessageType2["PRIVACY_SANITIZING"] = "privacy_sanitizing";
102
+ WSMessageType2["PRIVACY_REVIEW"] = "privacy_review";
103
+ WSMessageType2["PRIVACY_REVIEW_RESPONSE"] = "privacy_review_response";
101
104
  return WSMessageType2;
102
105
  })(WSMessageType || {});
103
106
  var ConversationRole = /* @__PURE__ */ ((ConversationRole3) => {
@@ -155,6 +158,7 @@ var PRBEAgentStatusType = /* @__PURE__ */ ((PRBEAgentStatusType2) => {
155
158
  PRBEAgentStatusType2["COMPLETED"] = "completed";
156
159
  PRBEAgentStatusType2["ERROR"] = "error";
157
160
  PRBEAgentStatusType2["AWAITING_INTERACTION"] = "awaiting_interaction";
161
+ PRBEAgentStatusType2["PRIVACY_SANITIZING"] = "privacy_sanitizing";
158
162
  return PRBEAgentStatusType2;
159
163
  })(PRBEAgentStatusType || {});
160
164
  var PRBEAgentErrorType = /* @__PURE__ */ ((PRBEAgentErrorType2) => {
@@ -220,10 +224,14 @@ var InvestigationConnection = class {
220
224
  return false;
221
225
  }
222
226
  }
223
- sendConversationMessage(content) {
227
+ sendConversationMessage(content, role, label) {
228
+ const metadata = {};
229
+ if (role) metadata["role"] = role;
230
+ if (label) metadata["label"] = label;
224
231
  this.send({
225
232
  type: "conversation_message" /* CONVERSATION_MESSAGE */,
226
- content
233
+ content,
234
+ ...Object.keys(metadata).length > 0 ? { metadata } : {}
227
235
  });
228
236
  }
229
237
  sendToolResult(callId, toolName, result, metadata) {
@@ -286,6 +294,7 @@ var PRBEAgentState = class extends import_events.EventEmitter {
286
294
  resolvedInteractions = [];
287
295
  agentMessage;
288
296
  conversationHistory = [];
297
+ isPrivacySanitizing = false;
289
298
  // Completed user investigations (history)
290
299
  completedInvestigations = [];
291
300
  // Background investigations (context requests, external requests, etc.)
@@ -383,6 +392,7 @@ var PRBEAgentState = class extends import_events.EventEmitter {
383
392
  });
384
393
  this.report = report;
385
394
  this.isInvestigating = false;
395
+ this.isPrivacySanitizing = false;
386
396
  this.emit("complete" /* COMPLETE */, { report });
387
397
  this.emit("status" /* STATUS */);
388
398
  }
@@ -390,9 +400,14 @@ var PRBEAgentState = class extends import_events.EventEmitter {
390
400
  this.appendEvent(`Error: ${message}`);
391
401
  this.investigationError = message;
392
402
  this.isInvestigating = false;
403
+ this.isPrivacySanitizing = false;
393
404
  this.emit("error" /* ERROR */, { message });
394
405
  this.emit("status" /* STATUS */);
395
406
  }
407
+ setPrivacySanitizing(value) {
408
+ this.isPrivacySanitizing = value;
409
+ this.emit("status" /* STATUS */);
410
+ }
396
411
  // ---------- Interaction state mutations ----------
397
412
  setPendingInteraction(payload) {
398
413
  this.pendingInteraction = payload;
@@ -573,6 +588,7 @@ var InteractionType = /* @__PURE__ */ ((InteractionType2) => {
573
588
  InteractionType2["ASK_QUESTION"] = "ask_question";
574
589
  InteractionType2["REQUEST_PERMISSION"] = "request_permission";
575
590
  InteractionType2["REQUEST_PATH_ACCESS"] = "request_path_access";
591
+ InteractionType2["REVIEW_SANITIZED_OUTPUT"] = "review_sanitized_output";
576
592
  return InteractionType2;
577
593
  })(InteractionType || {});
578
594
  var InvestigationSource = /* @__PURE__ */ ((InvestigationSource2) => {
@@ -1486,7 +1502,8 @@ var AskUserTool = class {
1486
1502
  const response = await this.requester.requestUserInteraction({
1487
1503
  type: "ask_question" /* ASK_QUESTION */,
1488
1504
  interactionId: (0, import_crypto3.randomUUID)(),
1489
- question: reason
1505
+ question,
1506
+ context: reason
1490
1507
  });
1491
1508
  const askResponse = response;
1492
1509
  return askResponse.answer;
@@ -1696,6 +1713,10 @@ var BashExecuteTool = class {
1696
1713
  return `Error: working directory '${cwdArg}' is outside auto-approved directories`;
1697
1714
  }
1698
1715
  cwd = resolved;
1716
+ } else if (this.autoApprovedDirs.length > 0) {
1717
+ cwd = this.autoApprovedDirs[0];
1718
+ } else {
1719
+ return "Error: no approved directories configured and no working directory specified";
1699
1720
  }
1700
1721
  const isSafe = this.isCommandSafe(command);
1701
1722
  if (!isSafe) {
@@ -1959,8 +1980,8 @@ var PRBEAgent = class _PRBEAgent {
1959
1980
  get investigationSource() {
1960
1981
  return this.currentInvestigationSource;
1961
1982
  }
1962
- sendConversationMessage(content) {
1963
- this.activeConnection?.sendConversationMessage(content);
1983
+ sendConversationMessage(content, role, label) {
1984
+ this.activeConnection?.sendConversationMessage(content, role, label);
1964
1985
  }
1965
1986
  async requestUserInteraction(payload) {
1966
1987
  if (!this.interactionHandler) {
@@ -1969,6 +1990,22 @@ var PRBEAgent = class _PRBEAgent {
1969
1990
  "No interaction handler configured"
1970
1991
  );
1971
1992
  }
1993
+ if (payload.type === "request_permission" /* REQUEST_PERMISSION */) {
1994
+ const p = payload;
1995
+ const content = p.reason ? `${p.command}
1996
+
1997
+ ${p.reason}` : p.command;
1998
+ this.sendConversationMessage(content, "agent" /* Agent */, p.action);
1999
+ } else if (payload.type === "request_path_access" /* REQUEST_PATH_ACCESS */) {
2000
+ const p = payload;
2001
+ const content = p.reason ? `${p.path}
2002
+
2003
+ ${p.reason}` : p.path;
2004
+ this.sendConversationMessage(content, "agent" /* Agent */, "Request path access");
2005
+ } else if (payload.type === "ask_question" /* ASK_QUESTION */) {
2006
+ const p = payload;
2007
+ this.sendConversationMessage(p.question, "agent" /* Agent */);
2008
+ }
1972
2009
  if (this.currentInvestigationSource !== "user" /* USER */ && this.currentBackgroundId) {
1973
2010
  this.state.setBackgroundPendingInteraction(this.currentBackgroundId, payload);
1974
2011
  } else {
@@ -2114,6 +2151,14 @@ var PRBEAgent = class _PRBEAgent {
2114
2151
  this.state.failInvestigation(status.message);
2115
2152
  }
2116
2153
  break;
2154
+ case "privacy_sanitizing" /* PRIVACY_SANITIZING */:
2155
+ if (isBackground && opts.sourceId) {
2156
+ this.state.appendBackgroundEvent(opts.sourceId, "Sanitizing data for privacy review...");
2157
+ } else {
2158
+ this.state.appendEvent("Sanitizing data for privacy review...");
2159
+ }
2160
+ this.state.setPrivacySanitizing(true);
2161
+ break;
2117
2162
  }
2118
2163
  };
2119
2164
  const result = await this.connectToProxy(
@@ -2206,6 +2251,30 @@ var PRBEAgent = class _PRBEAgent {
2206
2251
  return null;
2207
2252
  }
2208
2253
  }
2254
+ async fetchSanitizedFile(url) {
2255
+ const res = await fetch(url, {
2256
+ headers: { "X-API-Key": this.config.apiKey }
2257
+ });
2258
+ if (!res.ok) throw new Error(`Failed to fetch sanitized file: ${res.status}`);
2259
+ const buffer = Buffer.from(await res.arrayBuffer());
2260
+ if (!_PRBEAgent.isTextContent(buffer)) {
2261
+ return { isText: false, url };
2262
+ }
2263
+ return { isText: true, content: buffer.toString("utf-8"), url };
2264
+ }
2265
+ /**
2266
+ * Detect whether a buffer contains text by checking for null bytes
2267
+ * and verifying the content is valid UTF-8.
2268
+ */
2269
+ static isTextContent(buffer) {
2270
+ const checkLength = Math.min(buffer.length, 8192);
2271
+ for (let i = 0; i < checkLength; i++) {
2272
+ if (buffer[i] === 0) return false;
2273
+ }
2274
+ const decoded = buffer.toString("utf-8");
2275
+ const reEncoded = Buffer.from(decoded, "utf-8");
2276
+ return buffer.length === reEncoded.length;
2277
+ }
2209
2278
  stopPolling() {
2210
2279
  if (this.pollingTimer !== null) {
2211
2280
  clearInterval(this.pollingTimer);
@@ -2295,8 +2364,8 @@ var PRBEAgent = class _PRBEAgent {
2295
2364
  uploadBaseUrl = url;
2296
2365
  }),
2297
2366
  (message) => {
2298
- if (!isCancelled()) emit({ type: "error" /* ERROR */, message });
2299
- finish(null);
2367
+ if (!resolved && !isCancelled()) emit({ type: "error" /* ERROR */, message });
2368
+ if (!resolved) finish(null);
2300
2369
  },
2301
2370
  () => {
2302
2371
  if (!resolved) {
@@ -2439,6 +2508,41 @@ var PRBEAgent = class _PRBEAgent {
2439
2508
  }
2440
2509
  break;
2441
2510
  }
2511
+ case "privacy_sanitizing" /* PRIVACY_SANITIZING */: {
2512
+ emit({ type: "privacy_sanitizing" /* PRIVACY_SANITIZING */ });
2513
+ break;
2514
+ }
2515
+ case "privacy_review" /* PRIVACY_REVIEW */: {
2516
+ const sanitizedText = msg.content ?? "";
2517
+ const issues = msg.metadata?.issues ?? [];
2518
+ const files = msg.metadata?.files ?? [];
2519
+ const summary = msg.metadata?.summary ?? "";
2520
+ const payload = {
2521
+ type: "review_sanitized_output" /* REVIEW_SANITIZED_OUTPUT */,
2522
+ interactionId: (0, import_crypto5.randomUUID)(),
2523
+ sanitizedAnalysis: sanitizedText,
2524
+ files,
2525
+ summary,
2526
+ issues
2527
+ };
2528
+ try {
2529
+ const response = await this.requestUserInteraction(payload);
2530
+ const reviewResponse = response;
2531
+ conn.send({
2532
+ type: "privacy_review_response" /* PRIVACY_REVIEW_RESPONSE */,
2533
+ metadata: {
2534
+ approved: reviewResponse.approved,
2535
+ ...reviewResponse.editedText ? { editedText: reviewResponse.editedText } : {}
2536
+ }
2537
+ });
2538
+ } catch {
2539
+ conn.send({
2540
+ type: "privacy_review_response" /* PRIVACY_REVIEW_RESPONSE */,
2541
+ metadata: { approved: false }
2542
+ });
2543
+ }
2544
+ break;
2545
+ }
2442
2546
  case "ping" /* PING */:
2443
2547
  conn.sendPong();
2444
2548
  break;
@@ -2541,6 +2645,7 @@ var PRBEAgent = class _PRBEAgent {
2541
2645
  // src/serialization.ts
2542
2646
  var DEFAULT_PRBE_STATE = {
2543
2647
  isInvestigating: false,
2648
+ isPrivacySanitizing: false,
2544
2649
  events: [],
2545
2650
  report: "",
2546
2651
  summary: "",
@@ -2579,6 +2684,7 @@ function serializeBackgroundInvestigation(bg) {
2579
2684
  function serializePRBEState(state) {
2580
2685
  return {
2581
2686
  isInvestigating: state.isInvestigating,
2687
+ isPrivacySanitizing: state.isPrivacySanitizing,
2582
2688
  events: state.events,
2583
2689
  report: state.report,
2584
2690
  summary: state.summary,