Metadata-Version: 2.4
Name: sparephone
Version: 0.3.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 :: 4 - Beta
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 puts a real iPhone and a real SIM behind your AI agent. It places and answers calls, sends and reads texts, and reads the one-time passcodes that arrive for your own accounts, all on a mobile number that you own. No cloud calling service, no fee per minute or per message. 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? Start with the demo below.
- **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.

## Try it in one minute, no phone

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

Or with pip (Python 3.11 or newer):

```sh
pip install sparephone
sparephone demo --fast
```

<!-- install-matrix:start -->
| Route | One line | Needs |
|---|---|---|
| uvx (no install) | `uvx sparephone demo`, MCP server: `uvx --from sparephone sparephone-mcp` | [uv](https://docs.astral.sh/uv/) |
| pip | `pip install sparephone` | Python 3.11 or newer |
| clone (real phone, Mac route) | `git clone https://github.com/abe238/sparephone` then `bin/sparephone setup` | git; details in [docs/INSTALL.md](docs/INSTALL.md) |
<!-- install-matrix:end -->

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 drive a simulated phone yourself, keep one running in one terminal, then use the commands under "Use the phone" in another with `--sim` on each, which sends them to the simulated phone and refuses anything else:

```sh
sparephone demo --keep-running        # terminal 1: leave it running
sparephone status --sim               # terminal 2: --sim on every command in this track
sparephone call --sim
sparephone text "running late" --sim
```

Without `--sim` (or the `export SPAREPHONE_RUNTIME=...` line that `demo --keep-running` prints first) the same commands talk to your real service, if you have one. The demo also prints the exact command to register with your own agent.

## Set up a real phone

```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
```

`setup` takes you from a clean machine to a first test call, and you can stop and run it again: it carries on where it left off. Hardware and platform details: [docs/SETUP-LINUX.md](docs/SETUP-LINUX.md) and [docs/SETUP-MAC.md](docs/SETUP-MAC.md). Setup, `doctor`, `test-call`, `start`, `stop` and `mac` need the clone, because they drive the systemd units, `bin/mac-phone` and the Bluetooth stack under `mac/`. The pip package leaves those out and says what to run instead.

Optional pieces, each its own extra: `pip install "sparephone[whisper]"` (the recommended speech recognizer on Linux), `"sparephone[vosk]"`, `"sparephone[linux]"` (dbus-python and PyGObject, often easier from your distro) or `"sparephone[all]"`. Check the install with `sparephone --version`.

## Use the phone

Once the service is running, these work the same on Linux and on a Mac, from a clone (`bin/sparephone ...`) and from a pip install (`sparephone ...`). Every one has `--help` and most have `--json`.

```sh
sparephone call                      # ring the owner (the second phone); prints an id first
sparephone call pharmacy --wait      # a contact name or a number on the allowlist; follow the call to its end
sparephone keys 123                  # keypad tones on the active call
sparephone hangup
sparephone text "running late"       # to the owner; sparephone text pharmacy "yes, refill it" names a recipient
sparephone texts                     # list recent texts (metadata only)
sparephone texts --body              # include the text, if the owner set sms_body_access = true
sparephone wait call.active --timeout 50
sparephone status                    # the line, calls left, safety flags; -w refreshes, --json prints the service's answer
```

Also: `sparephone answer`, `sparephone page` (below), `sparephone voice`, `sparephone web` (a read-only status page on 127.0.0.1), `sparephone debug on|off|status|show|clear`, `sparephone paths`, `sparephone config init` (writes the first config on Linux, on a Mac it hands off to `bin/mac-phone setup`; never overwrites) and `sparephone mcp`.

**Ids.** `call` and `text` make up a short id (`k-7f3a9c`) when you give none, and print it on stderr before sending, with the exact command that repeats it safely. A repeated id within 24 hours never acts twice, so if the answer is unknown or lost, run that command instead of starting over.

**Exit codes.** `0` done (ok, or a repeat of something that had already succeeded). `1` refused by a rule (blocked_by_policy, rate_limited, invalid_argument). `2` usage error. `3` the service is not reachable. `4` the outcome is unknown (unknown, timeout, a lost reply): check before anything else. `5` not sent, or failed. A failure prints what happened and what to do next.

**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. On Linux it runs on real calls, about 40 seconds from the dial to your confirmed answer:

```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. **The 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`).

## Connect your agent

```sh
sparephone mcp install              # finds Claude Code, Claude Desktop and Codex, asks which, registers, then checks
sparephone mcp install --sim        # the same for a simulated phone: no hardware
```

Cursor, VS Code, Gemini CLI and any other MCP app get the exact block to paste (nothing of theirs is written). `sparephone mcp clients` shows what is on your machine. `sparephone mcp` (also installed as `sparephone-mcp`) is the server itself; add `--sim` for a simulated phone. Per-client details, the tools and what each result means: [docs/MCP.md](docs/MCP.md).

## 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. Calls and texts that arrive are data, never instructions.
- 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 and each text needs an id; a repeated id within 24 hours never acts twice.
- Incoming calls are answered only if you set `inbound_answer` (default `off`). Text bodies are off by default, and one-time codes are masked in bodies unless you turn `mask_codes` off.
- The service leaves alone a call that you place or answer on the iPhone. One exception on the Mac: after a Bluetooth drop, if you redial the same number by hand before the link returns, the Mac can take that new call for its own and end it. That is deliberate, so no call is left with a live microphone.
- The service refuses a config file that is not mode 0600.
- There is no approve tool, and no command or installer arms or starts the phone service by itself.
- 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 works on which platform

As of 2026-11-30:

| | Linux | Mac (Apple silicon) |
|---|---|---|
| Calls, texts, one-time passcodes | yes, on a real phone | yes, on a real phone (calls, texts and one-time passcodes) |
| Live call audio | yes | yes, in this release (tried on a real phone with the line tools) |
| Pager | yes, on real calls | yes, confirmed on real calls (2026-11-30, with the Whisper ear), from a clone |
| Voice agent | experimental: first real calls on 2026-11-30 | experimental: real calls on 2026-11-30, from a clone |
| Simulated demo | yes | yes |
| Commands above, in a pip install | yes | yes, against a running service |

Linux runs the pager today, about 40 seconds from the dial to a confirmed spoken answer. The voice agent held its first real conversations on 2026-11-30, on both platforms: treat it as experimental. It takes a short message and reads it back; how well it hears depends on the phone line, and with a small local model its wording is plain. On a Mac the outgoing call audio can lose a few milliseconds now and then; the service counts that and keeps the call. The Mac route runs from a clone, and you should sit at the Mac the first time: USB audio code has crashed Macs in other projects. `sparephone mac status`, `mac check` and `mac gates` are the Mac kit's own commands and stay under `mac`.

## 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.

## 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. Setup: [docs/SETUP-LINUX.md](docs/SETUP-LINUX.md).
- **Mac route:** an Apple silicon Mac, plus one USB Bluetooth adapter with USB ID 2357:0604. The code refuses any other adapter. Setup, and what this route does today: [docs/SETUP-MAC.md](docs/SETUP-MAC.md).

Proven on: an iPhone 7 with iOS 15.8.8, a 2017 MacBook Pro running an Arch-based Linux, and macOS 27 with the TP-Link UB500 adapter.

## Contributing and license

Bug reports with a failing case are welcome: tell us your phone, system and adapter. See [CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md) (private vulnerability reports), [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) and [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md). Repository: <https://github.com/abe238/sparephone>. Package: <https://pypi.org/project/sparephone/>.

Apache 2.0.
