### Local Development Setup Commands Source: https://github.com/4paradigm/phanthymotus/blob/main/CONTRIBUTING.md Clone the repository, install Agent Core dependencies with uv, and run the application locally. Requires ROS2 Humble; after running, visit http://localhost:15678. ```bash # Clone the repo git clone https://github.com/4paradigm/phanthymotus.git cd phanthymotus # Install Agent Core dependencies cd agent-core uv sync # Run locally (requires ROS2) source /opt/ros/humble/setup.bash ./run.zsh # Visit http://localhost:15678 ``` -------------------------------- ### Start the Agent Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Run the agent from the agent-core directory. The peer system starts automatically with identity and discovery providers. ```bash cd agent-core python src/start.py ``` -------------------------------- ### mDNS Discovery Troubleshooting Commands Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Commands to check firewall rules for mDNS, verify zeroconf installation, and restart peer discovery. Run these when GET /api/peer/discovered returns empty. ```bash # Check firewall allows mDNS (224.0.0.251:5353) sudo ufw allow from 224.0.0.0/4 # or sudo firewall-cmd --add-service=mdns --permanent # Check zeroconf is installed pip list | grep zeroconf # Restart peer discovery curl -X POST http://localhost:15678/api/peer/providers/restart ``` -------------------------------- ### Install PhanthyMotus with curl Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Installs PhanthyMotus with a single command. The script automatically installs Docker if needed, pulls the latest Agent Core image, and starts the service. After installation, open http://:15678 to access the Web Dashboard. ```bash curl -fsSL https://motus.phanthy.com/install.sh | sudo bash ``` -------------------------------- ### Install bluez-peripheral for BLE advertising Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Installs the optional BLE advertising package. Requires Linux with BlueZ >= 5.43 and root or CAP_NET_ADMIN. Without it, advertising is skipped and scanning still works. ```bash pip install bluez-peripheral ``` -------------------------------- ### Initiate Pairing Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Start pairing with a peer by sending a POST request with the peer ID. ```bash curl -X POST http://localhost:15678/api/peer/pair/start \ -H "Content-Type: application/json" \ -d '{"peer_id": "f7e8d9c0b1a2..."}' ``` -------------------------------- ### Startup Log Output Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Expected output when starting the agent, showing identity and discovery providers. ```text [peer] generated identity a1b2c3d4e5f6... [peer] discovery provider "mdns" started [peer] discovery provider "static" started ``` -------------------------------- ### Skill files manifest example Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Example JSON manifest for skill files, declaring each file's path, byte size, and SHA256 hash. The manifest does not specify who reads the files; that is determined by the LLM at runtime. ```json "files": [ {"path": "reference/etiquette.md", "bytes": 1840, "sha256": "…"}, {"path": "trajectory.jsonl", "bytes": 482301, "sha256": "…"} ] ``` -------------------------------- ### Install agent-core with pip Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Installs the base peer mesh package from the agent-core directory. Provides Ed25519 identity, mDNS discovery, BLE scanning, HTTPS transport, and tool proxy. ```bash cd agent-core pip install -e . ``` -------------------------------- ### x-skill-package declaration example Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Example JSON declaration for a skill package card. The schema field is required and must match the package's manifest.schema; otherwise the package is refused with 409. The other fields are capability bits that enable UI and code paths. ```json { "x-skill-package": { "schema": "example.device.package/1", "pending": true, "session_authorization": true, "persistent_execution": true, "legacy_slug_prefix": "recorded-" } } ``` -------------------------------- ### Atomic line writer installation Source: https://github.com/4paradigm/phanthymotus/blob/main/agents/pr_review/rules/common.md Install the atomic line writer (`logsafe.install()`) in new long-running Python entry points and every multiprocessing child entry point, because a spawned child does not inherit the parent's sys.stdout. ```python logsafe.install() ``` -------------------------------- ### Install a specific PhanthyMotus version Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Installs a specific version of PhanthyMotus by passing a tag to the install script. The tag replaces with the desired version identifier. ```bash curl -fsSL https://motus.phanthy.com/install.sh | sudo bash -s ``` -------------------------------- ### Build CUDA wheel inside a container Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Build a CUDA-enabled sherpa-onnx wheel inside a container started from the perception image for the target JetPack. This ensures the correct CPython ABI and glibc. The example shows the docker run command and the environment variables and setup.py invocation for jp6.1. ```bash # on the build host (must match the target JetPack: jp5.11 → L4T R35, jp6.1 → R36) docker run -d --name sherpa-build --runtime nvidia \ -v /path/to/k2-fsa/sherpa-onnx:/src:ro -v /path/to/outdir:/out \ --entrypoint bash /out/build.sh # inside, against a *writable* copy of the tree (setup.py appends __version__ to it). # jp6.1 shown; for jp5.11 use 1.16.0 and python3.8. export SHERPA_ONNX_ENABLE_GPU=ON export SHERPA_ONNX_LINUX_ARM64_GPU_ONNXRUNTIME_VERSION=1.18.1 # jp6.1 / CUDA 12.6 export SHERPA_ONNX_MAKE_ARGS="-j2" # Orin has 6 cores but ~3 GB free SHERPA_ONNX_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release \ -DSHERPA_ONNX_ENABLE_GPU=ON \ -DSHERPA_ONNX_LINUX_ARM64_GPU_ONNXRUNTIME_VERSION=1.18.1 \ -DPYTHON_EXECUTABLE=/usr/bin/python3.10 \ -DPython_EXECUTABLE=/usr/bin/python3.10" \ python3.10 setup.py bdist_wheel ``` -------------------------------- ### Enable discovery providers in config.json Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Example configuration enabling mDNS and a static peer, with BLE disabled. The static peer's peer_id is filled automatically after pairing. ```json { "peer_settings": { "enabled": true, "discovery": { "mdns": true, "ble": false, "static": [ { "url": "https://192.168.1.100:15678", "display_name": "Orin6", "peer_id": "" } ] } } } ``` -------------------------------- ### Example docker-compose.yml service definitions Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Shows how deployed services appear in /opt/phanthy-motus/docker-compose.yml. Includes agent-core and a unitree-g1 driver, both using host network, IPC, PID, privileged mode, and /dev mount. The agent-core also mounts /opt/phanthy-motus/data. ```yaml services: agent-core: image: registry/core:tag network_mode: host ipc: host pid: host privileged: true volumes: - /dev:/dev - /opt/phanthy-motus/data:/work/resource ... unitree-g1: image: registry/drivers/unitree/g1:tag network_mode: host ipc: host pid: host privileged: true volumes: - /dev:/dev ... ``` -------------------------------- ### Deploy PR image with curl and run-pr-image.sh Source: https://github.com/4paradigm/phanthymotus/blob/main/PR_REVIEW_AGENT.md One-line command to deploy a PR image for driver or perception targets. It pulls the image, reads the compose fragment from /deploy/service.yml, substitutes the real ref, and starts it from a standalone compose file under PR_IMAGE_DIR. Additional flags like --logs, --shell, --status, --down can be passed after the --. ```bash curl -fsSL https://motus.phanthy.com/run-pr-image.sh | bash -s -- ``` -------------------------------- ### Verify zxing-cpp wheel in clean container Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Run in a clean container of the same image to prove no ABI mismatch and that the keyword set is as expected. Installs the wheel and checks that 'try_invert' is in the read_barcodes docstring, then writes and reads a QR code. ```bash docker run --rm -v /root/zxwheels:/w "$IMG" bash -lc ' pip3 install /w/zxing_cpp-2.2.0-cp38-cp38-linux_aarch64.whl && python3 -c "import zxingcpp, numpy as np; sig=zxingcpp.read_barcodes.__doc__.splitlines()[0]; print(\"try_invert\" in sig); a=np.asarray(zxingcpp.write_barcode(zxingcpp.BarcodeFormat.QRCode, \"x\", width=240, height=240)); print([b.text for b in zxingcpp.read_barcodes(a)])"' ``` -------------------------------- ### Install and dump py-spy to diagnose the wedge Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Use py-spy to dump the stack of the stuck process. The first command installs py-spy inside the container; the second dumps the stack of the main.py process. This is the only way to see the hang, as docker logs and docker top do not reveal it. ```bash docker exec embodied-perception pip3 install -q py-spy docker exec --privileged embodied-perception py-spy dump --pid $(pgrep -f "python3 /work/main.py" | head -1) ``` -------------------------------- ### Pairing Start Response Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md JSON response with session ID, SAS code, and expiration time. ```json { "session_id": "abc123", "sas_code": "428197", "expires_at": 1735000300.0 } ``` -------------------------------- ### GET /api/peer/tools/list Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Lists tools that the calling peer is allowed to invoke. ```APIDOC ## GET /api/peer/tools/list ### Description Returns a list of tools that the calling peer is permitted to call. Requires Ed25519 signature. ### Method GET ### Endpoint /api/peer/tools/list ### Response #### Success Response (200) - **tools** (array) - List of allowed tools. #### Response Example { "tools": [] } ``` -------------------------------- ### Host baseline Docker daemon configuration Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Recommended `/etc/docker/daemon.json` configuration to set a floor for log rotation on containers started outside the compose/service.yml paths. Applying this requires restarting the Docker daemon, which stops every container on the host. ```json { "log-driver": "local", "log-opts": { "max-size": "10m", "max-file": "3" } } ``` -------------------------------- ### GET /api/peer/providers Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Returns the status of discovery providers (mDNS, static, BLE). ```APIDOC ## GET /api/peer/providers ### Description Returns the status of each discovery provider (mDNS, static, BLE). ### Method GET ### Endpoint /api/peer/providers ### Response #### Success Response (200) - **providers** (array) - List of provider statuses. #### Response Example { "providers": [] } ``` -------------------------------- ### BLE Discovery Log Output Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Additional log lines when discovery.ble is enabled, with the second line only if the peripheral half is installed. ```text [peer] ble advertising a1b2c3d4e5f6 on hci0 [peer] discovery provider "ble" started ``` -------------------------------- ### Check cuDNN soname with readelf Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Use readelf to verify the required cuDNN and CUDA libraries for the ONNX Runtime CUDA provider. This is critical because the provider will not load if the sonames don't match the installed libraries. ```bash readelf -d libonnxruntime_providers_cuda.so | grep NEEDED ``` -------------------------------- ### GET /api/peer/paired Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Lists peers that have been paired with this peer. ```APIDOC ## GET /api/peer/paired ### Description Returns a list of peers that have been paired with this peer. ### Method GET ### Endpoint /api/peer/paired ### Response #### Success Response (200) - **peers** (array) - List of paired peers. #### Response Example { "peers": [] } ``` -------------------------------- ### GET /v1/capabilities Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/music-catalog.md Retrieves the provider's capabilities, including available filters, tag vocabulary, maximum top_k, and audio URL lifetime. The response is cached in memory for 24 hours. ```APIDOC ## GET /v1/capabilities ### Description Returns the provider's capabilities, including filter options, tag vocabulary, maximum top_k, and audio URL lifetime. Capabilities are cached in memory for 24 hours. ### Method GET ### Endpoint /v1/capabilities ### Response #### Success Response (200) - **filters** (object) - Contains filter option lists. - **kind** (array) - List of {value,label} objects. - **category** (array) - List of {value,label} objects. - **genre** (array) - List of {value,label} objects. - **language** (array) - List of {value,label} objects. - **features** (array) - Contains 'asmr' when the provider serves ASMR content. - **max_top_k** (integer) - Maximum allowed top_k value. - **audio_url_lifetime** (integer) - Lifetime of audio URLs in seconds. #### Response Example { "schema": "motus.music/1", "request_id": "...", "filters": { "kind": [{"value": "song", "label": "Song"}], "category": [{"value": "pop", "label": "Pop"}], "genre": [{"value": "rock", "label": "Rock"}], "language": [{"value": "en", "label": "English"}] }, "features": ["asmr"], "max_top_k": 10, "audio_url_lifetime": 3600 } ``` -------------------------------- ### GET /api/peer/dds_topology Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Returns ROS2 topic lists from all peers (requires rclpy). ```APIDOC ## GET /api/peer/dds_topology ### Description Returns ROS2 topic lists from all peers. Requires rclpy to be installed. ### Method GET ### Endpoint /api/peer/dds_topology ### Response #### Success Response (200) - **topics** (object) - Mapping of peer_id to topic lists. #### Response Example { "topics": {} } ``` -------------------------------- ### GET /api/peer/tools/list Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Lists the tools that a peer can call. The response contains OpenAI function-calling schemas filtered by the peer's role and tool_filter. ```APIDOC ## GET /api/peer/tools/list ### Description Lists the tools that a peer can call. ### Method GET ### Endpoint /api/peer/tools/list ### Parameters #### Headers - **X-Motus-Peer-Id** (string) - Required - The ID of the peer requesting the tool list. - **X-Motus-Timestamp** (string) - Required - Unix timestamp of the request. - **X-Motus-Signature** (string) - Required - Ed25519 signature of the request. ### Response #### Success Response (200) - Returns OpenAI function-calling schemas filtered by the peer's role and tool_filter. #### Response Example No explicit response example is provided. ``` -------------------------------- ### Stop signals first, locks second Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Shows the correct stop method: call request_stop() before taking the lock to unblock an in-flight start, then tear down under the lock. ```python def stop(self) -> dict: self.request_stop() # non-blocking; unblocks an in-flight start with self._lifecycle_lock: self._teardown() self.state = "idle" return {"state": "idle"} ``` -------------------------------- ### GET /api/peer/discovered Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Lists peers discovered via mDNS, static configuration, or BLE. ```APIDOC ## GET /api/peer/discovered ### Description Returns a list of peers discovered through mDNS, static configuration, or BLE. ### Method GET ### Endpoint /api/peer/discovered ### Response #### Success Response (200) - **peers** (array) - List of discovered peers. #### Response Example { "peers": [] } ``` -------------------------------- ### Build VITS2 TensorRT TTS for JetPack 6.1 and 5.11 Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/plugins/vits2_tts_trt/README.md Build commands for the VITS2 TensorRT TTS plugin. ENABLE_VITS2_TRT defaults to 1, so both JetPack lines build with the VITS2 frontend installed. Use --jp-version 6.1 for TensorRT 10 and --jp-version 5.11 for TensorRT 8. ```bash cd phanthymotus/deploy ./build_perception.sh --jp-version 6.1 # TensorRT 10 ./build_perception.sh --jp-version 5.11 # TensorRT 8 ``` -------------------------------- ### GET /api/peer/paired Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Retrieves the list of paired peers. This endpoint returns the peers that have successfully completed the pairing process. ```APIDOC ## GET /api/peer/paired ### Description Retrieves the list of paired peers. ### Method GET ### Endpoint /api/peer/paired ### Response No response body is documented. ``` -------------------------------- ### Hooks API Endpoints Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Lists the REST endpoints for firing and listing system hooks. POST /api/hooks/fire triggers a hook by name, GET /api/hooks returns all registered hooks. ```bash POST /api/hooks/fire {"hook": "on_interrupt_all"} GET /api/hooks # list all registered hooks ``` -------------------------------- ### Export Thai TTS ONNX model Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Install required packages and run the export script. The script refuses non-16kHz or multi-speaker checkpoints and fails if the output is silent, duration mismatches, or length_scale is ignored. ```bash pip3 install torch transformers onnx onnxruntime soundfile # not in the image python3 tools/export_mms_thai_onnx.py --repo --out /tmp/thai-tts ``` -------------------------------- ### Build zxing-cpp cp38 wheel on x86 host under qemu Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Run inside the jp5.11 image on the x86 build host (172.18.66.241) to produce a wheel tagged for the exact interpreter and libstdc++. Uses --no-binary zxing-cpp, not --no-binary :all:, to avoid compiling build dependencies under qemu. No apt-get needed as the image already has g++ 9.4, cmake 3.27, and Python.h. ```bash # on 172.18.66.241 (x86_64, qemu-aarch64 binfmt registered; ~8 min) IMG=bj-warehouse.tencentcloudcr.com/phanthy-motus/perception:-jetson-jp5.11 docker run --rm -v /root/zxwheels:/out "$IMG" bash -lc ' pip3 wheel "zxing-cpp==2.2.0" --no-binary zxing-cpp \ -i https://mirrors.tencentyun.com/pypi/simple/ -w /out' ``` -------------------------------- ### Use fetch_status and ensure_model to download with progress Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Required pattern for plugins that download weights: create progress and stage callbacks via fetch_status, then pass them to ensure_model. The status line shows progress like '正在下载模型 'sensevoice-small' … 40% (180/449 MB)'. Callbacks fire only during work; a verified cache returns without calls, so set a 'preparing' line before calling. ```python from utils.model_progress import fetch_status progress_cb, stage_cb = fetch_status(on_status, "sensevoice-small") ensure_model(name, model_dir, progress_cb=progress_cb, stage_cb=stage_cb) # card shows: 正在下载模型 'sensevoice-small' … 40% (180/449 MB) ``` -------------------------------- ### Building Docker Images Source: https://github.com/4paradigm/phanthymotus/blob/main/CONTRIBUTING.md Commands to build the ROS2 base image, Agent Core, Perception Stack, and ActuCore. Configure registry settings in .env first. Perception and ActuCore builds are for Jetson only. ```bash cd deploy cp .env.example .env # Configure registry settings # Build ROS2 base image (first time only) ./build_ros_base.sh # Build Agent Core ./build_core.sh # Build Perception Stack (Jetson only — see the script's --jp-version flag) ./build_perception.sh # Build ActuCore (Jetson only) ./build_actucore.sh ``` -------------------------------- ### List Peer Tools Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md List tools a peer can call, with authentication headers. ```bash curl http://localhost:15678/api/peer/tools/list \ -H "X-Motus-Peer-Id: f7e8d9c0b1a2..." \ -H "X-Motus-Timestamp: $(date +%s)" \ -H "X-Motus-Signature: " ``` -------------------------------- ### POST /api/peer/pair/start Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Initiates the pairing process and returns a SAS code for verification. ```APIDOC ## POST /api/peer/pair/start ### Description Initiates pairing with a peer and returns a SAS (Short Authentication String) code for verification. ### Method POST ### Endpoint /api/peer/pair/start ### Response #### Success Response (200) - **sas_code** (string) - The SAS code to be confirmed by both peers. #### Response Example { "sas_code": "string" } ``` -------------------------------- ### POST /api/peer/pair/start Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Initiates the pairing process with a peer. This endpoint returns a session ID and a SAS code that must be confirmed by the other peer. ```APIDOC ## POST /api/peer/pair/start ### Description Initiates the pairing process with a peer. ### Method POST ### Endpoint /api/peer/pair/start ### Parameters #### Request Body - **peer_id** (string) - Required - The ID of the peer to pair with. ### Request Example { "peer_id": "f7e8d9c0b1a2..." } ### Response #### Success Response (200) - **session_id** (string) - Unique identifier for the pairing session. - **sas_code** (string) - Short authentication string (6-digit code) to be confirmed by the other peer. - **expires_at** (number) - Unix timestamp when the session expires. #### Response Example { "session_id": "abc123", "sas_code": "428197", "expires_at": 1735000300.0 } ``` -------------------------------- ### GET /api/peer/identity Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Retrieves the peer's own identity information, including peer_id and public key. ```APIDOC ## GET /api/peer/identity ### Description Returns the peer's own identity, including peer_id and public key. ### Method GET ### Endpoint /api/peer/identity ### Response #### Success Response (200) - **peer_id** (string) - The peer's unique identifier. - **public_key** (string) - The peer's public key. #### Response Example { "peer_id": "string", "public_key": "string" } ``` -------------------------------- ### Delegate a Task Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Spawn a subagent on another peer with goal and parameters. ```bash curl -X POST https://192.168.1.100:15678/api/peer/delegate \ -H "Content-Type: application/json" \ -H "X-Motus-Peer-Id: a1b2c3d4e5f6..." \ -H "X-Motus-Timestamp: $(date +%s)" \ -H "X-Motus-Signature: " \ -d '{ "goal": "Take a photo and describe what you see", "priority": 2, "max_rounds": 5, "timeout_s": 60.0 }' ``` -------------------------------- ### BLE host-side prerequisites commands Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Commands to unblock the Bluetooth radio, enable BlueZ, and bring up the adapter. Required before enabling BLE discovery. In containers, mount /var/run/dbus/system_bus_socket. ```bash # 1. The radio ships soft-blocked on Jetson — unblock it (bluetooth only; # `rfkill unblock all` would also enable WiFi, which is not what you want on # a robot wired to a fixed address). sudo rfkill unblock bluetooth # 2. BlueZ has to be running — bleak talks to it over D-Bus, not to the kernel. sudo systemctl enable --now bluetooth # 3. The adapter has to be up. sudo hciconfig hci0 up && hciconfig -a | head -3 ``` -------------------------------- ### Run catalogue contract/provider tests Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/music-catalog.md Run the contract and provider tests for the music catalog and phanthy music modules. Disables plugin autoload to avoid interference. Use from the perception directory. ```bash cd perception PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python3 -m pytest tests/test_music_catalog.py tests/test_phanthy_music.py -q ``` -------------------------------- ### Roster CRUD Operations Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Operations to list, get, update, forget persons, and list visits. Supports filtering, pagination, and profile updates. ```APIDOC ## Roster CRUD Operations ### Description Operations to list, get, update, forget persons, and list visits. Supports filtering, pagination, and profile updates. ### Methods - list_persons - get_person - update_person - forget - list_visits ### Endpoints - /persons - /persons/{id} - /persons/{id} - /persons/{id} - /visits ### Parameters #### list_persons - **named** (string) - Optional - Filter: all, named, unknown. - **query** (string) - Optional - Search over id, name, profile. - **limit** (integer) - Optional - Maximum number of results. - **offset** (integer) - Optional - Pagination offset. #### get_person - **id** (string) - Required - Person ID. #### update_person - **id** (string) - Required - Person ID. - **name** (string) - Optional - New name. - **profile** (object) - Optional - Profile fields. - **profile_delete[]** (array) - Optional - Profile keys to delete. - **merge** (boolean) - Optional - Default true (merge), false to replace. #### forget - **id** (string) - Required - Person ID. - **named** (string) - Optional - Set to "unknown" to clear all anonymous entries. #### list_visits - No parameters documented. ### Response #### Success Response (200) - Returns person objects or visit records. - Reads never return embeddings. ### Error Handling - Not specified. ``` -------------------------------- ### Data directory layout for persistence Source: https://github.com/4paradigm/phanthymotus/blob/main/PR_REVIEW_AGENT.md Shows the on-disk layout under DATA_HOST_DIR (default /opt/phanthy-motus/pr-review) bind-mounted to /data/repos in the container. Includes SQLite database, logs, bare clones, poller state, and transient worktrees. ```text /opt/phanthy-motus/pr-review/ jobs.db review history (SQLite) logs//-.log full build logs .git/ bare clones poller_state.json poller watermarks + processed comment IDs worktrees/ transient, removed after each job ``` -------------------------------- ### File upload flow diagram Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md ASCII diagram showing how a file moves from the browser or LLM through agent-core to the target service. The service replies with a path in its own container namespace, which becomes the tool argument verbatim. ```text browser ──pick──▶ agent-core POST /api/mcp/{mcp_id}/file/upload LLM ─────path──▶ │ address resolved from the MCP registry; │ body streamed on in 1 MiB chunks ▼ the service POST /file/upload │ writes it somewhere it can see ▼ ◀──reply── {"path": "/models/uploads/2026-09-08/alice.jpg"} that path becomes the tool argument, verbatim ``` -------------------------------- ### Deploy the PR review agent with deploy.sh Source: https://github.com/4paradigm/phanthymotus/blob/main/PR_REVIEW_AGENT.md Commands to deploy the PR review agent. Requires editing .env to set GITHUB_TOKEN, REGISTRY_*, and LLM_* variables. ```bash cd phanthymotus/deploy/pr-review cp .env.example .env $EDITOR .env # GITHUB_TOKEN, REGISTRY_*, LLM_* ./deploy.sh ``` -------------------------------- ### GET /v1/music/tracks/{id} Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/music-catalog.md Retrieves refreshed details for a specific track by ID. The response includes the track object and validates that the returned ID matches the requested ID. ```APIDOC ## GET /v1/music/tracks/{id} ### Description Returns refreshed details for a specific track. The client accepts both the versioned envelope and a versioned flat track, and validates that the returned ID matches the requested ID. ### Method GET ### Endpoint /v1/music/tracks/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The track ID. ### Response #### Success Response (200) - **schema** (string) - Envelope schema version. - **request_id** (string) - Request identifier. - **track** (object) - Track details. - **id** (string) - Track ID. - **title** (string) - Track title. - **kind** (string) - Track kind, defaults to 'song' if missing. - **genre** (array) - List of genres. - **duration_s** (integer) - Duration in seconds. - **vocal** (string|null) - Vocal type or null. #### Response Example { "schema": "motus.music/1", "request_id": "...", "track": { "id": "track123", "title": "Lofi Study", "kind": "song", "genre": ["chill"], "duration_s": 240, "vocal": null } } ``` -------------------------------- ### Trigger the PR review agent with /request_bot_review Source: https://github.com/4paradigm/phanthymotus/blob/main/PR_REVIEW_AGENT.md Comment this on a PR to trigger the agent. It detects build targets, builds them, and then reviews. ```text /request_bot_review ``` -------------------------------- ### Open the dashboard at http://:25000/ Source: https://github.com/4paradigm/phanthymotus/blob/main/PR_REVIEW_AGENT.md Direct URL to open the dashboard in a browser. The dashboard runs on the same port as the agent (default 25000). ```text http://:25000/ ``` -------------------------------- ### GET /api/peer/discovered Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Retrieves the list of discovered peers. This endpoint returns an array of peer objects with details such as peer ID, display name, endpoints, source, and last seen timestamp. ```APIDOC ## GET /api/peer/discovered ### Description Retrieves the list of discovered peers. ### Method GET ### Endpoint /api/peer/discovered ### Response #### Success Response (200) - **peers** (array) - List of discovered peers. - **peer_id** (string) - Unique identifier of the peer. - **display_name** (string) - Human-readable name of the peer. - **endpoints** (array of strings) - List of endpoint URLs for the peer. - **source** (string) - Discovery source (e.g., mdns). - **last_seen** (number) - Unix timestamp of last discovery. #### Response Example { "peers": [ { "peer_id": "f7e8d9c0b1a2...", "display_name": "Orin6-mDNS", "endpoints": ["https://192.168.1.100:15678"], "source": "mdns", "last_seen": 1735000000.0 } ] } ``` -------------------------------- ### Build vision engines inside a container from the target perception image Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Runs the export script inside a throwaway container from the target perception image, pinning numpy to the image's version and using a reachable mirror. Must be run inside the container, not on the Jetson host, and never in a live one. The image's TensorRT version is what counts; engines built on the host are rejected. Cap the builder workspace to avoid OOM kills on Jetson shared memory. ```bash docker run --rm --runtime nvidia --network host \ -v "$PWD/out:/work/exp" -w /work/exp -e YOLO_CONFIG_DIR=/work/exp \ --entrypoint bash -lc ' source /etc/dla-fallback.env pip3 install -i https://mirrors.tencent.com/pypi/simple/ onnx onnxslim \ "numpy==$(python3 -c "import numpy;print(numpy.__version__)")" python3 /work/exp/export_vision_engines.py --out /work/exp/engines --workspace 2 ' ``` -------------------------------- ### Declare a file parameter with format: file in inputSchema Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Mark a tool parameter as a file by setting "format": "file" and "uploadTo": "mcp" in the inputSchema. The canvas renders a file picker, and the upload is routed to the specified service. Omitting uploadTo sends the upload to agent-core's own /tmp/uploads, which is only correct for tools agent-core serves itself. ```python "image_path": { "type": "string", "format": "file", # → the canvas renders a file picker "accept": "image/*", # → picker filter "uploadTo": "mcp", # → route the upload to *this* service "description": "...", }, ``` -------------------------------- ### Architecture summary diagram Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md ASCII diagram showing the peer mesh layer architecture, including Identity, Discovery, Transport, and Application components, and their interactions with existing systems. Highlights design principles like zero-trust and graceful degradation. ```text ┌─────────────────────────────────────────────────────────────────┐ │ Peer Mesh Layer │ ├─────────────┬───────────────┬──────────────┬───────────────────┤ │ Identity │ Discovery │ Transport │ Application │ │ (Ed25519) │ (mDNS/BLE) │ (HTTPS+sig) │ (Tools/Delegate) │ ├─────────────┼───────────────┼──────────────┼───────────────────┤ │ • key gen │ • mDNS │ • sign req │ • tool proxy │ │ • peer_id │ • static list │ • verify sig │ • delegation │ │ • SAS pair │ • BLE scan │ • replay │ • lan messages │ │ │ • registry │ guard │ • DDS topology │ └─────────────┴───────────────┴──────────────┴───────────────────┘ ▲ │ ┌─────────┴─────────┐ │ Existing Systems │ ├───────────────────┤ │ • mcp_client │ │ • subagent │ │ • channel/acl │ │ • config │ └───────────────────┘ ``` -------------------------------- ### Run music and ASMR tests with pytest Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/phanthy_music.md Run the test suite for music, catalog, phanthy music, audio mixer, and bundle dispatch. Disables plugin autoload to avoid interference. The ASMR path is covered offline by AsmrContractTests and AsmrCardTests. ```bash cd perception PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python3 -m pytest \ tests/test_music.py tests/test_music_catalog.py tests/test_phanthy_music.py \ tests/test_audio_mixer.py tests/test_bundle_dispatch.py -q ``` -------------------------------- ### Upload zxing-cpp wheel with upload-artifact.js Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Upload the wheel using the artefact script (upload-figs.js cannot be used because it forces the resource-center/uploads/ prefix and image MIME types). The curl command checks that the printed URL returns HTTP 200 before building the image. ```bash cd resource-center && node prisma/articles/upload-artifact.js deploy/values.env \ /tmp/zxing_cpp-2.2.0-cp38-cp38-linux_aarch64.whl \ public/zxing-cpp/jp511/zxing_cpp-2.2.0-cp38-cp38-linux_aarch64.whl curl -sI | head -1 # must be 200 before building the image ``` -------------------------------- ### Project Structure Tree Source: https://github.com/4paradigm/phanthymotus/blob/main/CONTRIBUTING.md Directory layout of the phanthymotus repository, showing the main components: agent-core, perception, actucore, deploy, and docker-compose.yml. ```text phanthymotus/ ├── agent-core/ — Layer 3: Agent Core (FastAPI + LLM Loop + Web UI) │ ├── src/ — Python source │ │ ├── api/ — REST & WebSocket endpoints │ │ ├── event/ — Event-driven agent loop │ │ ├── client/ — MCP client implementations │ │ ├── start.py — FastAPI lifespan & router registration │ │ ├── config.py — SQLite ConfigDB │ │ ├── prompt.py — 4-layer prompt construction │ │ └── ros2_bridge.py — ROS2 DDS daemon thread │ ├── web/ — Vanilla JavaScript UI (no build step) │ │ ├── js/ — canvas.js, sidebar.js, dashboard.js │ │ └── css/ — style.css (CSS custom properties) │ └── resource/ — Memory & config files ├── perception/ — Layer 2: Perception Stack (ASR/TTS MCP Server) │ ├── main.py — MCP server entry point │ └── plugins/ — ASR/TTS plugin implementations ├── actucore/ — Layer 2: ActuCore (execution models, MCP Server) │ ├── main.py — MCP server entry point │ └── plugins/ — Execution model cards (none yet) ├── deploy/ — Build & deployment scripts └── docker-compose.yml — Full stack orchestration ``` -------------------------------- ### POST /api/peer/delegate Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Spawns a subagent and returns a SubagentResult. ```APIDOC ## POST /api/peer/delegate ### Description Delegates a task to a subagent and returns a SubagentResult. Requires Ed25519 signature. ### Method POST ### Endpoint /api/peer/delegate ### Request Body - **task** (string) - Required - The task description for the subagent. ### Request Example { "task": "string" } ### Response #### Success Response (200) - **subagent_result** (object) - The result from the subagent. #### Response Example { "subagent_result": {} } ``` -------------------------------- ### Configuration Parameters - detect_fps and ocr_fps Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Describes the detection and OCR frequency knobs that control how often detection and OCR run per second, with defaults and fallback behavior. ```APIDOC ## Configuration Parameters - detect_fps and ocr_fps ### Description These parameters control the frequency of face detection and OCR processing. They are expressed as detections per second (fps) and can be fractional. The default is 1.0, and `min_interval_ms` is honored as a fallback when the fps parameter is absent. ### Parameters - `detect_fps` (float) - Detection frequency in detections per second. Default: 1.0. Fractional allowed (e.g., 0.5 = once every two seconds, 0 = every frame). Per-instance, so different cameras can run at different cadences. - `ocr_fps` (float) - OCR frequency in operations per second. Same semantics as `detect_fps`, default 1.0, with `min_interval_ms` fallback. - `min_interval_ms` (integer) - Minimum interval in milliseconds between operations. Honored when `detect_fps` or `ocr_fps` is absent. ### Notes - Lowering `max_side_len` is not a way to make decode cheaper; the frame rate is the knob that matters. - OCR used to default to every frame, which was costly; once per second is the sensible default. ``` -------------------------------- ### Correct atomic get-or-create with lock Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Shows the correct pattern for atomic get-or-create using a per-plugin RLock. It guards the read-modify-write of the state dict and cleans up the node if registration fails. ```python # ✅ CORRECT — atomic get-or-create with self._nodes_lock: node = self._nodes.get(node_key) if node is None: node = _ASRNode(...) try: self._executor.add_node(node) except Exception: node.destroy_node() # don't leak a half-registered node raise self._nodes[node_key] = node else: self._sync_cfg(node) ``` -------------------------------- ### BLE Radio and Container Bus Check Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Commands to verify Bluetooth radio usability and container access to the D-Bus socket. Run when BLE scanning or advertising fails. ```bash # Is the radio actually usable, independent of Agent Core? rfkill list bluetooth hciconfig -a | head -3 pgrep -a bluetoothd # more reliable than systemctl on Jetson: some images # ship a Python systemctl shim that reports 'inactive' # for a bluetoothd that is demonstrably running # Does the container see the bus? docker exec phanthy-motus-agent-core-1 ls -l /var/run/dbus/system_bus_socket ``` -------------------------------- ### Run tests with PYTEST_DISABLE_PLUGIN_AUTOLOAD Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Runs the test suite from the agent-core directory. The PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 environment variable is required to prevent a globally-installed fugue_test plugin from failing to import and aborting collection. BLE tests do not require hardware as GATT reads are stubbed. ```bash cd agent-core PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python3 -m pytest tests/ -q ``` -------------------------------- ### Commands for managing container logs Source: https://github.com/4paradigm/phanthymotus/blob/main/README.md Table of commands for reading recent logs, reclaiming log space, reclaiming disk generally, and checking log size. Use `docker logs --tail 500 -f ` to read recent logs, `docker restart ` to reclaim log space, `docker image prune -a --filter until=168h` to reclaim disk, and `du -sh /var/lib/docker/containers/*/local-logs` to check log size. ```bash docker logs --tail 500 -f ``` ```bash docker restart ``` ```bash docker image prune -a --filter until=168h ``` ```bash du -sh /var/lib/docker/containers/*/local-logs ``` -------------------------------- ### configSchema with sensitive field markers Source: https://github.com/4paradigm/phanthymotus/blob/main/perception/README.md Declares api_key and app_key as sensitive so they are never packaged into Solutions; model is packaged as-is. api_key uses format: password for masked input, app_key uses x-sensitive: True for visible input. Unmarked credentials are uploaded in clear text. ```python "configSchema": { "type": "object", "properties": { "api_key": {"type": "string", "format": "password"}, # masked input + never packaged "app_key": {"type": "string", "x-sensitive": True}, # visible input + never packaged "model": {"type": "string"}, # packaged as-is }, } ``` -------------------------------- ### Call a Tool on Another Peer Source: https://github.com/4paradigm/phanthymotus/blob/main/docs/PEER_SETUP.md Call a tool on a remote peer with authentication and arguments. ```bash curl -X POST https://192.168.1.100:15678/api/peer/tools/call \ -H "Content-Type: application/json" \ -H "X-Motus-Peer-Id: a1b2c3d4e5f6..." \ -H "X-Motus-Timestamp: $(date +%s)" \ -H "X-Motus-Signature: " \ -d '{ "tool_name": "camera_capture", "arguments": {"resolution": "1080p"} }' ```