Location Command
Node location command (location.get), permission modes, background behavior
Summary
- location.get is a node command (via node.invoke).
- Default is off.
- Config uses a selector: off / while using / always.
- Independent toggle: precise location.
Why a Selector (Not Just a Switch)
OS permissions are multi-level. We can expose a selector in-app, but the OS decides actual grants.
- iOS/macOS: User can choose While Using or Always in system prompt/settings. App can request upgrade, OS might require settings.
- Android: Background location is a separate permission; Android 10+ often requires settings flow.
- Precise location is a separate grant (iOS 14+ "precise", Android "fine" vs "coarse").
Selector in UI drives requested mode; actual grant is in OS settings.
Config Model
Per node device:
- location.enabledMode: off | whileUsing | always
- location.preciseEnabled: boolean
UI Behavior:
- Selecting whileUsing requests foreground permission.
- Selecting always ensures whileUsing first, then requests background (sending user to settings if needed).
- If OS denies requested level, reverts to highest granted level and shows status.
Permission Mapping (node.permissions)
Optional. macOS nodes report location via permission map; iOS/Android might omit.
Command: `location.get`
Called via node.invoke.
Parameters (recommended):
{
"timeoutMs": 10000,
"maxAgeMs": 15000,
"desiredAccuracy": "coarse|balanced|precise"
}Response Payload:
{
"lat": 48.20849,
"lon": 16.37208,
"accuracyMeters": 12.5,
"altitudeMeters": 182.0,
"speedMps": 0.0,
"headingDeg": 270.0,
"timestamp": "2026-01-03T12:34:56.000Z",
"isPrecise": true,
"source": "gps|wifi|cell|unknown"
}Errors (stable codes):
- LOCATION_DISABLED: Selector off.
- LOCATION_PERMISSION_REQUIRED: Missing permission for requested mode.
- LOCATION_BACKGROUND_UNAVAILABLE: App in background but only allowed while using.
- LOCATION_TIMEOUT: No fix in time.
- LOCATION_UNAVAILABLE: System failure / no provider.
Background Behavior (Future)
Goal: Model can request location even if node is in background, but only if:
- User selected Always.
- OS granted background location.
- App is allowed to run in background (iOS Background Mode / Android Foreground Service or special permission).
Push Trigger Flow (Future):
1. Gateway sends push to node (Silent Push or FCM Data).
2. Node wakes temporarily and requests location from device.
3. Node forwards payload back to Gateway.
Note:
- iOS: Requires Always permission + Background Location mode. Silent pushes may be throttled; expect intermittent failures.
- Android: Background location might require Foreground Service; otherwise expect denial.
Model/Tool Integration
- Tool Surface: nodes tool adds location_get action (requires node).
- CLI: openclaw nodes location get --node <id>.
- Agent Guidelines: Call only if user enabled location and understands scope.
UX Copy (Recommended)
- Off: "Location sharing is disabled."
- While Using: "Only when OpenClaw is open."
- Always: "Allow background location. Requires system permission."
- Precise: "Use precise GPS location. Toggle off to share approximate location."