@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 +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +146 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +146 -59
- package/dist/index.mjs.map +1 -1
- package/dist/{types-CeIldtlI.d.mts → types-B_KS1-FJ.d.mts} +11 -2
- package/dist/{types-CeIldtlI.d.ts → types-B_KS1-FJ.d.ts} +11 -2
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
-
"
|
|
1324
|
-
"
|
|
1350
|
+
"uptime",
|
|
1351
|
+
"free",
|
|
1325
1352
|
"ps",
|
|
1326
1353
|
"top",
|
|
1327
|
-
|
|
1328
|
-
"
|
|
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
|
-
|
|
1340
|
-
"date",
|
|
1341
|
-
"systeminfo",
|
|
1410
|
+
// CMD — processes
|
|
1342
1411
|
"tasklist",
|
|
1343
|
-
"
|
|
1344
|
-
|
|
1345
|
-
"
|
|
1346
|
-
|
|
1347
|
-
|
|
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
|
-
"
|
|
1352
|
-
"get-date",
|
|
1425
|
+
"measure-object",
|
|
1353
1426
|
"get-host",
|
|
1354
1427
|
"get-computerinfo",
|
|
1428
|
+
"get-date",
|
|
1355
1429
|
"get-volume",
|
|
1356
|
-
"
|
|
1357
|
-
"
|
|
1358
|
-
"
|
|
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
|
-
...
|
|
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 =
|
|
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 =
|
|
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 (
|
|
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 =
|
|
1594
|
+
const commandName = IS_WINDOWS2 ? baseCommand.toLowerCase() : path3.basename(baseCommand);
|
|
1507
1595
|
if (!SAFE_COMMANDS.has(commandName)) {
|
|
1508
1596
|
return false;
|
|
1509
1597
|
}
|
|
@@ -1753,13 +1841,6 @@ var PRBEAgent = class _PRBEAgent {
|
|
|
1753
1841
|
this.state.updateTrackedSessionIDs(ids);
|
|
1754
1842
|
this.syncPolling(ids.length > 0);
|
|
1755
1843
|
}
|
|
1756
|
-
get respondedCRIDs() {
|
|
1757
|
-
return new Set(this.persistedData.respondedCRIds ?? []);
|
|
1758
|
-
}
|
|
1759
|
-
set respondedCRIDs(ids) {
|
|
1760
|
-
this.persistedData.respondedCRIds = Array.from(ids);
|
|
1761
|
-
savePersistedData(this.persistedData);
|
|
1762
|
-
}
|
|
1763
1844
|
syncPolling(hasSessions) {
|
|
1764
1845
|
if (this.config.backgroundPolling && hasSessions) {
|
|
1765
1846
|
if (this.pollingTimer === null) {
|
|
@@ -1821,6 +1902,22 @@ var PRBEAgent = class _PRBEAgent {
|
|
|
1821
1902
|
this.registry.register(new AskUserTool(requester));
|
|
1822
1903
|
this.registry.register(new BashExecuteTool(requester, roots, grantedPaths));
|
|
1823
1904
|
}
|
|
1905
|
+
this.registry.register(
|
|
1906
|
+
new PRBEClosureTool(
|
|
1907
|
+
"client_message_user",
|
|
1908
|
+
"Send a message to the user.",
|
|
1909
|
+
[{ name: "message", type: "STRING" /* STRING */, description: "Message for the user", required: true }],
|
|
1910
|
+
async (args) => {
|
|
1911
|
+
const message = args["message"] ?? "";
|
|
1912
|
+
if (this.currentInvestigationSource === "context_request" /* CONTEXT_REQUEST */ && this.currentCRId) {
|
|
1913
|
+
this.state.setCRAgentMessage(this.currentCRId, message);
|
|
1914
|
+
} else {
|
|
1915
|
+
this.state.setAgentMessage(message);
|
|
1916
|
+
}
|
|
1917
|
+
return "Message delivered.";
|
|
1918
|
+
}
|
|
1919
|
+
)
|
|
1920
|
+
);
|
|
1824
1921
|
if (this.config.captureConsole) {
|
|
1825
1922
|
this.logCapture.startCapturing();
|
|
1826
1923
|
}
|
|
@@ -2025,27 +2122,12 @@ var PRBEAgent = class _PRBEAgent {
|
|
|
2025
2122
|
"/api/agent/poll",
|
|
2026
2123
|
request
|
|
2027
2124
|
);
|
|
2028
|
-
const knownCRIDs = /* @__PURE__ */ new Set();
|
|
2029
2125
|
for (const ticket of response.tickets) {
|
|
2030
2126
|
for (const cr of ticket.context_requests) {
|
|
2031
|
-
|
|
2032
|
-
if (!cr.is_active || this.respondedCRIDs.has(cr.id)) continue;
|
|
2127
|
+
if (!cr.is_active) continue;
|
|
2033
2128
|
await this.investigateForCR(cr, ticket.ticket_id);
|
|
2034
|
-
const ids = this.respondedCRIDs;
|
|
2035
|
-
ids.add(cr.id);
|
|
2036
|
-
this.respondedCRIDs = ids;
|
|
2037
2129
|
}
|
|
2038
2130
|
}
|
|
2039
|
-
const currentRespondedIDs = this.respondedCRIDs;
|
|
2040
|
-
const stale = new Set(
|
|
2041
|
-
[...currentRespondedIDs].filter((id) => !knownCRIDs.has(id))
|
|
2042
|
-
);
|
|
2043
|
-
if (stale.size > 0) {
|
|
2044
|
-
const pruned = new Set(
|
|
2045
|
-
[...currentRespondedIDs].filter((id) => !stale.has(id))
|
|
2046
|
-
);
|
|
2047
|
-
this.respondedCRIDs = pruned;
|
|
2048
|
-
}
|
|
2049
2131
|
return response;
|
|
2050
2132
|
} catch {
|
|
2051
2133
|
return null;
|
|
@@ -2208,7 +2290,10 @@ var PRBEAgent = class _PRBEAgent {
|
|
|
2208
2290
|
}));
|
|
2209
2291
|
const startMetadata = {
|
|
2210
2292
|
agent_id: this.agentID,
|
|
2211
|
-
custom_tools: toolDeclarations
|
|
2293
|
+
custom_tools: toolDeclarations,
|
|
2294
|
+
platform: os2.platform(),
|
|
2295
|
+
os_version: os2.release(),
|
|
2296
|
+
arch: os2.arch()
|
|
2212
2297
|
};
|
|
2213
2298
|
if (contextRequestID) {
|
|
2214
2299
|
startMetadata["context_request_id"] = contextRequestID;
|
|
@@ -2547,6 +2632,7 @@ function serializeCR(cr) {
|
|
|
2547
2632
|
report: cr.report,
|
|
2548
2633
|
summary: cr.summary,
|
|
2549
2634
|
errorMessage: cr.errorMessage,
|
|
2635
|
+
agentMessage: cr.agentMessage,
|
|
2550
2636
|
startedAt: cr.startedAt.toISOString(),
|
|
2551
2637
|
pendingInteraction: cr.pendingInteraction,
|
|
2552
2638
|
resolvedInteractions: cr.resolvedInteractions ?? []
|
|
@@ -2562,6 +2648,7 @@ function serializePRBEState(state) {
|
|
|
2562
2648
|
investigationError: state.investigationError,
|
|
2563
2649
|
pendingInteraction: state.pendingInteraction,
|
|
2564
2650
|
resolvedInteractions: state.resolvedInteractions,
|
|
2651
|
+
agentMessage: state.agentMessage,
|
|
2565
2652
|
completedInvestigations: state.completedInvestigations.map((inv) => ({
|
|
2566
2653
|
id: inv.id,
|
|
2567
2654
|
query: inv.query,
|