capacitor-mobile-claw 1.6.4 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -50
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
**On-device AI agent engine for mobile apps** — run Claude directly on your phone with file tools, code execution, git, and extensible MCP tool support.
|
|
8
8
|
|
|
9
|
-
Mobile Claw is a [Capacitor](https://capacitorjs.com/) plugin that embeds a full AI agent runtime on Android and iOS. Two execution modes: a **WebView agent** for instant cold start (agent loop runs in-process) or a **Node.js worker** for full sandboxed tooling. Both talk directly to the Anthropic API — no cloud relay, no proxy. Includes
|
|
9
|
+
Mobile Claw is a [Capacitor](https://capacitorjs.com/) plugin that embeds a full AI agent runtime on Android and iOS. Two execution modes: a **WebView agent** for instant cold start (agent loop runs in-process) or a **Node.js worker** for full sandboxed tooling. Both talk directly to the Anthropic API — no cloud relay, no proxy. Includes **on-device vector memory** via [LanceDB](https://www.npmjs.com/package/capacitor-lancedb), **background scheduling** via [MobileCron](https://www.npmjs.com/package/capacitor-mobilecron) (WorkManager / BGTaskScheduler), cron jobs with reusable skills, and native streaming HTTP for WebView CORS bypass.
|
|
10
10
|
|
|
11
11
|
> Built on [OpenClaw](https://github.com/openclaw/openclaw) and the [Pi framework](https://www.npmjs.com/package/@mariozechner/pi-ai) by [Mario Zechner](https://github.com/badlogic). Pi's philosophy of *"what you leave out matters more than what you put in"* — just 4 core tools and a system prompt under 1,000 tokens — is what makes running a capable AI agent on a phone possible at all.
|
|
12
12
|
|
|
@@ -96,24 +96,17 @@ Once the app launches, enter your Anthropic API key in settings and start chatti
|
|
|
96
96
|
|
|
97
97
|
## How It Works
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
### WebView Agent (recommended)
|
|
102
|
-
|
|
103
|
-
The agent loop runs directly in the WebView for instant cold start. LLM API calls go through a native HTTP plugin (OkHttp on Android, URLSession on iOS) that bypasses WebView CORS restrictions and provides true streaming via `ReadableStream`. Worker tools are transparently proxied via the bridge.
|
|
99
|
+
The agent loop runs directly in the WebView for instant cold start — no waiting for Node.js worker boot. LLM API calls are routed through native HTTP (OkHttp / URLSession) to bypass WebView CORS, with full SSE streaming. Worker tools (file I/O, git, code exec) are transparently proxied via the bridge.
|
|
104
100
|
|
|
105
101
|
```
|
|
106
102
|
┌──────────────────────────────────────────────────────────┐
|
|
107
103
|
│ Your App (Vue, React, Svelte, vanilla JS) │
|
|
108
104
|
│ ┌────────────────────────────────────────────────────┐ │
|
|
109
105
|
│ │ MobileClawEngine (useWebViewAgent: true) │ │
|
|
110
|
-
│ │ ┌──────────────┐
|
|
111
|
-
│ │ │ Pi Agent
|
|
112
|
-
│ │ │ (in WebView) │
|
|
113
|
-
│ │ │
|
|
114
|
-
│ │ │ │ │ - CORS bypass │ │ │
|
|
115
|
-
│ │ │ │ │ - ReadableStream assembly │ │ │
|
|
116
|
-
│ │ └──────┬───────┘ └───────────────────────────┘ │ │
|
|
106
|
+
│ │ ┌──────────────┐ │ │
|
|
107
|
+
│ │ │ Pi Agent │──── Anthropic API (native HTTP) │ │
|
|
108
|
+
│ │ │ (in WebView) │ │ │
|
|
109
|
+
│ │ └──────┬───────┘ │ │
|
|
117
110
|
│ │ │ ToolProxy (bridge IPC) │ │
|
|
118
111
|
│ │ ┌──────▼───────────────────────────────────────┐ │ │
|
|
119
112
|
│ │ │ Node.js Worker (file tools, git, code exec) │ │ │
|
|
@@ -122,30 +115,6 @@ The agent loop runs directly in the WebView for instant cold start. LLM API call
|
|
|
122
115
|
└──────────────────────────────────────────────────────────┘
|
|
123
116
|
```
|
|
124
117
|
|
|
125
|
-
### Worker Agent (legacy)
|
|
126
|
-
|
|
127
|
-
The full agent loop runs inside the embedded Node.js worker. Higher cold start latency but full isolation.
|
|
128
|
-
|
|
129
|
-
```
|
|
130
|
-
┌──────────────────────────────────────────────────────────┐
|
|
131
|
-
│ Your App │
|
|
132
|
-
│ ┌────────────────────────────────────────────────────┐ │
|
|
133
|
-
│ │ MobileClawEngine │ │
|
|
134
|
-
│ └──────────────────┬─────────────────────────────────┘ │
|
|
135
|
-
│ │ Bridge Protocol (IPC) │
|
|
136
|
-
│ ┌──────────────────▼─────────────────────────────────┐ │
|
|
137
|
-
│ │ Node.js Worker (Capacitor-NodeJS) │ │
|
|
138
|
-
│ │ ┌──────────────┐ ┌──────────────────────┐ │ │
|
|
139
|
-
│ │ │ Pi Agent │ │ MCP Server │ │ │
|
|
140
|
-
│ │ │ (pi-ai) │ │ - Bridge transport │ │ │
|
|
141
|
-
│ │ │ │ │ - STOMP transport │ │ │
|
|
142
|
-
│ │ │ │ │ - Custom tools (BYO) │ │ │
|
|
143
|
-
│ │ └──────┬───────┘ └──────────────────────┘ │ │
|
|
144
|
-
│ │ ▼ Anthropic Messages API │ │
|
|
145
|
-
│ └─────────────────────────────────────────────────────┘ │
|
|
146
|
-
└──────────────────────────────────────────────────────────┘
|
|
147
|
-
```
|
|
148
|
-
|
|
149
118
|
## Install in Your Own App
|
|
150
119
|
|
|
151
120
|
```bash
|
|
@@ -231,9 +200,32 @@ await engine.init({
|
|
|
231
200
|
})
|
|
232
201
|
```
|
|
233
202
|
|
|
234
|
-
### With
|
|
203
|
+
### With On-Device Memory
|
|
204
|
+
|
|
205
|
+
The agent remembers across sessions using [capacitor-lancedb](https://www.npmjs.com/package/capacitor-lancedb) — a Rust-powered vector database running entirely on-device. Memories are stored, deduplicated, and recalled via semantic search. Five built-in tools (`memory_store`, `memory_recall`, `memory_search`, `memory_forget`, `memory_get`) are passed to the agent automatically.
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { MemoryManager } from 'capacitor-lancedb'
|
|
209
|
+
|
|
210
|
+
const memory = new MemoryManager({ dbPath: 'files://agent-memory' })
|
|
211
|
+
await memory.init()
|
|
212
|
+
|
|
213
|
+
const engine = new MobileClawEngine()
|
|
214
|
+
const memoryTools = memory.getTools()
|
|
215
|
+
await engine.init({ tools: memoryTools, useWebViewAgent: true })
|
|
216
|
+
|
|
217
|
+
// Agent can now store/recall memories across sessions.
|
|
218
|
+
// Auto-recall injects relevant context at turn start.
|
|
219
|
+
// Auto-capture extracts facts from agent responses.
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### With Background Scheduling
|
|
223
|
+
|
|
224
|
+
[capacitor-mobilecron](https://www.npmjs.com/package/capacitor-mobilecron) enables the agent to wake and run in the background via Android WorkManager and iOS BGTaskScheduler. The engine's scheduler manages heartbeats (periodic check-ins) and cron jobs (recurring tasks).
|
|
235
225
|
|
|
236
226
|
```typescript
|
|
227
|
+
import { MobileCron } from 'capacitor-mobilecron'
|
|
228
|
+
|
|
237
229
|
const engine = new MobileClawEngine()
|
|
238
230
|
await engine.init({ useWebViewAgent: true, mobileCron: MobileCron })
|
|
239
231
|
|
|
@@ -245,9 +237,6 @@ await engine.setHeartbeat({ enabled: true, everyMs: 1800000 })
|
|
|
245
237
|
engine.addListener('heartbeatCompleted', (event) => {
|
|
246
238
|
console.log(`Heartbeat: ${event.status} (${event.durationMs}ms)`)
|
|
247
239
|
})
|
|
248
|
-
|
|
249
|
-
// Manual trigger
|
|
250
|
-
await engine.triggerHeartbeatWake('manual')
|
|
251
240
|
```
|
|
252
241
|
|
|
253
242
|
### With Cron Jobs
|
|
@@ -260,7 +249,7 @@ const skill = await engine.addSkill({
|
|
|
260
249
|
timeoutMs: 60000,
|
|
261
250
|
})
|
|
262
251
|
|
|
263
|
-
// Schedule a cron job
|
|
252
|
+
// Schedule a recurring cron job
|
|
264
253
|
await engine.addCronJob({
|
|
265
254
|
name: 'morning-briefing',
|
|
266
255
|
enabled: true,
|
|
@@ -274,8 +263,10 @@ await engine.addCronJob({
|
|
|
274
263
|
|
|
275
264
|
## Features
|
|
276
265
|
|
|
277
|
-
- **
|
|
278
|
-
- **
|
|
266
|
+
- **Instant cold start** — agent loop runs in the WebView, worker tools proxied transparently
|
|
267
|
+
- **On-device vector memory** — store, recall, and search memories via [LanceDB](https://www.npmjs.com/package/capacitor-lancedb) with auto-recall context injection and deduplication
|
|
268
|
+
- **Background scheduling** — heartbeat check-ins and cron jobs via [MobileCron](https://www.npmjs.com/package/capacitor-mobilecron) (Android WorkManager / iOS BGTaskScheduler)
|
|
269
|
+
- **Cron jobs & skills** — recurring agent tasks with reusable skill definitions, run history, and delivery modes
|
|
279
270
|
- **Real-time streaming** — text deltas, tool use, and thinking events
|
|
280
271
|
- **Multi-turn conversations** — session persistence via native SQLite
|
|
281
272
|
- **OAuth PKCE + API key** — sign in with Claude Max or use a direct API key
|
|
@@ -285,9 +276,6 @@ await engine.addCronJob({
|
|
|
285
276
|
- **MCP device tools** — extensible via Model Context Protocol
|
|
286
277
|
- **Tool approval gate** — approve/deny tool executions before they run (120s TTL)
|
|
287
278
|
- **Agent steering** — inject follow-up instructions into a running turn
|
|
288
|
-
- **Background heartbeat** — scheduled agent check-ins via MobileCron + WorkManager
|
|
289
|
-
- **Cron jobs** — recurring agent tasks with skills, schedules, and delivery modes
|
|
290
|
-
- **On-device vector memory** — store/recall/search via LanceDB (capacitor-lancedb)
|
|
291
279
|
- **Vite plugin** — stubs Node.js-only transitive deps for browser bundling
|
|
292
280
|
|
|
293
281
|
## API Reference
|
|
@@ -365,13 +353,12 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, workflow, and guid
|
|
|
365
353
|
| Mobile framework | [Capacitor 8](https://capacitorjs.com/) |
|
|
366
354
|
| Agent core | [Pi](https://www.npmjs.com/package/@mariozechner/pi-ai) by Mario Zechner |
|
|
367
355
|
| Embedded runtime | [@choreruiz/capacitor-node-js](https://github.com/rogelioRuiz/capacitor-node-js) |
|
|
368
|
-
| Native HTTP | OkHttp (Android) + URLSession (iOS) — streaming, CORS bypass |
|
|
369
356
|
| Tool protocol | [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) |
|
|
370
357
|
| LLM provider | [Anthropic Claude](https://anthropic.com/) |
|
|
371
|
-
| Vector memory | [LanceDB](https://lancedb.com/) via [capacitor-lancedb](https://www.npmjs.com/package/capacitor-lancedb) |
|
|
358
|
+
| Vector memory | [LanceDB](https://lancedb.com/) via [capacitor-lancedb](https://www.npmjs.com/package/capacitor-lancedb) (Rust FFI, on-device) |
|
|
372
359
|
| Background scheduling | [capacitor-mobilecron](https://www.npmjs.com/package/capacitor-mobilecron) (WorkManager / BGTaskScheduler) |
|
|
373
360
|
| Git | [isomorphic-git](https://isomorphic-git.org/) |
|
|
374
|
-
| Database | [@capacitor-community/sqlite](https://github.com/nicepkg/capacitor-community-sqlite) (native SQLite
|
|
361
|
+
| Database | [@capacitor-community/sqlite](https://github.com/nicepkg/capacitor-community-sqlite) (native SQLite) |
|
|
375
362
|
| Python | [Pyodide](https://pyodide.org/) (CPython via WebAssembly) |
|
|
376
363
|
| Type system | TypeScript (strict mode) |
|
|
377
364
|
| Lint | [Biome](https://biomejs.dev/) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capacitor-mobile-claw",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "On-device AI agent engine for Capacitor apps — embedded Node.js worker with LLM, file tools, code execution, git, and extensible MCP server",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|