@prbe.ai/electron-sdk 0.1.10 → 0.1.13

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
  /**
@@ -152,8 +152,6 @@ declare class PRBEAgent implements PRBEInteractionRequester {
152
152
  private get agentID();
153
153
  private get trackedSessionIDs();
154
154
  private set trackedSessionIDs(value);
155
- private get respondedCRIDs();
156
- private set respondedCRIDs(value);
157
155
  private syncPolling;
158
156
  private addTrackedSession;
159
157
  constructor(config: PRBEAgentConfig);
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
  /**
@@ -152,8 +152,6 @@ declare class PRBEAgent implements PRBEInteractionRequester {
152
152
  private get agentID();
153
153
  private get trackedSessionIDs();
154
154
  private set trackedSessionIDs(value);
155
- private get respondedCRIDs();
156
- private set respondedCRIDs(value);
157
155
  private syncPolling;
158
156
  private addTrackedSession;
159
157
  constructor(config: PRBEAgentConfig);
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
  }
@@ -1823,13 +1911,6 @@ var PRBEAgent = class _PRBEAgent {
1823
1911
  this.state.updateTrackedSessionIDs(ids);
1824
1912
  this.syncPolling(ids.length > 0);
1825
1913
  }
1826
- get respondedCRIDs() {
1827
- return new Set(this.persistedData.respondedCRIds ?? []);
1828
- }
1829
- set respondedCRIDs(ids) {
1830
- this.persistedData.respondedCRIds = Array.from(ids);
1831
- savePersistedData(this.persistedData);
1832
- }
1833
1914
  syncPolling(hasSessions) {
1834
1915
  if (this.config.backgroundPolling && hasSessions) {
1835
1916
  if (this.pollingTimer === null) {
@@ -1891,6 +1972,22 @@ var PRBEAgent = class _PRBEAgent {
1891
1972
  this.registry.register(new AskUserTool(requester));
1892
1973
  this.registry.register(new BashExecuteTool(requester, roots, grantedPaths));
1893
1974
  }
1975
+ this.registry.register(
1976
+ new PRBEClosureTool(
1977
+ "client_message_user",
1978
+ "Send a message to the user.",
1979
+ [{ name: "message", type: "STRING" /* STRING */, description: "Message for the user", required: true }],
1980
+ async (args) => {
1981
+ const message = args["message"] ?? "";
1982
+ if (this.currentInvestigationSource === "context_request" /* CONTEXT_REQUEST */ && this.currentCRId) {
1983
+ this.state.setCRAgentMessage(this.currentCRId, message);
1984
+ } else {
1985
+ this.state.setAgentMessage(message);
1986
+ }
1987
+ return "Message delivered.";
1988
+ }
1989
+ )
1990
+ );
1894
1991
  if (this.config.captureConsole) {
1895
1992
  this.logCapture.startCapturing();
1896
1993
  }
@@ -2095,27 +2192,12 @@ var PRBEAgent = class _PRBEAgent {
2095
2192
  "/api/agent/poll",
2096
2193
  request
2097
2194
  );
2098
- const knownCRIDs = /* @__PURE__ */ new Set();
2099
2195
  for (const ticket of response.tickets) {
2100
2196
  for (const cr of ticket.context_requests) {
2101
- knownCRIDs.add(cr.id);
2102
- if (!cr.is_active || this.respondedCRIDs.has(cr.id)) continue;
2197
+ if (!cr.is_active) continue;
2103
2198
  await this.investigateForCR(cr, ticket.ticket_id);
2104
- const ids = this.respondedCRIDs;
2105
- ids.add(cr.id);
2106
- this.respondedCRIDs = ids;
2107
2199
  }
2108
2200
  }
2109
- const currentRespondedIDs = this.respondedCRIDs;
2110
- const stale = new Set(
2111
- [...currentRespondedIDs].filter((id) => !knownCRIDs.has(id))
2112
- );
2113
- if (stale.size > 0) {
2114
- const pruned = new Set(
2115
- [...currentRespondedIDs].filter((id) => !stale.has(id))
2116
- );
2117
- this.respondedCRIDs = pruned;
2118
- }
2119
2201
  return response;
2120
2202
  } catch {
2121
2203
  return null;
@@ -2278,7 +2360,10 @@ var PRBEAgent = class _PRBEAgent {
2278
2360
  }));
2279
2361
  const startMetadata = {
2280
2362
  agent_id: this.agentID,
2281
- custom_tools: toolDeclarations
2363
+ custom_tools: toolDeclarations,
2364
+ platform: os2.platform(),
2365
+ os_version: os2.release(),
2366
+ arch: os2.arch()
2282
2367
  };
2283
2368
  if (contextRequestID) {
2284
2369
  startMetadata["context_request_id"] = contextRequestID;
@@ -2617,6 +2702,7 @@ function serializeCR(cr) {
2617
2702
  report: cr.report,
2618
2703
  summary: cr.summary,
2619
2704
  errorMessage: cr.errorMessage,
2705
+ agentMessage: cr.agentMessage,
2620
2706
  startedAt: cr.startedAt.toISOString(),
2621
2707
  pendingInteraction: cr.pendingInteraction,
2622
2708
  resolvedInteractions: cr.resolvedInteractions ?? []
@@ -2632,6 +2718,7 @@ function serializePRBEState(state) {
2632
2718
  investigationError: state.investigationError,
2633
2719
  pendingInteraction: state.pendingInteraction,
2634
2720
  resolvedInteractions: state.resolvedInteractions,
2721
+ agentMessage: state.agentMessage,
2635
2722
  completedInvestigations: state.completedInvestigations.map((inv) => ({
2636
2723
  id: inv.id,
2637
2724
  query: inv.query,