phono-sdk 0.1.0__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,62 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # Dependencies
4
+ node_modules
5
+ .pnp
6
+ .pnp.js
7
+
8
+ # Local env files
9
+ .env
10
+ .env.local
11
+ .env.development.local
12
+ .env.test.local
13
+ .env.production.local
14
+
15
+ # Testing
16
+ coverage
17
+
18
+ # Turbo
19
+ .turbo
20
+
21
+ # Vercel
22
+ .vercel
23
+
24
+ # Build Outputs
25
+ .next/
26
+ out/
27
+ build
28
+ dist
29
+
30
+
31
+ # Debug
32
+ npm-debug.log*
33
+ yarn-debug.log*
34
+ yarn-error.log*
35
+
36
+ # Misc
37
+ .DS_Store
38
+ *.pem
39
+
40
+ # exécution locale du backend (binaires, médias, journaux)
41
+ .run/
42
+
43
+ # air (rechargement à chaud du backend)
44
+ backend/bin/
45
+ backend/build-errors.log
46
+ backend/data/
47
+
48
+ # binaire du serveur MCP (go build)
49
+ mcp/mcp
50
+
51
+ # config firebase de l'app (à fournir en secret pour les builds EAS)
52
+ google-services.json
53
+ GoogleService-Info.plist
54
+
55
+ # SDK Python
56
+ .venv/
57
+ __pycache__/
58
+ *.egg-info/
59
+ .pytest_cache/
60
+
61
+ # Les clés push (APNs .p8, compte de service FCM) : jamais versionnées.
62
+ secrets/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rauche Acho
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.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.5
2
+ Name: phono-sdk
3
+ Version: 0.1.0
4
+ Summary: Phono : appels, messages et vocaux pour vos agents — le transport, pas la voix.
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: httpx>=0.27
9
+ Requires-Dist: websockets>=13
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
12
+ Requires-Dist: pytest>=8; extra == 'dev'
13
+ Description-Content-Type: text/markdown
14
+
15
+ # phono — le SDK Python
16
+
17
+ Appels, messages et vocaux pour vos agents. **Phono transporte la voix, il ne la produit pas** : votre agent génère son audio (avec le moteur de synthèse de son choix), Phono le livre — en vocal, ou en temps réel dans un appel — et lui rend la voix d'en face.
18
+
19
+ ```bash
20
+ pip install phono-sdk # Python ≥ 3.10, asyncio
21
+ ```
22
+
23
+ ```python
24
+ from phono import Phono
25
+
26
+ async with Phono("https://phonoapi.raucheacho.com", "phk_…") as phono: # ou PHONO_URL, PHONO_API_KEY
27
+ await phono.messages.send("jean.acme", "Votre commande est prête.")
28
+ ```
29
+
30
+ ## Messages et vocaux
31
+
32
+ ```python
33
+ await phono.messages.send("alice", "Bonjour !")
34
+
35
+ # Un vocal : l'audio que VOTRE agent a produit. Ogg Opus passe tel quel ;
36
+ # WAV, MP3, M4A, WebM, FLAC sont convertis par Phono.
37
+ await phono.messages.send_voice("alice", "reponse.wav")
38
+ await phono.messages.send_voice("alice", tts_bytes) # des octets
39
+ await phono.messages.send_voice("alice", pcm, sample_rate=24000) # PCM 16 bits brut
40
+
41
+ thread = await phono.messages.list(with_="alice", limit=20) # le plus récent d'abord
42
+ for m in thread["messages"]:
43
+ print(m["kind"], m.get("body") or m.get("transcript"))
44
+ ```
45
+
46
+ Un vocal reçu arrive avec sa **transcription** (`transcript`, puis l'événement `message.transcribed`) quand une entreprise est d'un côté de la conversation.
47
+
48
+ ## Les événements
49
+
50
+ ```python
51
+ async for ev in phono.events(): # Server-Sent Events, reconnexion automatique
52
+ if ev.type == "message.created":
53
+ print(ev.data["sender"]["handle"], ev.data["message"]["body"])
54
+ elif ev.type == "call.ringing":
55
+ call = ev.data
56
+ await phono.calls.answer(call["id"])
57
+ ```
58
+
59
+ Les mêmes événements partent en webhooks signés :
60
+
61
+ ```python
62
+ from phono import parse_webhook
63
+ event = parse_webhook(secret, request_body, request.headers["X-Phono-Signature"])
64
+ ```
65
+
66
+ ## Les appels, en temps réel
67
+
68
+ Un appel, c'est un canal audio. Ouvrez son **flux média** : vous envoyez la voix de votre agent en PCM 16 bits little-endian mono, vous recevez celle de l'autre au même format.
69
+
70
+ ```python
71
+ placed = await phono.calls.create("alice") # alice sonne ; vous êtes dans l'appel
72
+ call_id = placed["call"]["id"]
73
+
74
+ async with phono.media(call_id, rate=16000) as stream:
75
+ await stream.send(greeting_pcm) # n'importe quelle taille : Phono cadence
76
+
77
+ async for item in stream:
78
+ if item.type == "audio":
79
+ transcriber.feed(item.pcm) # ce que dit alice, trame par trame
80
+ elif item.type == "drained":
81
+ pass # votre phrase est partie en entier
82
+ elif item.type == "end":
83
+ break # quelqu'un a raccroché
84
+
85
+ # L'autre reprend la parole pendant que vous parlez ? Coupez :
86
+ # await stream.clear()
87
+
88
+ await phono.calls.hangup(call_id)
89
+ ```
90
+
91
+ `rate` : 8000, 16000, 24000 ou 48000. Pour un appel entrant, `await phono.calls.answer(call_id)`, puis `phono.media(call_id)`.
92
+
93
+ Mettre deux personnes en relation, sans être dans l'appel : `await phono.calls.connect("jean.acme", "alice")`.
94
+
95
+ ## Les contacts
96
+
97
+ Hors de votre organisation, on n'écrit et on n'appelle qu'un **contact** : une demande, que l'autre accepte. Sinon, `PhonoError` avec `code == "contact_required"`.
98
+
99
+ ```python
100
+ await phono.contacts.request("alice", note="Le support d'Acme, pour votre commande")
101
+ pending = await phono.contacts.requests() # {incoming, outgoing}
102
+ await phono.contacts.accept("bob")
103
+ ```
104
+
105
+ ## Les erreurs
106
+
107
+ ```python
108
+ from phono import PhonoError
109
+ try:
110
+ await phono.calls.create("alice")
111
+ except PhonoError as e:
112
+ print(e.status, e.code, e.message) # 409 busy « @alice est déjà en ligne »
113
+ ```
@@ -0,0 +1,99 @@
1
+ # phono — le SDK Python
2
+
3
+ Appels, messages et vocaux pour vos agents. **Phono transporte la voix, il ne la produit pas** : votre agent génère son audio (avec le moteur de synthèse de son choix), Phono le livre — en vocal, ou en temps réel dans un appel — et lui rend la voix d'en face.
4
+
5
+ ```bash
6
+ pip install phono-sdk # Python ≥ 3.10, asyncio
7
+ ```
8
+
9
+ ```python
10
+ from phono import Phono
11
+
12
+ async with Phono("https://phonoapi.raucheacho.com", "phk_…") as phono: # ou PHONO_URL, PHONO_API_KEY
13
+ await phono.messages.send("jean.acme", "Votre commande est prête.")
14
+ ```
15
+
16
+ ## Messages et vocaux
17
+
18
+ ```python
19
+ await phono.messages.send("alice", "Bonjour !")
20
+
21
+ # Un vocal : l'audio que VOTRE agent a produit. Ogg Opus passe tel quel ;
22
+ # WAV, MP3, M4A, WebM, FLAC sont convertis par Phono.
23
+ await phono.messages.send_voice("alice", "reponse.wav")
24
+ await phono.messages.send_voice("alice", tts_bytes) # des octets
25
+ await phono.messages.send_voice("alice", pcm, sample_rate=24000) # PCM 16 bits brut
26
+
27
+ thread = await phono.messages.list(with_="alice", limit=20) # le plus récent d'abord
28
+ for m in thread["messages"]:
29
+ print(m["kind"], m.get("body") or m.get("transcript"))
30
+ ```
31
+
32
+ Un vocal reçu arrive avec sa **transcription** (`transcript`, puis l'événement `message.transcribed`) quand une entreprise est d'un côté de la conversation.
33
+
34
+ ## Les événements
35
+
36
+ ```python
37
+ async for ev in phono.events(): # Server-Sent Events, reconnexion automatique
38
+ if ev.type == "message.created":
39
+ print(ev.data["sender"]["handle"], ev.data["message"]["body"])
40
+ elif ev.type == "call.ringing":
41
+ call = ev.data
42
+ await phono.calls.answer(call["id"])
43
+ ```
44
+
45
+ Les mêmes événements partent en webhooks signés :
46
+
47
+ ```python
48
+ from phono import parse_webhook
49
+ event = parse_webhook(secret, request_body, request.headers["X-Phono-Signature"])
50
+ ```
51
+
52
+ ## Les appels, en temps réel
53
+
54
+ Un appel, c'est un canal audio. Ouvrez son **flux média** : vous envoyez la voix de votre agent en PCM 16 bits little-endian mono, vous recevez celle de l'autre au même format.
55
+
56
+ ```python
57
+ placed = await phono.calls.create("alice") # alice sonne ; vous êtes dans l'appel
58
+ call_id = placed["call"]["id"]
59
+
60
+ async with phono.media(call_id, rate=16000) as stream:
61
+ await stream.send(greeting_pcm) # n'importe quelle taille : Phono cadence
62
+
63
+ async for item in stream:
64
+ if item.type == "audio":
65
+ transcriber.feed(item.pcm) # ce que dit alice, trame par trame
66
+ elif item.type == "drained":
67
+ pass # votre phrase est partie en entier
68
+ elif item.type == "end":
69
+ break # quelqu'un a raccroché
70
+
71
+ # L'autre reprend la parole pendant que vous parlez ? Coupez :
72
+ # await stream.clear()
73
+
74
+ await phono.calls.hangup(call_id)
75
+ ```
76
+
77
+ `rate` : 8000, 16000, 24000 ou 48000. Pour un appel entrant, `await phono.calls.answer(call_id)`, puis `phono.media(call_id)`.
78
+
79
+ Mettre deux personnes en relation, sans être dans l'appel : `await phono.calls.connect("jean.acme", "alice")`.
80
+
81
+ ## Les contacts
82
+
83
+ Hors de votre organisation, on n'écrit et on n'appelle qu'un **contact** : une demande, que l'autre accepte. Sinon, `PhonoError` avec `code == "contact_required"`.
84
+
85
+ ```python
86
+ await phono.contacts.request("alice", note="Le support d'Acme, pour votre commande")
87
+ pending = await phono.contacts.requests() # {incoming, outgoing}
88
+ await phono.contacts.accept("bob")
89
+ ```
90
+
91
+ ## Les erreurs
92
+
93
+ ```python
94
+ from phono import PhonoError
95
+ try:
96
+ await phono.calls.create("alice")
97
+ except PhonoError as e:
98
+ print(e.status, e.code, e.message) # 409 busy « @alice est déjà en ligne »
99
+ ```
@@ -0,0 +1,22 @@
1
+ [project]
2
+ name = "phono-sdk"
3
+ version = "0.1.0"
4
+ description = "Phono : appels, messages et vocaux pour vos agents — le transport, pas la voix."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { text = "MIT" }
8
+ dependencies = ["httpx>=0.27", "websockets>=13"]
9
+
10
+ [project.optional-dependencies]
11
+ dev = ["pytest>=8", "pytest-asyncio>=0.24"]
12
+
13
+ [build-system]
14
+ requires = ["hatchling"]
15
+ build-backend = "hatchling.build"
16
+
17
+ [tool.hatch.build.targets.wheel]
18
+ packages = ["src/phono"]
19
+
20
+ [tool.pytest.ini_options]
21
+ asyncio_mode = "auto"
22
+ asyncio_default_fixture_loop_scope = "function"
@@ -0,0 +1,14 @@
1
+ """Phono : appels, messages et vocaux pour vos agents.
2
+
3
+ Phono transporte la voix, il ne la produit pas : votre agent génère son audio,
4
+ Phono le livre — en vocal, ou en temps réel dans un appel.
5
+ """
6
+
7
+ from .client import Phono
8
+ from .errors import PhonoError
9
+ from .events import Event
10
+ from .media import MediaItem, MediaStream
11
+ from .webhook import parse_webhook, verify_signature
12
+
13
+ __all__ = ["Phono", "PhonoError", "Event", "MediaItem", "MediaStream", "parse_webhook", "verify_signature"]
14
+ __version__ = "0.1.0"