bereach-openclaw 0.2.5 → 0.2.7

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/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "bereach-openclaw",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "BeReach LinkedIn automation plugin for OpenClaw",
5
5
  "license": "AGPL-3.0",
6
+ "scripts": {
7
+ "test:register": "tsx scripts/test-register.ts"
8
+ },
6
9
  "openclaw": {
7
10
  "extensions": [
8
11
  "./src/index.ts"
@@ -12,6 +15,7 @@
12
15
  "bereach": "^0.1.4"
13
16
  },
14
17
  "devDependencies": {
18
+ "tsx": "^4.21.0",
15
19
  "typescript": "^5.9.3"
16
20
  }
17
21
  }
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env tsx
2
+ /**
3
+ * Simulates OpenClaw plugin registration to catch config/trim errors.
4
+ * Run: pnpm exec tsx scripts/test-register.ts
5
+ * Or: BEREACH_API_KEY=brc_your_key pnpm exec tsx scripts/test-register.ts
6
+ */
7
+
8
+ import register from "../src/index";
9
+
10
+ const apiKey = process.env.BEREACH_API_KEY || "brc_test_placeholder";
11
+
12
+ const mockApi = {
13
+ config: { BEREACH_API_KEY: apiKey },
14
+ registerTool: () => {},
15
+ registerCommand: () => {},
16
+ registerCli: () => {},
17
+ };
18
+
19
+ console.log("Testing plugin register (simulates OpenClaw load)...");
20
+ try {
21
+ register(mockApi);
22
+ console.log("✓ register() completed — no trim/undefined errors");
23
+ } catch (err: any) {
24
+ console.error("✗ register() failed:", err?.message || err);
25
+ process.exit(1);
26
+ }
package/src/client.ts CHANGED
@@ -4,7 +4,9 @@ let instance: Bereach | null = null;
4
4
 
5
5
  export function createClient(key?: string): Bereach {
6
6
  if (!instance) {
7
- const apiKey = key || process.env.BEREACH_API_KEY;
7
+ const raw = key ?? process.env.BEREACH_API_KEY;
8
+ const apiKey =
9
+ typeof raw === "string" && raw.trim().length > 0 ? raw.trim() : undefined;
8
10
  if (!apiKey) {
9
11
  throw new Error(
10
12
  "BEREACH_API_KEY is required (set in plugin config or environment)",
package/src/index.ts CHANGED
@@ -2,8 +2,17 @@ import { createClient } from "./client";
2
2
  import { registerAllTools } from "./tools";
3
3
  import { registerCommands } from "./commands";
4
4
 
5
+ function getApiKey(api: any): string | undefined {
6
+ const cfg = api?.config;
7
+ const key =
8
+ cfg?.BEREACH_API_KEY ??
9
+ cfg?.plugins?.entries?.bereach?.config?.BEREACH_API_KEY;
10
+ return typeof key === "string" && key.trim().length > 0 ? key.trim() : undefined;
11
+ }
12
+
5
13
  export default function register(api: any) {
6
- const client = createClient(api.config.BEREACH_API_KEY);
14
+ const apiKey = getApiKey(api);
15
+ const client = createClient(apiKey);
7
16
  registerAllTools(api, client);
8
17
  registerCommands(api, client);
9
18
  }