-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
Current remory integration spawns CLI process for each operation (50-200ms overhead per call).
Research Findings
Remory supports direct Unix socket communication via JSON-RPC protocol:
- Daemon runs at
~/.remory/remory.sock - 20-100ms after daemon warm-up vs 50-200ms CLI spawn
- Full async/await support
- Rich error handling
Solution
Replace CLI spawning with direct socket client:
```typescript
// packages/opencode/src/memory/remory.ts
import { UnixSocketClient } from './socket-client'
export const remory = {
async add(text: string, userId?: string, infer = false) {
const client = new UnixSocketClient(defaultSocketPath())
const response = await client.send({
method: 'add',
params: { text, user_id: userId, infer }
})
return response.result
}
}
```
Protocol
JSON-RPC 2.0 lite:
```json
{"id": "req-1", "method": "add", "params": {"text": "...", "user_id": "alice"}}
{"id": "req-1", "result": {"id": "mem-123", "event": "added"}}
```
Files
- Rewrite:
packages/opencode/src/memory/remory.ts - Create:
packages/opencode/src/memory/socket-client.ts
Reference
Remory codebase at ../remory/ - see remory_daemon/ for protocol details.
Branch
claude/simplify-agentic-loop-2jRSP