Commit Graph

114 Commits

Author SHA1 Message Date
Sanju Sivalingam
8783fe90a3 feat: wire email verification into better-auth config 2026-02-18 23:08:27 +05:30
Sanju Sivalingam
7125aed49f feat: add email helper module using useSend SDK 2026-02-18 23:08:27 +05:30
Sanju Sivalingam
8748e7a28b feat: add usesend-js dependency for email verification 2026-02-18 23:08:27 +05:30
Sanju Sivalingam
b34088ceb7 feat: Polar license key integration and dashboard UI improvements
- Add license activation flow: server validates/activates keys via Polar SDK
- Auto-activate from Polar checkout redirect (checkout_id in URL)
- Gate dashboard behind license activation (redirect to /activate if no plan)
- Preserve redirect URL through login flow for post-purchase activation
- Show plan status badge in sidebar and overview page
- Add account section to settings (email, plan, license key)
- Add svelte-sonner toasts with custom black theme and iconify icons
- Improve validation messages across all forms
- Update API key prefix to droidclaw_
- Add cursor pointer globally for clickable elements
- Support Polar sandbox mode via POLAR_SANDBOX env flag
2026-02-18 23:08:27 +05:30
Somasundaram Mahesh
5aace17096 feat(overlay): tap floating button to return to app
Detect taps vs drags in the overlay touch handler — if movement is
under 10px, launch MainActivity with REORDER_TO_FRONT so tapping
the pill from any other app brings DroidClaw back into focus.
2026-02-18 23:08:07 +05:30
Somasundaram Mahesh
4199143de8 feat(android): UI overhaul — branded theme, onboarding, chat-style home
- Replace default purple Material 3 theme with logo-derived palette
  (crimson red primary, dark charcoal surfaces, golden accent)
- Add Instrument Serif + Inter fonts for custom typography scale
- Add first-launch onboarding flow (API key + server URL, permissions)
- Restructure navigation: 2-tab bottom nav (Home + Settings), logs
  via top bar icon, permission status indicators in top bar
- Redesign HomeScreen as chat-style interface with goal/step bubbles,
  auto-scroll, bottom input bar with send/stop buttons
- Redesign SettingsScreen with Server → Connection → Permissions sections
- Redesign LogsScreen with goal banner, step badges, timestamps
- Replace default Android icon with DroidClaw logo at all densities
- Add hasOnboarded DataStore flag with auto-connect on completion
- Fix logs navigation not clearing when switching bottom tabs
2026-02-18 22:09:32 +05:30
Sanju Sivalingam
59ee665088 revert: remove workflow automation, keep overlay and stop_goal
Remove all workflow-related code from PR #6 (input classifier,
workflow parser, notification listener, workflow CRUD handlers).
Keep the overlay, stop_goal, AbortSignal threading, and OkHttp
engine switch. Add v2 design doc for safer workflow implementation.
2026-02-18 20:39:04 +05:30
Somasundaram M
d8659cfe17 Merge pull request #6 from msomu/feat/overlay-and-state-persistence
feat: agent overlay, stability fixes, and workflow automation
2026-02-18 18:53:49 +05:30
Somasundaram Mahesh
4d4b7059e4 feat: workflow automation via NotificationListenerService
Add workflow system that lets users describe automations in natural
language through the same input field. The server LLM classifies
input as either an immediate goal or a workflow rule, then:

- Parses workflow descriptions into structured trigger conditions
- Stores workflows per-user in Postgres
- Syncs workflows to device via WebSocket
- NotificationListenerService monitors notifications and triggers
  matching workflows as agent goals

Also cleans up overlay text and adds network security config.
2026-02-18 18:51:25 +05:30
Somasundaram Mahesh
45766621f2 fix(android): switch Ktor CIO engine to OkHttp for stable background WebSocket
CIO uses Java NIO selectors which Android's power management freezes
when the app is backgrounded, dropping the WebSocket connection. OkHttp
is Android-native and maintains connections through the OS network stack.
2026-02-18 18:51:24 +05:30
Somasundaram Mahesh
0b36d92fef fix: thread AbortSignal through LLM calls so stop_goal cancels immediately
The agent loop checked signal.aborted only at the top of each iteration,
but the LLM fetch() call (which takes seconds) never received the signal.
Now the signal is passed to fetch() and checked after LLM errors and
before the inter-step sleep, so aborting takes effect mid-step.
2026-02-18 18:51:01 +05:30
Somasundaram Mahesh
011e2be291 feat: agent overlay, stop-goal support, and state persistence across app kill
- Add draggable agent overlay pill (status dot + step text + stop button)
  that shows over other apps while connected. Fix ComposeView rendering
  in service context by providing a SavedStateRegistryOwner.
- Add stop_goal protocol message so the overlay/client can abort a
  running agent session; server aborts via AbortController.
- Persist screen-capture consent to SharedPreferences so it survives
  process death; restore on ConnectionService connect and Settings resume.
- Query AccessibilityManager for real service state instead of relying
  on in-process MutableStateFlow that resets on restart.
- Add overlay permission checklist item and SYSTEM_ALERT_WINDOW manifest
  entry.
- Filter DroidClaw's own overlay nodes from the accessibility tree so the
  agent never interacts with them.
2026-02-18 18:51:01 +05:30
Sanju Sivalingam
88af77ddc7 fix: configure postgres idle timeout and connection recycling for Railway
Railway proxy closes idle DB connections after ~60s, causing
CONNECTION_CLOSED errors on stale sockets. Set idle_timeout=20s and
max_lifetime=5m so postgres-js recycles connections before they die.

Also fix sendCommand to fall back to persistent device ID on reconnect.
2026-02-18 13:56:34 +05:30
Sanju Sivalingam
3bab84f611 fix(auth): use internal secret for web→server calls instead of cookie forwarding
Cookie forwarding between dash.droidclaw.ai and tunnel.droidclaw.ai was
unreliable. Now the web app passes userId + shared internal secret via
headers. Also removes debug logging from device auth and session middleware.
2026-02-18 12:40:49 +05:30
Sanju Sivalingam
562d4095f0 fix(android): prevent save button from disappearing during API key editing
DataStore flow re-emissions were resetting editingApiKey via remember(apiKey),
hiding the save button mid-edit. Now uses null sentinel to track edit state
independently from stored value.
2026-02-18 12:32:26 +05:30
Sanju Sivalingam
8ef15af97a debug: add logging to device auth for hash mismatch investigation 2026-02-18 12:27:56 +05:30
Sanju Sivalingam
05d1cc657d fix code 2026-02-18 12:01:23 +05:30
Sanju Sivalingam
d03be7365e debug: add logging to session middleware for auth investigation 2026-02-18 11:59:59 +05:30
Sanju Sivalingam
68ca812267 revert(server): use direct DB queries for all auth validation
Reverts middleware and dashboard WS to direct DB session lookups.
Replaces auth.api.verifyApiKey in device WS with direct DB query
using SHA-256 hash matching, removing dependency on BETTER_AUTH_SECRET
for auth validation.
2026-02-18 11:46:48 +05:30
Sanju Sivalingam
a865c1e2f0 fix(android): add explicit connect/request timeouts to WebSocket client
CIO engine had no timeout config, causing connect failures on slower networks.
2026-02-18 11:31:47 +05:30
Sanju Sivalingam
a1ec1ac731 fix(agent): use device screen dimensions for scroll/swipe coordinates
Swipe coordinates were hardcoded for 1080x2400 screens, causing scrolls
to fail on devices with different resolutions. Now reads screenWidth and
screenHeight from DeviceInfo and computes coordinates proportionally.
2026-02-18 10:48:37 +05:30
Sanju Sivalingam
81d78684a5 refactor: use better-auth api for session validation in server middleware and websocket 2026-02-18 10:38:15 +05:30
Sanju Sivalingam
22b13bec2f update android app default server url to production 2026-02-18 10:25:42 +05:30
Sanju Sivalingam
22481c8834 add health endpoint to web app 2026-02-18 10:08:25 +05:30
Sanju Sivalingam
071b3960a7 add start:server script to root package.json 2026-02-18 09:38:04 +05:30
Sanju Sivalingam
7a2a1186a2 use bun instead of node for web start script 2026-02-18 09:31:16 +05:30
Sanju Sivalingam
dbff2e1e35 add start script to web package.json for railway deploy 2026-02-18 09:30:33 +05:30
Sanju Sivalingam
a745815400 update readme and configure monorepo for railway deployment
readme rewritten with ascii diagrams, detailed setup, and conversational tone.
root package.json updated with packageManager field for bun, web workspace,
and build/start scripts pointing to web/ for railway railpack compatibility.
2026-02-18 09:20:03 +05:30
Somasundaram M
b65004e015 Merge pull request #5 from msomu/main
Fix Settings UI reactivity, resolve compiler warnings, update .gitignore
2026-02-18 08:46:41 +05:30
Somasundaram Mahesh
5207e4ea9b Fix Settings UI reactivity, resolve compiler warnings, update .gitignore
- Make screen capture permission and battery optimization states reactive
- Add lifecycle observer to refresh battery status on resume
- Add lifecycle-runtime-compose dependency for non-deprecated LocalLifecycleOwner
- Replace deprecated LocalLifecycleOwner import
- Remove unused REQUEST_CODE constant
- Use KTX createBitmap() and bitmap[x,y] extensions
- Add misc.xml and junie.xml to .gitignore
2026-02-18 07:47:28 +05:30
Sanju Sivalingam
792b42974f feat(agent): implement server-side multi-step skills
Skills (copy_visible_text, find_and_tap, submit_message, read_screen,
wait_for_content, compose_email) were CLI-only using direct ADB. The
server prompt advertised them but they silently failed when chosen.

Now intercepted in the agent loop before actionToCommand() and executed
server-side using existing WebSocket primitives (get_screen, tap, swipe,
clipboard_set). Each skill replaces 3-8 LLM calls with deterministic
server-side logic.
2026-02-18 00:58:59 +05:30
Sanju Sivalingam
db995e4913 fix(agent): prevent stuck loop by adding action history to LLM prompt
The UI agent had no memory of previous actions — each step was a fresh
single-shot LLM call. After typing and sending a message, the LLM saw
an empty text field and retyped the message in a loop.

- Add RECENT_ACTIONS (last 5 actions with text/result) to user prompt
- Add chat app completion detection rule to dynamic prompt
- Add send-success hints for WhatsApp and Messages apps
- Add git convention to CLAUDE.md (no co-author lines)
2026-02-18 00:53:13 +05:30
Sanju Sivalingam
9193b02d36 fix(agent): address code review issues
- Add empty goal guard in parser (returns done instead of passthrough)
- Replace `as any` casts in pipeline.ts with proper ActionDecision types
- Add runtime type guards for untrusted LLM output in classifier
- Add intent action to dynamic prompt so UI agent can fire intents

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 00:32:14 +05:30
Sanju Sivalingam
3769b21ed1 refactor(agent): delete preprocessor.ts (replaced by parser.ts) 2026-02-18 00:28:50 +05:30
Sanju Sivalingam
d5c3466554 feat(agent): wire intent-first pipeline into all entrypoints
Replace preprocessor+runAgentLoop with runPipeline in both device.ts
(WebSocket) and goals.ts (REST). The pipeline orchestrates: deterministic
parser (stage 1) -> LLM classifier (stage 2) -> lean UI agent (stage 3).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 00:28:13 +05:30
Sanju Sivalingam
18b8509081 feat(agent): add pipeline mode with dynamic prompts to agent loop
When pipelineMode is enabled in AgentLoopOptions, the loop uses
buildDynamicPrompt() with per-screen context (editable fields,
scrollable elements, app hints, stuck state) instead of the static
mega-prompt. Legacy mode (default) is unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 00:24:25 +05:30
Sanju Sivalingam
3f389c5de6 feat(agent): add dynamic prompt builder for Stage 3 UI agent 2026-02-18 00:22:24 +05:30
Sanju Sivalingam
91a828452b feat(agent): add Stage 2 LLM goal classifier 2026-02-18 00:15:56 +05:30
Sanju Sivalingam
5dd199e0b8 feat(agent): add Stage 1 deterministic goal parser 2026-02-18 00:09:15 +05:30
Sanju Sivalingam
122bf87e72 feat(agent): add app-specific hints registry 2026-02-18 00:07:24 +05:30
Sanju Sivalingam
41a49f0619 feat(shared): add PipelineResult, IntentCommand, DeviceCapabilities types
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 00:04:36 +05:30
Sanju Sivalingam
e300f04e13 feat: installed apps, stop goal, auth fixes, remote commands
- Android: fetch installed apps via PackageManager, send to server on connect
- Android: add QUERY_ALL_PACKAGES permission for full app visibility
- Android: fix duplicate Intent import, increase accessibility retry window
- Android: default server URL to ws:// instead of wss://
- Server: store installed apps in device metadata JSONB
- Server: inject installed apps context into LLM prompt
- Server: preprocessor resolves app names from device's actual installed apps
- Server: add POST /goals/stop endpoint with AbortController cancellation
- Server: rewrite session middleware to direct DB token lookup
- Server: goals route fetches user's saved LLM config from DB
- Web: show installed apps in device detail Overview tab with search
- Web: add Stop button for running goals
- Web: replace API routes with remote commands (submitGoal, stopGoal)
- Web: add error display for goal submission failures
- Shared: add InstalledApp type and apps message to protocol
2026-02-17 22:50:18 +05:30
Sanju Sivalingam
fae5fd3534 fix: goals route now finds devices by persistent DB ID, not connection UUID 2026-02-17 21:22:43 +05:30
Sanju Sivalingam
5b73e89217 fix: add valibot schemas to query() functions — fixes bad request on detail page 2026-02-17 21:16:58 +05:30
Sanju Sivalingam
423cd7af01 fix: add getDevice query, fix IN clause, add error handling to getDeviceStats 2026-02-17 21:13:50 +05:30
Sanju Sivalingam
b240887b0e fix: resolve type errors in devices pages 2026-02-17 21:08:47 +05:30
Sanju Sivalingam
9de0b040dc feat: rewrite device detail page with tabbed layout (Overview/Sessions/Run)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 21:05:26 +05:30
Sanju Sivalingam
a46af1a236 feat: rewrite devices page as phone-card grid
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 21:04:18 +05:30
Sanju Sivalingam
a5bfe74384 feat: add DeviceCard.svelte phone-frame component
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 21:03:25 +05:30
Sanju Sivalingam
9423ed85ff feat: add device stats query and enrich listDevices with metrics
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 21:02:07 +05:30