@prbe.ai/electron-sdk 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +122 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # @prbe.ai/electron-sdk
2
+
3
+ A lightweight TypeScript SDK that adds an AI debug agent to your Electron app. When users hit a bug, the agent investigates autonomously — reading files, searching logs, exploring your codebase — and produces a structured report for your team.
4
+
5
+ Zero external runtime dependencies. Node.js built-ins only.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @prbe.ai/electron-sdk
11
+ ```
12
+
13
+ Requires Node.js 18+ (for native `fetch` and `WebSocket`).
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { PRBEAgent, PRBEAgentConfigKey } from "@prbe.ai/electron-sdk";
19
+ import { app } from "electron";
20
+
21
+ const agent = new PRBEAgent({
22
+ [PRBEAgentConfigKey.API_KEY]: "your-api-key",
23
+ [PRBEAgentConfigKey.ALLOWED_ROOTS]: [
24
+ app.getPath("userData"),
25
+ app.getAppPath(),
26
+ ],
27
+ });
28
+
29
+ // Run an investigation
30
+ agent.investigate("App crashes when opening settings");
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ All config keys are available via the `PRBEAgentConfigKey` enum:
36
+
37
+ | Key | Type | Default | Description |
38
+ |-----|------|---------|-------------|
39
+ | `API_KEY` | `string` | *required* | Your PRBE API key |
40
+ | `ALLOWED_ROOTS` | `string[]` | *required* | Directories the agent can read |
41
+ | `BACKGROUND_POLLING` | `boolean` | `true` | Poll for context requests in the background |
42
+ | `POLLING_INTERVAL` | `number` | `600000` | Polling interval in ms (10 min) |
43
+ | `CAPTURE_CONSOLE` | `boolean` | `true` | Capture `console.*` calls into the log buffer |
44
+ | `MAX_LOG_ENTRIES` | `number` | `10000` | Max entries in the in-memory log buffer |
45
+ | `INTERACTION_HANDLER` | `PRBEInteractionHandler` | — | Handler for user interaction requests (ask questions, request permissions) |
46
+ | `ELECTRON_LOG` | `object` | — | `electron-log` v5 instance for log capture |
47
+ | `IPC_MAIN` | `object` | — | Electron `ipcMain` for renderer log forwarding |
48
+ | `RENDERER_LOG_CHANNEL` | `string` | `"prbe-renderer-log"` | IPC channel name for renderer logs |
49
+
50
+ ## Listening to State
51
+
52
+ The agent exposes an observable state via `EventEmitter`:
53
+
54
+ ```typescript
55
+ import { PRBEStateEvent } from "@prbe.ai/electron-sdk";
56
+
57
+ agent.state.on(PRBEStateEvent.STATUS, () => {
58
+ console.log("Status:", agent.state.currentStatus);
59
+ console.log("Events:", agent.state.events);
60
+ });
61
+
62
+ agent.state.on(PRBEStateEvent.ERROR, (payload) => {
63
+ console.error("Investigation error:", payload.message);
64
+ });
65
+ ```
66
+
67
+ ## Custom Tools
68
+
69
+ Register tools that the AI agent can call during investigations:
70
+
71
+ ```typescript
72
+ agent.registerTool(
73
+ "get_database_stats",
74
+ "Returns row counts for all tables in the local database",
75
+ [
76
+ { name: "table_filter", type: ToolParamType.STRING, description: "Optional table name filter", required: false },
77
+ ],
78
+ async (args) => {
79
+ const filter = args.table_filter as string | undefined;
80
+ const stats = await getDbStats(filter);
81
+ return JSON.stringify(stats);
82
+ },
83
+ );
84
+ ```
85
+
86
+ ## Built-in Tools
87
+
88
+ The SDK ships with 9 built-in tools that the agent uses automatically:
89
+
90
+ **Filesystem** — `list_directory`, `read_file`, `search_content`, `find_files`, `flag_file`
91
+
92
+ **Logs** — `read_app_logs`, `search_app_logs`, `clear_app_logs`, `flag_app_logs`
93
+
94
+ All filesystem access is sandboxed to your configured `ALLOWED_ROOTS`.
95
+
96
+ ## Renderer-Safe Types
97
+
98
+ For renderer/browser code that needs PRBE types without Node.js imports:
99
+
100
+ ```typescript
101
+ import type { PRBESerializedState } from "@prbe.ai/electron-sdk/types";
102
+ ```
103
+
104
+ ## Serialization
105
+
106
+ Serialize agent state for IPC transport to your renderer process:
107
+
108
+ ```typescript
109
+ import { serializePRBEState, DEFAULT_PRBE_STATE } from "@prbe.ai/electron-sdk";
110
+
111
+ // Send to renderer
112
+ const serialized = serializePRBEState(agent.state);
113
+ mainWindow.webContents.send("prbe-state", serialized);
114
+ ```
115
+
116
+ ## Links
117
+
118
+ - [Website](https://useprobe.ai)
119
+
120
+ ## License
121
+
122
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prbe.ai/electron-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "PRBE debug agent SDK for Electron apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",