feat(agent): add typed server API tools

This commit is contained in:
2026-07-15 10:44:07 +08:00
parent f3f873e3c4
commit 8a21908785
30 changed files with 3119 additions and 15 deletions
+24 -3
View File
@@ -13,8 +13,8 @@ real auth provider through `src/context/`.
- No required `Authorization` or `X-Project-Id` headers.
- No `cli/`, no `tjwater_cli` opencode tool, no free-form CLI command bridge.
- Agent visual output is expressed through `agent-ui@1` UIEnvelope events.
- Backend data tools are not fully reintroduced yet; missing business data must
be reported honestly by the Agent.
- Backend business data is available through typed, allowlisted domain tools.
Arbitrary URLs, SQL, shell commands, and filesystem paths remain unavailable.
## Main API
@@ -51,10 +51,26 @@ Defaults:
```text
AGENT_LOCAL_USER_ID=local-user
AGENT_LOCAL_PROJECT_ID=local-project
AGENT_LOCAL_PROJECT_ID=<UUID returned as project_id by /api/v1/meta/projects>
AGENT_LOCAL_NETWORK=local-network
```
Local domain tools are enabled by default. Set `TJWATER_API_BASE_URL` to the
Server address and `AGENT_LOCAL_PROJECT_ID` to an enabled project UUID. Setting
`TJWATER_API_ENABLED=false` disables all Server calls. Production startup rejects
enabled Server tools while `TJWATER_AUTH_MODE=disabled`.
Available domain tools:
- `get_project_context`
- `list_monitoring_assets`
- `query_monitoring_readings` with required `observed_from` and `observed_to`
ISO8601 timestamps. The server rejects reversed or unbounded historical
queries.
- `start_data_quality_analysis` (requires approval)
- `start_simulation` (requires approval)
- `get_job_status`
Optional request headers can override the local context during experiments:
```text
@@ -78,6 +94,11 @@ Visual opencode tools are mapped by the service:
- `locate_features`, `zoom_to_map`, `render_junctions`, `apply_layer_style` -> `map_action`
- `view_history`, `view_scada` -> `registered_component`
`view_history` opens the historical data/result panel and must include
`start_time` and `end_time` ISO8601 timestamps. Use `query_monitoring_readings`
first when the answer needs actual monitoring values; use `view_history` only to
ask the frontend to display the selected feature history panel.
See [docs/agent-ui-protocol.md](docs/agent-ui-protocol.md).
## Development