npm.io
0.2.4 • Published 3 months ago

aindrive

Licence
MIT
Version
0.2.4
Deps
0
Vulns
0
Weekly
0

aindrive

Local agent for aindrive — connects any folder on your machine to an aindrive web server through an outbound WebSocket. No inbound ports are opened. Bytes never leave your machine unless requested over a signed RPC.

npm i -g aindrive
cd ~/Documents
aindrive
# first run: opens browser → click Authorize → folder is served at
# https://aindrive.ainetwork.ai/d/<drive-id>

aindrive will sign you in on first use. If you prefer to do it explicitly, aindrive login does the same thing — it opens https://aindrive.ainetwork.ai/cli-login/<linkId>, polls for your approval, and then immediately starts serving the current folder. Each pairing link is single-use and expires in 10 minutes.

Commands

aindrive [folder]          serve a folder (default: current dir; logs in on first use)
aindrive -d [folder]       serve in the BACKGROUND (returns your terminal)
aindrive login             sign in and serve the current folder
aindrive status [folder]   show drive id, server URL, and whether the agent is running
aindrive logs [folder]     follow the background agent's output (tail -f; Ctrl+C to stop)
aindrive stop [folder]     stop the background agent
aindrive rotate-token      rotate the per-drive agent token
aindrive mcp               run a Model Context Protocol stdio server

The agent is a long-lived process — it's the live bridge between the web app and your files, so the drive is online only while it runs. Plain aindrive stays in the foreground (Ctrl+C to stop); aindrive -d runs it in the background and hands your terminal back. Background state (pid + log) lives in the folder's .aindrive/, so you can background several folders independently and reattach to any with aindrive logs. First-time pairing must run in the foreground once (it needs the browser sign-in); after that -d works.

MCP integration

aindrive mcp exposes every drive operation (list/read/write/share/grant /ask-agent/x402-resolve) to MCP-aware AI assistants — Claude Code, Claude Desktop, Cursor, etc. The same single npm install enables it; no extra package needed.

// claude_desktop_config.json or .mcp.json
{
  "mcpServers": {
    "aindrive": { "command": "aindrive", "args": ["mcp"] }
  }
}

Auth precedence:

  1. AINDRIVE_SESSION env (raw aindrive_session=... cookie)
  2. AINDRIVE_WALLET_COOKIE env (raw aindrive_wallet=... cookie)
  3. ~/.aindrive/credentials.json from aindrive login.

AINDRIVE_CAP env attaches a Meadowcap cap to every request; useful for agents that paid via x402 and want to reuse the cap from another box.

Flags

--server <url>   server URL (default: $AINDRIVE_SERVER or https://aindrive.ainetwork.ai)
--name <name>    name for this drive on first pairing
--no-open        do not open the browser
--version        print version

How it works

aindrive dials out to the configured server over WSS and waits for signed RPC calls (list, read, write, mkdir, …). Each request carries an HMAC built from a per-drive secret negotiated at pairing time; the server cannot read or write files without a valid signature. The server is a relay — it never touches your disk.

State lives in two places:

  • ~/.aindrive/credentials.json — login session for the configured server.
  • <folder>/.aindrive/config.json — per-folder drive id, secret, and agent token. Same directory also holds <folder>/.aindrive/willow.db (Y.Doc updates) and <folder>/.aindrive/yjs/<docId>.bin (latest snapshots) once the agent runs.

Pair a new folder with aindrive (uses your global login), or re-attach an existing drive by running aindrive inside a folder that already has .aindrive/config.json.

Self-hosting

Point at your own server with --server or AINDRIVE_SERVER:

AINDRIVE_SERVER=https://drive.example.com aindrive login
AINDRIVE_SERVER=https://drive.example.com aindrive ~/work

Requirements

  • Node.js ≥ 20

License

MIT

Keywords