instar 0.12.20 → 0.12.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.
@@ -1224,7 +1224,7 @@ Present:
1224
1224
 
1225
1225
  Collect their phone number (plain text, NOT AskUserQuestion). Format it with country code (+1XXXXXXXXXX).
1226
1226
 
1227
- Write the config:
1227
+ Write the config with QR auth method (NOT pairing-code — QR is used for browser-automated pairing):
1228
1228
  ```bash
1229
1229
  node -e "
1230
1230
  const fs = require('fs');
@@ -1236,6 +1236,7 @@ c.messaging.push({
1236
1236
  enabled: true,
1237
1237
  config: {
1238
1238
  backend: 'baileys',
1239
+ authMethod: 'qr',
1239
1240
  authorizedNumbers: ['<PHONE_NUMBER>'],
1240
1241
  requireConsent: false
1241
1242
  }
@@ -1244,11 +1245,146 @@ fs.writeFileSync(p, JSON.stringify(c, null, 2));
1244
1245
  "
1245
1246
  ```
1246
1247
 
1247
- Then tell the user:
1248
+ #### Step 4g-1b: Automated WhatsApp Pairing (Baileys)
1249
+
1250
+ **The user should NOT have to run any commands, read logs, or touch tmux.** The wizard handles pairing end-to-end, just like Telegram setup.
1251
+
1252
+ **Step 1: Start the server (if not already running)**
1253
+
1254
+ The agent server must be running for WhatsApp to connect. Start it in the background:
1255
+
1256
+ ```bash
1257
+ cd <project_dir> && npx instar server start &
1258
+ sleep 5 # Wait for server to initialize and WhatsApp adapter to start
1259
+ ```
1260
+
1261
+ Verify the server is running:
1262
+ ```bash
1263
+ curl -s http://localhost:<PORT>/health | jq .status
1264
+ ```
1265
+
1266
+ **Step 2: Check WhatsApp connection status**
1248
1267
 
1249
- > WhatsApp is configured. When you start your agent, it will show a pairing code in the logs. Open WhatsApp on your phone → Settings → Linked Devices → Link a Device, and enter the code.
1268
+ ```bash
1269
+ curl -s http://localhost:<PORT>/whatsapp/status
1270
+ ```
1271
+
1272
+ If already connected (unlikely on first setup), skip to the end.
1273
+
1274
+ **Step 3: Browser-automated QR pairing**
1275
+
1276
+ Use the same browser automation strategy as Telegram (Step 3a detection waterfall: Playwright → Chrome extension → Manual fallback).
1277
+
1278
+ Tell the user:
1279
+
1280
+ > I'm going to pair WhatsApp now. A QR code will appear — you'll scan it with your phone just like linking WhatsApp Web.
1250
1281
  >
1251
- > You can also pair later with: `instar whatsapp connect`
1282
+ > Ready? Say OK and I'll start.
1283
+
1284
+ **Wait for confirmation.**
1285
+
1286
+ **Option A: Dashboard QR (preferred — no external browser needed)**
1287
+
1288
+ The agent's dashboard serves the QR code at `GET /whatsapp/qr`. Open this in the browser:
1289
+
1290
+ **If using Playwright:**
1291
+ ```
1292
+ mcp__playwright__browser_navigate({ url: "http://localhost:<PORT>/dashboard" })
1293
+ ```
1294
+
1295
+ **If using Chrome extension:**
1296
+ ```
1297
+ mcp__claude-in-chrome__navigate({ url: "http://localhost:<PORT>/dashboard", tabId: <tab_id> })
1298
+ ```
1299
+
1300
+ Navigate to the WhatsApp section of the dashboard. The QR code should be visible.
1301
+
1302
+ Tell the user:
1303
+
1304
+ > A QR code should be visible in the browser window. On your phone:
1305
+ > 1. Open WhatsApp
1306
+ > 2. Go to **Settings → Linked Devices → Link a Device**
1307
+ > 3. Scan the QR code in the browser
1308
+
1309
+ **Option B: WhatsApp Web direct (fallback if dashboard QR isn't rendering)**
1310
+
1311
+ Navigate to `https://web.whatsapp.com` in the browser. The QR code there works the same way — scan it with WhatsApp on your phone.
1312
+
1313
+ > If you don't see a QR code in the dashboard, I've opened WhatsApp Web instead. Scan the QR code there with your phone.
1314
+
1315
+ **Note:** This approach requires the Baileys session to NOT be simultaneously connected. If the server's Baileys adapter already took the QR, WhatsApp Web won't show one. In that case, use the dashboard QR endpoint or the pairing code fallback.
1316
+
1317
+ **Step 4: Wait for connection**
1318
+
1319
+ Poll the WhatsApp status endpoint every 5 seconds (up to 2 minutes):
1320
+
1321
+ ```bash
1322
+ curl -s http://localhost:<PORT>/whatsapp/status
1323
+ ```
1324
+
1325
+ Look for `"connected": true` or similar success indicator. Take a page snapshot periodically to check if WhatsApp Web shows the chat list (indicating successful pairing).
1326
+
1327
+ While waiting, tell the user:
1328
+
1329
+ > Waiting for you to scan the QR code... Take your time.
1330
+
1331
+ **Step 5: Confirm connection**
1332
+
1333
+ Once connected:
1334
+
1335
+ > WhatsApp is paired! Your agent can now send and receive messages through WhatsApp.
1336
+
1337
+ If the QR times out (Baileys QR codes expire after ~20 seconds and refresh automatically), tell the user:
1338
+
1339
+ > The QR code refreshed — that's normal. Just scan the new one.
1340
+
1341
+ If pairing fails after 2 minutes of attempts:
1342
+
1343
+ > Having trouble with the QR code? Let me try the pairing code method instead.
1344
+
1345
+ Fall back to pairing code:
1346
+
1347
+ ```bash
1348
+ # Reconfigure to pairing-code method
1349
+ node -e "
1350
+ const fs = require('fs');
1351
+ const p = '<project_dir>/.instar/config.json';
1352
+ const c = JSON.parse(fs.readFileSync(p, 'utf-8'));
1353
+ const wa = c.messaging.find(m => m.type === 'whatsapp');
1354
+ if (wa) { wa.config.authMethod = 'pairing-code'; wa.config.pairingPhoneNumber = '<PHONE_NUMBER>'; }
1355
+ fs.writeFileSync(p, JSON.stringify(c, null, 2));
1356
+ "
1357
+ ```
1358
+
1359
+ Then restart the WhatsApp adapter (or the server) and read the pairing code from the logs:
1360
+
1361
+ > I've switched to pairing code mode. An 8-digit code will appear shortly.
1362
+ >
1363
+ > On your phone: **WhatsApp → Settings → Linked Devices → Link a Device → Link with phone number instead**
1364
+ >
1365
+ > Enter the code when I show it to you.
1366
+
1367
+ Watch the server output for the pairing code and relay it to the user immediately.
1368
+
1369
+ **Option C: Manual fallback (no browser tools available)**
1370
+
1371
+ If neither Playwright nor Chrome extension is available:
1372
+
1373
+ > I don't have browser automation tools right now, so I'll walk you through pairing manually. It's quick — about 30 seconds.
1374
+
1375
+ Start the server, wait for the QR or pairing code in the server output, and relay the pairing code directly to the user:
1376
+
1377
+ > Your pairing code is: **XXXX-XXXX**
1378
+ >
1379
+ > On your phone:
1380
+ > 1. Open WhatsApp
1381
+ > 2. Go to **Settings → Linked Devices → Link a Device**
1382
+ > 3. Tap **Link with phone number instead**
1383
+ > 4. Enter the code above
1384
+
1385
+ Poll for connection and confirm when paired.
1386
+
1387
+ **CRITICAL: The user should NEVER have to run `tmux attach`, `instar whatsapp connect`, or any CLI command.** The wizard handles everything. If something goes wrong, the wizard diagnoses and retries — it doesn't hand the user a command to run.
1252
1388
 
1253
1389
  **If they choose Business API:**
1254
1390
 
@@ -1442,11 +1578,21 @@ curl -s http://localhost:<port>/health
1442
1578
 
1443
1579
  If the health check fails, retry once. If still failing, tell the user what happened and suggest `instar server start` manually.
1444
1580
 
1445
- ### Step 5b: Agent Greets the User in the Lifeline Topic
1581
+ ### Step 5a-2: WhatsApp Pairing (if WhatsApp configured and not yet paired)
1582
+
1583
+ **If WhatsApp (Baileys) was configured, pair it NOW — before declaring setup complete.** Do NOT leave pairing as a post-setup task. The user should walk away from this wizard with a fully connected, working messaging channel.
1584
+
1585
+ If WhatsApp pairing was already completed during Phase 4g (the wizard started the server early for pairing), skip this step.
1586
+
1587
+ If the server was just started in Step 5a and WhatsApp isn't paired yet, run the browser-automated QR pairing flow from Phase 4g Step 4g-1b now. The server is running, so the QR endpoint is available.
1588
+
1589
+ **The "All done!" message MUST NOT appear until WhatsApp is actually connected and the user has sent/received at least one test message.**
1590
+
1591
+ ### Step 5b: Agent Greets the User
1446
1592
 
1447
1593
  **If Telegram was configured, the new agent should reach out to the user in the Lifeline topic.** If WhatsApp was configured (without Telegram), send the greeting via WhatsApp instead. This is the magic moment — the agent comes alive.
1448
1594
 
1449
- Send the greeting to the Lifeline topic (using the `message_thread_id` from Step 3e-vi):
1595
+ **If Telegram:** Send the greeting to the Lifeline topic (using the `message_thread_id` from Step 3e-vi):
1450
1596
 
1451
1597
  ```bash
1452
1598
  curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" \
@@ -1456,7 +1602,18 @@ curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" \
1456
1602
 
1457
1603
  If the Lifeline topic wasn't created (Step 3e-vi failed), fall back to General (omit `message_thread_id`).
1458
1604
 
1459
- The greeting should be **in the agent's voice** AND explain how Telegram topics work. For example, if the agent is named "Scout" and is casual:
1605
+ **If WhatsApp (no Telegram):** Send the greeting via the WhatsApp API endpoint:
1606
+
1607
+ ```bash
1608
+ curl -s -X POST "http://localhost:<PORT>/whatsapp/send" \
1609
+ -H 'Content-Type: application/json' \
1610
+ -H 'Authorization: Bearer <AUTH_TOKEN>' \
1611
+ -d '{"to": "<USER_PHONE_NUMBER>", "message": "<GREETING>"}'
1612
+ ```
1613
+
1614
+ The greeting should be **in the agent's voice**. Adapt to the messaging platform:
1615
+
1616
+ **Telegram example** (if the agent is named "Scout" and is casual):
1460
1617
 
1461
1618
  > Hey! I'm Scout, your new project agent. I'm up and running.
1462
1619
  >
@@ -1470,6 +1627,14 @@ The greeting should be **in the agent's voice** AND explain how Telegram topics
1470
1627
  >
1471
1628
  > What should we work on first?
1472
1629
 
1630
+ **WhatsApp example** (same agent):
1631
+
1632
+ > Hey! I'm Scout, your new project agent. I'm up and running.
1633
+ >
1634
+ > This is our direct line — just message me here anytime. I'll respond right away when I'm active, or pick it up when I wake up.
1635
+ >
1636
+ > You can ask me to work on code, check on the project, run tests, or just chat. What should we work on first?
1637
+
1473
1638
  Adapt the tone and examples to the agent's personality and role. Keep it warm and practical.
1474
1639
 
1475
1640
  ### Step 5c: Install Auto-Start
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "0.12.20",
3
+ "version": "0.12.21",
4
4
  "description": "Persistent autonomy infrastructure for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-03-07T19:05:25.547Z",
5
- "instarVersion": "0.12.20",
4
+ "generatedAt": "2026-03-07T19:14:02.219Z",
5
+ "instarVersion": "0.12.21",
6
6
  "entryCount": 166,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -295,7 +295,7 @@
295
295
  "type": "skill",
296
296
  "domain": "skills",
297
297
  "sourcePath": ".claude/skills/setup-wizard/skill.md",
298
- "contentHash": "7cd0c49f7ed3b7a8bd962f981c52d62c5dedfa7e95dfdc0ce40206f303400f70",
298
+ "contentHash": "b21b0c7e57c0fb346ad444912a1842139aed902fc3a91c76fe2d3242917d77e2",
299
299
  "since": "2025-01-01"
300
300
  },
301
301
  "route-group:health": {
@@ -0,0 +1,28 @@
1
+ # Upgrade Guide — v0.12.21
2
+
3
+ <!-- bump: patch -->
4
+
5
+ ## What Changed
6
+
7
+ WhatsApp Baileys pairing is now fully automated during setup wizard. Instead of telling users to "check the server logs for a pairing code" and run `tmux attach`, the wizard now:
8
+
9
+ 1. Starts the server automatically
10
+ 2. Opens a browser with the dashboard QR code (or WhatsApp Web as fallback)
11
+ 3. Walks the user through scanning the QR with their phone
12
+ 4. Polls the connection status and confirms when paired
13
+ 5. Falls back to pairing code method if QR fails
14
+ 6. Falls back to manual relay of pairing code if no browser tools available
15
+
16
+ The wizard also sends a WhatsApp greeting message after pairing (mirroring the Telegram Lifeline greeting), and does NOT declare "All done" until WhatsApp is actually connected.
17
+
18
+ ## What to Tell Your User
19
+
20
+ - **WhatsApp setup is now hands-free**: "Setting up WhatsApp is now just as smooth as Telegram — the wizard handles everything automatically. You just scan a QR code when prompted."
21
+
22
+ ## Summary of New Capabilities
23
+
24
+ | Capability | How to Use |
25
+ |-----------|-----------|
26
+ | Browser-automated WhatsApp QR pairing | Automatic during setup wizard when Baileys is selected |
27
+ | WhatsApp greeting on setup completion | Automatic — agent introduces itself via WhatsApp |
28
+ | QR → pairing code fallback | Automatic if QR scanning fails after 2 minutes |