@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.mjs CHANGED
@@ -40,6 +40,7 @@ var ToolName = /* @__PURE__ */ ((ToolName2) => {
40
40
  ToolName2["CLIENT_FLAG_APP_LOGS"] = "client_flag_app_logs";
41
41
  ToolName2["CLIENT_ASK_USER"] = "client_ask_user";
42
42
  ToolName2["CLIENT_BASH_EXECUTE"] = "client_bash_execute";
43
+ ToolName2["CLIENT_MESSAGE_USER"] = "client_message_user";
43
44
  return ToolName2;
44
45
  })(ToolName || {});
45
46
  var PRBEAgentConfigKey = /* @__PURE__ */ ((PRBEAgentConfigKey3) => {
@@ -104,6 +105,7 @@ var PRBEStateEvent = /* @__PURE__ */ ((PRBEStateEvent2) => {
104
105
  PRBEStateEvent2["TICKET_INFO"] = "ticket-info";
105
106
  PRBEStateEvent2["INTERACTION_REQUESTED"] = "interaction-requested";
106
107
  PRBEStateEvent2["INTERACTION_RESOLVED"] = "interaction-resolved";
108
+ PRBEStateEvent2["AGENT_MESSAGE"] = "agent-message";
107
109
  return PRBEStateEvent2;
108
110
  })(PRBEStateEvent || {});
109
111
  var PRBEAgentState = class extends EventEmitter {
@@ -116,6 +118,7 @@ var PRBEAgentState = class extends EventEmitter {
116
118
  investigationError;
117
119
  pendingInteraction;
118
120
  resolvedInteractions = [];
121
+ agentMessage;
119
122
  // Completed user investigations (history)
120
123
  completedInvestigations = [];
121
124
  // Background context requests
@@ -143,6 +146,7 @@ var PRBEAgentState = class extends EventEmitter {
143
146
  this.summary = "";
144
147
  this.currentQuery = query;
145
148
  this.investigationError = void 0;
149
+ this.agentMessage = void 0;
146
150
  this.emit("status" /* STATUS */);
147
151
  }
148
152
  resetInvestigation() {
@@ -154,6 +158,7 @@ var PRBEAgentState = class extends EventEmitter {
154
158
  this.currentQuery = "";
155
159
  this.investigationError = void 0;
156
160
  this.pendingInteraction = void 0;
161
+ this.agentMessage = void 0;
157
162
  this.emit("status" /* STATUS */);
158
163
  }
159
164
  appendEvent(label, detail, completed = false) {
@@ -260,6 +265,18 @@ var PRBEAgentState = class extends EventEmitter {
260
265
  this.emit("interaction-resolved" /* INTERACTION_RESOLVED */);
261
266
  this.emit("status" /* STATUS */);
262
267
  }
268
+ setAgentMessage(message) {
269
+ this.agentMessage = message;
270
+ this.emit("agent-message" /* AGENT_MESSAGE */, { message });
271
+ this.emit("status" /* STATUS */);
272
+ }
273
+ setCRAgentMessage(crID, message) {
274
+ const cr = this.activeCRs.get(crID);
275
+ if (!cr) return;
276
+ cr.agentMessage = message;
277
+ this.emit("agent-message" /* AGENT_MESSAGE */, { message });
278
+ this.emit("status" /* STATUS */);
279
+ }
263
280
  toggleExpansion(eventId) {
264
281
  const event = this.events.find((e) => e.id === eventId);
265
282
  if (event) {
@@ -1294,70 +1311,136 @@ var AskUserTool = class {
1294
1311
  import { exec } from "child_process";
1295
1312
  import { randomUUID as randomUUID4 } from "crypto";
1296
1313
  import * as path3 from "path";
1297
- var IS_WINDOWS = process.platform === "win32";
1314
+
1315
+ // src/tools/safe-commands.ts
1298
1316
  var UNIX_SAFE_COMMANDS = /* @__PURE__ */ new Set([
1317
+ // Filesystem (read-only)
1299
1318
  "ls",
1300
1319
  "cat",
1301
1320
  "head",
1302
1321
  "tail",
1303
- "grep",
1304
- "rg",
1305
1322
  "find",
1306
- "which",
1307
- "whoami",
1308
- "pwd",
1309
- "echo",
1310
- "printf",
1311
- "wc",
1312
- "sort",
1313
- "uniq",
1314
- "diff",
1315
1323
  "file",
1316
1324
  "stat",
1317
1325
  "du",
1318
1326
  "df",
1327
+ "wc",
1328
+ "sort",
1329
+ "uniq",
1330
+ "diff",
1331
+ "tree",
1332
+ // Search
1333
+ "grep",
1334
+ "rg",
1335
+ "which",
1336
+ // Text
1337
+ "echo",
1338
+ "printf",
1339
+ // Identity / environment
1340
+ "whoami",
1341
+ "pwd",
1342
+ "id",
1343
+ "hostname",
1319
1344
  "uname",
1320
1345
  "env",
1321
1346
  "printenv",
1347
+ "locale",
1348
+ // System info (read-only reporters)
1322
1349
  "date",
1323
- "id",
1324
- "hostname",
1350
+ "uptime",
1351
+ "free",
1325
1352
  "ps",
1326
1353
  "top",
1327
- "uptime",
1328
- "free"
1354
+ // macOS-specific (read-only only)
1355
+ "sw_vers",
1356
+ // macOS version
1357
+ "system_profiler",
1358
+ // hardware/software info
1359
+ "mdls",
1360
+ // Spotlight metadata for a file
1361
+ "mdfind",
1362
+ // Spotlight search
1363
+ "lsof",
1364
+ // list open files
1365
+ "ioreg",
1366
+ // I/O registry (hardware tree)
1367
+ "log",
1368
+ // macOS unified log (show, stream — read-only)
1369
+ // Linux-specific (read-only reporters)
1370
+ "lsb_release",
1371
+ // distro info
1372
+ "lscpu",
1373
+ // CPU info
1374
+ "lsblk",
1375
+ // block devices
1376
+ "lspci",
1377
+ // PCI devices
1378
+ "lsusb",
1379
+ // USB devices
1380
+ "lsmem",
1381
+ // memory ranges
1382
+ "dmidecode",
1383
+ // BIOS/hardware info
1384
+ "ss",
1385
+ // socket statistics
1386
+ "journalctl"
1387
+ // systemd logs (read-only)
1329
1388
  ]);
1330
1389
  var WINDOWS_SAFE_COMMANDS = /* @__PURE__ */ new Set([
1390
+ // CMD — filesystem (read-only)
1331
1391
  "dir",
1332
1392
  "type",
1393
+ "tree",
1394
+ "more",
1333
1395
  "findstr",
1334
1396
  "where",
1397
+ // CMD — system info (read-only reporters)
1398
+ "systeminfo",
1399
+ "hostname",
1400
+ "ver",
1401
+ "vol",
1402
+ "date",
1403
+ "set",
1404
+ "path",
1405
+ "chcp",
1335
1406
  "whoami",
1336
1407
  "echo",
1337
1408
  "sort",
1338
1409
  "fc",
1339
- "hostname",
1340
- "date",
1341
- "systeminfo",
1410
+ // CMD — processes
1342
1411
  "tasklist",
1343
- "set",
1344
- "ver",
1345
- "vol",
1346
- "tree",
1347
- // PowerShell cmdlets (when shell is PowerShell)
1412
+ "driverquery",
1413
+ // CMD — network (read-only)
1414
+ "netstat",
1415
+ // CMD — policy (read-only)
1416
+ "gpresult",
1417
+ // PowerShell — Get-* cmdlets (strictly read-only by convention)
1348
1418
  "get-childitem",
1349
1419
  "get-content",
1420
+ "get-item",
1421
+ "test-path",
1422
+ "resolve-path",
1423
+ "get-itemproperty",
1350
1424
  "select-string",
1351
- "get-process",
1352
- "get-date",
1425
+ "measure-object",
1353
1426
  "get-host",
1354
1427
  "get-computerinfo",
1428
+ "get-date",
1355
1429
  "get-volume",
1356
- "test-path",
1357
- "resolve-path",
1358
- "measure-object"
1430
+ "get-disk",
1431
+ "get-partition",
1432
+ "get-process",
1433
+ "get-service",
1434
+ "get-netadapter",
1435
+ "get-nettcpconnection",
1436
+ "get-netipaddress",
1437
+ "get-netroute",
1438
+ "get-hotfix",
1439
+ "get-eventlog",
1440
+ "get-winevent",
1441
+ "get-wmiobject",
1442
+ "get-ciminstance"
1359
1443
  ]);
1360
- var SAFE_COMMANDS = IS_WINDOWS ? WINDOWS_SAFE_COMMANDS : UNIX_SAFE_COMMANDS;
1361
1444
  var SAFE_COMMAND_PREFIXES = /* @__PURE__ */ new Set([
1362
1445
  "git status",
1363
1446
  "git log",
@@ -1369,6 +1452,11 @@ var SAFE_COMMAND_PREFIXES = /* @__PURE__ */ new Set([
1369
1452
  "npm list",
1370
1453
  "npm ls"
1371
1454
  ]);
1455
+ var IS_WINDOWS = process.platform === "win32";
1456
+ var SAFE_COMMANDS = IS_WINDOWS ? WINDOWS_SAFE_COMMANDS : UNIX_SAFE_COMMANDS;
1457
+
1458
+ // src/tools/bash.ts
1459
+ var IS_WINDOWS2 = process.platform === "win32";
1372
1460
  var MAX_OUTPUT_BYTES = 100 * 1024;
1373
1461
  var DEFAULT_TIMEOUT_MS = 3e4;
1374
1462
  var MAX_TIMEOUT_MS = 12e4;
@@ -1446,7 +1534,7 @@ var BashExecuteTool = class {
1446
1534
  maxBuffer: MAX_OUTPUT_BYTES,
1447
1535
  env: process.env,
1448
1536
  // On Windows, use PowerShell for more consistent behavior
1449
- ...IS_WINDOWS ? { shell: "powershell.exe" } : {}
1537
+ ...IS_WINDOWS2 ? { shell: "powershell.exe" } : {}
1450
1538
  },
1451
1539
  (error, stdout, stderr) => {
1452
1540
  let output = "";
@@ -1483,9 +1571,9 @@ var BashExecuteTool = class {
1483
1571
  return true;
1484
1572
  }
1485
1573
  }
1486
- const firstCommand = IS_WINDOWS ? trimmed.split(/[|;]/, 1)[0].trim() : trimmed.split(/[|;&]/, 1)[0].trim();
1574
+ const firstCommand = IS_WINDOWS2 ? trimmed.split(/[|;]/, 1)[0].trim() : trimmed.split(/[|;&]/, 1)[0].trim();
1487
1575
  const baseCommand = firstCommand.split(/\s+/, 1)[0];
1488
- const commandName = IS_WINDOWS ? baseCommand.toLowerCase() : path3.basename(baseCommand);
1576
+ const commandName = IS_WINDOWS2 ? baseCommand.toLowerCase() : path3.basename(baseCommand);
1489
1577
  if (SAFE_COMMANDS.has(commandName)) {
1490
1578
  return this.areAllPipeSegmentsSafe(trimmed);
1491
1579
  }
@@ -1495,7 +1583,7 @@ var BashExecuteTool = class {
1495
1583
  * For piped commands, check that every segment uses a safe command.
1496
1584
  */
1497
1585
  areAllPipeSegmentsSafe(command) {
1498
- if (IS_WINDOWS) {
1586
+ if (IS_WINDOWS2) {
1499
1587
  if (/;/.test(command) && command.split("|").length <= 1) return false;
1500
1588
  } else {
1501
1589
  if (/[;&]|&&|\|\|/.test(command)) return false;
@@ -1503,7 +1591,7 @@ var BashExecuteTool = class {
1503
1591
  const segments = command.split("|").map((s) => s.trim());
1504
1592
  for (const segment of segments) {
1505
1593
  const baseCommand = segment.split(/\s+/, 1)[0];
1506
- const commandName = IS_WINDOWS ? baseCommand.toLowerCase() : path3.basename(baseCommand);
1594
+ const commandName = IS_WINDOWS2 ? baseCommand.toLowerCase() : path3.basename(baseCommand);
1507
1595
  if (!SAFE_COMMANDS.has(commandName)) {
1508
1596
  return false;
1509
1597
  }
@@ -1821,6 +1909,22 @@ var PRBEAgent = class _PRBEAgent {
1821
1909
  this.registry.register(new AskUserTool(requester));
1822
1910
  this.registry.register(new BashExecuteTool(requester, roots, grantedPaths));
1823
1911
  }
1912
+ this.registry.register(
1913
+ new PRBEClosureTool(
1914
+ "client_message_user",
1915
+ "Send a message to the user.",
1916
+ [{ name: "message", type: "STRING" /* STRING */, description: "Message for the user", required: true }],
1917
+ async (args) => {
1918
+ const message = args["message"] ?? "";
1919
+ if (this.currentInvestigationSource === "context_request" /* CONTEXT_REQUEST */ && this.currentCRId) {
1920
+ this.state.setCRAgentMessage(this.currentCRId, message);
1921
+ } else {
1922
+ this.state.setAgentMessage(message);
1923
+ }
1924
+ return "Message delivered.";
1925
+ }
1926
+ )
1927
+ );
1824
1928
  if (this.config.captureConsole) {
1825
1929
  this.logCapture.startCapturing();
1826
1930
  }
@@ -2208,7 +2312,10 @@ var PRBEAgent = class _PRBEAgent {
2208
2312
  }));
2209
2313
  const startMetadata = {
2210
2314
  agent_id: this.agentID,
2211
- custom_tools: toolDeclarations
2315
+ custom_tools: toolDeclarations,
2316
+ platform: os2.platform(),
2317
+ os_version: os2.release(),
2318
+ arch: os2.arch()
2212
2319
  };
2213
2320
  if (contextRequestID) {
2214
2321
  startMetadata["context_request_id"] = contextRequestID;
@@ -2547,6 +2654,7 @@ function serializeCR(cr) {
2547
2654
  report: cr.report,
2548
2655
  summary: cr.summary,
2549
2656
  errorMessage: cr.errorMessage,
2657
+ agentMessage: cr.agentMessage,
2550
2658
  startedAt: cr.startedAt.toISOString(),
2551
2659
  pendingInteraction: cr.pendingInteraction,
2552
2660
  resolvedInteractions: cr.resolvedInteractions ?? []
@@ -2562,6 +2670,7 @@ function serializePRBEState(state) {
2562
2670
  investigationError: state.investigationError,
2563
2671
  pendingInteraction: state.pendingInteraction,
2564
2672
  resolvedInteractions: state.resolvedInteractions,
2673
+ agentMessage: state.agentMessage,
2565
2674
  completedInvestigations: state.completedInvestigations.map((inv) => ({
2566
2675
  id: inv.id,
2567
2676
  query: inv.query,