@prbe.ai/electron-sdk 0.1.10 → 0.1.12

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,5 +1,5 @@
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, g as PollResponse, T as TicketInfoOut } from './types-CeIldtlI.mjs';
2
- export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, j as InteractionType, k as InvestigationResult, M as MIDDLEWARE_URL, l as PRBEAgentConfigKey, m as PRBEAgentError, n as PRBEAgentErrorType, o as PRBEAgentStatus, p as PRBEAgentStatusType, q as PRBECRInvestigation, r as PRBECompletedInvestigation, s as PRBEInteractionHandler, t as PRBESerializedCR, u as PRBESerializedCompletedInvestigation, v as PRBESerializedState, w as PRBESerializedTicket, x as PRBEStateEvent, y as PRBEStatusEvent, z as PollRequest, R as RequestPathAccessPayload, B as RequestPathAccessResponse, E as RequestPermissionPayload, G as RequestPermissionResponse, H as ResolveSessionsRequest, J as ResolveSessionsResponse, K as ResolvedInteraction, L as ResolvedTicketOut, N as TicketInfoRequest, O as TicketInfoResponse, Q as TicketStatusOut, S as ToolName, U as ToolParamType, W as WSMessage, V as WSMessageType, X as redactPII, Y as serializePRBEState } from './types-CeIldtlI.mjs';
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, g as PollResponse, T as TicketInfoOut } from './types-B_KS1-FJ.mjs';
2
+ export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, j as InteractionType, k as InvestigationResult, M as MIDDLEWARE_URL, l as PRBEAgentConfigKey, m as PRBEAgentError, n as PRBEAgentErrorType, o as PRBEAgentStatus, p as PRBEAgentStatusType, q as PRBECRInvestigation, r as PRBECompletedInvestigation, s as PRBEInteractionHandler, t as PRBESerializedCR, u as PRBESerializedCompletedInvestigation, v as PRBESerializedState, w as PRBESerializedTicket, x as PRBEStateEvent, y as PRBEStatusEvent, z as PollRequest, R as RequestPathAccessPayload, B as RequestPathAccessResponse, E as RequestPermissionPayload, G as RequestPermissionResponse, H as ResolveSessionsRequest, J as ResolveSessionsResponse, K as ResolvedInteraction, L as ResolvedTicketOut, N as TicketInfoRequest, O as TicketInfoResponse, Q as TicketStatusOut, S as ToolName, U as ToolParamType, W as WSMessage, V as WSMessageType, X as redactPII, Y as serializePRBEState } from './types-B_KS1-FJ.mjs';
3
3
  import 'events';
4
4
 
5
5
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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, g as PollResponse, T as TicketInfoOut } from './types-CeIldtlI.js';
2
- export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, j as InteractionType, k as InvestigationResult, M as MIDDLEWARE_URL, l as PRBEAgentConfigKey, m as PRBEAgentError, n as PRBEAgentErrorType, o as PRBEAgentStatus, p as PRBEAgentStatusType, q as PRBECRInvestigation, r as PRBECompletedInvestigation, s as PRBEInteractionHandler, t as PRBESerializedCR, u as PRBESerializedCompletedInvestigation, v as PRBESerializedState, w as PRBESerializedTicket, x as PRBEStateEvent, y as PRBEStatusEvent, z as PollRequest, R as RequestPathAccessPayload, B as RequestPathAccessResponse, E as RequestPermissionPayload, G as RequestPermissionResponse, H as ResolveSessionsRequest, J as ResolveSessionsResponse, K as ResolvedInteraction, L as ResolvedTicketOut, N as TicketInfoRequest, O as TicketInfoResponse, Q as TicketStatusOut, S as ToolName, U as ToolParamType, W as WSMessage, V as WSMessageType, X as redactPII, Y as serializePRBEState } from './types-CeIldtlI.js';
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, g as PollResponse, T as TicketInfoOut } from './types-B_KS1-FJ.js';
2
+ export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, j as InteractionType, k as InvestigationResult, M as MIDDLEWARE_URL, l as PRBEAgentConfigKey, m as PRBEAgentError, n as PRBEAgentErrorType, o as PRBEAgentStatus, p as PRBEAgentStatusType, q as PRBECRInvestigation, r as PRBECompletedInvestigation, s as PRBEInteractionHandler, t as PRBESerializedCR, u as PRBESerializedCompletedInvestigation, v as PRBESerializedState, w as PRBESerializedTicket, x as PRBEStateEvent, y as PRBEStatusEvent, z as PollRequest, R as RequestPathAccessPayload, B as RequestPathAccessResponse, E as RequestPermissionPayload, G as RequestPermissionResponse, H as ResolveSessionsRequest, J as ResolveSessionsResponse, K as ResolvedInteraction, L as ResolvedTicketOut, N as TicketInfoRequest, O as TicketInfoResponse, Q as TicketStatusOut, S as ToolName, U as ToolParamType, W as WSMessage, V as WSMessageType, X as redactPII, Y as serializePRBEState } from './types-B_KS1-FJ.js';
3
3
  import 'events';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -110,6 +110,7 @@ var ToolName = /* @__PURE__ */ ((ToolName2) => {
110
110
  ToolName2["CLIENT_FLAG_APP_LOGS"] = "client_flag_app_logs";
111
111
  ToolName2["CLIENT_ASK_USER"] = "client_ask_user";
112
112
  ToolName2["CLIENT_BASH_EXECUTE"] = "client_bash_execute";
113
+ ToolName2["CLIENT_MESSAGE_USER"] = "client_message_user";
113
114
  return ToolName2;
114
115
  })(ToolName || {});
115
116
  var PRBEAgentConfigKey = /* @__PURE__ */ ((PRBEAgentConfigKey3) => {
@@ -174,6 +175,7 @@ var PRBEStateEvent = /* @__PURE__ */ ((PRBEStateEvent2) => {
174
175
  PRBEStateEvent2["TICKET_INFO"] = "ticket-info";
175
176
  PRBEStateEvent2["INTERACTION_REQUESTED"] = "interaction-requested";
176
177
  PRBEStateEvent2["INTERACTION_RESOLVED"] = "interaction-resolved";
178
+ PRBEStateEvent2["AGENT_MESSAGE"] = "agent-message";
177
179
  return PRBEStateEvent2;
178
180
  })(PRBEStateEvent || {});
179
181
  var PRBEAgentState = class extends import_events.EventEmitter {
@@ -186,6 +188,7 @@ var PRBEAgentState = class extends import_events.EventEmitter {
186
188
  investigationError;
187
189
  pendingInteraction;
188
190
  resolvedInteractions = [];
191
+ agentMessage;
189
192
  // Completed user investigations (history)
190
193
  completedInvestigations = [];
191
194
  // Background context requests
@@ -213,6 +216,7 @@ var PRBEAgentState = class extends import_events.EventEmitter {
213
216
  this.summary = "";
214
217
  this.currentQuery = query;
215
218
  this.investigationError = void 0;
219
+ this.agentMessage = void 0;
216
220
  this.emit("status" /* STATUS */);
217
221
  }
218
222
  resetInvestigation() {
@@ -224,6 +228,7 @@ var PRBEAgentState = class extends import_events.EventEmitter {
224
228
  this.currentQuery = "";
225
229
  this.investigationError = void 0;
226
230
  this.pendingInteraction = void 0;
231
+ this.agentMessage = void 0;
227
232
  this.emit("status" /* STATUS */);
228
233
  }
229
234
  appendEvent(label, detail, completed = false) {
@@ -330,6 +335,18 @@ var PRBEAgentState = class extends import_events.EventEmitter {
330
335
  this.emit("interaction-resolved" /* INTERACTION_RESOLVED */);
331
336
  this.emit("status" /* STATUS */);
332
337
  }
338
+ setAgentMessage(message) {
339
+ this.agentMessage = message;
340
+ this.emit("agent-message" /* AGENT_MESSAGE */, { message });
341
+ this.emit("status" /* STATUS */);
342
+ }
343
+ setCRAgentMessage(crID, message) {
344
+ const cr = this.activeCRs.get(crID);
345
+ if (!cr) return;
346
+ cr.agentMessage = message;
347
+ this.emit("agent-message" /* AGENT_MESSAGE */, { message });
348
+ this.emit("status" /* STATUS */);
349
+ }
333
350
  toggleExpansion(eventId) {
334
351
  const event = this.events.find((e) => e.id === eventId);
335
352
  if (event) {
@@ -1364,70 +1381,136 @@ var AskUserTool = class {
1364
1381
  var import_child_process = require("child_process");
1365
1382
  var import_crypto4 = require("crypto");
1366
1383
  var path3 = __toESM(require("path"));
1367
- var IS_WINDOWS = process.platform === "win32";
1384
+
1385
+ // src/tools/safe-commands.ts
1368
1386
  var UNIX_SAFE_COMMANDS = /* @__PURE__ */ new Set([
1387
+ // Filesystem (read-only)
1369
1388
  "ls",
1370
1389
  "cat",
1371
1390
  "head",
1372
1391
  "tail",
1373
- "grep",
1374
- "rg",
1375
1392
  "find",
1376
- "which",
1377
- "whoami",
1378
- "pwd",
1379
- "echo",
1380
- "printf",
1381
- "wc",
1382
- "sort",
1383
- "uniq",
1384
- "diff",
1385
1393
  "file",
1386
1394
  "stat",
1387
1395
  "du",
1388
1396
  "df",
1397
+ "wc",
1398
+ "sort",
1399
+ "uniq",
1400
+ "diff",
1401
+ "tree",
1402
+ // Search
1403
+ "grep",
1404
+ "rg",
1405
+ "which",
1406
+ // Text
1407
+ "echo",
1408
+ "printf",
1409
+ // Identity / environment
1410
+ "whoami",
1411
+ "pwd",
1412
+ "id",
1413
+ "hostname",
1389
1414
  "uname",
1390
1415
  "env",
1391
1416
  "printenv",
1417
+ "locale",
1418
+ // System info (read-only reporters)
1392
1419
  "date",
1393
- "id",
1394
- "hostname",
1420
+ "uptime",
1421
+ "free",
1395
1422
  "ps",
1396
1423
  "top",
1397
- "uptime",
1398
- "free"
1424
+ // macOS-specific (read-only only)
1425
+ "sw_vers",
1426
+ // macOS version
1427
+ "system_profiler",
1428
+ // hardware/software info
1429
+ "mdls",
1430
+ // Spotlight metadata for a file
1431
+ "mdfind",
1432
+ // Spotlight search
1433
+ "lsof",
1434
+ // list open files
1435
+ "ioreg",
1436
+ // I/O registry (hardware tree)
1437
+ "log",
1438
+ // macOS unified log (show, stream — read-only)
1439
+ // Linux-specific (read-only reporters)
1440
+ "lsb_release",
1441
+ // distro info
1442
+ "lscpu",
1443
+ // CPU info
1444
+ "lsblk",
1445
+ // block devices
1446
+ "lspci",
1447
+ // PCI devices
1448
+ "lsusb",
1449
+ // USB devices
1450
+ "lsmem",
1451
+ // memory ranges
1452
+ "dmidecode",
1453
+ // BIOS/hardware info
1454
+ "ss",
1455
+ // socket statistics
1456
+ "journalctl"
1457
+ // systemd logs (read-only)
1399
1458
  ]);
1400
1459
  var WINDOWS_SAFE_COMMANDS = /* @__PURE__ */ new Set([
1460
+ // CMD — filesystem (read-only)
1401
1461
  "dir",
1402
1462
  "type",
1463
+ "tree",
1464
+ "more",
1403
1465
  "findstr",
1404
1466
  "where",
1467
+ // CMD — system info (read-only reporters)
1468
+ "systeminfo",
1469
+ "hostname",
1470
+ "ver",
1471
+ "vol",
1472
+ "date",
1473
+ "set",
1474
+ "path",
1475
+ "chcp",
1405
1476
  "whoami",
1406
1477
  "echo",
1407
1478
  "sort",
1408
1479
  "fc",
1409
- "hostname",
1410
- "date",
1411
- "systeminfo",
1480
+ // CMD — processes
1412
1481
  "tasklist",
1413
- "set",
1414
- "ver",
1415
- "vol",
1416
- "tree",
1417
- // PowerShell cmdlets (when shell is PowerShell)
1482
+ "driverquery",
1483
+ // CMD — network (read-only)
1484
+ "netstat",
1485
+ // CMD — policy (read-only)
1486
+ "gpresult",
1487
+ // PowerShell — Get-* cmdlets (strictly read-only by convention)
1418
1488
  "get-childitem",
1419
1489
  "get-content",
1490
+ "get-item",
1491
+ "test-path",
1492
+ "resolve-path",
1493
+ "get-itemproperty",
1420
1494
  "select-string",
1421
- "get-process",
1422
- "get-date",
1495
+ "measure-object",
1423
1496
  "get-host",
1424
1497
  "get-computerinfo",
1498
+ "get-date",
1425
1499
  "get-volume",
1426
- "test-path",
1427
- "resolve-path",
1428
- "measure-object"
1500
+ "get-disk",
1501
+ "get-partition",
1502
+ "get-process",
1503
+ "get-service",
1504
+ "get-netadapter",
1505
+ "get-nettcpconnection",
1506
+ "get-netipaddress",
1507
+ "get-netroute",
1508
+ "get-hotfix",
1509
+ "get-eventlog",
1510
+ "get-winevent",
1511
+ "get-wmiobject",
1512
+ "get-ciminstance"
1429
1513
  ]);
1430
- var SAFE_COMMANDS = IS_WINDOWS ? WINDOWS_SAFE_COMMANDS : UNIX_SAFE_COMMANDS;
1431
1514
  var SAFE_COMMAND_PREFIXES = /* @__PURE__ */ new Set([
1432
1515
  "git status",
1433
1516
  "git log",
@@ -1439,6 +1522,11 @@ var SAFE_COMMAND_PREFIXES = /* @__PURE__ */ new Set([
1439
1522
  "npm list",
1440
1523
  "npm ls"
1441
1524
  ]);
1525
+ var IS_WINDOWS = process.platform === "win32";
1526
+ var SAFE_COMMANDS = IS_WINDOWS ? WINDOWS_SAFE_COMMANDS : UNIX_SAFE_COMMANDS;
1527
+
1528
+ // src/tools/bash.ts
1529
+ var IS_WINDOWS2 = process.platform === "win32";
1442
1530
  var MAX_OUTPUT_BYTES = 100 * 1024;
1443
1531
  var DEFAULT_TIMEOUT_MS = 3e4;
1444
1532
  var MAX_TIMEOUT_MS = 12e4;
@@ -1516,7 +1604,7 @@ var BashExecuteTool = class {
1516
1604
  maxBuffer: MAX_OUTPUT_BYTES,
1517
1605
  env: process.env,
1518
1606
  // On Windows, use PowerShell for more consistent behavior
1519
- ...IS_WINDOWS ? { shell: "powershell.exe" } : {}
1607
+ ...IS_WINDOWS2 ? { shell: "powershell.exe" } : {}
1520
1608
  },
1521
1609
  (error, stdout, stderr) => {
1522
1610
  let output = "";
@@ -1553,9 +1641,9 @@ var BashExecuteTool = class {
1553
1641
  return true;
1554
1642
  }
1555
1643
  }
1556
- const firstCommand = IS_WINDOWS ? trimmed.split(/[|;]/, 1)[0].trim() : trimmed.split(/[|;&]/, 1)[0].trim();
1644
+ const firstCommand = IS_WINDOWS2 ? trimmed.split(/[|;]/, 1)[0].trim() : trimmed.split(/[|;&]/, 1)[0].trim();
1557
1645
  const baseCommand = firstCommand.split(/\s+/, 1)[0];
1558
- const commandName = IS_WINDOWS ? baseCommand.toLowerCase() : path3.basename(baseCommand);
1646
+ const commandName = IS_WINDOWS2 ? baseCommand.toLowerCase() : path3.basename(baseCommand);
1559
1647
  if (SAFE_COMMANDS.has(commandName)) {
1560
1648
  return this.areAllPipeSegmentsSafe(trimmed);
1561
1649
  }
@@ -1565,7 +1653,7 @@ var BashExecuteTool = class {
1565
1653
  * For piped commands, check that every segment uses a safe command.
1566
1654
  */
1567
1655
  areAllPipeSegmentsSafe(command) {
1568
- if (IS_WINDOWS) {
1656
+ if (IS_WINDOWS2) {
1569
1657
  if (/;/.test(command) && command.split("|").length <= 1) return false;
1570
1658
  } else {
1571
1659
  if (/[;&]|&&|\|\|/.test(command)) return false;
@@ -1573,7 +1661,7 @@ var BashExecuteTool = class {
1573
1661
  const segments = command.split("|").map((s) => s.trim());
1574
1662
  for (const segment of segments) {
1575
1663
  const baseCommand = segment.split(/\s+/, 1)[0];
1576
- const commandName = IS_WINDOWS ? baseCommand.toLowerCase() : path3.basename(baseCommand);
1664
+ const commandName = IS_WINDOWS2 ? baseCommand.toLowerCase() : path3.basename(baseCommand);
1577
1665
  if (!SAFE_COMMANDS.has(commandName)) {
1578
1666
  return false;
1579
1667
  }
@@ -1891,6 +1979,22 @@ var PRBEAgent = class _PRBEAgent {
1891
1979
  this.registry.register(new AskUserTool(requester));
1892
1980
  this.registry.register(new BashExecuteTool(requester, roots, grantedPaths));
1893
1981
  }
1982
+ this.registry.register(
1983
+ new PRBEClosureTool(
1984
+ "client_message_user",
1985
+ "Send a message to the user.",
1986
+ [{ name: "message", type: "STRING" /* STRING */, description: "Message for the user", required: true }],
1987
+ async (args) => {
1988
+ const message = args["message"] ?? "";
1989
+ if (this.currentInvestigationSource === "context_request" /* CONTEXT_REQUEST */ && this.currentCRId) {
1990
+ this.state.setCRAgentMessage(this.currentCRId, message);
1991
+ } else {
1992
+ this.state.setAgentMessage(message);
1993
+ }
1994
+ return "Message delivered.";
1995
+ }
1996
+ )
1997
+ );
1894
1998
  if (this.config.captureConsole) {
1895
1999
  this.logCapture.startCapturing();
1896
2000
  }
@@ -2278,7 +2382,10 @@ var PRBEAgent = class _PRBEAgent {
2278
2382
  }));
2279
2383
  const startMetadata = {
2280
2384
  agent_id: this.agentID,
2281
- custom_tools: toolDeclarations
2385
+ custom_tools: toolDeclarations,
2386
+ platform: os2.platform(),
2387
+ os_version: os2.release(),
2388
+ arch: os2.arch()
2282
2389
  };
2283
2390
  if (contextRequestID) {
2284
2391
  startMetadata["context_request_id"] = contextRequestID;
@@ -2617,6 +2724,7 @@ function serializeCR(cr) {
2617
2724
  report: cr.report,
2618
2725
  summary: cr.summary,
2619
2726
  errorMessage: cr.errorMessage,
2727
+ agentMessage: cr.agentMessage,
2620
2728
  startedAt: cr.startedAt.toISOString(),
2621
2729
  pendingInteraction: cr.pendingInteraction,
2622
2730
  resolvedInteractions: cr.resolvedInteractions ?? []
@@ -2632,6 +2740,7 @@ function serializePRBEState(state) {
2632
2740
  investigationError: state.investigationError,
2633
2741
  pendingInteraction: state.pendingInteraction,
2634
2742
  resolvedInteractions: state.resolvedInteractions,
2743
+ agentMessage: state.agentMessage,
2635
2744
  completedInvestigations: state.completedInvestigations.map((inv) => ({
2636
2745
  id: inv.id,
2637
2746
  query: inv.query,