{"success":true,"name":"brimind-phone-line","description":"Use when calling/texting or wiring phone audio. Preflight.","category":"brimind","path":"brimind/brimind-phone-line/SKILL.md","file":"SKILL.md","content":"---\nname: brimind-phone-line\ndescription: Use when calling/texting or wiring phone audio. Preflight.\nversion: 1.0.0\nauthor: Hermes Agent\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [phone, gsm, whatsapp, adb, call]\n    related_skills: []\n---\n\n# Brimind Huawei phone line (GSM + WhatsApp app)\n\n## When to Use\nThe owner asks to be called (\"call me using the huawei\"), or any task places/answers a GSM or WhatsApp-app call or\nsends a message through the Huawei phone.\n\nRepo: [PATH] ([PRIVATE_HOST]). The Huawei Y6s (Android 9, adb serial 9EHNW20107010099) is on the [PRIVATE_HOST]'s USB;\nits call audio goes over Bluetooth to the [PRIVATE_HOST] (BT addr A0:D8:07:05:6A:0A, ssh host `[PRIVATE_HOST]`).\nadb is NOT on PATH: use `[PATH] -s 9EHNW20107010099`.\nOwner's number: OWNER_PHONE in agents/method/reach-owner.mjs (+[PHONE]).\n\n## Which command\n- Voice call (default line = GSM SIM via sim-call.js): `node agents/method/call.mjs --to \"+216...\" --text \"<opening>\" --lang en --talk --confirm`\n  Without `--confirm` it is a dry preflight (nothing rings) — run it first; it names the failing piece.\n  `--line phone` = WhatsApp app on the Huawei; `--line web` = WhatsApp Web in Chrome.\n- WhatsApp app actions (send/reply/call/answer/hangup/state): `node phone/wa.mjs <cmd>`.\n- \"Call me\" from the owner = he wants it to ring now: he already authorized it, use `--confirm`.\n\n## Procedure\n1. Dry run call.mjs (no --confirm). If it says `sim line not ready: bluetooth`, do the preflight below.\n2. Preflight on the phone (one batched call):\n   - `adb ... shell settings get global airplane_mode_on` → must be 0. Also `dumpsys telephony.registry | grep -oE \"mVoiceRegState=[^,]+\"` must show IN_SERVICE.\n   - `adb ... shell dumpsys bluetooth_manager | grep -m2 -E \"enabled|state:\"` → must be ON.\n3. Fix airplane mode via the Settings UI (the proven route; the phone is not rooted, so a bare `settings put` would not\n   broadcast the change to the radio):\n   dismiss any \"Mode de connexion USB\" dialog first (tap ANNULER, or KEYCODE_BACK) — it sits on top and swallows taps;\n   `am start -a android.settings.AIRPLANE_MODE_SETTINGS`, uiautomator dump, tap the checkable switch next to \"Mode avion\"\n   (was ~[640,198]), wait ~8 s, re-check airplane_mode_on and IN_SERVICE. Press HOME after.\n4. Bluetooth: `adb ... shell svc bluetooth enable` works; then on the [PRIVATE_HOST]\n   `ssh [PRIVATE_HOST] 'bluetoothctl --timeout 25 connect A0:D8:07:05:6A:0A; bluetoothctl info A0:D8:07:05:6A:0A | grep Connected'`.\n   Connect fails/hangs while the phone's BT is off — fix the phone side first.\n5. Place the call with `--confirm`. A talking call runs for minutes: launch it as a background process with output to\n   a log in $TMPDIR, then tail the log (`tour N entendu …` / `tour N répondu …` lines = the conversation is live).\n6. Report: what was fixed on the phone (airplane/BT), that it's ringing/connected, first-turn latency, log path.\n\n## realme RMX3231 (test phone, +[PHONE])\nThe owner handles realme/second-phone work in separate sessions: don't start it (or keep a subagent on it) unasked.\nIt is BT-paired to the [PRIVATE_HOST] as D0:97:FE:B0:4E:38; never `remove` that pairing while testing.\nOn the [PRIVATE_HOST]'s USB, driven from the [PRIVATE_HOST] by `agents/tools/realme` (ssh tunnel [PRIVATE_HOST]:5038 -> [PRIVATE_HOST] adb :5037, scrcpy port 27199;\nadb client must be the [PRIVATE_HOST] platform-tools 37.0.1 = [PRIVATE_HOST] server version, never the scrcpy-bundled adb 36).\n`realme screen|hear|call|answer|hangup|tap|key|text|shot|ui|sh`. Ear works (scrcpy voice-call); mouth needs a USB sound\ncard on the [PRIVATE_HOST] wired to the realme jack (REALME_MIC_SINK) — no software path. Proof run: `agents/tools/realme-test.sh prove`.\n- After a reboot the realme sits on the lock screen and scrcpy audio capture records pure SILENCE (Android 11):\n  `wm dismiss-keyguard` + swipe first (built into `realme hear/screen` and realme-test.sh prep).\n- The owner's plain jack splitter (realme -> [PRIVATE_HOST] headphone+mic jacks, either orientation) passed no signal both ways and\n  the realme sees it as headphone type 8 (no mic) — check `dumpsys audio | grep -A1 \"Connected devices\"` after any rewire.\n- The [PRIVATE_HOST] BT dongle (0a12:0001, bcd 88.91, labelled \"bt6.0\", sold as 5.1) is a CSR clone with no SCO: useless for calls\n  on any host/port. Recommended mouth+ear fix: a branded USB BT adapter (TP-Link UB500 etc.) on the [PRIVATE_HOST].\n  Judge any dongle by `hciconfig -a` (Manufacturer, LMP version, `SCO MTU`), never by its sticker.\n- A second phone is NOT a Bluetooth headset for the realme: stock Android is HFP Audio Gateway only. Prove it in one\n  read before promising anything: `getprop bluetooth.profile.hfp.hf.enabled` (empty/false = no headset role) and\n  `bluetooth.profile.a2dp.sink.enabled`; `setprop` of it is denied without root (checked on a Galaxy A33, Android 15).\n  Never root/wipe an owner's phone for this. A new phone on USB shows `unauthorized` until he taps Allow on it.\n- The only no-hardware \"mouth\" for calls FROM the realme's number is a network conference: realme calls the client +\n  calls the Huawei (which talks/hears via the [PRIVATE_HOST]), then merges. Costs two calls, busies the Huawei, needs operator\n  conference support, and cannot serve line tests where the Huawei is the caller. Untested — offer, don't claim.\n- Before any audio-path verdict, run the tone tests in `references/audio-path-tests.md` (prove the source actually\n  played, then look for the tone, not just a level).\n\n## Owner's latency target and chosen stack\n- Reply budget <= 3.9 s from his last word; turn end = 0.75 s silence (CALL_END_SILENCE_S, 0.25 s slices). He wants\n  fixes applied DURING a call: agents/method/data/calls/live.json is re-read every turn (CALL_END_SILENCE_S in the\n  driver, CALL_VOICE_ENGINE in voiceFile); other knobs only apply at call start.\n- Call brain (owner 16/11): order `claude` (warm Opus 4.8 fast, 1.1 s) > `claude2` (Opus 5.5 fast) > `claude3` (Haiku\n  5.5 fast) > `hermes` (Haiku 5.5 one-shot, ~4.9 s). Warm ONE BY ONE: only the first keeps a spare; a backup starts cold\n  and keeps a spare only while all before it are down. dropSpares(): a listener holds no spare while waiting (the ring\n  re-warms), and every spare dies at hang-up. Each spare ~160-180 MB. Warm fast bench (avg s): opus-4-8 1.11, sonnet-5-5\n  1.41, opus-5-5 1.46, sonnet-4-6 1.50, haiku-5-5 1.65, opus-5 1.67, sonnet-5 2.00, haiku-4-5 2.68 (±0.5 s). Fast mode acts\n  only on Opus 4.8/5/5.5. In a real call (08:28 16/11) the [PRIVATE_HOST] was out of RAM (load 30, swap 11 GB): brain 3-12 s, voice\n  up to 15 s — check `free -m` and /proc/pressure/memory before blaming a model.\n- After a hang-up sim-call.js may hang for minutes (call.mjs then never exits and keeps its spares): if the driver log\n  has `hungUp` and the phone is idle, SIGTERM sim-call.js.\n- His stack: `EAR_MSI_ENGINE=parakeet EAR_MSI_ARGS=\"--strange-mean -0.6\" CALL_BRAIN_FIRST=claude,claude2,hermes CALL_VOICE_ENGINE=piper\n  CALL_HANDOVER=off` (piper en/fr; Arabic stays edge). HANDOVER off because he hated \"passing you to my Tunisian/English\n  friend\" flips (one Arabic word marks the turn 'ar'; ear prob is a fixed 0.95). Parakeet is fast but mishears brand\n  words on GSM — accuracy for en/fr is still open ([PRIVATE_HOST] Whisper needs an install: ask first).\n- Measurements, per-module options, hidden-time causes and benchmark recipes: see `references/call-latency-and-stack.md`\n  He asks for per-turn tables + averages, colored; report what HE hears (add the 0.75 s silence).\n- Line held until --seconds 1140; a running call.mjs/sim-call.js of an inbound `--answer` listener is not ours to kill.\n\n## Agent behaviour he requires in a call (speakerPrompt / mergeDone in call.mjs)\n- Answer his NEWEST sentence first; a finished task result comes after it, and only replaces an ack/\"still searching\".\n- Before acting, ask ONE short question for a missing detail; confirm a doubtful or out-of-context word (\"Bitcoin, right?\")\n  before launching anything; with guests/prospects collect name, role, company, city, need, deadline, contact, and read\n  it back before hanging up (ASK_OWNER/ASK_GUEST/ASK_FAMILY, CALL_ASK=off disables).\n- He must be able to interrupt her: barge-in = CALL_BARGE_VOICED_MS/WINDOW_MS (300/600), live-tunable per phrase via\n  live.json. Check `bargeIn` vs `heardWhileSpeaking` counts in driver-*.log to see how often she ignored him.\n- When he hangs up the call must end at once and NEVER ring him back.\n\n## Debugging a live call\n- Code edits do NOT reach the running call (modules load at start); only live.json keys do. Say so, and offer to\n  end + re-call so the fix is tested on a real call.\n- Evidence: the talk log in $TMPDIR (`tour N entendu/répondu/temps`), agents/method/data/calls/driver-<id>.log (JSON\n  events: hungUp, bargeIn, rxSilent, btReset, called), session-<id>/in-N.wav to replay through an ear.\n- Hang-up truth is the phone: `dumpsys telephony.registry | grep mCallState` (0 = idle). Echo/noise keeps `spoke` true,\n  so any end-of-call check gated on silence never fires; a line of exact zeros after a hang-up looks like a dead BT link —\n  any heal/redial must first check the phone is still in a call.\n- To stop our own stuck call: SIGTERM the sim-call.js child, then its call.mjs parent; SIGKILL only if still alive.\n  Leave the `--answer` listener processes alone; the phone lock is then re-taken by the listener (normal).\n- After every test call, check the driver log tail: `hungUp` present, no `called` event after it.\n\n## Rules\n- The owner writes short, non-native English and does the physical work himself: answer in plain short lines, give\n  numbered physical steps (which plug into which jack/port, what to tap), say yes/no first, and after every change he\n  reports (\"i did swap\", \"is it good\") re-measure immediately instead of reasoning from the old result.\n- One phone, one call: never touch /tmp/brimind-sim-phone.lock; if a call holds it, wait (CLAUDE.md).\n- Mention to the owner any phone state you changed (airplane mode off, BT on) — he may have set it on purpose.\n- grep the repo with `rg -g '*.mjs' -g '!**/node_modules/**' -g '!brimind-tunnel/**'` — unfiltered rg on words like\n  \"airplane\" dumps megabytes of minified icon bundles from brimind-tunnel.\n- The post-call summary may say \"whisper a refusé: faster-whisper is not installed\" for the pickup clip: that is the [PRIVATE_HOST]'s\n  local transcription for the call record only. The live talk loop still works (its ear is on the [PRIVATE_HOST]). Report it to the owner and don't pip-install it without asking.\n- call.mjs auto-switches voice/language to what the owner speaks unless CALL_HANDOVER=off (his preference for en/fr tests).\n","linked_files":["references/audio-path-tests.md","references/call-latency-and-stack.md"],"origin":"brimind","owner_id":null,"source":"router"}