@prbe.ai/electron-sdk 0.1.15 → 0.1.17

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,7 +1,9 @@
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-Cyfgy1uD.mjs';
2
- export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, j as ConversationEntry, k as ConversationRole, D as DEFAULT_PRBE_STATE, l as InteractionType, m as InvestigationResult, M as MIDDLEWARE_URL, n as PRBEAgentConfigKey, o as PRBEAgentError, p as PRBEAgentErrorType, q as PRBEAgentStatus, r as PRBEAgentStatusType, s as PRBECRInvestigation, t as PRBECompletedInvestigation, u as PRBEInteractionHandler, v as PRBESerializedCR, w as PRBESerializedCompletedInvestigation, x as PRBESerializedState, y as PRBESerializedTicket, z as PRBEStateEvent, B as PRBEStatusEvent, E as PollRequest, R as RequestPathAccessPayload, G as RequestPathAccessResponse, H as RequestPermissionPayload, J as RequestPermissionResponse, K as ResolveSessionsRequest, L as ResolveSessionsResponse, N as ResolvedInteraction, O as ResolvedTicketOut, Q as TicketInfoRequest, S as TicketInfoResponse, U as TicketStatusOut, V as ToolName, W as ToolParamType, X as WSMessage, Y as WSMessageType, Z as redactPII, _ as serializePRBEState } from './types-Cyfgy1uD.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, U as UserIdentifierType, g as PollResponse, T as TicketInfoOut } from './types-BmH_CmsO.mjs';
2
+ export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, j as ConversationEntry, k as ConversationRole, D as DEFAULT_PRBE_STATE, l as InteractionType, m as InvestigationResult, M as MIDDLEWARE_URL, n as PRBEAgentConfigKey, o as PRBEAgentError, p as PRBEAgentErrorType, q as PRBEAgentStatus, r as PRBEAgentStatusType, s as PRBECRInvestigation, t as PRBECompletedInvestigation, u as PRBEInteractionHandler, v as PRBESerializedCR, w as PRBESerializedCompletedInvestigation, x as PRBESerializedState, y as PRBESerializedTicket, z as PRBEStateEvent, B as PRBEStatusEvent, E as PollRequest, R as RequestPathAccessPayload, G as RequestPathAccessResponse, H as RequestPermissionPayload, J as RequestPermissionResponse, K as ResolveSessionsRequest, L as ResolveSessionsResponse, N as ResolvedInteraction, O as ResolvedTicketOut, Q as TicketInfoRequest, S as TicketInfoResponse, V as TicketStatusOut, W as ToolName, X as ToolParamType, Y as WSMessage, Z as WSMessageType, _ as redactPII, $ as serializePRBEState } from './types-BmH_CmsO.mjs';
3
3
  import 'events';
4
4
 
5
+ var version = "0.1.17";
6
+
5
7
  /**
6
8
  * tools/index.ts — Tool interface, registry, and closure tool
7
9
  *
@@ -150,6 +152,8 @@ declare class PRBEAgent implements PRBEInteractionRequester {
150
152
  private readonly historyStore;
151
153
  /** Files flagged during the current tool call — uploaded immediately after the tool returns. */
152
154
  private pendingFlaggedFiles;
155
+ private userEmail?;
156
+ private userId?;
153
157
  private get agentID();
154
158
  private get trackedSessionIDs();
155
159
  private set trackedSessionIDs(value);
@@ -171,6 +175,18 @@ declare class PRBEAgent implements PRBEInteractionRequester {
171
175
  * Call this to add user profile data, app version, etc. after async initialization.
172
176
  */
173
177
  updateSessionMetadata(metadata: Record<string, unknown>): void;
178
+ /**
179
+ * Set a user identifier for this agent. Persists to the backend agents table.
180
+ * Can be called multiple times with different types to set both email and ID.
181
+ * Also auto-injects user_email and/or user_id into session metadata for investigations.
182
+ */
183
+ setUserIdentifier(type: UserIdentifierType, value: string): void;
184
+ /**
185
+ * Clear user identifier(s) for this agent.
186
+ * Pass a specific type to clear only that identifier, or omit to clear both email and ID.
187
+ */
188
+ clearUserIdentifier(type?: UserIdentifierType): void;
189
+ private syncUserIdentifierToBackend;
174
190
  /**
175
191
  * Register a custom tool that the middleware can invoke during investigations.
176
192
  */
@@ -344,4 +360,4 @@ declare class BashExecuteTool implements PRBETool {
344
360
  */
345
361
  declare const PROBE_MARK_SVG = "<svg width=\"256\" height=\"256\" viewBox=\"0 0 256 256\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M50 112 L114 148 L50 184 Z\" fill=\"#111111\" opacity=\"0.07\"/>\n <path d=\"M70 86 L148 134 L70 182 Z\" fill=\"#111111\" opacity=\"0.18\"/>\n <path d=\"M92 56 L192 118 L92 180 Z\" fill=\"#111111\"/>\n</svg>";
346
362
 
347
- export { AskUserTool, BashExecuteTool, ClearAppLogsTool, FindFilesTool, FlagAppLogsTool, FlagFileTool, FlaggedFileIn, InteractionPayload, InteractionResponse, InvestigationSource, ListDirectoryTool, type LogEntry, PRBEAgent, PRBEAgentConfig, PRBEAgentState, PRBEClosureTool, PRBEInteractionRequester, PRBELogCapture, type PRBETool, PRBEToolDeclaration, PRBEToolParameter, PRBEToolRegistry, PROBE_MARK_SVG, PollResponse, ReadAppLogsTool, ReadFileTool, SearchAppLogsTool, SearchContentTool, TicketInfoOut, humanReadableSize, resolveAndValidate, resolveWithAccessRequest };
363
+ export { AskUserTool, BashExecuteTool, ClearAppLogsTool, FindFilesTool, FlagAppLogsTool, FlagFileTool, FlaggedFileIn, InteractionPayload, InteractionResponse, InvestigationSource, ListDirectoryTool, type LogEntry, PRBEAgent, PRBEAgentConfig, PRBEAgentState, PRBEClosureTool, PRBEInteractionRequester, PRBELogCapture, type PRBETool, PRBEToolDeclaration, PRBEToolParameter, PRBEToolRegistry, PROBE_MARK_SVG, PollResponse, ReadAppLogsTool, ReadFileTool, version as SDK_VERSION, SearchAppLogsTool, SearchContentTool, TicketInfoOut, UserIdentifierType, humanReadableSize, resolveAndValidate, resolveWithAccessRequest };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
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-Cyfgy1uD.js';
2
- export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, j as ConversationEntry, k as ConversationRole, D as DEFAULT_PRBE_STATE, l as InteractionType, m as InvestigationResult, M as MIDDLEWARE_URL, n as PRBEAgentConfigKey, o as PRBEAgentError, p as PRBEAgentErrorType, q as PRBEAgentStatus, r as PRBEAgentStatusType, s as PRBECRInvestigation, t as PRBECompletedInvestigation, u as PRBEInteractionHandler, v as PRBESerializedCR, w as PRBESerializedCompletedInvestigation, x as PRBESerializedState, y as PRBESerializedTicket, z as PRBEStateEvent, B as PRBEStatusEvent, E as PollRequest, R as RequestPathAccessPayload, G as RequestPathAccessResponse, H as RequestPermissionPayload, J as RequestPermissionResponse, K as ResolveSessionsRequest, L as ResolveSessionsResponse, N as ResolvedInteraction, O as ResolvedTicketOut, Q as TicketInfoRequest, S as TicketInfoResponse, U as TicketStatusOut, V as ToolName, W as ToolParamType, X as WSMessage, Y as WSMessageType, Z as redactPII, _ as serializePRBEState } from './types-Cyfgy1uD.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, U as UserIdentifierType, g as PollResponse, T as TicketInfoOut } from './types-BmH_CmsO.js';
2
+ export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, j as ConversationEntry, k as ConversationRole, D as DEFAULT_PRBE_STATE, l as InteractionType, m as InvestigationResult, M as MIDDLEWARE_URL, n as PRBEAgentConfigKey, o as PRBEAgentError, p as PRBEAgentErrorType, q as PRBEAgentStatus, r as PRBEAgentStatusType, s as PRBECRInvestigation, t as PRBECompletedInvestigation, u as PRBEInteractionHandler, v as PRBESerializedCR, w as PRBESerializedCompletedInvestigation, x as PRBESerializedState, y as PRBESerializedTicket, z as PRBEStateEvent, B as PRBEStatusEvent, E as PollRequest, R as RequestPathAccessPayload, G as RequestPathAccessResponse, H as RequestPermissionPayload, J as RequestPermissionResponse, K as ResolveSessionsRequest, L as ResolveSessionsResponse, N as ResolvedInteraction, O as ResolvedTicketOut, Q as TicketInfoRequest, S as TicketInfoResponse, V as TicketStatusOut, W as ToolName, X as ToolParamType, Y as WSMessage, Z as WSMessageType, _ as redactPII, $ as serializePRBEState } from './types-BmH_CmsO.js';
3
3
  import 'events';
4
4
 
5
+ var version = "0.1.17";
6
+
5
7
  /**
6
8
  * tools/index.ts — Tool interface, registry, and closure tool
7
9
  *
@@ -150,6 +152,8 @@ declare class PRBEAgent implements PRBEInteractionRequester {
150
152
  private readonly historyStore;
151
153
  /** Files flagged during the current tool call — uploaded immediately after the tool returns. */
152
154
  private pendingFlaggedFiles;
155
+ private userEmail?;
156
+ private userId?;
153
157
  private get agentID();
154
158
  private get trackedSessionIDs();
155
159
  private set trackedSessionIDs(value);
@@ -171,6 +175,18 @@ declare class PRBEAgent implements PRBEInteractionRequester {
171
175
  * Call this to add user profile data, app version, etc. after async initialization.
172
176
  */
173
177
  updateSessionMetadata(metadata: Record<string, unknown>): void;
178
+ /**
179
+ * Set a user identifier for this agent. Persists to the backend agents table.
180
+ * Can be called multiple times with different types to set both email and ID.
181
+ * Also auto-injects user_email and/or user_id into session metadata for investigations.
182
+ */
183
+ setUserIdentifier(type: UserIdentifierType, value: string): void;
184
+ /**
185
+ * Clear user identifier(s) for this agent.
186
+ * Pass a specific type to clear only that identifier, or omit to clear both email and ID.
187
+ */
188
+ clearUserIdentifier(type?: UserIdentifierType): void;
189
+ private syncUserIdentifierToBackend;
174
190
  /**
175
191
  * Register a custom tool that the middleware can invoke during investigations.
176
192
  */
@@ -344,4 +360,4 @@ declare class BashExecuteTool implements PRBETool {
344
360
  */
345
361
  declare const PROBE_MARK_SVG = "<svg width=\"256\" height=\"256\" viewBox=\"0 0 256 256\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M50 112 L114 148 L50 184 Z\" fill=\"#111111\" opacity=\"0.07\"/>\n <path d=\"M70 86 L148 134 L70 182 Z\" fill=\"#111111\" opacity=\"0.18\"/>\n <path d=\"M92 56 L192 118 L92 180 Z\" fill=\"#111111\"/>\n</svg>";
346
362
 
347
- export { AskUserTool, BashExecuteTool, ClearAppLogsTool, FindFilesTool, FlagAppLogsTool, FlagFileTool, FlaggedFileIn, InteractionPayload, InteractionResponse, InvestigationSource, ListDirectoryTool, type LogEntry, PRBEAgent, PRBEAgentConfig, PRBEAgentState, PRBEClosureTool, PRBEInteractionRequester, PRBELogCapture, type PRBETool, PRBEToolDeclaration, PRBEToolParameter, PRBEToolRegistry, PROBE_MARK_SVG, PollResponse, ReadAppLogsTool, ReadFileTool, SearchAppLogsTool, SearchContentTool, TicketInfoOut, humanReadableSize, resolveAndValidate, resolveWithAccessRequest };
363
+ export { AskUserTool, BashExecuteTool, ClearAppLogsTool, FindFilesTool, FlagAppLogsTool, FlagFileTool, FlaggedFileIn, InteractionPayload, InteractionResponse, InvestigationSource, ListDirectoryTool, type LogEntry, PRBEAgent, PRBEAgentConfig, PRBEAgentState, PRBEClosureTool, PRBEInteractionRequester, PRBELogCapture, type PRBETool, PRBEToolDeclaration, PRBEToolParameter, PRBEToolRegistry, PROBE_MARK_SVG, PollResponse, ReadAppLogsTool, ReadFileTool, version as SDK_VERSION, SearchAppLogsTool, SearchContentTool, TicketInfoOut, UserIdentifierType, humanReadableSize, resolveAndValidate, resolveWithAccessRequest };
package/dist/index.js CHANGED
@@ -56,10 +56,12 @@ __export(src_exports, {
56
56
  PROBE_MARK_SVG: () => PROBE_MARK_SVG,
57
57
  ReadAppLogsTool: () => ReadAppLogsTool,
58
58
  ReadFileTool: () => ReadFileTool,
59
+ SDK_VERSION: () => version,
59
60
  SearchAppLogsTool: () => SearchAppLogsTool,
60
61
  SearchContentTool: () => SearchContentTool,
61
62
  ToolName: () => ToolName,
62
63
  ToolParamType: () => ToolParamType,
64
+ UserIdentifierType: () => UserIdentifierType,
63
65
  WSMessageType: () => WSMessageType,
64
66
  humanReadableSize: () => humanReadableSize,
65
67
  redactPII: () => redactPII,
@@ -69,6 +71,9 @@ __export(src_exports, {
69
71
  });
70
72
  module.exports = __toCommonJS(src_exports);
71
73
 
74
+ // package.json
75
+ var version = "0.1.17";
76
+
72
77
  // src/agent.ts
73
78
  var fs3 = __toESM(require("fs"));
74
79
  var path5 = __toESM(require("path"));
@@ -121,6 +126,11 @@ var ToolName = /* @__PURE__ */ ((ToolName2) => {
121
126
  ToolName2["CLIENT_MESSAGE_USER"] = "client_message_user";
122
127
  return ToolName2;
123
128
  })(ToolName || {});
129
+ var UserIdentifierType = /* @__PURE__ */ ((UserIdentifierType2) => {
130
+ UserIdentifierType2["EMAIL"] = "email";
131
+ UserIdentifierType2["ID"] = "id";
132
+ return UserIdentifierType2;
133
+ })(UserIdentifierType || {});
124
134
  var PRBEAgentConfigKey = /* @__PURE__ */ ((PRBEAgentConfigKey3) => {
125
135
  PRBEAgentConfigKey3["API_KEY"] = "apiKey";
126
136
  PRBEAgentConfigKey3["AUTO_APPROVED_DIRS"] = "autoApprovedDirs";
@@ -1984,6 +1994,9 @@ var PRBEAgent = class _PRBEAgent {
1984
1994
  historyStore;
1985
1995
  /** Files flagged during the current tool call — uploaded immediately after the tool returns. */
1986
1996
  pendingFlaggedFiles = [];
1997
+ // ---------- User Identifier ----------
1998
+ userEmail;
1999
+ userId;
1987
2000
  // ---------- Persistence ----------
1988
2001
  get agentID() {
1989
2002
  if (this.persistedData.agentId) {
@@ -2030,7 +2043,7 @@ var PRBEAgent = class _PRBEAgent {
2030
2043
  };
2031
2044
  this.interactionHandler = config.interactionHandler;
2032
2045
  this.appDataPath = config.appDataPath;
2033
- this.sessionMetadata = config.sessionMetadata ?? {};
2046
+ this.sessionMetadata = { sdk_version: version, ...config.sessionMetadata };
2034
2047
  if (this.appDataPath && !this.config.autoApprovedDirs.includes(this.appDataPath)) {
2035
2048
  this.config.autoApprovedDirs.push(this.appDataPath);
2036
2049
  }
@@ -2038,6 +2051,7 @@ var PRBEAgent = class _PRBEAgent {
2038
2051
  this.logCapture = new PRBELogCapture(this.config.maxLogEntries);
2039
2052
  this.persistedData = loadPersistedData();
2040
2053
  this.historyStore = new HistoryStore(this.config.apiKey);
2054
+ void this.agentID;
2041
2055
  const history = this.historyStore.load();
2042
2056
  this.state.completedInvestigations = history.investigations;
2043
2057
  this.state.completedCRs = history.crs;
@@ -2191,6 +2205,47 @@ var PRBEAgent = class _PRBEAgent {
2191
2205
  updateSessionMetadata(metadata) {
2192
2206
  this.sessionMetadata = { ...this.sessionMetadata, ...metadata };
2193
2207
  }
2208
+ /**
2209
+ * Set a user identifier for this agent. Persists to the backend agents table.
2210
+ * Can be called multiple times with different types to set both email and ID.
2211
+ * Also auto-injects user_email and/or user_id into session metadata for investigations.
2212
+ */
2213
+ setUserIdentifier(type, value) {
2214
+ if (type === "email" /* EMAIL */) {
2215
+ this.userEmail = value;
2216
+ } else {
2217
+ this.userId = value;
2218
+ }
2219
+ this.syncUserIdentifierToBackend(type, value);
2220
+ }
2221
+ /**
2222
+ * Clear user identifier(s) for this agent.
2223
+ * Pass a specific type to clear only that identifier, or omit to clear both email and ID.
2224
+ */
2225
+ clearUserIdentifier(type) {
2226
+ if (type) {
2227
+ if (type === "email" /* EMAIL */) {
2228
+ this.userEmail = void 0;
2229
+ } else {
2230
+ this.userId = void 0;
2231
+ }
2232
+ this.syncUserIdentifierToBackend(type, null);
2233
+ } else {
2234
+ this.userEmail = void 0;
2235
+ this.userId = void 0;
2236
+ this.syncUserIdentifierToBackend("email" /* EMAIL */, null);
2237
+ this.syncUserIdentifierToBackend("id" /* ID */, null);
2238
+ }
2239
+ }
2240
+ syncUserIdentifierToBackend(type, value) {
2241
+ void this.post("/api/agent/update-user", {
2242
+ agent_id: this.agentID,
2243
+ identifier_type: type,
2244
+ identifier_value: value
2245
+ }).catch((err) => {
2246
+ console.error(`[PRBEAgent] Failed to sync user identifier: ${err}`);
2247
+ });
2248
+ }
2194
2249
  /**
2195
2250
  * Register a custom tool that the middleware can invoke during investigations.
2196
2251
  */
@@ -2491,8 +2546,15 @@ var PRBEAgent = class _PRBEAgent {
2491
2546
  if (contextRequestID) startMetadata["context_request_id"] = contextRequestID;
2492
2547
  if (ticketId) startMetadata["ticket_id"] = ticketId;
2493
2548
  if (this.appDataPath) startMetadata["app_data_path"] = this.appDataPath;
2494
- if (Object.keys(this.sessionMetadata).length > 0) {
2495
- startMetadata["session_metadata"] = this.sessionMetadata;
2549
+ const enrichedMetadata = { ...this.sessionMetadata };
2550
+ if (this.userEmail) {
2551
+ enrichedMetadata["user_email"] = this.userEmail;
2552
+ }
2553
+ if (this.userId) {
2554
+ enrichedMetadata["user_id"] = this.userId;
2555
+ }
2556
+ if (Object.keys(enrichedMetadata).length > 0) {
2557
+ startMetadata["session_metadata"] = enrichedMetadata;
2496
2558
  }
2497
2559
  if (!conn.send({ type: "start" /* START */, content: query, metadata: startMetadata })) {
2498
2560
  emit({ type: "error" /* ERROR */, message: "Failed to send start message" });
@@ -2793,10 +2855,12 @@ var PROBE_MARK_SVG = `<svg width="256" height="256" viewBox="0 0 256 256" fill="
2793
2855
  PROBE_MARK_SVG,
2794
2856
  ReadAppLogsTool,
2795
2857
  ReadFileTool,
2858
+ SDK_VERSION,
2796
2859
  SearchAppLogsTool,
2797
2860
  SearchContentTool,
2798
2861
  ToolName,
2799
2862
  ToolParamType,
2863
+ UserIdentifierType,
2800
2864
  WSMessageType,
2801
2865
  humanReadableSize,
2802
2866
  redactPII,