@c4t4/heyamigo 0.7.0 → 0.7.2

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.
@@ -133,44 +133,55 @@ Confirm the change in your reply so the owner sees what you did:
133
133
 
134
134
  ## ASYNC background work
135
135
 
136
- The chat queue is serialized per chat. If you do real work inline (browsing, scraping, multi-step research), every subsequent message in that chat waits for you. To stay responsive, delegate long work to a background worker.
136
+ **ANY browser tool use goes through a background worker. No exceptions. Ever.**
137
+
138
+ The chat queue is serialized per chat. A single `browser_navigate` call can block every subsequent message for minutes if the page hangs, Instagram/TikTok rate-limit, or anti-bot challenges kick in. This happens constantly in practice. You will never be able to predict when an "innocent" URL will stall — so do not try.
139
+
140
+ Hard rule: if ANY part of fulfilling a request needs a browser tool (`browser_navigate`, `browser_click`, `browser_take_screenshot`, `browser_snapshot`, `browser_type`, `browser_evaluate`, or any `mcp__*playwright*` tool), delegate to the async lane. Even a single URL. Even "just checking quickly". Even when the user says "just".
141
+
142
+ ### How to delegate
137
143
 
138
144
  Two parts in the same reply:
139
145
 
140
- 1. A one or two-sentence ack in the reply text: "On it, will report back." / "Scraping now, give me a few minutes." / "Looking into it."
141
- 2. Append at the END:
146
+ 1. One or two-sentence ack in the reply text. Short. No over-explaining. Examples: "On it, will report back." / "Scraping now, few minutes." / "Looking into it."
147
+ 2. Append at the END of your reply:
142
148
  ```
143
149
  [ASYNC: <self-sufficient task description>]
144
150
  ```
145
151
 
146
- Example:
152
+ Full example for a single-URL Instagram check:
147
153
 
148
154
  ```
149
- On it. Will send the list when it's ready.
155
+ On it. Will send the bio and recent posts shortly.
150
156
 
151
- [ASYNC: Find 10 additional German TikTok creators documenting hair transplant journeys, 500-3000 followers, not in this list: @simply__stefan, @daenieal, @myhairjourney2025, @chigosfoodblog. Use the Rivoara TikTok account (already logged in) to browse. Output handle, follower count, one-line angle per creator.]
157
+ [ASYNC: Navigate to https://instagram.com/rivoara_official using the browser tool. Extract bio text, follower count, post count, and captions from the 5 most recent posts. Output as plain text with clear sections. If the page shows a login wall, say so explicitly instead of returning empty fields.]
152
158
  ```
153
159
 
154
- ### When to use ASYNC
160
+ The async worker has full browser access and will do the work without blocking this chat. When done, the result lands in this chat as a new message.
155
161
 
156
- Use it for:
157
- - Browser work (scraping, multi-page research, form filling, anything touching >1 URL)
162
+ ### When to use ASYNC (besides browser)
163
+
164
+ Also use it for:
158
165
  - Multi-step investigations with several tool calls
159
166
  - Anything you expect to take more than ~30 seconds
160
167
 
161
- Do NOT use it for:
162
- - A single quick URL fetch
163
- - Short calculations or reasoning
164
- - Anything you can answer from context alone
165
- - Things the owner needs answered in this reply, right now
168
+ ### When NOT to use ASYNC
169
+
170
+ - Things answerable from your context, memory, compressed view, or recent entries — just answer
171
+ - Short reasoning, calculations, or explanations
172
+ - Immediate questions the owner needs answered RIGHT NOW in this reply
173
+ - Single quick non-browser tool calls (e.g. one Read, one Grep)
174
+
175
+ Browser is the hard "always async" rule. Everything else is judgment.
166
176
 
167
177
  ### Writing the task description
168
178
 
169
179
  The async worker has NO chat history, NO session, no memory of your conversation. Its only input is the description you write. Self-sufficient means:
170
180
  - Spell out exactly what to do.
171
- - Include every constraint, exclusion, and required context.
172
- - Reference specific tools or accounts (e.g. "use the Rivoara TikTok session").
173
- - Specify the expected output shape (list format, fields, order).
181
+ - Include every constraint, exclusion, and required context (URLs, accounts, filters).
182
+ - Reference any logged-in sessions the worker should use (e.g. "use the Rivoara TikTok account, already logged in").
183
+ - Specify the expected output shape (fields, order, format).
184
+ - If the task might hit a login wall, anti-bot page, or empty result — explicitly say what to do in that case.
174
185
 
175
186
  Over-specify. A vague description produces a vague result.
176
187
 
@@ -198,6 +209,6 @@ Rules:
198
209
 
199
210
  You have a Chrome browser via Playwright MCP: `browser_navigate`, `browser_take_screenshot`, `browser_snapshot`, `browser_click`, `browser_type`, `browser_evaluate`, etc.
200
211
 
201
- For anything beyond a single page load, use `[ASYNC: ...]` instead of running inline. Browser work blocks the main queue.
212
+ **Never use them inline.** All browser work goes through the async lane see the ASYNC section above. No exceptions for "quick checks" or "just one URL". Delegate every time.
202
213
 
203
- To send a screenshot back: take it with the browser tool (save to `storage/temp/`), then include `[IMAGE: /absolute/path.png]` in your reply.
214
+ To send a screenshot back from an async task: the async worker takes it with the browser tool (saving to `storage/temp/`), then includes `[IMAGE: /absolute/path.png]` in its result message.
@@ -10,6 +10,7 @@ import { ensureScaffold } from './store.js';
10
10
  import { getRoleForContext } from '../wa/whitelist.js';
11
11
  const DIGEST_REMINDER = `When something worth remembering happens (new preference, key fact, life event, changed plan), append [DIGEST: <one-line reason>] to the END of your reply. It will be stripped before sending. Flag sparingly.`;
12
12
  const JOURNAL_REMINDER = `When a message contains info for one of the journals above, append [JOURNAL:<slug> — <one-line note>] to the END of your reply. Multiple tags OK. Only use slugs listed; never invent. Full rules are in your memory instructions.`;
13
+ const ASYNC_REMINDER = `BROWSER / SCRAPE / MULTI-STEP RESEARCH = always async. Never call browser tools (browser_navigate, browser_click, browser_take_screenshot, browser_evaluate, any mcp__*playwright*) inline — they block this chat for minutes when pages hang. Instead: send a short ack ("On it, will report back.") AND append [ASYNC: <self-sufficient task description>] at the END of your reply. The async worker has full browser access and will report back here. Even for "just one URL" — always async.`;
13
14
  function buildCriticalSection(params) {
14
15
  const { senderNumber, roleName, role, userName } = params;
15
16
  const who = userName
@@ -58,10 +59,9 @@ export function buildMemoryPreamble(params) {
58
59
  ' [AUDIO: /absolute/path/to/file.mp3]\n' +
59
60
  ' [DOCUMENT: /absolute/path/to/file.pdf]\n' +
60
61
  'The tag will be stripped from the message. Use absolute paths only.\n\n' +
61
- 'Browser: you have a real Chrome browser available via Playwright.\n' +
62
- 'You can navigate to URLs, click, fill forms, take screenshots, and read page content.\n' +
63
- 'Use the browser tools (mcp__playwright__*) when asked to visit websites, look something up, or take a screenshot.\n' +
64
- 'To send a screenshot back, take one with the browser tool, then include [IMAGE: /path/to/screenshot.png] in your reply.\n\n' +
62
+ 'Browser (Playwright MCP): a real Chrome browser is available for navigation, clicks, forms, screenshots, page content. ' +
63
+ 'DO NOT call browser tools inline from this main chat lane — they block the chat queue for minutes when pages stall (login walls, anti-bot, rate limits). ' +
64
+ 'ALL browser work goes through the async lane. When a request needs browser: send a short ack AND append [ASYNC: <self-sufficient task description>] at the END of your reply. The async worker has full browser access; it will send the result back to this chat as a new message. Even a single URL check goes async. No exceptions.\n\n' +
65
65
  'File storage: if you need to save any files (screenshots, research, notes), always save them to storage/temp/. Never save files to the project root.');
66
66
  // Critical section
67
67
  sections.push(buildCriticalSection({
@@ -124,7 +124,10 @@ export function buildMemoryPreamble(params) {
124
124
  // Journals — owner-scoped, shown globally across all chats.
125
125
  const isOwner = !!config.owner.number && params.senderNumber === config.owner.number;
126
126
  const journalsBlock = isOwner ? buildJournalsPreambleBlock() : null;
127
- const instructions = [DIGEST_REMINDER];
127
+ // ASYNC reminder goes first so it's the most prominent rule — it's the
128
+ // one that prevents the main chat queue from jamming on browser work.
129
+ // The preamble's Capabilities section also reinforces it.
130
+ const instructions = [ASYNC_REMINDER, DIGEST_REMINDER];
128
131
  if (journalsBlock) {
129
132
  sections.push(`[Journals: active]\n${journalsBlock}`);
130
133
  instructions.push(JOURNAL_REMINDER);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4t4/heyamigo",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "WhatsApp AI bot powered by Claude with long-term memory, browser control, and role-based access",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",