Skip to content

feat(agents): add droid adapter#121

Closed
yyovil wants to merge 1 commit into
agents/01-grokfrom
agents/02-droid
Closed

feat(agents): add droid adapter#121
yyovil wants to merge 1 commit into
agents/01-grokfrom
agents/02-droid

Conversation

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 6, 2026

Greptile Summary

This PR introduces the droid adapter for the Factory Droid terminal coding agent, completing the harness stack. It adds a new droid package with launch/restore commands, hook management, and an activity deriver, then registers it in the global adapter registry and activity dispatch table.

  • droid/droid.go: Implements Plugin with binary resolution, atomic settings-file writes (via hookutil.AtomicWriteFile) for permission modes, and session metadata surfacing.
  • droid/hooks.go: Manages .factory/hooks.json hook install/uninstall/check with idempotent, user-hook-preserving writes; uses sort.Strings for deterministic event-key processing and atomic file writes.
  • droid/activity.go + activitydispatch/dispatch.go: Adds a Droid-specific activity deriver that maps Droid hook events to AO activity states (treating all Notifications as waiting_input since Droid omits notification_type).

Confidence Score: 5/5

The droid adapter is a self-contained addition that follows established patterns; no existing behavior is modified and the change is safe to merge.

Both issues flagged in the previous review round have been addressed: settings files are now written atomically via hookutil.AtomicWriteFile, and event keys are sorted before processing in GetAgentHooks. The adapter logic — binary resolution, permission-settings file generation, hook install/uninstall, and activity derivation — is straightforward and covered by a thorough test suite. No correctness issues were found.

No files require special attention.

Important Files Changed

Filename Overview
backend/internal/adapters/agent/droid/droid.go New adapter Plugin: binary resolution with mutex cache, atomic settings-file write for permission modes, session metadata surfacing — all clean with proper error handling.
backend/internal/adapters/agent/droid/hooks.go Hook install/uninstall/check for .factory/hooks.json; uses sorted event iteration, atomic writes, and matcher-aware deduplication — previously flagged issues resolved.
backend/internal/adapters/agent/droid/activity.go Activity deriver mapping Droid hook events to AO states; intentionally ignores json.Unmarshal error in sessionEndState (safe: empty reason maps to exited).
backend/internal/adapters/agent/droid/activity_test.go Comprehensive table-driven tests covering all event cases including malformed payloads, clear vs. real session-end, and unknown events.
backend/internal/adapters/agent/droid/droid_test.go Good coverage of launch/restore/session-info paths including settings-file content verification, idempotency, and user-hook preservation on uninstall.
backend/internal/adapters/agent/activitydispatch/dispatch.go Trivial one-line addition registering droid.DeriveActivityState under the "droid" key.
backend/internal/adapters/agent/registry/registry.go Registers droid.New() in the adapter Constructors list alongside the other agents.
backend/internal/daemon/wiring_test.go Adds domain.HarnessDroid → "droid" to the resolver round-trip test — confirms end-to-end wiring.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[AO: Launch/Restore Request] --> B{Has agentSessionID?}
    B -- No --> C[GetLaunchCommand]
    B -- Yes --> D[GetRestoreCommand]
    C --> E{PermissionMode != default?}
    D --> E
    E -- Yes --> F[droidAutonomyLevel]
    F --> G[AtomicWriteFile settings]
    G --> H[argv: droid --settings path]
    E -- No --> J[argv: droid]
    T[Droid fires hook] --> U[ao hooks droid event]
    U --> V[DeriveActivityState]
    V --> W{event?}
    W -- user-prompt-submit --> X[ActivityActive]
    W -- stop --> Y[ActivityIdle]
    W -- notification --> Z[ActivityWaitingInput]
    W -- session-end --> AA{reason?}
    AA -- clear --> AB[no signal]
    AA -- other/absent --> AC[ActivityExited]
Loading

Reviews (2): Last reviewed commit: "feat(agents): add droid adapter" | Re-trigger Greptile

Comment thread backend/internal/adapters/agent/droid/droid.go Outdated
Comment thread backend/internal/adapters/agent/droid/hooks.go Outdated
Registers the droid harness, stacked on the agent platform. Includes its own activity deriver.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants