tello-ai-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.
- tello_ai_sdk-0.1.0/.github/workflows/ci.yml +26 -0
- tello_ai_sdk-0.1.0/.github/workflows/publish-pypi.yml +59 -0
- tello_ai_sdk-0.1.0/.gitignore +16 -0
- tello_ai_sdk-0.1.0/CHANGELOG.md +119 -0
- tello_ai_sdk-0.1.0/LICENSE +202 -0
- tello_ai_sdk-0.1.0/PKG-INFO +228 -0
- tello_ai_sdk-0.1.0/README.ko.md +206 -0
- tello_ai_sdk-0.1.0/README.md +204 -0
- tello_ai_sdk-0.1.0/docs/architecture.md +1043 -0
- tello_ai_sdk-0.1.0/docs/errors/errors.v1.json +140 -0
- tello_ai_sdk-0.1.0/docs/events/sdk-events.v1.schema.json +158 -0
- tello_ai_sdk-0.1.0/docs/protocol/sdk-ws.v1.md +293 -0
- tello_ai_sdk-0.1.0/docs/sdk-structure.md +894 -0
- tello_ai_sdk-0.1.0/examples/.env.example +13 -0
- tello_ai_sdk-0.1.0/examples/README.ko.md +63 -0
- tello_ai_sdk-0.1.0/examples/README.md +64 -0
- tello_ai_sdk-0.1.0/examples/agent_callback.py +134 -0
- tello_ai_sdk-0.1.0/examples/basic_call.py +43 -0
- tello_ai_sdk-0.1.0/examples/call_summary.py +223 -0
- tello_ai_sdk-0.1.0/pyproject.toml +46 -0
- tello_ai_sdk-0.1.0/src/tello/__init__.py +80 -0
- tello_ai_sdk-0.1.0/src/tello/_version.py +1 -0
- tello_ai_sdk-0.1.0/src/tello/client.py +480 -0
- tello_ai_sdk-0.1.0/src/tello/commands.py +84 -0
- tello_ai_sdk-0.1.0/src/tello/config.py +27 -0
- tello_ai_sdk-0.1.0/src/tello/errors.py +110 -0
- tello_ai_sdk-0.1.0/src/tello/events.py +228 -0
- tello_ai_sdk-0.1.0/src/tello/py.typed +0 -0
- tello_ai_sdk-0.1.0/src/tello/realtime.py +53 -0
- tello_ai_sdk-0.1.0/src/tello/types.py +26 -0
- tello_ai_sdk-0.1.0/tests/test_client.py +820 -0
- tello_ai_sdk-0.1.0/tests/test_errors.py +83 -0
- tello_ai_sdk-0.1.0/tests/test_events.py +271 -0
- tello_ai_sdk-0.1.0/tests/test_realtime.py +48 -0
- tello_ai_sdk-0.1.0/uv.lock +301 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ['3.10', '3.13']
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
persist-credentials: false
|
|
22
|
+
- uses: astral-sh/setup-uv@v10.2.0
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
- run: uv sync --locked --extra dev
|
|
26
|
+
- run: uv run pytest -q
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Publish PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
with:
|
|
17
|
+
persist-credentials: false
|
|
18
|
+
- uses: astral-sh/setup-uv@v10.2.0
|
|
19
|
+
with:
|
|
20
|
+
python-version: '3.13'
|
|
21
|
+
- run: uv sync --locked --extra dev
|
|
22
|
+
- run: uv run pytest -q
|
|
23
|
+
|
|
24
|
+
build:
|
|
25
|
+
needs: test
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
with:
|
|
30
|
+
persist-credentials: false
|
|
31
|
+
- uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version: '3.12'
|
|
34
|
+
- name: Sync version from tag
|
|
35
|
+
run: |
|
|
36
|
+
VERSION="${GITHUB_REF_NAME#v}"
|
|
37
|
+
printf '__version__ = "%s"\n' "$VERSION" > src/tello/_version.py
|
|
38
|
+
- run: python -m pip install --upgrade build
|
|
39
|
+
- run: python -m build
|
|
40
|
+
- run: python -m pip install --upgrade twine && python -m twine check dist/*
|
|
41
|
+
- uses: actions/upload-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: dist
|
|
44
|
+
path: dist/
|
|
45
|
+
|
|
46
|
+
publish:
|
|
47
|
+
needs: build
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
environment: pypi
|
|
50
|
+
permissions:
|
|
51
|
+
id-token: write
|
|
52
|
+
steps:
|
|
53
|
+
- uses: actions/download-artifact@v4
|
|
54
|
+
with:
|
|
55
|
+
name: dist
|
|
56
|
+
path: dist/
|
|
57
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
58
|
+
with:
|
|
59
|
+
skip-existing: true
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- `wait_closed()` no longer ends on an error from a command other than
|
|
8
|
+
`create_call`. It used to raise on any error frame that arrived while a call
|
|
9
|
+
was active, so a mid-call `dtmfDigitsInvalid` raised `ValidationError` while
|
|
10
|
+
the call was still live, and a caller that then closed the socket made the
|
|
11
|
+
gateway cancel the real call. The wire contract (§6) keeps the connection
|
|
12
|
+
open on a failed command, and a failed `answer` / `send_dtmf` /
|
|
13
|
+
`get_summary` / `cancel` leaves the call running, so `wait_closed()` now
|
|
14
|
+
raises only for an error echoing the `requestId` of the current call's
|
|
15
|
+
`create_call`: a refusal, or a failure after `call.created`. Errors from
|
|
16
|
+
those other commands are delivered only to `EventType.ERROR` handlers.
|
|
17
|
+
- `create_call` always sends a `requestId`: `request_id` when non-empty,
|
|
18
|
+
otherwise a generated UUID. The signature is unchanged.
|
|
19
|
+
- A `callAlreadyActive` answering the `create_call` that started the call now
|
|
20
|
+
ends `wait_closed()` with `CallAlreadyActiveError`. Right after a call ends,
|
|
21
|
+
the gateway holds the session until it has cleaned that call up (contract
|
|
22
|
+
§4.1), so a `create_call` sent in that window is refused and never gets
|
|
23
|
+
`call.created`; `wait_closed()` used to ignore that refusal and hang. Retry
|
|
24
|
+
the call shortly. A `callAlreadyActive` answering a `create_call` sent
|
|
25
|
+
during a live call is still only an event, and `noActiveCall` never ends
|
|
26
|
+
the wait.
|
|
27
|
+
- A `create_call` whose frame cannot be sent (the client is not connected, or
|
|
28
|
+
the socket has already closed) no longer leaves the client treating a call
|
|
29
|
+
as running. It raises as before, the next `wait_closed()` raises the same
|
|
30
|
+
error instead of hanging, and the next `create_call` starts a new call.
|
|
31
|
+
- A call cut off by a dropped connection no longer carries over into the next
|
|
32
|
+
connection: after `connect()`, an error echoing the dropped call's
|
|
33
|
+
`create_call` requestId no longer ends the new call's wait.
|
|
34
|
+
- Reconnecting from a `DISCONNECTED` handler works. The dropped connection's
|
|
35
|
+
receive loop marked the new connection closed once the handler returned,
|
|
36
|
+
so `wait_closed()` returned at once while the new call was still live, and
|
|
37
|
+
the dropped call's wait returned instead of raising `ConnectionClosedError`.
|
|
38
|
+
|
|
39
|
+
### Changed (call wait)
|
|
40
|
+
|
|
41
|
+
- **Behavior change**: a `wait_closed()` started during a call returns when
|
|
42
|
+
that call ends, with that call's outcome, even if a handler has already
|
|
43
|
+
started the next call. It used to keep waiting through a follow-up call
|
|
44
|
+
started from a terminal handler. Call `wait_closed()` again to wait for the
|
|
45
|
+
follow-up.
|
|
46
|
+
|
|
47
|
+
### Changed (packaging)
|
|
48
|
+
|
|
49
|
+
- Requires `websockets>=14` (was `>=13`). The test suite runs on the asyncio
|
|
50
|
+
implementation that `websockets` 14 made the default, so 13 was declared
|
|
51
|
+
but never tested.
|
|
52
|
+
- The package metadata declares the license as a PEP 639 expression
|
|
53
|
+
(`License-Expression: Apache-2.0`, with `LICENSE` as the license file) and
|
|
54
|
+
lists trove classifiers for Python 3.10–3.13, `Typing :: Typed`,
|
|
55
|
+
`Framework :: AsyncIO`, and `Development Status :: 3 - Alpha`. Building
|
|
56
|
+
needs hatchling 1.27 or newer.
|
|
57
|
+
- The README links on PyPI point at GitHub; as relative paths they were
|
|
58
|
+
broken on the project page.
|
|
59
|
+
|
|
60
|
+
### Breaking changes (PyPI distribution name)
|
|
61
|
+
|
|
62
|
+
- **Breaking**: the distribution is published as `tello-ai-sdk`. `tello-sdk` on PyPI belongs to an unrelated Tello EDU drone library, so `pip install tello-sdk` never installed this SDK. The import name stays `tello`.
|
|
63
|
+
- License is Apache-2.0 (was MIT), matching tello-go and tello-js.
|
|
64
|
+
|
|
65
|
+
### Breaking changes (SMS removed from the SDK contract)
|
|
66
|
+
|
|
67
|
+
- **Breaking**: `send_sms` was removed entirely (the `sendSms` command, the `sms.sent` event, and the `SmsSentEvent` / `EventType.SMS_SENT` symbols no longer exist). The gateway dropped the `sendSms` handler, so a client still sending the frame matches no handler, receives no response at all, and blocks until its own timeout.
|
|
68
|
+
- **Breaking**: the `smsToRequired` / `smsMessageRequired` / `smsFailed` error codes are gone from the contract and from the error-code → exception mapping.
|
|
69
|
+
- **Breaking**: `examples/send_sms.py` was deleted, and `examples/call_summary_sms.py` became `examples/call_summary.py` (the call → `getSummary` half is unchanged; only the follow-up SMS was dropped). `LIVE_SMS_TO` / `LIVE_SMS_MESSAGE` are no longer read by any example.
|
|
70
|
+
|
|
71
|
+
### Breaking changes (agent selection removed from the SDK contract)
|
|
72
|
+
|
|
73
|
+
- **Breaking**: `create_call` no longer takes an `agent_id` parameter; the `createCall` wire frame never carries an `agentId` field (the gateway resolves the agent server-side). The `agentIdRequired` error code is gone from the contract.
|
|
74
|
+
- **Breaking**: `list_agents` was removed entirely (the `listAgents` command, the `agents.listed` event, and the `AgentInfo` / `AgentsListedEvent` / `EventType.AGENTS_LISTED` symbols no longer exist).
|
|
75
|
+
|
|
76
|
+
- Initial WS realtime client for turn-provider-gateway `/sdk`.
|
|
77
|
+
- `TelloClient`: connect (internal `auth`/`auth.ok` handshake), `create_call` / `answer` / `send_dtmf` / `cancel`, pub/sub event handlers, `wait_closed`.
|
|
78
|
+
- `send_dtmf(digits, message_id=None, request_id=None)`: mirrors `answer` but sends DTMF `digits` via the `sendDtmf` wire command.
|
|
79
|
+
- Event parsing for `user.turn` / `agent.turn` / `call.statusChanged` / `call.completed` / `call.noAnswer` / `call.failed` / `error`.
|
|
80
|
+
|
|
81
|
+
### Changed (auth handshake)
|
|
82
|
+
|
|
83
|
+
- Connection auth moved from the `Authorization: Bearer` upgrade header to an
|
|
84
|
+
application-level handshake: the client sends
|
|
85
|
+
`{"event":"auth","data":{"token":"<apiKey>"}}` as the first frame and blocks
|
|
86
|
+
until the server returns `auth.ok` before `connect()` succeeds. Auth stays
|
|
87
|
+
internal (no public step). The API key never appears on the upgrade request,
|
|
88
|
+
in the URL query, in logs, or in exceptions. An `unauthenticated` error frame,
|
|
89
|
+
a 4401 close, or an `auth.ok` wait timeout each raise `AuthenticationError`
|
|
90
|
+
from `connect()`.
|
|
91
|
+
|
|
92
|
+
### Changed (camelCase wire contract)
|
|
93
|
+
|
|
94
|
+
- Inbound frames are camelCase-only: event types `call.statusChanged` / `call.noAnswer`,
|
|
95
|
+
keys `sessionId` / `callId` / `turnIndex` / `previousStatus` / `failureReason` / `requestId`,
|
|
96
|
+
status vocabulary `inProgress` / `noAnswer` (etc.), error codes `toRequired` /
|
|
97
|
+
`callIdRequired` / `callNotFound` / `callNotCompleted` / `callAlreadyActive` /
|
|
98
|
+
`noActiveCall` / `dtmfDigitsRequired` / `dtmfDigitsInvalid` / `callRejected` /
|
|
99
|
+
`internalError`.
|
|
100
|
+
- Added `dtmf.accepted` event parsing (`DtmfAcceptedEvent`), acking a `sendDtmf` command.
|
|
101
|
+
- Python attribute names stay snake_case (`event.call_id`, `event.turn_index`, ...);
|
|
102
|
+
`Event` gains a `session_id` attribute (parsed from `sessionId`).
|
|
103
|
+
- Outbound commands were already camelCase and are unchanged.
|
|
104
|
+
- Error-code → exception mapping; automatic pong via `websockets`.
|
|
105
|
+
- `TELLO_API_KEY` / `TELLO_URL` environment-variable config (`TelloClient()` with no args).
|
|
106
|
+
- Version sourced solely from `src/tello/_version.py` (hatch dynamic version).
|
|
107
|
+
|
|
108
|
+
### Fixes (code review)
|
|
109
|
+
|
|
110
|
+
- `wait_closed()` no longer hangs when the gateway rejects a `create_call`
|
|
111
|
+
(toRequired / callRejected / internalError); it raises the mapped error.
|
|
112
|
+
- Abnormal mid-call disconnect now raises `ConnectionClosedError` instead of
|
|
113
|
+
returning as a phantom success.
|
|
114
|
+
- Receive loop drops valid-JSON non-object frames instead of crashing.
|
|
115
|
+
- Terminal handler that starts a follow-up call no longer trips a stale done flag.
|
|
116
|
+
- `DISCONNECTED` is delivered as a typed `Event` (was a raw dict).
|
|
117
|
+
- Map close code 4429 to `SessionReplacedError`; derive auth error from the
|
|
118
|
+
socket close code on the connect-then-send race.
|
|
119
|
+
- Remove empty `calls.py` placeholder.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: tello-ai-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tello SDK for Python — WebSocket realtime client for turn-provider-gateway
|
|
5
|
+
Project-URL: Homepage, https://telloai.io
|
|
6
|
+
Project-URL: Repository, https://github.com/tello-ai/tello-python
|
|
7
|
+
Author: Tello
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: realtime,sdk,telephony,tello,voice,websocket
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Framework :: AsyncIO
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: websockets>=14
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
**English** | [한국어](https://github.com/tello-ai/tello-python/blob/main/README.ko.md)
|
|
26
|
+
|
|
27
|
+
# tello-ai-sdk (Python)
|
|
28
|
+
|
|
29
|
+
> repo: `tello-python` · PyPI package: `tello-ai-sdk` · import: `tello`
|
|
30
|
+
|
|
31
|
+
Tello SDK for Python — a thin **WebSocket** realtime client for the
|
|
32
|
+
turn-provider-gateway `/sdk` endpoint. The SDK is the "conversation brain":
|
|
33
|
+
the gateway streams each caller turn from a live phone call, and your handler's
|
|
34
|
+
reply is forwarded back into the call.
|
|
35
|
+
|
|
36
|
+
> Transport is WebSocket only. There is no REST or webhook surface. The protocol
|
|
37
|
+
> contract lives in [`docs/protocol/sdk-ws.v1.md`](https://github.com/tello-ai/tello-python/blob/main/docs/protocol/sdk-ws.v1.md).
|
|
38
|
+
|
|
39
|
+
## 1. Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install tello-ai-sdk # requires Python >= 3.10; imports as `tello`
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 2. API key
|
|
46
|
+
|
|
47
|
+
The key authenticates the connection through an application-level handshake:
|
|
48
|
+
right after the socket opens the SDK sends an `auth` frame carrying the key in
|
|
49
|
+
its `token` field and waits for the server's `auth.ok` before anything else
|
|
50
|
+
runs. The key is never placed on the WS upgrade request or in the URL query.
|
|
51
|
+
This is fully internal — you never call auth yourself; `connect()` (and `async
|
|
52
|
+
with`) simply does not succeed until authentication has. Issue a key in the portal
|
|
53
|
+
(Agent settings → Advanced → Agent-linked / SDK).
|
|
54
|
+
|
|
55
|
+
Pass it explicitly or via environment variables:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
export TELLO_API_KEY="tello_live_xxx"
|
|
59
|
+
export TELLO_URL="ws://localhost:3000/sdk" # optional; defaults to ws://localhost:3000/sdk
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`TelloClient()` with no arguments then reads `TELLO_API_KEY` / `TELLO_URL`.
|
|
63
|
+
|
|
64
|
+
## 3. Connect + start a call
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import asyncio
|
|
68
|
+
from tello import TelloClient, EventType
|
|
69
|
+
|
|
70
|
+
async def main():
|
|
71
|
+
async with TelloClient(api_key="tello_live_xxx", url="ws://localhost:3000/sdk") as client:
|
|
72
|
+
@client.on(EventType.USER_TURN)
|
|
73
|
+
async def on_user_turn(event):
|
|
74
|
+
await client.answer(text="확인했습니다. 계속 말씀해주세요.")
|
|
75
|
+
|
|
76
|
+
await client.create_call(to="+821012345678", prompt="예약 확인")
|
|
77
|
+
await client.wait_closed()
|
|
78
|
+
|
|
79
|
+
asyncio.run(main())
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`TelloClient(...)` is the constructor (Python has no `new`). The `async with`
|
|
83
|
+
form is sugar for `connect()` / `aclose()`; use them explicitly if you prefer:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
client = TelloClient(api_key="tello_live_xxx", url="ws://localhost:3000/sdk")
|
|
87
|
+
await client.connect()
|
|
88
|
+
client.on(EventType.USER_TURN, on_user_turn)
|
|
89
|
+
await client.create_call(to="+821012345678", prompt="예약 확인")
|
|
90
|
+
await client.wait_closed()
|
|
91
|
+
await client.aclose()
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 4. Realtime turn events (pub/sub)
|
|
95
|
+
|
|
96
|
+
Subscribe handlers (sync or async) per event type via `client.on(...)`:
|
|
97
|
+
|
|
98
|
+
| `EventType` | value | payload fields |
|
|
99
|
+
| --- | --- | --- |
|
|
100
|
+
| `CALL_CREATED` | `call.created` | `call_id`, `session_id` |
|
|
101
|
+
| `USER_TURN` | `user.turn` | `turn_index`, `text` |
|
|
102
|
+
| `AGENT_TURN` | `agent.turn` | `turn_index`, `text` |
|
|
103
|
+
| `ANSWER_ACCEPTED` | `answer.accepted` | `request_id?`, `message_id` |
|
|
104
|
+
| `DTMF_ACCEPTED` | `dtmf.accepted` | `request_id?`, `message_id`, `digits` |
|
|
105
|
+
| `CALL_SUMMARY` | `call.summary` | `request_id?`, `status`, `duration_seconds?`, `transcript?`, `summary?`, `credit_charged?` |
|
|
106
|
+
| `CALL_STATUS_CHANGED` | `call.statusChanged` | `status`, `previous_status` |
|
|
107
|
+
| `CALL_COMPLETED` | `call.completed` | `status` |
|
|
108
|
+
| `CALL_NO_ANSWER` | `call.noAnswer` | `status`, `failure_reason?` |
|
|
109
|
+
| `CALL_FAILED` | `call.failed` | `status`, `failure_reason?` |
|
|
110
|
+
| `ERROR` | `error` | `code`, `message`, `request_id?`, `question?` |
|
|
111
|
+
| `DISCONNECTED` | `disconnected` | SDK-local; emitted when the WS closes |
|
|
112
|
+
|
|
113
|
+
Payload fields above are the Python attribute names; the wire frames themselves
|
|
114
|
+
use camelCase keys (`sessionId`, `callId`, `turnIndex`, `previousStatus`,
|
|
115
|
+
`failureReason`, `requestId`). An unknown `type` falls back to the base `Event`
|
|
116
|
+
so forward-compatible additions still reach subscribers.
|
|
117
|
+
|
|
118
|
+
Commands: `await client.create_call(to, prompt="", metadata=None, request_id=None)`,
|
|
119
|
+
`await client.answer(text, message_id=None, request_id=None)`,
|
|
120
|
+
`await client.send_dtmf(digits, message_id=None, request_id=None)`, `await client.cancel()`,
|
|
121
|
+
`await client.get_summary(call_id, request_id=None)`. `create_call` always sends
|
|
122
|
+
a `requestId`: the one you pass, or a generated UUID when you omit it. Give each
|
|
123
|
+
command its own `request_id`, or omit it (see §5).
|
|
124
|
+
|
|
125
|
+
`await client.wait_closed()` resolves when the call reaches a terminal state
|
|
126
|
+
(`call.completed` / `call.noAnswer` / `call.failed`, or a `call.statusChanged`
|
|
127
|
+
with status `cancelled`) or the connection closes. After `cancel()`, the gateway
|
|
128
|
+
ends the call with that cancelled `call.statusChanged` (its `previous_status` is
|
|
129
|
+
the status before the cancel); no `call.completed` follows. A wait in progress
|
|
130
|
+
returns when its own call ends, even if a handler has already started a
|
|
131
|
+
follow-up call; call `wait_closed()` again to wait for the follow-up. It raises
|
|
132
|
+
instead when the call's `create_call` fails (see §5); an error from any other
|
|
133
|
+
command does not end the wait.
|
|
134
|
+
|
|
135
|
+
## 5. Error handling
|
|
136
|
+
|
|
137
|
+
Gateway error frames map 1:1 to exceptions
|
|
138
|
+
(see [`docs/errors/errors.v1.json`](https://github.com/tello-ai/tello-python/blob/main/docs/errors/errors.v1.json)):
|
|
139
|
+
|
|
140
|
+
| gateway `code` | exception |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
| `unauthenticated` | `AuthenticationError` (auth handshake; also close code 4401) |
|
|
143
|
+
| `toRequired` | `ValidationError` |
|
|
144
|
+
| `callIdRequired` | `ValidationError` |
|
|
145
|
+
| `callNotFound` | `ValidationError` |
|
|
146
|
+
| `callNotCompleted` | `ValidationError` |
|
|
147
|
+
| `dtmfDigitsRequired` | `ValidationError` |
|
|
148
|
+
| `dtmfDigitsInvalid` | `ValidationError` |
|
|
149
|
+
| `callAlreadyActive` | `CallAlreadyActiveError` |
|
|
150
|
+
| `noActiveCall` | `NoActiveCallError` |
|
|
151
|
+
| `callRejected` | `CallRejectedError` (with `.question`) |
|
|
152
|
+
| `internalError` | `TelloServerError` |
|
|
153
|
+
|
|
154
|
+
Every error carries the gateway code on `.code` — branch on that, never on
|
|
155
|
+
`.args[0]`, which is display text the gateway may reword.
|
|
156
|
+
|
|
157
|
+
`createCall` can also be refused before any call exists — no `call.created`, no
|
|
158
|
+
`callId`, no charge. The gateway never retries these; any retry policy is yours.
|
|
159
|
+
|
|
160
|
+
| gateway `code` | exception | what to do |
|
|
161
|
+
| --- | --- | --- |
|
|
162
|
+
| `insufficientCredit` | `CallRefusedError` | tell the user to top up; do not resend |
|
|
163
|
+
| `concurrentLimitExceeded` | `CallRefusedError` | wait for one of your own calls to end, then retry |
|
|
164
|
+
| `callerNotVerified` | `CallRefusedError` | tell the user to verify the number; do not resend |
|
|
165
|
+
| `noRepresentativeNumber` | `CallRefusedError` | tell the user to configure a caller number; do not resend |
|
|
166
|
+
| `callProviderUnauthorized` | `CallProviderError` | service fault; report it, resending never helps |
|
|
167
|
+
| `callProviderDraining` | `CallProviderError` | retry later at your own pace |
|
|
168
|
+
| `callProviderUnavailable` | `CallProviderError` | retry later at your own pace |
|
|
169
|
+
| `callSetupFailed` | `CallProviderError` | surface as a failure and report it |
|
|
170
|
+
|
|
171
|
+
Command-level errors are also delivered to `EventType.ERROR` subscribers without
|
|
172
|
+
closing the socket. Only an error answering the call's own `create_call` ends
|
|
173
|
+
the call: `create_call` always sends a `requestId` (generated when you omit it)
|
|
174
|
+
and the gateway echoes it on the error frame, which is how the SDK tells that
|
|
175
|
+
error apart. Errors from `answer`, `send_dtmf`, `get_summary`, and `cancel` do
|
|
176
|
+
not end the call; they are delivered only as `EventType.ERROR` events, and
|
|
177
|
+
`wait_closed()` keeps waiting for the call's terminal event. So give each
|
|
178
|
+
command its own `request_id`, or omit it: never reuse the `create_call`
|
|
179
|
+
requestId on another command, because an error answering that command would
|
|
180
|
+
then end the wait. `wait_closed()` re-raises the relevant error so a failed
|
|
181
|
+
`create_call` (e.g. `toRequired`, `callRejected`) does not hang:
|
|
182
|
+
|
|
183
|
+
- auth failure (`unauthenticated` frame, close 4401, or `auth.ok` timeout) → `AuthenticationError`, raised from `connect()`
|
|
184
|
+
- a `create_call` error (a refusal before `call.created`, or a failure after it) → its mapped exception above
|
|
185
|
+
- `callAlreadyActive` → `CallAlreadyActiveError`, but only when it answers the `create_call` that started the call: the gateway is still finishing the previous call, so this one never started. Retry shortly. Answering a `create_call` sent during a live call, it is only an `EventType.ERROR` event and the live call continues. `noActiveCall` never ends the wait
|
|
186
|
+
- the connection dropping mid-call → `ConnectionClosedError`
|
|
187
|
+
- the session being displaced (close 4429) → `SessionReplacedError`
|
|
188
|
+
|
|
189
|
+
An `EventType.ERROR` handler receives an `ErrorEvent`, not an exception. To turn
|
|
190
|
+
it into the typed exception from the tables above, pass its fields to
|
|
191
|
+
`exception_for` from `tello.errors`:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
from tello import CallRefusedError, EventType
|
|
195
|
+
from tello.errors import exception_for
|
|
196
|
+
|
|
197
|
+
@client.on(EventType.ERROR)
|
|
198
|
+
def on_error(event):
|
|
199
|
+
error = exception_for(event.code, event.message, event.question)
|
|
200
|
+
if isinstance(error, CallRefusedError):
|
|
201
|
+
print(f"refused: {error.code}")
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The gateway drives a WS-level ping heartbeat; `websockets` answers pongs
|
|
205
|
+
automatically. There is no reconnect/resume — treat an abnormal close as
|
|
206
|
+
reconnect-worthy and restart the call.
|
|
207
|
+
|
|
208
|
+
## 6. Examples
|
|
209
|
+
|
|
210
|
+
Runnable programs live in [`examples/`](https://github.com/tello-ai/tello-python/blob/main/examples/README.md):
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
uv run python examples/basic_call.py # connect, one call, answer each turn
|
|
214
|
+
uv run python examples/agent_callback.py # full lifecycle, history, cancel, typed errors
|
|
215
|
+
uv run python examples/call_summary.py # gated live scenario ending in call.summary
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
They place real calls. Read [`examples/README.md`](https://github.com/tello-ai/tello-python/blob/main/examples/README.md) first.
|
|
219
|
+
|
|
220
|
+
## 7. Version compatibility
|
|
221
|
+
|
|
222
|
+
`tello-ai-sdk 0.1.x` implements Tello WS protocol `1.0`.
|
|
223
|
+
|
|
224
|
+
The full frame contract is in [`docs/protocol/sdk-ws.v1.md`](https://github.com/tello-ai/tello-python/blob/main/docs/protocol/sdk-ws.v1.md),
|
|
225
|
+
with [`docs/events/sdk-events.v1.schema.json`](https://github.com/tello-ai/tello-python/blob/main/docs/events/sdk-events.v1.schema.json)
|
|
226
|
+
and [`docs/errors/errors.v1.json`](https://github.com/tello-ai/tello-python/blob/main/docs/errors/errors.v1.json). Those three files
|
|
227
|
+
are generated copies of the canonical contract that lives beside the gateway
|
|
228
|
+
implementation — read them here, edit them there.
|