From cebacc27a48168e666679018f8e27156d12d4527 Mon Sep 17 00:00:00 2001 From: Agando Date: Wed, 17 Jun 2026 06:01:20 +0200 Subject: auto: 2026-06-17_06:01 changes --- A2A_protocol_spec.md | 115 +- cheatsheet.html | 7 + .../2026-06-17_readonly-wallet-lookup.md | 45 + help.html | 34 + main.html | 8 +- modules/core/core-bundle.js | 1124 ++++++++++++++++---- modules/core/module-agent-registry.js | 320 +++++- modules/core/module-aiassist.js | 196 +++- modules/core/module-fs.js | 74 +- modules/core/module-leases.js | 25 + modules/core/module-loader.js | 2 +- modules/core/module-neural-vfs.js | 2 +- modules/core/module-orchestrator.js | 41 +- modules/core/module-smartctx.js | 59 +- modules/core/module-world-model.js | 83 +- modules/core/ollama-manager.js | 41 +- modules/core/terminal.js | 97 +- modules/core/virtual-fs.js | 39 +- modules/ext/critical-ext-bundle.js | 4 +- modules/ext/webdav.js | 14 +- newos4_whitepaper.md | 2 +- session-resume-2026-06-17.md | 67 ++ skills/agent-orchestration.md | 14 +- 23 files changed, 2010 insertions(+), 403 deletions(-) create mode 100644 docs/session-notes/2026-06-17_readonly-wallet-lookup.md create mode 100644 session-resume-2026-06-17.md diff --git a/A2A_protocol_spec.md b/A2A_protocol_spec.md index bb3d713..3c4d7ac 100644 --- a/A2A_protocol_spec.md +++ b/A2A_protocol_spec.md @@ -1,69 +1,78 @@ -# A2A Protocol Specification v0.2 +# A2A Protocol Specification v0.3 ## Overview -Agent-to-Agent (A2A) is a decentralized message protocol for agent negotiation within newOS4. Agents discover each other via VFS registrations and communicate through a VFS mailbox system. No central broker. +Agent-to-Agent (A2A) is a decentralized message protocol for agent negotiation within newOS4. Agents communicate through a **shared VFS scratchpad** (`/_agents/scratchpad.json`). No central broker — discovery is via VFS registrations. -## Message Format -All messages are JSON with this envelope: +## Scratchpad Data Structure + +All messages live in a single JSON file at `/_agents/scratchpad.json`: ```json { - "a2a_version": "0.1", - "msg_id": "", - "type": "request" | "response" | "broadcast" | "lease" | "heartbeat", - "from": "", - "to": "" | "*", - "timestamp": "", - "ttl_seconds": 30, - "contract": { - "capabilities": ["list_files", "read_file", "web_search"], - "constraints": { - "max_tool_turns": 8, - "max_duration_seconds": 60 + "messages": [ + { + "id": "msg_001", + "from": "user", + "to": "researcher", + "type": "request", + "capability": "code.search", + "payload": { "query": "test" }, + "ttl": 300000, + "status": "pending", + "ts": 1234567890, + "reply_to": null + } + ], + "seq": 1, + "agents": { + "researcher": { + "last_poll": 1234567890, + "capabilities": ["coder", "reader", "writer"] } - }, - "payload": { } + } } ``` -## Transport Layer (VFS Mailbox) -Each agent has a VFS mailbox: -- **Inbox** — `/agents//inbox.json` — receives incoming A2A messages -- **Outbox** — `/agents//outbox.json` — agent writes results here after execution - -The orchestrator polls all agent inboxes every **500ms** via `_pollAgentMailboxes()`. When a new A2A message appears, it: -1. Reads the message envelope -2. Routes by type: - - `request` — task delegation, checks outbox for completion - - `response` — task result from agent - - `broadcast` — capability advertisement - - `heartbeat` — updates agent's lastHeartbeat timestamp -3. Marks messages as `_processed` to avoid re-routing - -## Message Types -- **request**: Point-to-point task delegation. From=orchestrator, To=worker. -- **response**: Task result. From=worker, To=orchestrator. -- **broadcast**: Discovery / capability advertisement. To="*". -- **lease**: Time-bound contract granting a worker exclusive task rights. -- **heartbeat**: Alive signal. Every 5 seconds. Missing 3 consecutive = presumed dead. +### Message Statuses +| Status | Meaning | +|---|---| +| `pending` | Not yet delivered | +| `delivered` | Read by recipient via poll | +| `completed` | Acknowledged with result | +| `failed` | Rejected with error | ## Commands -- `a2a-send ` — Send an A2A message to an agent's inbox -- `a2a-list` — Show all A2A messages across agents with status + +| Command | Description | +|---|---| +| `a2a-post ` | Post a message to an agent | +| `a2a-poll [agentId]` | Poll for pending messages (default: current agent or "user") | +| `a2a-ack ` | Mark message completed with result | +| `a2a-reject ` | Mark message failed with error | +| `a2a-status` | Show scratchpad stats per agent | +| `a2a-prune` | Clean up expired and old completed messages | ## Lifecycle -1. Orchestrator sends `request` to agent's inbox via `a2a-send` -2. AI module receives delegated task, executes it -3. Result written to agent's outbox -4. Polling loop detects outbox completion, sends `response` message -5. Orchestrator marks lease as complete, agent returns to idle pool + +1. **Register** — `agent-register ` creates agent dir + auto-registers in scratchpad +2. **Post** — `a2a-post ` writes to scratchpad with `status: pending` +3. **Poll** — `a2a-poll ` returns pending messages, marks them `delivered` +4. **Ack/Reject** — Recipient acknowledges with result or rejects with error +5. **Unregister** — `agent-unregister ` removes agent from scratchpad + deletes VFS dir +6. **Auto-prune** — Every 60 seconds, expired messages (past TTL) and completed messages older than 1 hour are removed + +## Integration Points + +- **Orchestrator** — auto-calls `a2aRegister` on agent spawn, `a2aUnregister` on kill +- **Lease system** — posts A2A messages on lease create and lease revoke +- **Garbage collection** — `_a2aCleanup()` removes orphaned agent entries when agent dirs are deleted ## Implementation Status -- ✅ Message format (v0.1 envelope) -- ✅ VFS mailbox transport (inbox.json / outbox.json) -- ✅ 500ms polling loop in orchestrator -- ✅ Type routing (request, response, broadcast, heartbeat) -- ✅ a2a-send / a2a-list CLI commands -- ⬜ Heartbeat sending from worker agents -- ⬜ Full broadcast discovery flow -- ⬜ Lease revocation via A2A message (currently uses separate LeaseModule) \ No newline at end of file +- ✅ Scratchpad data structure (/_agents/scratchpad.json) +- ✅ a2a-post / a2a-poll / a2a-ack / a2a-reject / a2a-status / a2a-prune CLI commands +- ✅ Auto-register on agent spawn +- ✅ Auto-unregister on agent kill +- ✅ A2A messages on lease create/revoke +- ✅ Auto-prune timer (60s interval) +- ✅ Garbage collection for orphaned agent entries +- ✅ Security whitelist (all A2A commands whitelisted, not destructive) diff --git a/cheatsheet.html b/cheatsheet.html index 61ead4e..25ce256 100644 --- a/cheatsheet.html +++ b/cheatsheet.html @@ -269,6 +269,13 @@ pre{background:var(--bg2);border:1px solid var(--border);border-radius:var(--rad
shadow-rollbackUndo shadow VFS changes
+

🧠 VaultMind AI

+
+
vaultmind_connectConnect wallet to VaultMind (reads key from SecretVault)
+
vaultmind_statusCheck VaultMind session status
+
vaultmind_queryQuery prices, portfolio, chat, etc.
+
+

🛠️ Developer

js <expr>Eval JS in page context
diff --git a/docs/session-notes/2026-06-17_readonly-wallet-lookup.md b/docs/session-notes/2026-06-17_readonly-wallet-lookup.md new file mode 100644 index 0000000..c387954 --- /dev/null +++ b/docs/session-notes/2026-06-17_readonly-wallet-lookup.md @@ -0,0 +1,45 @@ +# Read-Only Wallet Lookup — Session Notes + +**Date:** 2026-06-17 +**Goal:** Add read-only Hyperliquid wallet lookup for `0xA12b193832d401A1B5f738170631fD6547aF3C3F` — no private key needed. + +## What was done + +### 1. Backend endpoint (`/home/darkbot/ai/vaultmind-ai/backend/main.py`) +- Added `GET /wallet/{address}` — uses `hl_client.info` (no key required) +- Returns: `account_value`, `margin_used`, `withdrawable`, `positions[]` (coin, size, entry_px, pnl, market) +- Hardcoded `mainnet1` for the read-only endpoint (was hitting testnet) +- Cache: `Cache-Control: public, max-age=5` + +### 2. Nginx proxy +- Added `location /wallet/` → `http://127.0.0.1:8000/wallet/` +- **Bug:** The nginx config was corrupted — `/vmai/` block missing closing `}`, `/vmai-api/` nested inside it, 7 duplicate `/wallet/` blocks from repeated patch attempts. Rewrote the entire file cleanly. +- **Important:** `/etc/nginx/sites-enabled/webx11.duckdns.org` is a **regular file** (not a symlink to sites-available). Both files must be kept in sync. + +### 3. AI tool (`module-aiassist.js` + `core-bundle.js`) +- Added `wallet_lookup` tool: schema + handler + system prompt +- Usage: `ai show wallet 0xA12b...3C3F` +- Tool calls `GET /wallet/{address}` via `web_fetch` + +### 4. Stale `.pyc` fix +- `find /home/darkbot/ai/vaultmind-ai/ -name '*.pyc' -delete` after adding new route +- Without this, the running process doesn't see the new endpoint + +## Files changed +- `backend/main.py` — new `/wallet/{address}` route +- `module-aiassist.js` — `wallet_lookup` tool def + handler + system prompt +- `core-bundle.js` — same changes in bundled copy +- `/etc/nginx/sites-enabled/webx11.duckdns.org` — added `/wallet/` proxy +- `/etc/nginx/sites-available/webx11.duckdns.org` — synced + +## Verification +```bash +curl -s https://webx11.duckdns.org/wallet/0xA12b193832d401A1B5f738170631fD6547aF3C3F +``` +Returns: $11.67 equity, 4 positions (BTC, NEAR, FIL, TAO) + +## Key lessons +- Nginx sites-enabled is a regular file, not a symlink — edit both +- Stale `.pyc` hides new routes — always clear after adding endpoints +- Read-only Hyperliquid queries use `Info` class, no key needed +- The stored key (`0x0e80...055c`) controls a different wallet (`0x6cB4...1Aa2`, empty) — not the user's trading wallet diff --git a/help.html b/help.html index e50124c..2429121 100644 --- a/help.html +++ b/help.html @@ -664,6 +664,9 @@ diff a.txt b.txt view/edit/test/reloadModule operationsedit ✅ user_get/set/list/forgetUser profile❌ session_save/load/recent/statsSession memory❌ + vaultmind_connectConnect wallet to VaultMind AI (reads key from SecretVault)❌ + vaultmind_statusCheck VaultMind session status❌ + vaultmind_queryQuery VaultMind: prices, portfolio, chat❌

Sound Notification

@@ -824,6 +827,37 @@ ollamaconnect + +
+

🧠 VaultMind AI

+
+ Hyperliquid AI Assistant + VaultMind is an AI-powered wallet assistant for Hyperliquid. It provides market data, portfolio analysis, transaction analysis, and AI chat agents. +
+ +

Setup

+
    +
  1. Store your Hyperliquid private key: secret-set hyperliquid_key 0x...
  2. +
  3. Ask the AI to connect: ai connect to vaultmind or use the vaultmind_connect tool
  4. +
  5. Check status: ai check vaultmind status or vaultmind_status
  6. +
+ +

AI Tools

+
+ + + + +
ToolDescription
vaultmind_connectReads hyperliquid_key from SecretVault, authenticates with VaultMind backend, stores session token
vaultmind_statusChecks if a valid VaultMind session token exists in localStorage
vaultmind_queryQuery endpoints: prices, portfolio, transactions, copy-trade, or chat with an AI agent
+ +

API Endpoints (proxied via nginx)

+
+ + + +
PathBackend
/vmai/Proxied to VaultMind backend at 127.0.0.1:8000
/vmai-api/Alias for frontend chat — also proxied to 127.0.0.1:8000
+
+

🧩 Module System

diff --git a/main.html b/main.html index fc1b4dd..2e963bc 100644 --- a/main.html +++ b/main.html @@ -1280,12 +1280,12 @@ } - - - + + + - +