Commit Graph

12 Commits

Author SHA1 Message Date
James Rich
a629336642 Fix review findings: timeout handling, cancellation, docs
- Add TimeoutCancellationException handling to getNodeDetails and getMeshMetrics
  AppFunctions (consistent with Phase 1 functions)
- Rethrow CancellationException in all provider catch blocks to preserve
  structured concurrency semantics
- Fix voltage documentation: millivolts → volts (matches actual Float field)
- Fix stale test comment referencing non-existent test class

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-21 17:17:14 -05:00
James Rich
1abdd1a143 Phase 2b: Add getNodeDetails and getMeshMetrics App Functions
- Extend AiFunctionProvider with two new suspend methods for advanced queries
- getNodeDetails: Retrieve per-node telemetry (16 fields) by hex or user ID
- getMeshMetrics: Aggregate mesh statistics and compute health score
- Add result types (GetNodeDetailsResult, GetMeshMetricsResult) and data models
- Add response models (@AppFunctionSerializable) for KSP serialization
- Both methods support timeout protection and rate limiting
- Health score calculation: 50 base + 50 online ratio, clamped 0-100
- All JVM, Android, detekt, spotless checks passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-21 15:36:54 -05:00
James Rich
e9dbb23bd5 Phase 2a: Add non-destructive AppFunctions (getNodeList, getChannelInfo, getDeviceStatus)
Implement three Phase 2a read-only query functions for AI agent integration:

Core Data (commonMain):
- Extended AiFunctionProvider interface with 3 new methods
- Implemented getNodeList() - queries all mesh nodes with battery and online status
- Implemented getChannelInfo() - lists mesh channels with settings
- Implemented getDeviceStatus() - returns local device info and status
- Added result types: GetNodeListResult, GetChannelInfoResult, GetDeviceStatusResult
- Added data models: NodeSummary, ChannelSummary, DeviceStatus
- All functions protected by timeout (5s), rate limiter (5 calls/60s), connection check

Android AppFunctions:
- Added 3 @AppFunction methods with KSP annotations
- Response models marked @AppFunctionSerializable for AI runtime
- Proper exception handling and timeout protection

Constants:
- HEX_RADIX (16): For node ID formatting
- MS_PER_SEC (1000): Time unit conversions
- ONLINE_THRESHOLD_MS (30000): Node online detection threshold

Fixes:
- Use node.user.long_name (not longName)
- Use node.deviceMetrics.battery_level?.coerceIn() for nullable battery
- Use nodeRepository.nodeDBbyNum (not nodes)
- Convert node.lastHeard (seconds) to milliseconds
- Suppress MagicNumber and ReturnCount lints appropriately

All builds and tests pass:
✓ :core:data:compileKotlinJvm
✓ :androidApp:compileGoogleDebugKotlin
✓ :androidApp:compileFdroidDebugKotlin
✓ detekt clean
✓ spotlessApply clean
✓ :core:data:allTests pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-21 15:19:12 -05:00
James Rich
d66c393732 fix: Return unique messageId from SendMessageUseCase
Previously, AiFunctionProviderImpl returned a hardcoded messageId of 0
for all successful sends, preventing unique message identification. The
underlying SendMessageUseCase generates a packetId but had no return
value to expose it.

Changes:
- Modified SendMessageUseCase interface to return Int (the packetId)
- Updated SendMessageUseCaseImpl to return the generated packetId
- Updated AiFunctionProviderImpl to capture and use the returned messageId

This enables the AI system to track individual messages and correlate
responses to specific send requests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-21 14:23:59 -05:00
James Rich
88c6cf98a8 feat: add App Functions integration for system AI assistants
Expose Meshtastic mesh networking capabilities (sendMessage, getMeshStatus)
to Android system AI agents via the App Functions API.

Architecture:
- AiFunctionProvider interface in core/data commonMain (platform-agnostic)
- FuzzyNameResolver for node/channel name matching (LCS algorithm)
- RateLimiter with 5-call/60s sliding window to protect mesh radio
- AiFunctionProviderImpl wiring repositories and use cases
- @AppFunction declarations in androidApp Google flavor only
- GoogleMeshUtilApplication with AppFunctionConfiguration.Provider
- DI via AppFunctionsModule included in FlavorModule

Key design decisions:
- No confirmation dialog (AI invocation = user intent)
- Fuzzy name matching with 50% LCS threshold, error on ambiguity
- Admin channels excluded from resolution
- 5-second operation timeout
- 237-byte message length limit (Meshtastic standard)

Includes unit tests for RateLimiter and FuzzyNameResolver (LCS algorithm).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-21 10:50:22 -05:00
James Rich
ea85b906e8 feat(nav): rename tab labels to canonical order (#5551)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-20 17:57:08 -05:00
James Rich
228765a159 fix(ci): unblock Dokka documentation generation (#5496)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-19 13:00:45 -05:00
James Rich
83bb1a31f7 chore: Scheduled updates (Firmware, Hardware, Translations, Graphs) (#5465) 2026-05-19 10:12:04 -05:00
James Rich
fc0df1a79a feat(docs): In-app documentation browser with Jekyll site and Docusaurus sync (#5445)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-19 04:00:22 +00:00
James Rich
f5128798a8 feat: adopt Material 3 Expressive design system (M3-native APIs only) (#5479)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-19 01:10:47 +00:00
James Rich
df4f10c4d6 fix(nav): remote admin nodenum + Nav3 consolidation and improvements (#5478)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-18 17:29:27 +00:00
James Rich
f4b6b02ace refactor(build): rename entry modules and remove DESKTOP_ONLY mode (#5476)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-18 12:44:12 +00:00