Metadata-Version: 2.4
Name: sparephone
Version: 0.1.0
Summary: Give your spare phone to your agent.
Author: The sparephone contributors
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/abe238/sparephone
Project-URL: Homepage, https://sparephone.abediaz.ai
Keywords: agent,phone,bluetooth,hfp,mcp,voice
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Communications :: Telephony
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Provides-Extra: linux
Requires-Dist: dbus-python; extra == "linux"
Requires-Dist: PyGObject; extra == "linux"
Provides-Extra: vosk
Requires-Dist: vosk; extra == "vosk"
Provides-Extra: whisper
Requires-Dist: faster-whisper; extra == "whisper"
Provides-Extra: all
Requires-Dist: sparephone[linux,vosk,whisper]; extra == "all"
Dynamic: license-file

# sparephone

**Give your spare phone to your agent.**

*Your agent's first phone.* Sparephone lets your AI agent use a real iPhone and SIM. It places and answers calls, sends and reads texts, and reads the one-time codes that arrive for your own accounts, all on a mobile number that you own. Use it in place of a costly cloud calling service. Site: <https://sparephone.abediaz.ai>

- **You need:** a spare iPhone with a $30/yr SIM plan, and a Linux laptop or a Mac with a small $9 USB Bluetooth adapter. A second phone helps for test calls. No phone yet? `sparephone demo` runs without one.
- **It stays inside your rules:** an allowlist, hourly limits and a refusal of emergency numbers, enforced in code. No prompt or phone tool can change them.

## Install

```sh
pip install sparephone              # the service, the command line, the MCP server, the pager, the demo: standard library only
pip install "sparephone[whisper]"   # adds faster-whisper: the recommended speech recognizer on Linux
pip install "sparephone[linux]"     # adds dbus-python and PyGObject for the Linux backend (often easier from your distro's packages)
pip install "sparephone[vosk]"      # adds the Vosk speech recognizer (needs a model folder you download yourself)
pip install "sparephone[all]"       # linux, vosk and whisper
sparephone --version
```

It needs Python 3.11 or newer and installs two commands: `sparephone` and `sparephone-mcp` (the same MCP server as `sparephone mcp`).

**What works from the pip package:** `demo`, `page`, `mcp`, `voice`, `web`, `debug`, `paths`, `status`, `ctl` (Linux) and `migrate`. On Linux the installed package imports the phone service and reads a running one (`sparephone status`), but it cannot set a service up: the systemd units, the audio routing files and the installers are in the source tree only.

**What needs the source tree.** `setup`, `doctor`, `test`, `start`, `stop`, `check`, `gates`, `mac` and the whole Mac Bluetooth route run only from a clone of the repository. They drive the systemd units, `bin/mac-phone` and the Bluetooth stack that the Mac route vendors under `mac/bumble-probe`, and none of that is in the pip package. From the package they print what to run instead. There is no `mac` extra, because that route cannot run from a pip install:

```sh
git clone https://github.com/abe238/sparephone
cd sparephone
bin/sparephone setup     # the guided setup; `bin/sparephone doctor` runs the same checks and changes nothing
```

## Try it without a phone

```sh
sparephone demo --fast
```

The demo runs the real service and its real rules against a simulated phone. Every line starts with `[SIMULATED]`. Real output (abbreviated):

```text
[SIMULATED] 4/11 The agent tries to dial +12065550199, which is NOT on the allowlist.
[SIMULATED]     Service answered: blocked_by_policy. Rule that decided: not_on_allowlist. ...
[SIMULATED] 5/11 The agent tries to dial 911.
[SIMULATED]     Service answered: blocked_by_policy. Rule that decided: emergency_number. ...
[SIMULATED] 11/11 The agent dials +12065550142 again.
[SIMULATED]     Service answered: rate_limited. Rule that decided: rate_limited. ...
```

To point your own agent at a simulated phone, run `sparephone demo --keep-running`. It prints the exact `sparephone mcp --sim --runtime DIR` command to register.

## What it does

- **Calls.** Place a call, answer one, hang up, send keypad tones: `sparephone ctl dial owner --call-id first-1`, `ctl answer`, `ctl hangup`, `ctl dtmf DIGITS`. A number must be on your allowlist to be dialed.
- **Texts.** `sparephone ctl sms-send` and `ctl sms-read`. Message bodies stay hidden until you set `sms_body_access = true` in the config, and one-time codes are masked in bodies unless you turn `mask_codes` off.
- **An agent interface.** `sparephone mcp` speaks MCP over stdio with these tools: `phone_status`, `phone_dial`, `phone_answer`, `phone_hangup`, `phone_send_dtmf`, `phone_send_sms`, `phone_read_sms` and `phone_wait_for_event`. There is no approve tool.
- **A voice agent.** `sparephone voice` talks on a call: speech to text, a language model or a fixed script, then text to speech (`--once`, `--check`, `--write-default-config`).
- **Page the owner.** One command phones only the owner when something breaks, says what happened, takes a spoken choice, reads it back and needs a spoken yes:

  ```sh
  sparephone page --choice "roll back" --choice "leave it" "Build 412 failed on main"
  ```

  Add `--dry-run` to print the plan and the speech engines without calling or texting.
- **A status page and debug log.** `sparephone web` serves a read-only status page on 127.0.0.1 only. `sparephone debug on|off|status|show|clear` controls a debug log that is off by default.

## Speech for the voice agent and the pager

Speech to text can use faster-whisper (Linux, the recommended engine), Vosk, or Parakeet (Apple silicon, needs the `parakeet_mlx` package). Text to speech can use flite, the Phonon speech server, or a speech service of your own over HTTP. With no engine, `sparephone page --dry-run` exits 13 and says so.

For Whisper on Linux:

```sh
pip install "sparephone[whisper]"
sparephone page --fetch-speech-model    # the one step that uses the network: downloads the configured model once
sparephone page --check-speech          # builds the engines from voice.toml and says which are active
```

The model is never downloaded during a call. Setting `stt = "whisper"` (or `"auto"`) and the model name goes in `voice.toml`; `sparephone voice --write-default-config` writes a starting file. The repository's `docs/SPEECH-LINUX.md` has every step.

## Is it safe?

These rules are in the service's code (`sparephone/policy.py`, `service.py`), not in a prompt. Give the agent no write access to the config file.

- Only allowlisted numbers can be dialed or texted.
- The service refuses emergency and short numbers, whatever the allowlist says. After it sees one (an incoming call from one included) it answers nothing for 60 minutes.
- The default limits are 4 calls and 10 texts an hour, kept on disk.
- Each dial needs a call id; a repeated id never redials.
- Incoming calls are answered only if you set `inbound_answer` (default `off`). Text bodies are off by default.
- The service leaves alone a call that you place or answer on the iPhone.
- The service refuses a config file that is not mode 0600.
- The pager phones only the owner number and needs a spoken yes before acting on a choice.

A code rule refuses every case that matches it, including some a person would allow. A wrong refusal costs a retry. Use sparephone to read codes for accounts you own; using it to get past someone else's verification is misuse. This service places real calls that can annoy or harm people. Consent, recording and AI-voice rules depend on where you and the other person are, and you are responsible for them. This is not legal advice.

## What it does not do

- It does not open apps or control the screen.
- One phone means one line. For many numbers at once, use a cloud calling service.
- If the Bluetooth link drops during a call, the iPhone can move the call to its own handset, and the far side can hear the room.

## Hardware

- **Linux route:** a Linux computer with Bluetooth, a spare iPhone with a SIM and a second phone to receive test calls.
- **Mac route:** an Apple silicon Mac, plus one USB Bluetooth adapter with USB ID 2357:0604. The code refuses any other adapter. Run it from a clone, and sit at the Mac the first time: USB audio code has crashed Macs in other projects.

Other phones, systems and adapters are untested.

## Contributing and license

Bug reports with a failing case are welcome: tell us your phone, system and adapter. The dated record is `docs/JOURNEY.md` and the decisions are in `docs/DECISIONS.md` in the repository: <https://github.com/abe238/sparephone>.

Apache 2.0.
