bereach-openclaw 1.5.1 → 1.5.4

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.
@@ -2055,4 +2055,23 @@ export const definitions: ToolDefinition[] = [
2055
2055
  properties: {},
2056
2056
  },
2057
2057
  },
2058
+
2059
+ // ── API Key Setup ────────────────────────────────────────────────
2060
+
2061
+ {
2062
+ name: "bereach_set_api_key",
2063
+ description: "Save the BeReach API key in plugin configuration. Call this when the user provides their API key (starts with brc_). After saving, tell the user to restart the gateway with 'openclaw gateway restart' and start a new chat with /new.",
2064
+ handler: "__set_api_key__",
2065
+ parameters: {
2066
+ type: "object",
2067
+ required: ["apiKey"],
2068
+ properties: {
2069
+ apiKey: {
2070
+ type: "string",
2071
+ description: "The BeReach API key (must start with brc_)",
2072
+ },
2073
+ },
2074
+ additionalProperties: false,
2075
+ },
2076
+ },
2058
2077
  ];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "bereach-openclaw",
3
3
  "name": "BeReach",
4
- "version": "1.5.1",
4
+ "version": "1.5.4",
5
5
  "description": "LinkedIn outreach automation — 75+ tools, hook-based enforcement, dynamic context",
6
6
  "configSchema": {
7
7
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bereach-openclaw",
3
- "version": "1.5.1",
3
+ "version": "1.5.4",
4
4
  "description": "BeReach LinkedIn automation plugin for OpenClaw",
5
5
  "license": "AGPL-3.0",
6
6
  "exports": {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: bereach
3
3
  description: "Automate LinkedIn outreach via BeReach (bereach.ai). Use when: prospecting, engaging posts, scraping engagement, searching LinkedIn, managing inbox, running campaigns, managing invitations, analytics, company pages, Sales Navigator, content engagement, feed monitoring. Requires BEREACH_API_KEY."
4
- lastUpdatedAt: 1775561761
4
+ lastUpdatedAt: 1775565279
5
5
  metadata: { "openclaw": { "requires": { "env": ["BEREACH_API_KEY"] }, "primaryEnv": "BEREACH_API_KEY" } }
6
6
  ---
7
7
 
@@ -45,13 +45,13 @@ At install or upgrade, set up the workspace with these templates:
45
45
 
46
46
  When the user provides their BeReach API key (`brc_...`):
47
47
 
48
- 1. Tell them to paste this command in chat: `/bereach-set-key brc_THEIR_KEY` (replacing with their actual key)
48
+ 1. Call the `bereach_set_api_key` tool with their key
49
49
  2. Tell them to restart the gateway: `openclaw gateway restart`
50
50
  3. After restart, start a new chat with `/new`
51
51
 
52
52
  If the user doesn't have a key, direct them to https://bereach.ai/token
53
53
 
54
- **Never** try to set the key via environment variables, auth profiles, or manual config edits. Always use `/bereach-set-key`.
54
+ **Never** use config.patch, environment variables, or manual config edits. Always use the `bereach_set_api_key` tool.
55
55
 
56
56
  ## Two Modes of Operation
57
57
 
@@ -1015,16 +1015,16 @@ export function registerContextHook(api: any, apiKey: string | undefined, state:
1015
1015
  "IMPORTANT: BeReach plugin is installed but no API key is configured.",
1016
1016
  "",
1017
1017
  "If the user provides their BeReach API key (a string starting with brc_):",
1018
- "- Tell them to paste this command in chat: /bereach-set-key brc_THEIR_KEY",
1019
- "- Then restart the gateway: openclaw gateway restart",
1018
+ "- Call the bereach_set_api_key tool with their key",
1019
+ "- Then tell them to restart the gateway: openclaw gateway restart",
1020
1020
  "- Then start a new chat: /new",
1021
1021
  "",
1022
1022
  "If the user has NOT provided a key yet:",
1023
1023
  "- Ask them for their BeReach API key",
1024
1024
  "- They can get one at https://bereach.ai/token",
1025
1025
  "",
1026
- "The /bereach-set-key command saves the key securely in the plugin config.",
1027
- "Do NOT suggest environment variables, config.patch, or any other method.",
1026
+ "ALWAYS use the bereach_set_api_key tool to save the key.",
1027
+ "Do NOT use config.patch, environment variables, or any other method.",
1028
1028
  ].join("\n") };
1029
1029
  }
1030
1030
 
@@ -592,11 +592,14 @@ export function registerEnforcementHook(
592
592
  const toolName: string = ctx?.toolName ?? ctx?.name ?? "";
593
593
  if (!toolName.startsWith("bereach_")) return;
594
594
 
595
+ // Allow set_api_key and self_upgrade without an API key
596
+ if (toolName === "bereach_set_api_key" || toolName === "bereach_self_upgrade") return;
597
+
595
598
  // Resolve API key dynamically
596
599
  const resolvedKey = api?.pluginConfig?.BEREACH_API_KEY ?? api?.pluginConfig?.apiKey ?? apiKey;
597
600
  const key = typeof resolvedKey === "string" && resolvedKey.trim() ? resolvedKey.trim() : undefined;
598
601
  if (!key) {
599
- return { block: true, blockReason: "BLOCKED: BeReach API key not configured. Set it via /bereach-setup or plugin settings, then restart the gateway." };
602
+ return { block: true, blockReason: "BLOCKED: BeReach API key not configured. Provide your key so the agent can save it with bereach_set_api_key. Get a key at https://bereach.ai/token" };
600
603
  }
601
604
 
602
605
  const params: Record<string, unknown> = ctx?.params ?? ctx?.input ?? {};
@@ -65,6 +65,9 @@ async function executeApiCall(def: ToolDefinition, params: Record<string, unknow
65
65
 
66
66
  if (!resp.ok) {
67
67
  const errorBody = await resp.text();
68
+ if (resp.status === 401) {
69
+ throw new Error(`BeReach API key is invalid or expired (401 Unauthorized). The user should get a valid key at https://bereach.ai/token and set it with: /bereach-set-key brc_NEW_KEY`);
70
+ }
68
71
  throw new Error(`API ${method} ${path} failed (${resp.status}): ${errorBody}`);
69
72
  }
70
73
 
@@ -124,7 +127,7 @@ export function registerAllTools(api: any, taskType?: string) {
124
127
  let skipped = 0;
125
128
 
126
129
  for (const def of definitions) {
127
- if (!def.apiPath && def.handler !== "__self_upgrade__" && def.handler !== "__local__") {
130
+ if (!def.apiPath && def.handler !== "__self_upgrade__" && def.handler !== "__local__" && def.handler !== "__set_api_key__") {
128
131
  console.warn(`[bereach:tools] SKIP ${def.name}: no apiPath defined`);
129
132
  continue;
130
133
  }
@@ -145,10 +148,28 @@ export function registerAllTools(api: any, taskType?: string) {
145
148
  return executeSelfUpgrade();
146
149
  }
147
150
 
151
+ if (def.handler === "__set_api_key__") {
152
+ const key = String(params.apiKey ?? "").trim();
153
+ if (!key || !key.startsWith("brc_")) {
154
+ return {
155
+ content: [{ type: "text" as const, text: JSON.stringify({ success: false, error: "Invalid key format. Must start with brc_. Get your key at https://bereach.ai/token" }) }],
156
+ };
157
+ }
158
+ if (typeof api?.config?.set !== "function") {
159
+ return {
160
+ content: [{ type: "text" as const, text: JSON.stringify({ success: false, error: "Config API not available. Set BEREACH_API_KEY as an environment variable instead." }) }],
161
+ };
162
+ }
163
+ api.config.set("plugins.entries.bereach-openclaw.config.BEREACH_API_KEY", key);
164
+ return {
165
+ content: [{ type: "text" as const, text: JSON.stringify({ success: true, message: `API key saved (…${key.slice(-6)}). Tell the user to run: openclaw gateway restart, then /new` }) }],
166
+ };
167
+ }
168
+
148
169
  const apiKey = resolveApiKey(api);
149
170
  if (!apiKey) {
150
171
  return {
151
- content: [{ type: "text" as const, text: JSON.stringify({ success: false, error: "BEREACH_API_KEY not configured. Set it via /bereach-setup or plugin settings." }) }],
172
+ content: [{ type: "text" as const, text: JSON.stringify({ success: false, error: "BEREACH_API_KEY not configured. The user should provide their key so you can call bereach_set_api_key. Get a key at https://bereach.ai/token" }) }],
152
173
  };
153
174
  }
154
175