chantey 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,121 @@
1
+ .claude/handoffs/
2
+ .claude/scratch/
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+
10
+ .DS_Store
11
+ # C extensions
12
+ *.so
13
+
14
+ # TLS certificates
15
+ ## Ignore all PEM files anywhere
16
+ *.pem
17
+ ## Also ignore any certs directory
18
+ certs/
19
+
20
+ # Distribution / packaging
21
+ .Python
22
+ build/
23
+ develop-eggs/
24
+ dist/
25
+ downloads/
26
+ eggs/
27
+ .eggs/
28
+ lib/
29
+ lib64/
30
+ parts/
31
+ sdist/
32
+ var/
33
+ wheels/
34
+ node_modules/
35
+ *.egg-info/
36
+ .installed.cfg
37
+ *.egg
38
+ MANIFEST
39
+ _build
40
+
41
+ # PyInstaller
42
+ # Usually these files are written by a python script from a template
43
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
44
+ *.manifest
45
+ *.spec
46
+
47
+ # Installer logs
48
+ pip-log.txt
49
+ pip-delete-this-directory.txt
50
+
51
+ # Unit test / coverage reports
52
+ htmlcov/
53
+ .tox/
54
+ .coverage
55
+ .coverage.*
56
+ .cache
57
+ nosetests.xml
58
+ coverage.xml
59
+ *.cover
60
+ .hypothesis/
61
+ .pytest_cache/
62
+
63
+ # Translations
64
+ *.mo
65
+ *.pot
66
+
67
+ # Django stuff:
68
+ *.log
69
+ local_settings.py
70
+ db.sqlite3
71
+
72
+ # Flask stuff:
73
+ instance/
74
+ .webassets-cache
75
+
76
+ # Scrapy stuff:
77
+ .scrapy
78
+
79
+ # Sphinx documentation
80
+ docs/_build/
81
+
82
+ # PyBuilder
83
+ target/
84
+
85
+ # Jupyter Notebook
86
+ .ipynb_checkpoints
87
+
88
+ # pyenv
89
+ .python-version
90
+
91
+ # celery beat schedule file
92
+ celerybeat-schedule
93
+
94
+ # SageMath parsed files
95
+ *.sage.py
96
+
97
+ # Environments
98
+ .env
99
+ .venv
100
+ env/
101
+ venv/
102
+ ENV/
103
+ env.bak/
104
+ venv.bak/
105
+
106
+ # Spyder project settings
107
+ .spyderproject
108
+ .spyproject
109
+
110
+ # Rope project settings
111
+ .ropeproject
112
+
113
+ # mkdocs documentation
114
+ /site
115
+
116
+ # mypy
117
+ .mypy_cache/
118
+
119
+ # PyCharm
120
+ .idea
121
+ .ruff_cache/
chantey-0.0.2/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thor Whalen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
chantey-0.0.2/PKG-INFO ADDED
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.5
2
+ Name: chantey
3
+ Version: 0.0.2
4
+ Summary: Control your listening from Claude: list, play, pause, seek, skip and speed for a web player you are signed in to, over MCP or a CLI, with pluggable sources and no audio links handed to the model.
5
+ Project-URL: Homepage, https://github.com/thorwhalen/chantey
6
+ Project-URL: Repository, https://github.com/thorwhalen/chantey
7
+ Project-URL: Documentation, https://thorwhalen.github.io/chantey
8
+ Author: Thor Whalen
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: agents,audio,mcp,media player,remote control,voice
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: cw<0.2,>=0.1
14
+ Provides-Extra: dev
15
+ Requires-Dist: fastapi>=0.100; extra == 'dev'
16
+ Requires-Dist: httpx>=0.24; extra == 'dev'
17
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
18
+ Requires-Dist: pytest>=7.0; extra == 'dev'
19
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
20
+ Provides-Extra: docs
21
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == 'docs'
22
+ Requires-Dist: sphinx>=6.0; extra == 'docs'
23
+ Provides-Extra: http
24
+ Requires-Dist: fastapi>=0.100; extra == 'http'
25
+ Provides-Extra: mcp
26
+ Requires-Dist: py2mcp>=0.1.9; extra == 'mcp'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # chantey
30
+
31
+ Control your listening from Claude: "list the recent stuff", "play the second one", "pause", "back thirty seconds", "next", "faster". chantey is an MCP server (and a CLI) whose tools steer a web player you are signed in to. The player plays; Claude never gets a link to the audio.
32
+
33
+ ```bash
34
+ pip install 'chantey[mcp]'
35
+ chantey audio-list --limit 5
36
+ chantey audio-play 2
37
+ chantey audio-seek --by-s -30
38
+ chantey audio-next
39
+ chantey audio-status
40
+ ```
41
+
42
+ Every verb prints `{"ok": ..., "say": "...", ...}`; `say` is one sentence written to be read aloud.
43
+
44
+ ## How it works
45
+
46
+ Claude cannot play audio from a tool result, and a phone cannot start audio from the background while a voice call holds the sound. So chantey keeps a **desired player state** on the server (which item, playing or not, speed, a one-time seek), and each tool edits it. Your player page follows that state over Server-Sent Events, applies what changed since it last looked (also when it comes back to the front after a call), and reports back what it actually does. "Where am I" is computed from the last report. Details and the research behind them: [docs/adr/0001](docs/adr/0001-control-plane-and-desired-state.md).
47
+
48
+ | Piece | Module |
49
+ |---|---|
50
+ | The verbs (the one list every surface uses) | `chantey.tools` |
51
+ | Items, sources, finding "the second one" or "the one about rates" | `chantey.items` |
52
+ | The desired state, each player's reports, the last list | `chantey.channel` |
53
+ | The player's routes (`/events`, `/desired`, `/state`), to mount in the app that serves the player | `chantey.router` (`pip install 'chantey[http]'`) |
54
+ | MCP: `TOOL_REFS`, `SERVER_INSTRUCTIONS`, `mk_server()` | `chantey.mcp` |
55
+
56
+ ## Plugging it into your player
57
+
58
+ 1. **Mount the routes** behind your app's login, with one channel folder per user:
59
+
60
+ ```python
61
+ from chantey.channel import Channel
62
+ from chantey.router import mk_router
63
+ app.include_router(mk_router(lambda request: Channel(folder_of(request.user))), prefix="/remote")
64
+ ```
65
+
66
+ 2. **In the page**, keep a random `device_id` (in `localStorage`) and open `EventSource('/remote/events?device_id=…&device=iPhone')`. On each `desired` event (check `protocol` is 1), apply the aspects whose version (`item_version`, `playing_version`, `rate_version`, `seek_version`) is newer than the version you applied last, then `POST /remote/state` with `device_id`, `applied_version`, `item_id`, `title`, `position_s`, `duration_s`, `playing`, `rate`, and an `error` code when something failed (`autoplay_blocked`, `not_in_library`, `load_failed`). Re-read `GET /remote/desired` on `visibilitychange`, `online` and `pageshow`.
67
+
68
+ 3. **Tell chantey where your items are and whose channel to use**: a source is any callable returning records with `id` and, ideally, `title`, `source`, `created`, `duration_s`; `channel` is a callable returning the current user's channel folder (the same function the routes use). Settings come from `chantey.tools.configure(...)`, environment variables (`CHANTEY_SOURCES=mypkg.items:all`, `CHANTEY_CHANNEL=mypkg.remote:folder`, `CHANTEY_DATA_DIR`, `CHANTEY_PLAYER`, `CHANTEY_PLAYER_URL`, `CHANTEY_WAIT_S`), or `~/.config/chantey/config.json` with the same keys in lower case. With nothing set, the source is the audio files in `$CHANTEY_FOLDER` (default `~/Music`) and the channel is `~/.local/share/chantey`.
69
+
70
+ ## Serving it to claude.ai
71
+
72
+ `python -m chantey.mcp` runs the server over stdio. For claude.ai, serve it over Streamable HTTP behind OAuth: `chantey.mcp.mk_server(auth=..., middleware=...)` returns the FastMCP server with the tools, the instructions and the annotations (read-only, never destructive), so a host adds only its auth. Add its URL as a custom connector, and set the tools to "Always allow", or voice mode stops for a tap on each call.
73
+
74
+ ## Limits worth knowing
75
+
76
+ - On an iPhone, start playing with one tap; after that, voice can pause, resume, seek, go to the next item and change speed. Android web players can usually start on their own.
77
+ - The answer to "play" says whether the player confirmed; "No player is open" means open your player and it will do it.
78
+ - Every open player follows the same orders (choosing one is the next feature).
79
+ - Titles are other people's text: chantey drops invisible characters and links from them and from what a player reports, quotes them in its answers, and tells the model they are names, not instructions. Errors are codes chantey words itself.
@@ -0,0 +1,51 @@
1
+ # chantey
2
+
3
+ Control your listening from Claude: "list the recent stuff", "play the second one", "pause", "back thirty seconds", "next", "faster". chantey is an MCP server (and a CLI) whose tools steer a web player you are signed in to. The player plays; Claude never gets a link to the audio.
4
+
5
+ ```bash
6
+ pip install 'chantey[mcp]'
7
+ chantey audio-list --limit 5
8
+ chantey audio-play 2
9
+ chantey audio-seek --by-s -30
10
+ chantey audio-next
11
+ chantey audio-status
12
+ ```
13
+
14
+ Every verb prints `{"ok": ..., "say": "...", ...}`; `say` is one sentence written to be read aloud.
15
+
16
+ ## How it works
17
+
18
+ Claude cannot play audio from a tool result, and a phone cannot start audio from the background while a voice call holds the sound. So chantey keeps a **desired player state** on the server (which item, playing or not, speed, a one-time seek), and each tool edits it. Your player page follows that state over Server-Sent Events, applies what changed since it last looked (also when it comes back to the front after a call), and reports back what it actually does. "Where am I" is computed from the last report. Details and the research behind them: [docs/adr/0001](docs/adr/0001-control-plane-and-desired-state.md).
19
+
20
+ | Piece | Module |
21
+ |---|---|
22
+ | The verbs (the one list every surface uses) | `chantey.tools` |
23
+ | Items, sources, finding "the second one" or "the one about rates" | `chantey.items` |
24
+ | The desired state, each player's reports, the last list | `chantey.channel` |
25
+ | The player's routes (`/events`, `/desired`, `/state`), to mount in the app that serves the player | `chantey.router` (`pip install 'chantey[http]'`) |
26
+ | MCP: `TOOL_REFS`, `SERVER_INSTRUCTIONS`, `mk_server()` | `chantey.mcp` |
27
+
28
+ ## Plugging it into your player
29
+
30
+ 1. **Mount the routes** behind your app's login, with one channel folder per user:
31
+
32
+ ```python
33
+ from chantey.channel import Channel
34
+ from chantey.router import mk_router
35
+ app.include_router(mk_router(lambda request: Channel(folder_of(request.user))), prefix="/remote")
36
+ ```
37
+
38
+ 2. **In the page**, keep a random `device_id` (in `localStorage`) and open `EventSource('/remote/events?device_id=…&device=iPhone')`. On each `desired` event (check `protocol` is 1), apply the aspects whose version (`item_version`, `playing_version`, `rate_version`, `seek_version`) is newer than the version you applied last, then `POST /remote/state` with `device_id`, `applied_version`, `item_id`, `title`, `position_s`, `duration_s`, `playing`, `rate`, and an `error` code when something failed (`autoplay_blocked`, `not_in_library`, `load_failed`). Re-read `GET /remote/desired` on `visibilitychange`, `online` and `pageshow`.
39
+
40
+ 3. **Tell chantey where your items are and whose channel to use**: a source is any callable returning records with `id` and, ideally, `title`, `source`, `created`, `duration_s`; `channel` is a callable returning the current user's channel folder (the same function the routes use). Settings come from `chantey.tools.configure(...)`, environment variables (`CHANTEY_SOURCES=mypkg.items:all`, `CHANTEY_CHANNEL=mypkg.remote:folder`, `CHANTEY_DATA_DIR`, `CHANTEY_PLAYER`, `CHANTEY_PLAYER_URL`, `CHANTEY_WAIT_S`), or `~/.config/chantey/config.json` with the same keys in lower case. With nothing set, the source is the audio files in `$CHANTEY_FOLDER` (default `~/Music`) and the channel is `~/.local/share/chantey`.
41
+
42
+ ## Serving it to claude.ai
43
+
44
+ `python -m chantey.mcp` runs the server over stdio. For claude.ai, serve it over Streamable HTTP behind OAuth: `chantey.mcp.mk_server(auth=..., middleware=...)` returns the FastMCP server with the tools, the instructions and the annotations (read-only, never destructive), so a host adds only its auth. Add its URL as a custom connector, and set the tools to "Always allow", or voice mode stops for a tap on each call.
45
+
46
+ ## Limits worth knowing
47
+
48
+ - On an iPhone, start playing with one tap; after that, voice can pause, resume, seek, go to the next item and change speed. Android web players can usually start on their own.
49
+ - The answer to "play" says whether the player confirmed; "No player is open" means open your player and it will do it.
50
+ - Every open player follows the same orders (choosing one is the next feature).
51
+ - Titles are other people's text: chantey drops invisible characters and links from them and from what a player reports, quotes them in its answers, and tells the model they are names, not instructions. Errors are codes chantey words itself.
@@ -0,0 +1,28 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """chantey: control your listening from Claude (or any agent): list, play, pause, seek, next, speed.
3
+
4
+ An agent gives orders; a web player you are signed in to plays. The orders are edits to a
5
+ desired player state on the server (:mod:`chantey.channel`); the player follows it over an
6
+ event stream (:mod:`chantey.router`, mounted by the app that serves the player) and
7
+ reports back what it does. Items come from sources you plug in (:mod:`chantey.items`).
8
+ The verbs (:mod:`chantey.tools`) are plain functions, served as a CLI (``chantey``) and an
9
+ MCP server (:mod:`chantey.mcp`), and never hand out a link to the audio.
10
+
11
+ >>> from chantey import audio_list, audio_play, audio_status # doctest: +SKIP
12
+ """
13
+
14
+ from chantey.channel import Channel
15
+ from chantey.items import clean_text, folder_source, gather, pick
16
+ from chantey.tools import (
17
+ TOOLS,
18
+ audio_list,
19
+ audio_next,
20
+ audio_pause,
21
+ audio_play,
22
+ audio_previous,
23
+ audio_resume,
24
+ audio_seek,
25
+ audio_set_speed,
26
+ audio_status,
27
+ configure,
28
+ )
@@ -0,0 +1,36 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """CLI over the listening verbs: ``chantey <verb> [args]`` prints the verb's JSON answer.
3
+
4
+ chantey audio-list --limit 5
5
+ chantey audio-play 2
6
+ chantey audio-play "rates outlook" --from-start
7
+ chantey audio-seek --by-s -30
8
+ chantey audio-next
9
+ chantey audio-status
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import json
15
+ import sys
16
+
17
+ from chantey.tools import TOOLS
18
+
19
+
20
+ def _json_egress(result, *, out=None, err=None) -> int:
21
+ """Print a verb's answer as JSON; exit 1 when it says it did not work."""
22
+ (out or sys.stdout).write(json.dumps(result, ensure_ascii=False, indent=1) + "\n")
23
+ return 0 if not isinstance(result, dict) or result.get("ok", True) else 1
24
+
25
+
26
+ def main(argv=None) -> int:
27
+ """Run one verb (``argv``, default the command line)."""
28
+ import cw
29
+
30
+ return cw.dispatch(
31
+ list(TOOLS), argv, convention=cw.MODERN, egress=_json_egress, prog="chantey"
32
+ )
33
+
34
+
35
+ if __name__ == "__main__":
36
+ raise SystemExit(main())