Skip to content

leileiya1/turin-code

Repository files navigation

Claude Code Restored Workspace + Turin Remote Backend

Status Bun TypeScript Tauri Elysia PostgreSQL

Language: English | 简体中文

This repository is not just a source-map recovery archive. It is a working multi-project workspace built around a restored Claude Code tree, a Tauri desktop shell, and a self-hosted remote session backend. The workspace currently centers on Claude-Code-main and turin-remote/backend: the first provides the CLI, multi-agent orchestration, assistant flows, and desktop app; the second provides the remote sessions, environments, work queue, and WebSocket backend.

Warning

This is still an unofficial research-oriented repository. The Claude-Code-main codebase is based on source-map reconstruction from the published @anthropic-ai/claude-code package. Original Claude Code rights belong to Anthropic.

🔎 Best for: Claude Code research, self-hosted remote session experiments, multi-agent orchestration work, and desktop integration testing

🧩 Stack: Bun + TypeScript + Tauri + Elysia + PostgreSQL

🧭 Quick Links: Workspace · Feature Status · Quick Start · CLI Capabilities · Remote Backend · Desktop


What This Repository Is

This root directory is a workspace, not a single Bun package.

Path Role
Claude-Code-main/ Restored Claude Code core with Buddy, KAIROS, Coordinator, Bridge-related work, and desktop integration
Claude-Code-main/apps/desktop/ Tauri desktop shell with Remote Hub, sidebar session management, settings UI, and desktop pet window
Claude-Code-main/apps/session-backend-reference/ Reference session backend for local protocol testing without PostgreSQL
turin-remote/backend/ Elysia + PostgreSQL remote session backend for environments, sessions, work polling, and WebSocket streaming
root docs Operations, remote-control setup, coordinator notes, testing guides, and feature-gate analysis

Feature Status

The original "hidden features" list should now be interpreted based on the actual state of this workspace:

ID Capability Status Notes
1 Buddy ✅ Implemented /buddy hatch, /buddy card, /buddy pet, plus desktop pet identity reuse
2 KAIROS ✅ Implemented assistant, daemon, tasks, proactive, and autodream paths are wired up
3 Ultraplan ⏳ Not implemented source traces still exist, but this workspace does not present it as a working feature
4 Coordinator ✅ Implemented extended beyond the base feature with scratchpad, ledger, phases, file locks, limits, checkpointing, tracing, and auto-retry
5 Hidden commands and gates 🟡 Partial /assistant, /proactive, /buddy, --coordinator, daemon, and related flows are usable; strict internal-only upstream paths remain gated
6 Bridge / Remote Control ✅ Implemented assistant attach, remote-control workers, self-hosted session backend support, and desktop Remote Hub are connected
7 Feature-gate analysis 📌 Preserved compile-time gates, USER_TYPE, and GrowthBook analysis remain documented

What Has Been Added Beyond the Old README

The old root README mainly described recovered source. This workspace now includes real runnable and testable integrations:

  • Claude-Code-main is no longer just a restored tree. It now exposes working Buddy, KAIROS, Proactive, Coordinator, assistant, and remote session flows.
  • Coordinator mode was extended with:
    • shared scratchpad state
    • coordinator ledger
    • phase state machine
    • file write locks and ownership checks
    • worker resource limits
    • checkpoints
    • trace timeline output
    • automatic retry orchestration
  • The desktop app is no longer a placeholder:
    • Tauri host
    • CLI transcript-backed sidebar session model
    • Remote Hub
    • Windows idle pet window
    • settings pages for session, safety, context, and integrations
    • MCP draft/runtime views
    • browser/computer-use management panels
  • Remote collaboration is no longer tied only to claude.ai:
    • apps/session-backend-reference for local smoke testing
    • turin-remote/backend for a real PostgreSQL-backed deployment

Requirements

General

  • Bun >= 1.3.5
  • Node.js >= 24

Desktop

  • Rust toolchain
  • Tauri 2.x prerequisites
  • Windows is the current primary target for the desktop pet flow

Remote Backend

  • PostgreSQL >= 14

The repository root does not contain one shared package.json. Install and run dependencies per subproject.


Quick Start

Examples below assume PowerShell from the repository root.

1. Install Dependencies

bun install --cwd .\Claude-Code-main
bun install --cwd .\Claude-Code-main\apps\desktop
bun install --cwd .\turin-remote\backend

2. Run the CLI Core

bun run --cwd .\Claude-Code-main version
bun run --cwd .\Claude-Code-main dev

Useful entry points:

bun run --cwd .\Claude-Code-main dev:cli --help
bun run --cwd .\Claude-Code-main dev:cli daemon --help

3. Run the Reference Session Backend

If you want to test assistant or remote-control flows without PostgreSQL first:

$env:SESSION_BACKEND_URL='http://127.0.0.1:8787'
$env:SESSION_BACKEND_TOKEN='local-dev-session-token'
$env:SESSION_BACKEND_ORG_ID='local-dev-org'

bun run --cwd .\Claude-Code-main session-backend:ref

Built-in checks:

bun run --cwd .\Claude-Code-main session-backend:ref:test
bun run --cwd .\Claude-Code-main session-backend:ref:e2e

4. Run the Desktop App

bun run --cwd .\Claude-Code-main\apps\desktop tauri:dev

5. Run the Real Remote Backend

Copy-Item .\turin-remote\backend\.env.example .\turin-remote\backend\.env

Then configure turin-remote/backend/.env and run:

bun run --cwd .\turin-remote\backend db:migrate
bun run --cwd .\turin-remote\backend db:seed
bun run --cwd .\turin-remote\backend dev

What Currently Works in Claude-Code-main

Buddy

Commands:

/buddy hatch
/buddy card
/buddy pet
/buddy mute
/buddy unmute

In this workspace, Buddy is not only a CLI gimmick:

  • the buddy identity is generated by the CLI core
  • the desktop app reads the same identity via apps/desktop/scripts/readBuddyIdentity.ts
  • the Tauri pet window reuses the same pet instead of creating a second desktop-only pet profile

KAIROS / Assistant / Tasks

Current entry points include:

  • bun run --cwd .\Claude-Code-main dev:cli --assistant
  • bun run --cwd .\Claude-Code-main dev:cli assistant
  • /assistant status
  • /assistant run <goal>
  • /assistant stop <taskId|latest>
  • /assistant resume <taskId|latest>
  • /assistant tasks

Typical assistant daemon startup:

$env:SESSION_BACKEND_URL='http://127.0.0.1:8787'
$env:SESSION_BACKEND_TOKEN='local-dev-session-token'
$env:SESSION_BACKEND_ORG_ID='local-dev-org'

bun run --cwd .\Claude-Code-main dev:cli daemon start --worker assistant --dir D:\Project\TypeProject\Claude-Code-main\Claude-Code-main

Status and task inspection:

bun run --cwd .\Claude-Code-main dev:cli daemon status --worker assistant --dir D:\Project\TypeProject\Claude-Code-main\Claude-Code-main
bun run --cwd .\Claude-Code-main dev:cli -p "/assistant status --all"
bun run --cwd .\Claude-Code-main dev:cli -p "/assistant tasks --all --json"

The assistant path currently covers:

  • daemon supervisor
  • task lifecycle tracking
  • attach and discovery
  • automatic backgrounding of long-running commands
  • persistent assistant work

Proactive / AutoDream

Proactive mode is wired up:

$env:CLAUDE_CODE_ENABLE_PROACTIVE='1'
bun run --cwd .\Claude-Code-main dev

Inside REPL:

/proactive on
/proactive off
/proactive pause
/proactive resume
/proactive status

AutoDream is also connected to the long-running assistant flow and memory consolidation path.

Coordinator Mode

This is the area that has been most explicitly extended in this workspace.

Enable it with:

$env:CLAUDE_CODE_ENABLE_COORDINATOR='1'
$env:CLAUDE_CODE_COORDINATOR_MODE='1'
$env:CLAUDE_CODE_ENABLE_SCRATCHPAD='1'
$env:CLAUDE_CODE_ENABLE_COORDINATOR_AUTO_RETRY='1'

bun run --cwd .\Claude-Code-main dev

Or directly through the CLI wrapper:

bun run --cwd .\Claude-Code-main dev:cli --coordinator

Implemented coordinator extensions:

  • worker-only coordinator orchestration
  • shared scratchpad JSON state
  • coordinator ledger
  • phase state machine
  • file lock manager
  • write guard
  • retry policy plus auto-retry orchestrator
  • worker checkpoints
  • coordinator trace
  • resource limit profiles

Common limit overrides:

$env:CLAUDE_CODE_WORKER_MAX_TURNS='25'
$env:CLAUDE_CODE_WORKER_MAX_TOKENS='100000'
$env:CLAUDE_CODE_WORKER_MAX_DURATION_MS='300000'
$env:CLAUDE_CODE_WORKER_MAX_TOOL_CALLS='50'
$env:CLAUDE_CODE_WORKER_LIMIT_POLICY='stop'

Remote Control / Bridge

The recommended remote flow in this workspace is to connect Claude-Code-main to either the reference backend or turin-remote/backend, not to rely only on upstream claude.ai infrastructure.

Local smoke path:

$env:SESSION_BACKEND_URL='http://127.0.0.1:8787'
$env:SESSION_BACKEND_TOKEN='local-dev-session-token'
$env:SESSION_BACKEND_ORG_ID='local-dev-org'

bun run --cwd .\Claude-Code-main dev:cli remote-control

Long-running worker path:

$env:SESSION_BACKEND_URL='http://127.0.0.1:3000'
$env:SESSION_BACKEND_TOKEN='<your-backend-token>'
$env:SESSION_BACKEND_ORG_ID='<your-org-id>'

bun run --cwd .\Claude-Code-main dev:cli daemon start --worker remoteControl --dir D:\Project\TypeProject\Claude-Code-main\Claude-Code-main

The desktop app already exposes a Remote Hub for assistant sessions and remote-control sessions.


What turin-remote/backend Provides

turin-remote/backend is the real remote session backend in this workspace, built on Elysia and PostgreSQL.

Implemented Modules

Module Current Capability
Health /health and /ready, including protocol version, capabilities, and counts
Auth /v1/auth/context with token source, org binding, and security warnings
Sessions create, query, update, archive, append events, paginate events, summaries, WebSocket subscribe
Environments register and deregister bridge environments, reconnect sessions
Work Queue poll, ack, heartbeat, and stop with session ingress token support
Token tooling tokens:create, tokens:list, tokens:revoke
DB scripts db:migrate, db:seed
Tests bun test and integration coverage in test/integration/session-backend.test.ts

Minimal Startup Flow

Copy-Item .\turin-remote\backend\.env.example .\turin-remote\backend\.env

At minimum, configure:

  • DATABASE_URL
  • SESSION_BACKEND_ORG_ID
  • SESSION_INGRESS_SIGNING_SECRET
  • SECRET_HASH_PEPPER

Then run:

bun run --cwd .\turin-remote\backend db:migrate
bun run --cwd .\turin-remote\backend db:seed
bun run --cwd .\turin-remote\backend tokens:create -- --label "local-dev-machine"
bun run --cwd .\turin-remote\backend dev

Health check:

Invoke-RestMethod http://127.0.0.1:3000/health

To connect the CLI or desktop app to this backend, set:

$env:SESSION_BACKEND_URL='http://127.0.0.1:3000'
$env:SESSION_BACKEND_TOKEN='<plain-text-token>'
$env:SESSION_BACKEND_ORG_ID='<org-id>'

Desktop App Status

Claude-Code-main/apps/desktop is already a functional desktop shell, not just a placeholder directory.

Current pieces include:

  • Tauri host plus React UI
  • CLI transcript-backed sidebar session model
  • desktop overlay index at ~/.turin/desktop/sidebar-index.json
  • session rename, pin, hide, and restore
  • Remote Hub
  • live remote session storage and view
  • Windows idle pet window
  • buddy identity bridge
  • settings shell
  • MCP management panels
  • browser/computer-use panels

Relationship with CLI state:

  • CLI transcripts are the source of truth for real sessions
  • desktop stores only UI overlays and drafts
  • rename writes back to CLI transcript metadata
  • pin and hide are desktop-local overlay state

Related docs:


Documentation Index

Recommended reading order:


Boundaries and Current Limitations

  • Ultraplan is intentionally not described here as a working capability.
  • Some upstream paths still remain behind original entitlement gates, especially flows that depend on Anthropic internal access, claude.ai OAuth, or GrowthBook rollout conditions.
  • voice, some ant-only commands, and some official remote-bridge behavior should not be treated as fully replaced by the self-hosted backend in this repository.
  • This README describes the features that are actually wired up and testable in this workspace, not every source artifact that still exists in the restored tree.

Legal Notice

  • Claude-Code-main is reconstructed from publicly published package artifacts and is kept here for research and learning purposes.
  • Original Claude Code rights belong to Anthropic.
  • turin-remote/backend, the desktop wiring, and the operational documentation reflect additional work in this workspace.
  • If there are copyright or compliance concerns, remove or adjust the affected material accordingly.

About

Restored Claude Code workspace with KAIROS assistant, Coordinator mode, Tauri desktop app, and a self-hosted remote session backend.恢复版 Claude Code 工作区,集成 KAIROS assistant、Coordinator 多 Agent 编排、Tauri 桌面端与自托管远程会话后端。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages