narwhal

yumingtao/narwhal Checked 6 hours ago

A local-first, privacy-first AI agent.

C 57/100 Not smoke-tested License not confirmed SearchGit

A local-first, privacy-first DeepSeek Harness desktop app. An Electron-based desktop shell that runs a compatible DeepSeek Harness runtime on loopback only. Manage your own AI agent workbench, MCP servers, Cordis plugins (runtime extensions), and skills — all locally, with zero cloud lock-in. Workspace picker, agent workbench, conversation history, and composer controls — all local, all loopback.

Summary extracted from the README.

An Electron-based desktop shell that runs a compatible DeepSeek Harness runtime on loopback only. Manage your own AI agent workbench, MCP servers, Cordis plugins (runtime extensions), and skills — all locally, with zero cloud lock-in.

⚠️ Early Release — Narwhal is a personal open-source project. This is the first public release: core features work, but there are known gaps (Windows/Linux builds, auto-update, advanced model presets, rich trajectory renderer, etc.). Bug reports, feature requests, and PRs are all welcome. Roadmap is tracked in GitHub Issues.


Screenshots

Main Workbench

Integrations Marketplace

Narwhal's standout feature: a built-in marketplace for MCP servers, Runtime Extensions (Cordis plugins), and Skills. Search, install, and manage everything from the Settings UI.

What is Narwhal?

Narwhal is a desktop application that brings a local-first, privacy-first AI agent to your machine. It starts a compatible DeepSeek Harness runtime on loopback only, using it strictly as a local Agent sidecar. The desktop app owns every visible conversation, activity, project, and work-context surface — you never interact with the upstream product's UI.

Narwhal is designed for anyone who wants the power of DeepSeek Harness without compromising local control, privacy, or workflow autonomy.

Why Narwhal?

Narwhal — the Arctic unicorn whale. Here's the naming intent:

1. Lineage with DeepSeek

Narwhal is a whale, and DeepSeek's logo is also a whale. The name expresses that Narwhal is not a separate species — it's the desktop extension of the DeepSeek ecosystem. It wraps DeepSeek Harness runtime in a local, dedicated, fully autonomous host. Logo, colors, and overall visual language all follow DeepSeek's whale lineage.

2. Deep

Narwhals live in Arctic waters and are one of the deepest-diving mammals, reaching 1,500 meters. Narwhal aims the same way: not a surface-level chatbot, but something that goes deep — into project context, Git repositories, MCP toolchains, runtime plugins — becoming the Agent's actual execution layer, not just a chat window.

3. Focus

The narwhal's signature tusk grows from a single canine tooth piercing through the upper jaw — sharp, concentrated, not branched. Narwhal follows the same philosophy: it is DeepSeek Harness's desktop shell. Not a generic IDE, not a Swiss army knife. One purpose, done well.

4. Progress

Narwhals don't passively dive — they navigate under ice, explore, migrate. Narwhal aims to do one thing: liberate DeepSeek Harness's capabilities from the browser, push them into broader work scenarios, and let AI agents genuinely move onto developers' daily desktops.


Key Features

Capability What it does
Local-First, Privacy-First Native workspace picker, remembered local workspaces, and project-scoped session management — all stored locally. Zero cloud lock-in.
Narwhal-Owned Conversations A dedicated Work / Activity view with real history loading, prompt cancellation, and local-only data persistence.
Safe Task Execution Local task plans, checkable steps, Git branch/changed-file inspection, and safely pinned deliverables.
Secure Loopback BFF A main-process-only Backend-for-Frontend: fixed Host origin, allow-listed session RPCs, and normalized event streams. The renderer cannot fetch the Host, pick a URL/cwd, or receive raw host configuration.
Narrow Typed IPC Bridge No Node, generic file system, shell, terminal, raw IPC, or arbitrary-path API is exposed to the renderer. A strict typed contract in src/shared/desktop-contract.ts defines the entire surface.
Zero Cloud Lock-In No accounts, cloud sync, teams, task assignments, telemetry, or automatic external uploads in V1.

V1 Scope

Included:

  • Native workspace picker and remembered local workspaces
  • Local task plans, checkable steps, Git branch/changed-file inspection, and safely pinned deliverables
  • Narwhal-owned local Agent conversations with Work / Activity view, real history loading, and prompt cancellation
  • Main-process-only loopback BFF with fixed Host origin and allow-listed session RPCs
  • Narrow typed IPC bridge with no Node/shell/FS access from the renderer
  • Integrations marketplace — search, install, and manage MCP servers, Runtime Extensions (Cordis plugins), and Skills. All changes persist in config.json and sync to the DSH runtime. Add Custom MCP form supports stdio (self-developed JS processes) and streamable-http (remote endpoints).

Deferred (not in V1):

  • File/image uploads, approval and question-answer screens
  • Advanced model or preset selection
  • Conversation forks/search, prompt steering
  • Upstream product's rich trajectory renderer

Architecture

Narwhal follows a strict security boundary between the renderer (UI) and the runtime:

┌─────────────────────────────────────────────────────────────┐
│                      Electron Main Process                  │
│  ┌─────────────┐  ┌──────────────┐  ┌──────────────────┐   │
│  │  Host Bridge │  │  Runtime     │  │  BFF (loopback)  │   │
│  │  (IPC handlers)│  │  Supervisor │  │  fixed origin    │   │
│  └──────┬──────┘  └──────┬───────┘  └────────┬─────────┘   │
│         │                │                   │              │
│  ┌──────┴────────────────┴───────────────────┴─────────┐   │
│  │              Typed IPC Bridge (preload)              │   │
│  │   src/preload/index.cts — narrow, audited surface    │   │
│  └──────────────────────────┬───────────────────────────┘   │
│                             │                               │
│  ┌──────────────────────────┴───────────────────────────┐   │
│  │              Renderer (React + Vite)                   │   │
│  │   src/renderer/ — no Node, no shell, no FS access      │   │
│  └─────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘

Design principles:

  • The renderer can never directly access the Host runtime or its configuration
  • All Host interactions go through the main process's loopback BFF with fixed origin
  • The IPC bridge exposes only typed, narrowly-scoped operations
  • User data stays local to the desktop application

Platform Support

Platform Status Notes
macOS arm64 ✅ Available Primary development target
macOS x64 🚧 Planned Universal build
Windows x64 🚧 Planned On the roadmap
Linux 🚧 Planned On the roadmap

Quick Start

Option A — Download the app (end users)

Narwhal ships as a self-contained desktop application. The DSH runtime is bundled inside — no Node.js, pnpm, or any other dependency is required on your machine.

  1. Download the latest .dmg or .zip from GitHub Releases (macOS arm64)
  2. Double-click the .dmg, drag Narwhal.app into /Applications
  3. Open Narwhal. On first launch macOS may prompt "Narwhal can't be opened" — right-click → Open → confirm again
  4. Open Settings (gear icon, bottom-left), add your API keys, and start chatting

macOS Gatekeeper note for unsigned builds The current GitHub Releases are notarized yet. After downloading from a browser, macOS marks the app with a quarantine attribute and shows: "Narwhal is damaged and can't be opened."

Quick fix — right-click in Finder: Right-click Narwhal.app → Open → confirm with Open again in the security dialog. macOS will remember this for this app.

Terminal fix (one line):

xattr -d com.apple.quarantine /Applications/Narwhal.app

We plan to enable Apple notarization once the project obtains a Developer ID. See docs/macos-release-checklist.md for details.

That's it — everything runs on loopback. No accounts, no cloud setup, no telemetry.

Option B — Build from source (developers)

Prerequisites:

  • Node.js 22+
  • pnpm
# Install dependencies
pnpm install

# Stage the DSH runtime (fetches the pinned version of @deepseek-ai/dsh from npm)
pnpm stage:runtime

# Run in development mode
pnpm dev

Package a production .app (macOS):

# Build + stage runtime + produce DMG + ZIP in release/
pnpm package:mac

The packaged .app bundles the DSH runtime into Contents/Resources/runtime/dsh/ — end users who install from the resulting DMG/ZIP do not need Node.js or any other toolchain.

Runtime discovery priority (dev mode):

  1. config.json → runtime.root override
  2. DSH_RUNTIME_ROOT environment variable
  3. runtime/dsh/ (npm-staged — primary path, produced by pnpm stage:runtime)
  4. ../DeepSeek-Harness/ (source checkout — for Harness core development)

Set DSH_NODE_EXECUTABLE when the appropriate Node binary is not on PATH. See runtime/manifest.json for the pinned runtime version (npm@0.1.1-rc.2).

Configuration

Narwhal uses a single authoritative config file that is synced to the DSH runtime before each startup.

Config file location: ~/.config/narwhal/config.json (override with NARWHAL_CONFIG_DIR)

Every time Narwhal launches, it regenerates two runtime files from config.json:

  • dsh-home/settings.yaml — provider routes, default model, permission preset
  • dsh-home/profiles/web/cordis.patch.yml — MCP servers and skills

Edit config.json (or use the in-app Settings UI), then restart Narwhal for changes to take effect.

Complete Example

{
  "version": 1,
  "theme": "auto",
  "defaultModel": {
    "provider": "deepseek",
    "model": "deepseek-chat"
  },
  "agent": {
    "preset": "standard",
    "permissionLevel": "workspace-write"
  },
  "providers": {
    "deepseek": {
      "displayName": "DeepSeek",
      "api": "openai-completions",
      "baseURL": "https://api.deepseek.com/v1",
      "apiKeyEnv": "DEEPSEEK_API_KEY",
      "models": [
        { "id": "deepseek-chat", "contextWindow": 128000, "reasoningEfforts": ["low", "medium", "high"] },
        { "id": "deepseek-reasoner", "contextWindow": 64000, "reasoningEfforts": ["low", "medium", "high"] }
      ]
    },
    "anthropic": {
      "displayName": "Anthropic",
      "api": "messages",
      "baseURL": "https://api.anthropic.com",
      "apiKeyEnv": "ANTHROPIC_API_KEY",
      "headers": { "anthropic-version": "2023-06-01" },
      "models": [
        { "id": "claude-sonnet-4-20250514", "contextWindow": 200000, "reasoningEfforts": ["low", "medium", "high"] }
      ]
    }
  },
  "skills": {
    "enabled": true,
    "customDirs": ["~/.config/narwhal/skills"]
  },
  "bundlePlugins": ["@deepseek-ai/dsh-sandbox"],
  "mcpServers": [
    {
      "serverName": "filesystem",
      "transport": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "~/projects"],
      "toolCallTimeoutMs": 60000,
      "failOnStartupError": false
    },
    {
      "serverName": "github",
      "transport": "streamable-http",
      "url": "https://mcp.example.com/github",
      "headers": { "Authorization": "{env:GITHUB_TOKEN}" },
      "toolCallTimeoutMs": 30000
    }
  ]
}

Integrations: MCP · Runtime Extensions · Skills

Narwhal has three tiers of extensibility, all managed through the Integrations settings panel:

Tier What it is Where it lives Install flow
Runtime Extensions Cordis framework plugins (npm packages with JS) — e.g. sandbox shells, credential manager, MCP protocol client Installed to <dsh-home>/profiles/web/node_modules/; symlinked to <dsh-home>/profiles/node_modules/ for Node resolution Settings UI Install button → config.json.bundlePlugins[]
MCP Servers Tool servers exposing JSON-RPC tools to the Agent Config-only (no code downloaded) — DSH spawns them at runtime Registry search or Add Custom form → config.json.mcpServers[]
Skills Markdown guidance packages (SKILL.md + optional resources) that steer Agent behavior ~/.config/narwhal/skills/<name>/SKILL.md URL paste (GitHub raw or git repo) → config.json.skills.customDirs[] + enabled=true

Every change writes to config.json and syncToDsh() regenerates cordis.patch.yml, which DSH loads at next startup.

API Keys

Narwhal never stores plaintext API keys in config.json. Provider credentials are referenced by environment variable name via apiKeyEnv:

"providers": {
  "my-provider": {
    "apiKeyEnv": "MY_PROVIDER_API_KEY"
  }
}

MCP server headers can also use the {env:VAR_NAME} pattern to keep secrets out of config files:

"headers": { "Authorization": "{env:GITHUB_TOKEN}" }

The required env vars are automatically passed through to the DSH runtime process. Export them in your shell profile, GUI session manager, or set them via Narwhal's Settings UI (they are still stored in the OS keychain, never in config.json).

MCP Servers

Narwhal supports both MCP transports. Each server becomes one dsh-mcp-client plugin entry in the generated cordis.patch.yml.

stdio transport — spawns a local process:

{
  "serverName": "brave-search",
  "transport": "stdio",
  "command": "node",
  "args": ["/path/to/brave-mcp-server/index.js"],
  "env": { "BRAVE_API_KEY": "{env:BRAVE_API_KEY}" },
  "cwd": "/path/to/brave-mcp-server",
  "toolCallTimeoutMs": 120000,
  "failOnStartupError": false
}

streamable-http transport — connects to a remote MCP endpoint:

{
  "serverName": "datadog",
  "transport": "streamable-http",
  "url": "https://mcp.datadoghq.com/v1",
  "headers": { "DD_API_KEY": "{env:DD_API_KEY}" },
  "toolCallTimeoutMs": 60000,
  "failOnStartupError": true
}
Option Default Description
toolCallTimeoutMs 60000 Maximum milliseconds per tool call
failOnStartupError false If true, the Agent aborts when this server fails to start; if false, the server is skipped silently

Skills

Narwhal's skill system is disabled by default. Enable it to give the Agent persistent skill packs from bundled and custom directories:

"skills": {
  "enabled": true,
  "customDirs": ["~/.config/narwhal/skills", "./my-skills"],
  "bundledDir": "/opt/narwhal/skills"
}
Field Description
enabled Enable skill loading. When true, Narwhal writes the skill-filesystem DSH plugin entry into cordis.patch.yml.
customDirs Absolute paths to directories containing skill folders. Each folder has a SKILL.md at its root. Default install path is ~/.config/narwhal/skills (written by the Integrations UI).
bundledDir Optional path to a bundled skill directory distributed alongside Narwhal itself.

Configuration Schema

Narwhal uses Zod to validate config.json on every load. See src/shared/config-schema.ts for the authoritative schema and src/main/dsh-sync.ts for the exact settings.yaml and cordis.patch.yml builders.

Development

The project uses:

  • React + Vite for the renderer UI
  • Electron for the desktop shell
  • TypeScript throughout
# Type checking
pnpm typecheck

# Build only
pnpm build

# Development with live reload
pnpm dev

The pinned runtime version is declared in both package.json.dshRuntime (npm@0.1.1-rc.2) and runtime/manifest.json. The pnpm stage:runtime script installs that exact version of @deepseek-ai/dsh into runtime/dsh/ so it can be auto-discovered at startup.

Packaging

pnpm package:mac runs build + stage:runtime + electron-builder. The stage script reads package.json.dshRuntime (npm@0.1.1-rc.2) and installs the pinned @deepseek-ai/dsh into runtime/dsh/, which electron-builder then copies into the app bundle.

# Build the DMG + ZIP (uses pinned npm runtime)
pnpm package:mac

# Or stage from a local DeepSeek-Harness source checkout (for Harness developers)
DSH_RUNTIME_SOURCE=/absolute/path/to/DeepSeek-Harness pnpm package:mac

Currently, only macOS arm64 builds are available. Windows and Linux packaging are on the roadmap.

Builds remain unsigned until the owner supplies signing and notarization credentials. See docs/macos-release-checklist.md for details.

Project Structure

narwhal/
├── src/
│   ├── main/            # Electron main process (BFF, runtime management, IPC)
│   ├── preload/         # Preload script (typed IPC bridge)
│   ├── renderer/        # React renderer (UI components, styles)
│   ├── recovery/        # Recovery mode UI
│   └── shared/          # Shared types and contracts
├── runtime/             # Staged Harness runtime
├── scripts/             # Build utilities
├── docs/                # Documentation
└── build/               # Icons and build assets

runtime/dsh/package.json is a generated staging manifest produced by pnpm stage:runtime. It pins @deepseek-ai/dsh-* workspace packages from a local Harness checkout and is only resolvable inside that upstream workspace. Do not edit it by hand or run pnpm install against it directly.

Runtime Boundary & Known Limitations

Narwhal spawns DeepSeek Harness (@deepseek-ai/dsh) as an independent Node.js subprocess. This section documents what each side owns, and the known boundary workarounds.

What Narwhal owns vs. DSH owns

Concern Narwhal DSH Runtime
Process lifecycle ✅ Spawn, monitor, restart DSH ❌ Self-managed (no supervisor)
UI rendering ✅ All visible UI ❌ None (pure API layer)
Workspace list ✅ workbench.json (userData) ❌ Doesn't know workspaces exist
Session CRUD ❌ Read-only (via session.list) ✅ Authoritative store in memory + disk
Session lifecycle ⚠️ Workaround only (see below) ✅ Has no session.delete API
Provider CRUD ✅ UI + config.json ⚠️ DSH settings namespace (Narwhal must also clean credentials)
Credentials (API keys) ❌ Read-only UI display ✅ .credentials.yaml + credentials.set/unset APIs
Settings ✅ config.json (authoritative) ⚠️ settings.yaml (generated from config.json on startup)
Plugin loading ✅ Cordis plugin install/remove ✅ Executes plugins at runtime

Communication protocol

All interaction is JSON-over-HTTP with typed envelope:

{ "type": "client-request", "rpcId": "uuid", "method": "session.list", "payload": {} }

Inbound events arrive over WebSocket (/api/events.mux):

{ "type": "agent-error", "text": "...", "time": 1234567890 }

Known boundary gaps & workarounds

These are places where DSH doesn't provide an API Narwhal needs, so we bypass the clean boundary. They should be revisited whenever DSH releases a version that closes the gap.

1. Deleting a workspace (with sessions)

DSH has no session.delete HTTP API. Deleting sessions from disk (~/.narwhal/sessions/<slug>/) and clearing the projcache (storages/session_projcache.json) has no effect on the running DSH process — it keeps serving the stale session IDs from its in-memory cache.

Workaround: After deleting session files from disk, Narwhal calls supervisor.stop() then supervisor.start() to respawn the DSH process. On restart, DSH re-reads from disk and the stale sessions are gone.

Where: src/main/index.ts → deleteDshSessionsForCwd() + delete-workspace IPC handler.

2. Deleting a provider (with saved API key)

settings.mutate {op:"unset"} only removes the provider config from DSH's settings namespace — it does not clean up the credential entry in ~/.narwhal/.credentials.yaml. DSH requires an explicit separate credentials.unset {ref} call. The credential ref is derived from the provider's apiKeyEnv field (or defaults to <ID>_API_KEY).

Workaround: Before calling settings.mutate unset, Narwhal first reads the provider profile from DSH settings to compute the credential ref. Then it calls credentials.describe to confirm a key exists, followed by credentials.unset.

Where: src/main/host-bridge.ts → deleteProvider().

3. supervisor.start() is a no-op when DSH is alive

supervisor.start() returns immediately if an active DSH process already exists (it's idempotent by design — "start running DSH"). This means any code path that needs to restart DSH (not just ensure it's running) must call supervisor.stop() first, then supervisor.start().

Known trap: Naive startHost() calls that assume they restart DSH are silently no-ops when DSH is already running. The fix is always stop() → start() for actual restarts.


Relationship to DeepSeek Harness

Narwhal is an independent project that relies on a compatible DeepSeek Harness runtime. Key points:

  • Narwhal does not modify or redistribute DeepSeek Harness source code
  • It stages a verified compatible runtime for local-only execution
  • Narwhal's desktop UI, branding, and interaction patterns are entirely its own
  • The upstream license and notices must be preserved when distributing the staged runtime

Contributing

We welcome contributions! See CONTRIBUTING.md for detailed guidelines.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes (ensure pnpm typecheck and pnpm build pass)
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

License

This project is licensed under the MIT License — see the LICENSE file for details.

When distributing Narwhal, preserve the upstream license and notices for the staged runtime located in runtime/dsh/.