Skip to main content

t4l-server

t4l-server is the small trusted bridge between one T4L Trainer phone and one host-owned OpenClaw coach.

It does four jobs:

  1. Pair the phone through an authenticated owner channel.
  2. Verify every phone request with an Ed25519 device proof.
  3. Store phone-accepted state, chat, and reviewable agent results in SQLite.
  4. Expose the same data to the coach through MCP.

It does not install or manage OpenClaw. It does not accept model keys from the phone. It does not expose its MCP key to the phone.

The whole system

authenticated owner channel
          |
          | confirms XXXX-XXXX on the host
          v
phone -- signed HTTPS --> t4l-server <-- host-only MCP key -- OpenClaw coach
                              |
                              v
                           SQLite

Run one isolated server and one OpenClaw coach per athlete. Put the public phone routes behind trusted HTTPS. Keep the channel-confirmation and MCP calls on the host.

Install

Python 3.11 or newer is required.

python3 -m venv .venv
.venv/bin/pip install -e '.[dev]'

Run

Set two host-only secrets:

  • MCP_T4L_API_KEY: used only by OpenClaw for POST /mcp.
  • T4L_CONNECTOR_RUNTIME_TOKEN: used only by the authenticated owner-channel adapter to confirm pairing.

Then start the server:

export MCP_T4L_API_KEY='replace-with-a-long-random-secret'
export T4L_CONNECTOR_RUNTIME_TOKEN='replace-with-another-long-random-secret'

t4l-server serve \
  --data-dir /var/lib/t4l/coach-tobi \
  --host 127.0.0.1 \
  --port 8787 \
  --api-key "$MCP_T4L_API_KEY" \
  --agent-id coach-tobi \
  --agent-name "T4L Gym Bro" \
  --agent-runtime openclaw \
  --connector-owner-id 'slack:workspace-id:user-id' \
  --require-https

Bind locally and publish it through a trusted HTTPS reverse proxy. If the proxy terminates TLS, it must send Forwarded: proto=https or X-Forwarded-Proto: https.

The owner identity format is exactly channel:account:sender. Repeat --connector-owner-id if the coach has more than one authenticated owner channel.

Pairing

The normal first launch has one input: the connector address.

  1. The phone reads /.well-known/t4l-agent.
  2. It creates an Ed25519 device key and calls POST /v1/pairing/requests.
  3. It shows /t4l connect XXXX-XXXX.
  4. The user sends that command through the authenticated owner channel.
  5. The host adapter calls POST /v1/pairing/channel-confirmation with its runtime token and verified channel identity.
  6. The phone signs the challenge and calls POST /v1/pairing/complete.

The returned token is bound to that device key and has only chat, sync, and status scopes. Every later app request signs the token id, device id, timestamp, nonce, method, exact path, and SHA-256 body hash.

Pairing fails closed when the runtime token or owner list is missing.

Phone API

Public discovery and pairing:

Method Path Auth
GET /.well-known/t4l-agent none
POST /v1/pairing/requests trusted HTTPS
POST /v1/pairing/complete trusted HTTPS
POST /v1/pairing/channel-confirmation host runtime token; loopback by default

Signed phone routes:

Method Path Scope
GET /v1/session status
DELETE /v1/devices/{deviceId} status
POST /v1/chat/onboarding chat
GET/POST /v1/chat/messages chat
PUT /v2/context/bundle sync
GET /v2/results/pending sync
GET /v2/results/{resultId}/{revision} sync
POST /v2/results/{resultId}/{revision}/ack sync

The app publishes one atomic v2 bundle. Its only context kind is accepted_state. A fresh accepted setup may also contain exactly one training_block_request.

The only phone-review results are:

  • athlete_setup_draft
  • training_block_plan

A result stays pending until the phone acknowledges its exact resultId and revision. Importing a training block is always an explicit user action.

MCP API

POST /mcp accepts the host-only API key through Authorization: Bearer ... or x-t4l-token.

The coach can:

  • read the accepted state and current block request;
  • read recent chat and standing coaching notes;
  • reply in chat;
  • write a pending athlete setup draft;
  • write a pending training block plan.

It cannot write accepted phone state. It cannot install software. It cannot create nutrition, hydration, supplement, weight, or body-composition prescriptions. The server blocks those topics in agent output and strips old nutrition fields before they can re-enter a coach prompt.

State ownership

The phone is the source of truth.

  • Server context is a copy of phone-accepted state.
  • Agent writes are pending proposals.
  • The phone validates and accepts or rejects them.
  • Daily workout choice is local and deterministic.
  • The active workout uses the frozen phone session snapshot.
  • Apple Watch owns progress while it controls the session.

Development

.venv/bin/ruff check .
.venv/bin/mypy
.venv/bin/pytest -q

The production phone uses device-bound proofs. The production coach uses MCP from the host.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

t4l_server-0.8.1.tar.gz (120.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

t4l_server-0.8.1-py3-none-any.whl (44.6 kB view details)

Uploaded Python 3

File details

Details for the file t4l_server-0.8.1.tar.gz.

File metadata

  • Download URL: t4l_server-0.8.1.tar.gz
  • Upload date:
  • Size: 120.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for t4l_server-0.8.1.tar.gz
Algorithm Hash digest
SHA256 996d127767b649567c00a10a532012ef3447b4cc43392ef78e6cccc3dd62fd63
MD5 72feb10ef4f0e5bca74cb67e90e63e1d
BLAKE2b-256 e9b02e56faf4f626e580019cb4870a9d6a7558c1f4ebe6cf064fb8028fd9fb71

See more details on using hashes here.

Provenance

The following attestation bundles were made for t4l_server-0.8.1.tar.gz:

Publisher: publish.yml on BigSlikTobi/t4l-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file t4l_server-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: t4l_server-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 44.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for t4l_server-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7505901d4f911738c0b3aaa8f43d285aec9b8a880599cdc72477167f2db3313
MD5 c258005e230306796ecb894367279eba
BLAKE2b-256 7ee76cb4d036f4bd2d67e69114da47b75e4bd9dd218edf6b2e1508f198a258e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for t4l_server-0.8.1-py3-none-any.whl:

Publisher: publish.yml on BigSlikTobi/t4l-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.9.0

2 files

This release

0.8.1 This release

2 files

0.8.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.2

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page