Null-DRM-Official/apps/agent/README.md
404errordeveloper da8e1123ec
All checks were successful
release / build-and-upload (push) Successful in 7m5s
Streamd v0.2.0: rename, modules panel, stable/beta channels
- Rename product/host binary to streamd (drm compat copy still shipped)
- Go module path streamd; STREAMD_* env aliases; agent UA streamd-agent
- Panel Modules store + agent pull sync (modstore / modsync)
- Rolling stable + beta download tags; README/docs channel curl blocks
- Release notes in docs/releases/v0.2.0.md attached by Forgejo Actions
2026-10-10 15:58:26 +02:00

71 lines
2.4 KiB
Markdown

# agent
Always-on credentials refresher, hosted by the single binary as `streamd agent`.
```text
apps/agent/
agentcmd/ the command body, imported by apps/cli
internal/ poller, durable queue, device pool, worker, ws client
agent.yaml config
```
## What it does
1. Polls streamd (`GET /api/streams`)
2. When an **enabled** stream is down/errored or missing `mpd`/`key`, enqueues a job
in a durable SQLite queue under `data_dir`
3. Claims a free ADB device that **already has** the app installed — it never installs
4. Runs a phone capture through the stream's app module
5. `POST /api/streams/:id/credentials`
6. Force-stops the app and clears the device proxy so the phone is free
It never runs a downloader. Claims are kept alive by a websocket heartbeat, so they
expire by themselves if the agent dies.
## Run
```bash
# terminal 1 — control plane
./bin/streamd serve --bind 127.0.0.1:8083 --data .cache/streamd
# terminal 2 — agent (operator API key from streamd Settings → API keys)
export STREAMD_API_KEY=ndk_…
# or legacy: export STREAMD_TOKEN=…
./bin/streamd agent run --config apps/agent/agent.yaml
```
```bash
./bin/streamd agent status
./bin/streamd agent devices
./bin/streamd agent enqueue --stream tg4-ioi --reason manual
./bin/streamd agent cancel --job 3
```
With `sync_modules: true` (default in the sample config), the agent **pulls**
provider modules from the streamd Modules page into `<data_dir>/modules/`. You do
not need a hand-maintained `modules/` tree on each agent host. The agent drives
whichever module a stream names and contains no provider logic.
## Config
`agent.yaml` — `streamd_url`, **`api_key`** (preferred) or `token` (alias), or
env `STREAMD_API_KEY` / `STREAMD_TOKEN`. Also: `poll_interval_sec`, `workers`,
`max_attempts`, `capture_wait_sec`, `devices` (empty = any authorised device),
`wvd`, `user_agent`, `agent_id`, `data_dir`, `sync_modules`, `modules_dir`
(default `<data_dir>/modules`), `modules_sync_interval_sec`, `modules_prune`.
Create the key in the streamd dashboard (role **operator**). The legacy shared
`--token` / `STREAMD_TOKEN` still works but is meant for migration only.
`wvd` must be set or key fetches fail.
## Build
```bash
go -C apps/cli build -o ../../bin/streamd .
# cross-compile
GOOS=darwin GOARCH=arm64 go -C apps/cli build -o ../../bin/streamd .
```
**Full guide: [docs/streamd.md](../../docs/streamd.md)**