Metadata-Version: 2.4
Name: sparephone
Version: 0.3.2
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>

- **A real number.** Real calls, real texts and real one-time passcodes on a mobile number you control: a real SIM on a real carrier, the kind of number every service expects.
- **The price of a SIM plan.** 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 takes your test calls.
- **Rules in code.** An allowlist, hourly limits and a hard refusal of emergency numbers, enforced by the service. No prompt or phone tool can change them.
- **A pager and a voice.** It phones you when something breaks and takes a spoken decision, and its voice agent holds a conversation on a real call. Connect Claude Code, Claude Desktop or Codex with `sparephone mcp install`.

Try it now, with no phone and no install: `uvx sparephone demo`

## 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. 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` run from 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, also available 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, reads the choices, takes a spoken answer, reads it back and acts only on a spoken yes. It runs on real calls on Linux and on a Mac. Your confirmed decision arrives about 40 seconds after the dial:

```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`, holds a conversation on a call: speech to text, a language model or a fixed script, then text to speech (`--once`, `--check`, `--write-default-config`). It hears and speaks on your own machine, runs entirely on your own machines with a local model, answers in about two seconds, and has exactly one power: ending the call.

## 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.
- On Linux the service watches the call's audio links for the whole call, and cuts a microphone leak in about 43 milliseconds.
- 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. No prompt can talk it round. 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 |
| Live call audio | yes | yes |
| Pager | yes, with Whisper | yes, with Whisper, from a clone |
| Voice agent | yes | yes, from a clone |
| Simulated demo | yes | yes |
| Commands above, in a pip install | yes | yes, against a running service |

Calls, texts, passcodes, the pager and the voice agent all run on real calls on both platforms, and every release ships after real calls on Linux and on a Mac. On Linux the link recovers about 3 seconds after a Bluetooth drop. On a Mac the route runs from a clone through the $9 adapter: the link recovers in about 40 seconds, the service ends its own call when the link drops, and a single lost audio packet never ends a call. Run the first Mac setup at the Mac. `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 runs on your own machines. To hear, it uses faster-whisper (the recommended engine on Linux and the pager's ear), Vosk, or Parakeet (Apple silicon, with the `parakeet_mlx` package). To speak, it uses 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.
- Place the phone where its microphone hears nothing private: if the Bluetooth link drops during a call, the iPhone carries the call on its own handset, and the far side hears 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 everything this route does: [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.
