@prbe.ai/electron-sdk 0.1.19 → 0.1.21

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
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.1.19";
2
+ var version = "0.1.21";
3
3
 
4
4
  // src/agent.ts
5
5
  import * as fs2 from "fs";
@@ -54,6 +54,8 @@ var ToolName = /* @__PURE__ */ ((ToolName2) => {
54
54
  ToolName2["CLIENT_ASK_USER"] = "client_ask_user";
55
55
  ToolName2["CLIENT_BASH_EXECUTE"] = "client_bash_execute";
56
56
  ToolName2["CLIENT_MESSAGE_USER"] = "client_message_user";
57
+ ToolName2["SDK_MESSAGE_USER"] = "sdk_message_user";
58
+ ToolName2["SDK_ASK_USER"] = "sdk_ask_user";
57
59
  return ToolName2;
58
60
  })(ToolName || {});
59
61
  var UserIdentifierType = /* @__PURE__ */ ((UserIdentifierType2) => {
@@ -125,7 +127,9 @@ var InvestigationConnection = class {
125
127
  if (!raw) return;
126
128
  try {
127
129
  const msg = JSON.parse(raw);
128
- this.onMessage(msg);
130
+ Promise.resolve(this.onMessage(msg)).catch((err) => {
131
+ this.onError(`Message handler error: ${err instanceof Error ? err.message : String(err)}`);
132
+ });
129
133
  } catch {
130
134
  }
131
135
  };
@@ -1400,7 +1404,7 @@ var AskUserTool = class {
1400
1404
  }
1401
1405
  get declaration() {
1402
1406
  return {
1403
- name: "client_ask_user" /* CLIENT_ASK_USER */,
1407
+ name: "sdk_ask_user" /* SDK_ASK_USER */,
1404
1408
  description: "Ask the user a question and wait for their response. Use this when you need clarification or additional information from the user to continue the investigation.",
1405
1409
  interactive: true,
1406
1410
  parameters: [
@@ -1839,7 +1843,7 @@ var PRBEAgent = class _PRBEAgent {
1839
1843
  }
1840
1844
  this.registry.register(
1841
1845
  new PRBEClosureTool(
1842
- "client_message_user",
1846
+ "sdk_message_user" /* SDK_MESSAGE_USER */,
1843
1847
  "Send a message to the user.",
1844
1848
  [{ name: "message", type: "STRING" /* STRING */, description: "Message for the user", required: true }],
1845
1849
  async (args) => {
@@ -1929,9 +1933,6 @@ ${p.reason}` : p.command;
1929
1933
 
1930
1934
  ${p.reason}` : p.path;
1931
1935
  this.sendConversationMessage(content, "agent" /* Agent */, "Request path access");
1932
- } else if (payload.type === "ask_question" /* ASK_QUESTION */) {
1933
- const p = payload;
1934
- this.sendConversationMessage(p.question, "agent" /* Agent */);
1935
1936
  }
1936
1937
  if (this.currentInvestigationSource !== "user" /* USER */ && this.currentBackgroundId) {
1937
1938
  this.state.setBackgroundPendingInteraction(this.currentBackgroundId, payload);
@@ -2325,6 +2326,8 @@ ${p.reason}` : p.path;
2325
2326
  }));
2326
2327
  const startMetadata = {
2327
2328
  agent_id: this.agentID,
2329
+ sdk_name: "electron",
2330
+ supports_chat: true,
2328
2331
  custom_tools: toolDeclarations,
2329
2332
  platform: os.platform(),
2330
2333
  os_version: os.release(),
@@ -2373,7 +2376,12 @@ ${p.reason}` : p.path;
2373
2376
  const args = this.extractArgs(msg.metadata);
2374
2377
  emit({ type: "tool_call" /* TOOL_CALL */, name: toolName, label: msg.content ?? `Running ${toolName}` });
2375
2378
  this.pendingFlaggedFiles = [];
2376
- const toolResult = redactPII(await this.registry.execute(toolName, args));
2379
+ let toolResult;
2380
+ try {
2381
+ toolResult = redactPII(await this.registry.execute(toolName, args));
2382
+ } catch (err) {
2383
+ toolResult = `Error: Tool execution failed: ${err instanceof Error ? err.message : String(err)}`;
2384
+ }
2377
2385
  emit({ type: "observation" /* OBSERVATION */, text: toolResult.substring(0, 200) });
2378
2386
  let resultMetadata;
2379
2387
  const uploadBaseUrl = getUploadBaseUrl();