Metadata-Version: 2.4
Name: agent-signalbox
Version: 0.1.0
Summary: Usage-aware model routing for coding agents: reads Claude Code, Codex and Cursor limits and picks the cheapest model that still has room.
License-Expression: MIT
Project-URL: Repository, https://github.com/dxbh0517/signalbox
Keywords: claude-code,codex,cursor,agent-skills,llm-routing,orchestration
Classifier: Environment :: Console
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# signalbox

Usage-aware model routing for coding agents. A sibling of
[Switchyard](https://github.com/dxbh0517/switchyard): Switchyard shares one GPU
between engines, Signalbox shares your subscriptions between models.

Coding agents now run on several subscriptions at once: Claude Code's 5-hour
and weekly windows, Codex's, Cursor's Auto and named-model pools. The strong
models run out first, usually mid-task. `signalbox` reads how much of each
pool is left, using the logins already on your machine, and picks the
cheapest model that still has room for each phase of the work. An agent
skill turns your current agent into the orchestrator that uses it.

Example output:

```
$ signalbox usage
cursor-auto  ok       cycle 84%              within limits
cursor-api   out      cycle 100%             cycle 100% used
codex        ok       5h 22%  7d 41%         within limits
claude       tight    5h 71%  7d 48%         5h 71% used
free         ok       -                      no limits reported
mode         claude-frugal

$ signalbox route review-m --not-family cursor
  grok@high      out      cursor grok-4.7                    cycle 100% used
→ codex@high     ok       codex (default model)              within limits
  gemini@high    out      cursor gemini-4-neon               cycle 100% used
  sonnet@high    tight    claude claude-sonnet-5-5           5h 71% used
```

## What it does

- **Reads real limits.** Claude Code (5h, 7d, per-model weekly), Cursor
  (Auto/Composer and named-model pools, on-demand), Codex (5h and weekly,
  from its session logs). Results are cached for 5 minutes, and a failed
  read backs off for a minute so it doesn't make a rate limit worse.
- **Routes per phase.** Plan, implement, review, CI fix: each has a
  cheapest-first ladder per budget mode in [`routing.toml`](skills/signalbox/scripts/signalbox/routing.toml).
  Pools that are `out`, or whose CLI isn't installed, are skipped. `tight`
  pools are used only when nothing cheaper fits.
- **Picks the mode for you.** Claude near its cap → `claude-off`. Cursor's
  Auto pool gone → `cursor-frugal`. Everything low → `survival`.
- **Keeps reviewers honest.** `--not-family` skips the author's model family.
- **Delegates across vendors.** `signalbox delegate` runs the brief on the
  picked model's own CLI (`claude -p`, `codex exec`, `cursor-agent -p`,
  `opencode run`), read-only when asked. A usage-limit error in the output
  marks the pool out and exits 75, so the next `route` goes elsewhere.
- **Measures a task.** `usage --save <task>` … `usage --diff <task>`.

Tokens are read from the vendor CLIs' own login files, sent only to that
vendor's usage endpoint, and never printed or written.

## Install

The skill is self-contained (stdlib Python 3.11+, no dependencies):

```sh
git clone https://github.com/dxbh0517/signalbox
python3 signalbox/skills/signalbox/scripts/signalbox.py install   # every agent found on this machine
```

That copies `skills/signalbox` into `~/.claude/skills`, `~/.codex/skills`,
`~/.cursor/skills` and `~/.agents/skills` (the cross-agent location).
`--host claude,codex` picks hosts; `--link` symlinks for development.

For the CLI on your PATH: `pipx install git+https://github.com/dxbh0517/signalbox`.

Then ask your agent to "orchestrate" something, or run `signalbox doctor`.

## Commands

| | |
| --- | --- |
| `usage [--json] [--save N] [--diff N]` | Pools, status, recommended mode |
| `route PHASE [--mode M] [--not-family F] [--skip R]` | Pick a model for a phase |
| `delegate --phase P \| --route R[@effort] --brief FILE` | Run a brief on the picked CLI |
| `mark POOL [--hours H \| --clear]` | Mark a pool out by hand |
| `install [--host …] [--link]` | Install the skill |
| `doctor` | CLIs, installs and usage at a glance |
| `config path \| show \| init` | Where routing lives; `init` makes an editable copy |

Phases: `plan-m`, `plan-l`, `implement`, `review-s`, `review-m`,
`review-risk`, `ci-fix`.

## Hosts

| Host | Delegation | Notes |
| --- | --- | --- |
| T3 Code | native `delegate_task` | `route --no-host-check`, then map to a provider |
| Claude Code | own `Agent` for Claude, `signalbox delegate` for the rest | |
| Codex | own subagent for Codex, `signalbox delegate` for the rest | the sandbox must allow the other CLIs |
| Cursor | own subagent for Cursor models, `signalbox delegate` for the rest | |

Details: [`references/hosts.md`](skills/signalbox/references/hosts.md).

## Caveats

- The usage endpoints for Claude Code and Cursor aren't public APIs, and the
  Codex reader parses session logs. Any of them can change without notice.
  A reader that breaks reports `unknown`, and routing treats that pool as
  `tight`.
- Codex writes its limits only during a session, so its reading is as old as
  your last Codex run (shown as `stale`).
- Model IDs in `routing.toml` were current on 2026-11-26.

## Develop

```sh
python3 -m unittest discover -s tests -v
python3 skills/signalbox/scripts/signalbox.py install --link --host claude
```

## License

MIT

## Releasing

Bump `version` in `pyproject.toml` and `signalbox/__init__.py`, commit, then
`git tag vX.Y.Z && git push --tags`. The Release workflow tests, builds and
publishes to PyPI through trusted publishing (environment `pypi`).
