AgentSkillsCN

about-oneclaw

全面掌握OneClaw的架构、功能、工具与源代码

SKILL.md
--- frontmatter
name: about-oneclaw
description: Comprehensive knowledge about OneClaw's architecture, features, tools, and source code

You now have detailed knowledge about OneClaw's architecture. Use this to answer questions about how OneClaw works, its features, and its source code. When needed, fetch actual source files from GitHub using http_get.

Identity

OneClaw is an open-source Android AI assistant (Apache 2.0) at https://github.com/GNHua/oneclaw. It runs entirely on-device with no cloud backend and no root access required. The user provides their own LLM API key (OpenAI-compatible, Anthropic, or Google Gemini).

Module Structure

ModulePurposeKey Entry Point
appAndroid app -- UI, DI, services, navigationapp/src/main/java/com/tomandy/oneclaw/
core-agentReAct agent loop, LLM clients, tool executioncore-agent/src/main/java/com/tomandy/oneclaw/agent/
lib-workspaceSandboxed workspace tools (file ops, exec)lib-workspace/src/main/java/com/tomandy/oneclaw/workspace/
skill-engineSkill loading, slash commands, prompt augmentationskill-engine/src/main/java/com/tomandy/oneclaw/skill/
lib-schedulerWorkManager/AlarmManager scheduled taskslib-scheduler/src/main/java/com/tomandy/oneclaw/scheduler/
plugin-runtimeQuickJS-based JavaScript plugin engineplugin-runtime/src/main/java/com/tomandy/oneclaw/plugin/
plugin-managerBuilt-in and user plugin managementplugin-manager/src/main/java/com/tomandy/oneclaw/pluginmanager/
lib-device-controlAccessibility Service screen automationlib-device-control/src/main/java/com/tomandy/oneclaw/devicecontrol/
lib-webWeb search/fetch via Tavily or Bravelib-web/src/main/java/com/tomandy/oneclaw/web/
lib-qrcodeQR code scan and generatelib-qrcode/src/main/java/com/tomandy/oneclaw/qrcode/
lib-locationGPS, nearby places, directionslib-location/src/main/java/com/tomandy/oneclaw/location/
lib-notification-mediaNotification + media playback controllib-notification-media/src/main/java/com/tomandy/oneclaw/notification/
lib-pdfPDF info, text extraction, page renderinglib-pdf/src/main/java/com/tomandy/oneclaw/pdf/

Chat Execution Data Flow

  1. ChatInput composable -> ChatViewModel.sendMessage() -> inserts user MessageEntity to Room DB
  2. ChatViewModel calls ChatExecutionService.startExecution() (foreground service)
  3. ChatExecutionService resolves the active agent profile, builds the system prompt (base text + skills XML + conversation summary)
  4. Creates AgentCoordinator with a toolFilter from the profile's allowedTools
  5. AgentCoordinator.execute() -> ReActLoop.step() -> LlmClient.complete() (iterates with tool calls)
  6. Final response persisted to DB -> UI updates reactively via Room Flow

Key files:

  • app/.../service/ChatExecutionService.kt -- foreground service orchestration
  • app/.../viewmodel/ChatViewModel.kt -- UI-layer message handling
  • core-agent/.../agent/AgentCoordinator.kt -- tool filtering, category activation, loop control
  • core-agent/.../agent/ReActLoop.kt -- single-step LLM call + tool execution
  • core-agent/.../agent/llm/LlmClient.kt -- LLM abstraction interface

Complete Tool Inventory

Always-on tools (no activation needed)

ToolPluginDescription
read_fileWorkspacePluginRead a file from the workspace
write_fileWorkspacePluginWrite/create a file in the workspace
edit_fileWorkspacePluginApply edits to an existing file
list_filesWorkspacePluginList files and directories
execWorkspacePluginRun a shell command in the workspace
javascript_evalWorkspacePluginEvaluate JavaScript in QuickJS
search_memoryMemoryPluginFull-text search across memory files
create_scheduled_taskSchedulerPluginCreate a cron-based recurring task
list_scheduled_tasksSchedulerPluginList all scheduled tasks
delete_scheduled_taskSchedulerPluginDelete a scheduled task
get_configConfigPluginRead runtime configuration
search_conversationsSearchPluginSearch conversation history
delegate_agentDelegateAgentPluginRun a sub-task with a different agent profile
activate_toolsActivateToolsPluginActivate an on-demand tool category
scan_qr_codeQrCodePluginScan a QR code from an image
generate_qr_codeQrCodePluginGenerate a QR code image
http_getweb-fetch (JS)Fetch a URL via GET
http_postweb-fetch (JS)POST JSON to a URL
http_requestweb-fetch (JS)Full HTTP request with custom method/headers
get_current_timetime (JS)Get current date/time
install_pluginInstallPluginToolInstall a JS plugin from source

On-demand categories (use activate_tools first)

CategoryToolsPlugin
webweb_search, web_fetchWebPlugin
device_controlobserve_screen, tap, type_text, swipe, press_key, open_appDeviceControlPlugin
locationget_location, search_nearby, get_directions_urlLocationPlugin
phonesend_sms, list_sms, search_sms, dial_phone, get_call_logSmsPhonePlugin
cameratake_photoCameraPlugin
voice_memorecord_audio, transcribe_audioVoiceMemoPlugin
notificationslist_notifications, get_notification, dismiss_notificationNotificationPlugin
media_controlmedia_play_pause, media_next, media_previous, media_stopMediaControlPlugin
pdfpdf_info, pdf_extract_text, pdf_render_pagePdfToolsPlugin

Google Workspace tools (via Google Sign-In)

PluginKey Tools
gmailgmail_search, gmail_read, gmail_send, gmail_reply, gmail_trash, gmail_label
gmail-settingsgmail_get_filters, gmail_create_filter, gmail_get_auto_reply, gmail_set_auto_reply
calendarcalendar_list_events, calendar_create_event, calendar_update_event, calendar_delete_event
contactscontacts_search, contacts_create, contacts_update
taskstasks_list, tasks_create, tasks_complete, tasks_delete
drivedrive_search, drive_upload, drive_download, drive_create_folder
docsdocs_create, docs_read, docs_append
sheetssheets_create, sheets_read, sheets_write, sheets_append
slidesslides_create, slides_add_slide, slides_read
formsforms_create, forms_add_question, forms_get_responses

Two-Tier Tool Activation

Tools are either always-on or gated behind categories. The LLM calls activate_tools({ "category": "web" }) to enable a category mid-conversation. Once activated, a category stays active for the rest of that conversation. Agent profiles can restrict available tools via allowedTools in their YAML frontmatter.

Agent Profiles

Markdown files with YAML frontmatter in assets/agents/ (bundled) or workspace/agents/ (user-created). Fields: name, description, model, allowedTools, enabledSkills. The body is the system prompt. User profiles override bundled ones with the same name.

Skill System

Skills are markdown files in assets/skills/{name}/SKILL.md (bundled) or workspace/skills/{name}/SKILL.md (user). Only metadata appears in the system prompt. The full skill body is injected when the user invokes /skill-name. Skills can be enabled/disabled in Settings.

Fetching Source Code from GitHub

Use a two-step approach to find and read source files:

Step 1 -- Discover file paths. Fetch the full repo tree in one call:

code
http_get({ "url": "https://api.github.com/repos/GNHua/oneclaw/git/trees/main?recursive=1" })

This returns every file path in the repo as a JSON array of { "path": "...", "type": "blob|tree" } entries. Search the result for the file you need.

Step 2 -- Fetch the file content:

code
http_get({ "url": "https://raw.githubusercontent.com/GNHua/oneclaw/main/<path>" })

List a specific directory (alternative to the full tree when you know the area):

code
http_get({ "url": "https://api.github.com/repos/GNHua/oneclaw/contents/<directory-path>" })

Returns a JSON array with name, path, type, and download_url fields.

Entry-point files by topic

These are good starting points -- but always verify paths via the tree API first.

TopicFile to fetch
Agent loopcore-agent/src/main/java/com/tomandy/oneclaw/agent/AgentCoordinator.kt
ReAct stepcore-agent/src/main/java/com/tomandy/oneclaw/agent/ReActLoop.kt
Tool registrycore-agent/src/main/java/com/tomandy/oneclaw/agent/tool/ToolRegistry.kt
LLM client interfacecore-agent/src/main/java/com/tomandy/oneclaw/agent/llm/LlmClient.kt
OpenAI clientcore-agent/src/main/java/com/tomandy/oneclaw/agent/llm/OpenAiClient.kt
Anthropic clientcore-agent/src/main/java/com/tomandy/oneclaw/agent/llm/AnthropicClient.kt
Gemini clientcore-agent/src/main/java/com/tomandy/oneclaw/agent/llm/GeminiClient.kt
Chat executionapp/src/main/java/com/tomandy/oneclaw/service/ChatExecutionService.kt
System prompt builderapp/src/main/java/com/tomandy/oneclaw/service/SystemPromptBuilder.kt
Workspace toolslib-workspace/src/main/java/com/tomandy/oneclaw/workspace/WorkspacePlugin.kt
Memory toolslib-workspace/src/main/java/com/tomandy/oneclaw/workspace/MemoryPlugin.kt
Schedulerlib-scheduler/src/main/java/com/tomandy/oneclaw/scheduler/SchedulerPlugin.kt
Skill loaderskill-engine/src/main/java/com/tomandy/oneclaw/skill/SkillLoader.kt
Slash command routerskill-engine/src/main/java/com/tomandy/oneclaw/skill/SlashCommandRouter.kt
JS plugin hostplugin-runtime/src/main/java/com/tomandy/oneclaw/plugin/JsPlugin.kt
Plugin coordinatorplugin-manager/src/main/java/com/tomandy/oneclaw/pluginmanager/PluginCoordinator.kt
Device controllib-device-control/src/main/java/com/tomandy/oneclaw/devicecontrol/DeviceControlPlugin.kt
Koin DI setupapp/src/main/java/com/tomandy/oneclaw/di/AppModule.kt
Database schemaapp/src/main/java/com/tomandy/oneclaw/data/AppDatabase.kt
Agent profilesapp/src/main/java/com/tomandy/oneclaw/agent/AgentProfileRepository.kt
Google authapp/src/main/java/com/tomandy/oneclaw/auth/CompositeGoogleAuthProvider.kt
Backupapp/src/main/java/com/tomandy/oneclaw/backup/BackupManager.kt

Conversation Summarization

Auto-triggers when prompt tokens exceed 80% of the context window. Old messages are summarized into a meta message prepended to the system prompt. A pre-summarization callback flushes important context to workspace memory files first.

Database

Room database (version 11). Key tables: ConversationEntity (id, title, timestamps) and MessageEntity (id, conversationId, role, content, tool fields, media attachment JSON arrays).

Configuration

  • ModelPreferences (SharedPreferences) -- selected model, max iterations, active agent
  • ConversationPreferences -- active conversation ID
  • CredentialVault (EncryptedSharedPreferences) -- API keys per provider