Skip to content

Commit 6d6be24

Browse files
authored
Merge pull request tinyhumansai#36 from M3gA-Mind/feat/memory-flow
Feat/memory flow
2 parents dafde59 + 41d88e1 commit 6d6be24

464 files changed

Lines changed: 5357 additions & 7585 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "mcpServers": { "alphaHuman": { "type": "http", "url": "https://alphahuman.readme.io/mcp" } } }
1+
{ "mcpServers": { "alphahuman": { "type": "http", "url": "https://openhuman.readme.io/mcp" } } }

.claude/rules/01-project-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ This project is a **crypto-focused communication platform** built with Tauri v2,
5858
## Project Structure
5959

6060
```
61-
frontend-runner-alphahuman/
61+
frontend-runner-openhuman/
6262
├── .claude/ # Claude AI configuration
6363
│ ├── rules/ # Modular documentation
6464
│ └── agents/ # Subagent configurations
@@ -86,7 +86,7 @@ frontend-runner-alphahuman/
8686

8787
## Key Configuration Files
8888

89-
- `tauri.conf.json` - Tauri configuration (app identifier: com.alphahuman.app)
89+
- `tauri.conf.json` - Tauri configuration (app identifier: com.openhuman.app)
9090
- `Cargo.toml` - Rust dependencies and workspace configuration
9191
- `package.json` - Node.js dependencies and scripts
9292
- `vite.config.ts` - Vite build configuration with Node.js polyfills

.claude/rules/02-development-commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ adb kill-server # Stop ADB server
116116
adb start-server # Restart ADB server
117117

118118
# Force stop app on device:
119-
adb shell am force-stop com.alphahuman.app
119+
adb shell am force-stop com.openhuman.app
120120

121121
# Kill Gradle daemon if stuck:
122122
# macOS/Linux:

.claude/rules/13-backend-auth-implementation.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Web Browser Backend Server Desktop App (Tauri
2424
│<─────────────────────────────│ │
2525
│ │ │
2626
│ 5. Redirect to │ │
27-
alphahuman://auth?token= │ │
27+
openhuman://auth?token= │ │
2828
│─────────────────────────────────────────────────────────────>│
2929
│ │ │
3030
│ │ 6. Rust invoke │
@@ -58,7 +58,7 @@ Initiates Telegram OAuth. The frontend opens this URL in the system browser.
5858
2. On callback, validate Telegram user data
5959
3. Create or find user in database
6060
4. Generate a short-lived `loginToken` (single-use, 5-minute TTL)
61-
5. Redirect to `alphahuman://auth?token=<loginToken>`
61+
5. Redirect to `openhuman://auth?token=<loginToken>`
6262

6363
### 2. `POST /api/auth/web-complete`
6464

@@ -181,7 +181,7 @@ Called by the Tauri Rust command `exchange_token` (NOT browser fetch). Exchanges
181181
3. **HTTPS only** in production — tokens travel as URL parameters and POST bodies
182182
4. **Rate limiting** — on `/api/auth/web-complete` and `/auth/desktop-exchange`
183183
5. **Token entropy** — minimum 256 bits of randomness
184-
6. **Deep link validation** — the desktop app only processes `alphahuman://auth` paths; ignore unknown paths
184+
6. **Deep link validation** — the desktop app only processes `openhuman://auth` paths; ignore unknown paths
185185
7. **Telegram data verification** — validate the `hash` field using your bot token per Telegram docs
186186

187187
## Implementation Details
@@ -226,14 +226,14 @@ Set `VITE_BACKEND_URL` environment variable for different environments.
226226

227227
## Frontend Integration Points
228228

229-
| File | Role |
230-
| -------------------------------------- | ------------------------------------------------------------------------------------- |
231-
| `src/main.tsx` | Lazy-imports and starts the deep link listener |
232-
| `src/utils/desktopDeepLinkListener.ts` | Parses deep link -> invokes Rust `exchange_token` -> stores session -> navigates |
233-
| `src/utils/deeplink.ts` | Web-side: calls `/api/auth/web-complete` and builds `alphahuman://auth?token=...` URL |
234-
| `src/utils/config.ts` | Backend URL configuration |
235-
| `src/pages/Login.tsx` | Opens `GET /auth/telegram?platform=desktop` in browser |
236-
| `src-tauri/src/lib.rs` | Rust `exchange_token` command using `reqwest` (CORS-free) |
229+
| File | Role |
230+
| -------------------------------------- | ------------------------------------------------------------------------------------ |
231+
| `src/main.tsx` | Lazy-imports and starts the deep link listener |
232+
| `src/utils/desktopDeepLinkListener.ts` | Parses deep link -> invokes Rust `exchange_token` -> stores session -> navigates |
233+
| `src/utils/deeplink.ts` | Web-side: calls `/api/auth/web-complete` and builds `openhuman://auth?token=...` URL |
234+
| `src/utils/config.ts` | Backend URL configuration |
235+
| `src/pages/Login.tsx` | Opens `GET /auth/telegram?platform=desktop` in browser |
236+
| `src-tauri/src/lib.rs` | Rust `exchange_token` command using `reqwest` (CORS-free) |
237237

238238
## Phone OTP Flow (Future)
239239

.claude/rules/14-deep-link-platform-guide.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
## Overview
44

5-
The `alphahuman://` custom URL scheme is used to hand off authentication from a web browser to the Tauri desktop app. This document covers platform-specific behavior, gotchas, and build requirements discovered during development.
5+
The `openhuman://` custom URL scheme is used to hand off authentication from a web browser to the Tauri desktop app. This document covers platform-specific behavior, gotchas, and build requirements discovered during development.
66

77
## Scheme Registration
88

99
Configured in `src-tauri/tauri.conf.json`:
1010

1111
```json
12-
{ "plugins": { "deep-link": { "desktop": { "schemes": ["alphahuman"] } } } }
12+
{ "plugins": { "deep-link": { "desktop": { "schemes": ["openhuman"] } } } }
1313
```
1414

1515
## macOS
@@ -50,7 +50,7 @@ cp -R src-tauri/target/debug/bundle/macos/tauri-app.app /Applications/
5050
open /Applications/tauri-app.app
5151

5252
# Test deep link
53-
open "alphahuman://auth?token=YOUR_TOKEN"
53+
open "openhuman://auth?token=YOUR_TOKEN"
5454
```
5555

5656
### Cargo Caching Gotcha
@@ -68,9 +68,9 @@ open "alphahuman://auth?token=YOUR_TOKEN"
6868
- The macOS WebView (WKWebView) caches aggressively
6969
- Clear caches when debugging stale content:
7070
```bash
71-
rm -rf ~/Library/WebKit/com.alphahuman.app
72-
rm -rf ~/Library/Caches/com.alphahuman.app
73-
rm -rf ~/Library/Application\ Support/com.alphahuman.app
71+
rm -rf ~/Library/WebKit/com.openhuman.app
72+
rm -rf ~/Library/Caches/com.openhuman.app
73+
rm -rf ~/Library/Application\ Support/com.openhuman.app
7474
```
7575

7676
### Debug Builds: Secondary Instance Behavior

.claude/rules/16-macos-background-execution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ npm run tauri build -- --debug --bundles app
213213
Clear WebKit cache if needed:
214214

215215
```bash
216-
rm -rf ~/Library/WebKit/com.alphahuman.app
217-
rm -rf ~/Library/Caches/com.alphahuman.app
216+
rm -rf ~/Library/WebKit/com.openhuman.app
217+
rm -rf ~/Library/Caches/com.openhuman.app
218218
```
219219

220220
## Configuration Options

.claude/rules/17-skills-memory-inference-flow.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ Token present
3131

3232
Two Tauri event listeners run continuously:
3333

34-
| Event | What it does |
35-
|---|---|
36-
| `skill-state-changed` | Dispatches `setSkillState` into Redux `skillsSlice.skillStates[skillId]` |
37-
| `runtime:skill-status-changed` | Updates `skillsSlice.skills[skillId].status`; surfaces errors |
34+
| Event | What it does |
35+
| ------------------------------ | ------------------------------------------------------------------------ |
36+
| `skill-state-changed` | Dispatches `setSkillState` into Redux `skillsSlice.skillStates[skillId]` |
37+
| `runtime:skill-status-changed` | Updates `skillsSlice.skills[skillId].status`; surfaces errors |
3838

3939
---
4040

@@ -48,7 +48,8 @@ It is constructed with the user's JWT (`authSlice.token`) and stored as `Arc<Mem
4848
in `MemoryState` (a `Mutex<Option<MemoryClientRef>>`).
4949

5050
Base URL resolution (in priority order):
51-
1. `ALPHAHUMAN_BASE_URL` env var
51+
52+
1. `OPENHUMAN_BASE_URL` env var
5253
2. `TINYHUMANS_BASE_URL` env var
5354
3. SDK default
5455

@@ -109,12 +110,12 @@ Examples: `skill:gmail:user@example.com`, `skill:notion:default`.
109110

110111
**File**: `src-tauri/src/memory/mod.rs`
111112

112-
| Method | SDK call | When used |
113-
|---|---|---|
114-
| `store_skill_sync(...)` | `insert_memory` | OAuth complete, periodic sync |
115-
| `query_skill_context(...)` | `query_memory` | RAG query — fetch relevant chunks for a user question |
116-
| `recall_skill_context(...)` | `recall_memory` | Recall synthesised summary from Master node |
117-
| `clear_skill_memory(...)` | `delete_memory` | OAuth revoke / disconnect |
113+
| Method | SDK call | When used |
114+
| --------------------------- | --------------- | ----------------------------------------------------- |
115+
| `store_skill_sync(...)` | `insert_memory` | OAuth complete, periodic sync |
116+
| `query_skill_context(...)` | `query_memory` | RAG query — fetch relevant chunks for a user question |
117+
| `recall_skill_context(...)` | `recall_memory` | Recall synthesised summary from Master node |
118+
| `clear_skill_memory(...)` | `delete_memory` | OAuth revoke / disconnect |
118119

119120
---
120121

@@ -141,16 +142,17 @@ chatSend({ threadId, message, model, authToken, backendUrl, messages, notionCont
141142

142143
Completion events flow back over Tauri events:
143144

144-
| Event | Frontend handler |
145-
|---|---|
146-
| `chat:tool_call` | shows active tool indicator |
147-
| `chat:tool_result` | clears tool indicator |
148-
| `chat:done` | `dispatch(addInferenceResponse(...))` |
149-
| `chat:error` | shows error, clears loading state |
145+
| Event | Frontend handler |
146+
| ------------------ | ------------------------------------- |
147+
| `chat:tool_call` | shows active tool indicator |
148+
| `chat:tool_result` | clears tool indicator |
149+
| `chat:done` | `dispatch(addInferenceResponse(...))` |
150+
| `chat:error` | shows error, clears loading state |
150151

151152
### 5b. Web/Fallback Path
152153

153154
Used when not running in Tauri (browser). Runs the agentic loop entirely in TypeScript:
155+
154156
- Calls `inferenceApi.createChatCompletion(request)` directly
155157
- Executes tools via `skillManager.callTool(skillId, toolName, args)`
156158
- Both paths share the same 5-round `MAX_TOOL_ROUNDS` limit and `{skillId}__{toolName}` naming convention
@@ -215,6 +217,7 @@ Step 6: Agentic loop (max 5 rounds)
215217
**File**: `src-tauri/src/runtime/qjs_engine.rs``call_tool(skill_id, tool_name, args)`
216218

217219
The Rust runtime routes `call_tool` into the running QuickJS/V8 skill instance:
220+
218221
- Serialises `args` as JSON
219222
- Calls the JS tool handler registered by the skill
220223
- Returns `ToolCallResult { content: Vec<ToolContent>, is_error: bool }`
@@ -262,14 +265,14 @@ Separately (async, fire-and-forget):
262265

263266
## Key Files Reference
264267

265-
| File | Role |
266-
|---|---|
267-
| `src/providers/SkillProvider.tsx` | Discovery, lifecycle, Redux state sync |
268-
| `src/pages/Conversations.tsx` | Message send, both code paths, Notion context |
269-
| `src/services/chatService.ts` | `chatSend()`, `chatCancel()`, `useRustChat()` |
270-
| `src-tauri/src/commands/chat.rs` | Rust agentic loop, context assembly, tool dispatch |
271-
| `src-tauri/src/commands/memory.rs` | `recall_memory` Tauri command |
272-
| `src-tauri/src/memory/mod.rs` | `MemoryClient` wrapping tinyhumansai SDK |
273-
| `src-tauri/src/runtime/qjs_skill_instance.rs` | Skill sync → memory write triggers |
274-
| `src-tauri/src/runtime/qjs_engine.rs` | `discover_skills()`, `call_tool()`, `all_tools()` |
275-
| `skills/skills/*/manifest.json` | Skill metadata (git submodule) |
268+
| File | Role |
269+
| --------------------------------------------- | -------------------------------------------------- |
270+
| `src/providers/SkillProvider.tsx` | Discovery, lifecycle, Redux state sync |
271+
| `src/pages/Conversations.tsx` | Message send, both code paths, Notion context |
272+
| `src/services/chatService.ts` | `chatSend()`, `chatCancel()`, `useRustChat()` |
273+
| `src-tauri/src/commands/chat.rs` | Rust agentic loop, context assembly, tool dispatch |
274+
| `src-tauri/src/commands/memory.rs` | `recall_memory` Tauri command |
275+
| `src-tauri/src/memory/mod.rs` | `MemoryClient` wrapping tinyhumansai SDK |
276+
| `src-tauri/src/runtime/qjs_skill_instance.rs` | Skill sync → memory write triggers |
277+
| `src-tauri/src/runtime/qjs_engine.rs` | `discover_skills()`, `call_tool()`, `all_tools()` |
278+
| `skills/skills/*/manifest.json` | Skill metadata (git submodule) |

.claude/skills-system-troubleshooting.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Skills System is a Python-based plugin architecture that allows AI agents to
1010

1111
- Skills modal shows "Setup Failed" with "Skill process exited with code: 1"
1212
- Console shows `ModuleNotFoundError: No module named 'pydantic'`
13-
- Error paths like `/Users/cyrus/alphahuman/skills/skills/telegram/`
13+
- Error paths like `/Users/cyrus/openhuman/skills/skills/telegram/`
1414
- Python import failures and subprocess stderr messages
1515

1616
### Root Cause Analysis
@@ -51,7 +51,7 @@ git submodule init
5151
git submodule update
5252
```
5353

54-
This downloads the skills repository from `https://github.com/alphahumanxyz/skills`.
54+
This downloads the skills repository from `https://github.com/openhumanxyz/skills`.
5555

5656
#### 2. Create Python Virtual Environment
5757

@@ -87,7 +87,7 @@ This installs:
8787
#### Development vs Production Paths
8888

8989
- **Development**: Skills in git submodule at `./skills/skills/`
90-
- **Production**: Skills in `~/.alphahuman/skills/`
90+
- **Production**: Skills in `~/.openhuman/skills/`
9191
- **Configuration**: `src/lib/skills/paths.ts` handles path resolution
9292

9393
#### Skill Execution Process

.github/pull_request_template.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Summary
2+
3+
- What changed and why.
4+
- Keep this to 3-6 bullets focused on user-visible or architecture-impacting changes.
5+
6+
## Problem
7+
8+
- What issue or risk this PR addresses.
9+
- Include context needed for reviewers to evaluate correctness quickly.
10+
11+
## Solution
12+
13+
- How the implementation solves the problem.
14+
- Note important design decisions and tradeoffs.
15+
16+
## Testing
17+
18+
- [ ] `yarn -s compile`
19+
- [ ] `cargo check --manifest-path src-tauri/Cargo.toml`
20+
- [ ] Other checks run (list commands)
21+
- [ ] Manual validation completed (list scenarios)
22+
23+
## Impact
24+
25+
- Runtime/platform impact (desktop/mobile/web/CLI), if any.
26+
- Performance, security, migration, or compatibility implications.
27+
28+
## Breaking Changes
29+
30+
- [ ] None
31+
- [ ] Yes (describe clearly, including migration steps)
32+
33+
## Related
34+
35+
- Issue(s):
36+
- Follow-up PR(s)/TODOs:

.github/workflows/build.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: actions/setup-node@v4
2828
with:
2929
node-version: 24.x
30-
cache: "yarn"
30+
cache: 'yarn'
3131

3232
- name: Install Rust stable
3333
uses: dtolnay/rust-toolchain@stable
@@ -39,23 +39,22 @@ jobs:
3939
sudo apt-get update
4040
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
4141
42-
- name: Cache Cargo registry
42+
# Skip first 7 lines of Cargo.lock (workspace package version bumps) so the key tracks dependency changes only
43+
- name: Cargo.lock fingerprint (deps only)
44+
id: cargo-lock-fingerprint
45+
shell: bash
46+
run: |
47+
echo "hash=$(tail -n +8 src-tauri/Cargo.lock | openssl dgst -sha256 | awk '{print $2}')" >> "$GITHUB_OUTPUT"
48+
49+
- name: Cache Cargo registry and git sources
4350
uses: actions/cache@v4
4451
with:
4552
path: |
4653
~/.cargo/registry
4754
~/.cargo/git
48-
key: ${{ runner.os }}-cargo-${{ hashFiles('src-tauri/Cargo.lock') }}
49-
restore-keys: |
50-
${{ runner.os }}-cargo-
51-
52-
- name: Cache Cargo build artifacts
53-
uses: actions/cache@v4
54-
with:
55-
path: src-tauri/target
56-
key: ${{ runner.os }}-cargo-target-${{ hashFiles('src-tauri/Cargo.lock') }}
55+
key: ${{ runner.os }}-cargo-registry-${{ steps.cargo-lock-fingerprint.outputs.hash }}
5756
restore-keys: |
58-
${{ runner.os }}-cargo-target-
57+
${{ runner.os }}-cargo-registry-
5958
6059
- name: Cache node modules
6160
id: yarn-cache
@@ -74,6 +73,6 @@ jobs:
7473
run: cd skills && yarn install --frozen-lockfile
7574

7675
- name: Build Tauri app
77-
run: yarn tauri build -- --target x86_64-unknown-linux-gnu
76+
run: yarn tauri build -- --target x86_64-unknown-linux-gnu -- --bin OpenHuman
7877
env:
7978
NODE_ENV: production

0 commit comments

Comments
 (0)