bereach-openclaw 1.6.11 → 1.6.13

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "bereach-openclaw",
3
3
  "name": "BeReach",
4
- "version": "1.6.11",
4
+ "version": "1.6.13",
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.6.11",
3
+ "version": "1.6.13",
4
4
  "description": "BeReach LinkedIn automation plugin for OpenClaw",
5
5
  "license": "AGPL-3.0",
6
6
  "exports": {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * agent:bootstrap internal hook — drops workspace bootstrap files (SOUL.md,
3
+ * AGENTS.md, IDENTITY.md, USER.md, TOOLS.md, BOOTSTRAP.md, HEARTBEAT.md,
4
+ * MEMORY.md) from every run.
5
+ *
6
+ * Why: the bereach plugin already injects its full soul template + live status
7
+ * via the before_prompt_build hook (appendSystemContext). Shipping the same
8
+ * 35K soul template again through workspace/SOUL.md doubles it in the system
9
+ * prompt and wastes ~5.2K cached tokens per turn (measured on Haiku 4.5).
10
+ *
11
+ * Mutating event.context.bootstrapFiles = [] drops every file without
12
+ * touching disk, so users' workspace directories stay intact.
13
+ *
14
+ * Proven on 2026-04-14 Docker test: restoring SOUL.md from template and
15
+ * enabling this hook gives 37,492 cached tokens/turn vs 42,690 without it.
16
+ */
17
+ export function registerBootstrapHook(api: any) {
18
+ if (typeof api?.registerHook !== "function") return;
19
+ api.registerHook(
20
+ "agent:bootstrap",
21
+ async (event: any) => {
22
+ if (event && event.context) {
23
+ event.context.bootstrapFiles = [];
24
+ }
25
+ },
26
+ {
27
+ name: "bereach-blank-bootstrap",
28
+ description:
29
+ "Drop workspace bootstrap files — bereach context ships via before_prompt_build already.",
30
+ },
31
+ );
32
+ }
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import { registerContextHook } from "./hooks/context";
5
5
  import { registerEnforcementHook } from "./hooks/enforcement";
6
6
  import { registerTrackingHook } from "./hooks/tracking";
7
7
  import { registerLifecycleHook } from "./hooks/lifecycle";
8
+ import { registerBootstrapHook } from "./hooks/bootstrap";
8
9
  import { setTtl, isApiBaseConfigured } from "./hooks/cache";
9
10
  import { createSessionState, type PluginConfig } from "./hooks/types";
10
11
  import { errMsg, createLogger } from "./hooks/utils";
@@ -88,6 +89,7 @@ export default function register(api: any) {
88
89
  ["enforcement", () => registerEnforcementHook(api, apiKey, config, state)],
89
90
  ["tracking", () => registerTrackingHook(api, state)],
90
91
  ["lifecycle", () => registerLifecycleHook(api, apiKey, {}, state)],
92
+ ["bootstrap", () => registerBootstrapHook(api)],
91
93
  ];
92
94
 
93
95
  for (const [name, fn] of hooks) {
@@ -5,6 +5,63 @@ import { resolveApiKey } from "../index";
5
5
 
6
6
  const API_BASE = "https://api.bereach.ai";
7
7
 
8
+ // 42 bereach tools that are never used by automation tasks AND have low chat
9
+ // value. Skipping at registration saves ~5,200 prompt tokens/turn (−15%).
10
+ // Proven via Haiku 4.5 probe 2026-04-15: pt 34,121 → 28,912.
11
+ const SKIP_TOOLS = new Set([
12
+ "bereach_typing_indicator", "bereach_react_message", "bereach_unreact_message",
13
+ "bereach_mark_all_read", "bereach_unarchive_conversation", "bereach_unstar_conversation",
14
+ "bereach_list_starred_conversations", "bereach_list_archived_conversations",
15
+ "bereach_edit_profile", "bereach_edit_post", "bereach_edit_comment",
16
+ "bereach_repost_post", "bereach_unlike_post", "bereach_like_comment",
17
+ "bereach_unlike_comment", "bereach_reply_to_comment", "bereach_save_post",
18
+ "bereach_unsave_post", "bereach_follow_profile", "bereach_unfollow_profile",
19
+ "bereach_follow_company", "bereach_unfollow_company", "bereach_get_profile_views",
20
+ "bereach_search_appearances", "bereach_follower_analytics",
21
+ "bereach_company_page_analytics", "bereach_company_page_posts",
22
+ "bereach_company_page_permissions", "bereach_list_company_pages",
23
+ "bereach_get_own_posts", "bereach_get_followers", "bereach_get_connections",
24
+ "bereach_search_conversations", "bereach_decline_invitation",
25
+ "bereach_list_sent_invitations", "bereach_withdraw_invitation",
26
+ "bereach_switch_account", "bereach_list_account", "bereach_update_account",
27
+ "bereach_collect_comment_replies", "bereach_collect_saved_posts",
28
+ "bereach_refresh_profile",
29
+ ]);
30
+
31
+ // Essential chat tools keep full descriptions; non-essential tools get "" to
32
+ // save ~3,800 prompt tokens/turn. Agent infers purpose from tool names.
33
+ // Proven via Haiku 4.5 probe 2026-04-15: pt 29,430 → 25,624.
34
+ const KEEP_DESCRIPTION = new Set([
35
+ "bereach_list_campaigns", "bereach_create_campaign", "bereach_context_get",
36
+ "bereach_context_set", "bereach_review_drafts", "bereach_list_tasks",
37
+ "bereach_events_feed", "bereach_campaign_health", "bereach_unified_search",
38
+ "bereach_save_conversation", "bereach_get_dm_history",
39
+ "bereach_scheduled_message_create", "bereach_scheduled_message_update",
40
+ "bereach_contacts_add", "bereach_get_credits", "bereach_set_api_key",
41
+ ]);
42
+
43
+ // Drops short/redundant property descriptions before registration to shrink the
44
+ // cached tool-schema prefix (~3,400 tokens/turn on Haiku 4.5). Keeps any
45
+ // description that contains quoted enum hints, cross-refs to other tools, or
46
+ // format/range constraints — the agent still needs those to pick the right value.
47
+ function isDescriptionLoadBearing(desc: string): boolean {
48
+ if (desc.length > 90) return true;
49
+ if (/["'].+["']/.test(desc)) return true;
50
+ if (/\bresolve\b|bereach_|\brequired\b|\boptional\b|\bmax\b|\bdefault\b|\bmin\b|\bformat\b|\bISO\b|\bURN\b|\burn:/i.test(desc)) return true;
51
+ return false;
52
+ }
53
+
54
+ function compactSchemaDescriptions(schema: any): any {
55
+ if (!schema || typeof schema !== "object") return schema;
56
+ if (Array.isArray(schema)) return schema.map(compactSchemaDescriptions);
57
+ const out: Record<string, any> = {};
58
+ for (const [k, v] of Object.entries(schema)) {
59
+ if (k === "description" && typeof v === "string" && !isDescriptionLoadBearing(v)) continue;
60
+ out[k] = compactSchemaDescriptions(v);
61
+ }
62
+ return out;
63
+ }
64
+
8
65
  /**
9
66
  * Register all tools with OpenClaw.
10
67
  * Per-request filtering is handled via allowedTools in the before_prompt_build hook.
@@ -17,12 +74,13 @@ export function registerAllTools(api: any) {
17
74
  console.warn(`[bereach:tools] SKIP ${def.name}: no apiPath defined`);
18
75
  continue;
19
76
  }
77
+ if (SKIP_TOOLS.has(def.name)) continue;
20
78
 
21
79
  registered++;
22
80
  api.registerTool({
23
81
  name: def.name,
24
- description: def.description,
25
- parameters: def.parameters,
82
+ description: KEEP_DESCRIPTION.has(def.name) ? def.description : "",
83
+ parameters: compactSchemaDescriptions(def.parameters),
26
84
  async execute(_id: string, params: Record<string, unknown>) {
27
85
  if (def.handler === "__set_api_key__") {
28
86
  const key = String(params.apiKey ?? "").trim();