Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

6.1 KB
Raw Blame

Codync cloud

Cloudflare Worker for accounts and the off-LAN relay (spec: docs/reference/remote-relay.md).

  • /v1 API (src/api.ts, route groups in src/routes/): Clerk-authenticated account routes (devices, claims, computers, access requests, grants), Codync-Sig-authenticated host routes (/v1/host/*), the Clerk webhook, and a 15-minute cron that expires requests and prunes nonces, a 5-minute cron that runs the release gate while a release waits behind GitHub's latest mark or the Homebrew tap trails it (src/release-gate.ts), and the public routine webhook route POST /v1/hooks/:computerId/:routineId (spec §7.8). D1 schema: migrations/ (later files rebuild some tables).
  • Cloud assistant connector (src/routes/assistant.ts, spec §7.9): the MCP server at mcp.codync.dev/mcp (dev dev-mcp.codync.dev, same Worker) that ChatGPT, Claude and other MCP clients sign in to with the Codync account (Clerk OAuth, tokens bound to the connector URL); its tool calls go to the account's computers through their DOs (src/host-calls.ts), and only a computer that turned cloud assistants on answers them. Setup and checks: docs/features/cloud-assistants.md.
  • ComputerRelay (src/relay.ts): one Durable Object per computer (SQLite storage, WebSocket Hibernation). It admits device sockets against the host-signed ACL, forwards channel frames it can't read, reports presence, holds the offline mailbox, and queues routine webhook deliveries (hookbox, checked against the keys the host registers; src/hooks.ts). It is reachable only through requests the Worker builds itself (X-Codync-Internal: 1); /internal/* has no public route.
  • Auth (src/auth.ts): Clerk session JWTs via @clerk/backend (CLERK_SECRET_KEY → JWKS fetched and cached per isolate; CLERK_JWT_KEY → networkless, dev/e2e only) and Ed25519 request signatures (WebCrypto).

The channel relay sees ciphertext and routing metadata. The account API also stores account/device metadata. It can shorten access (revoke, block) but never grant it: new devices come from the host's own QR pairing or its approval, and the ACL is signed by the host.

Test

npm ci
npm run typecheck
npm test          # vitest in workerd: vectors, Codync-Sig, API, DO relay/mailbox

test/ref.ts is a device/host reference implementation on @noble/*, checked against docs/reference/fixtures/remote-relay-vectors.json and reused by the relay tests and the e2e harness.

The vitest pool's bundled workerd may trail wrangler's; vitest.config.ts pins the test compatibility date to the newest one it supports. wrangler.toml keeps the deploy date.

End to end (spec §12.1)

(cd ../host && cargo build)
npm run e2e       # local D1 + wrangler dev + real codync-host + test/e2e/phone.ts

Env: CODYNC_HOST_BIN (default ../host/target/debug/codync-host), CODYNC_E2E_CLOUD_PORT (default 8787), E2E_VERBOSE=1 to stream wrangler and host logs. Needs python3 for the fake agent.

Deploy

Development deployment (see environment readiness; these commands change remote resources):

# Only if the database does not exist: npx wrangler d1 create codync-dev
# Confirm its database_id in [env.dev] before applying migrations.
npx wrangler d1 migrations apply codync-dev --env dev --remote   # includes 0005 (short pairing codes), 0006 (signed-out devices)
npx wrangler secret put CLERK_SECRET_KEY --env dev
npx wrangler secret put CLERK_WEBHOOK_SECRET --env dev
# The device certificate key: without it phones can't pair (503 notConfigured).
grep '^CODYNC_DEVICE_CERT_KEY=' ../.env.development | cut -d= -f2- | npx wrangler secret put DEVICE_CERT_KEY --env dev
npx wrangler deploy --env dev               # → https://dev-api.codync.dev
Name Kind Purpose
CLERK_SECRET_KEY secret JWKS for session tokens
CLERK_WEBHOOK_SECRET secret Svix signature on /v1/webhooks/clerk (user.deleted)
DEVICE_CERT_KEY secret Ed25519 private key (JWK JSON) that signs device certificates (POST /v1/devices/certificate); hosts compile in its public half (host/src/environment.rs), CODYNC_DEVICE_CERT_KEY on a host overrides it for a self-hosted cloud. Kept in the git-ignored .env.development / .env.production as CODYNC_DEVICE_CERT_KEY
RELEASE_GATE_TOKEN secret, main only fine-grained GitHub token, Actions: write on leepokai/Codync: dispatches the release gate
CLERK_ISSUER var Clerk Frontend API URL; tokens must carry this iss
CLERK_AUTHORIZED_PARTIES var, optional comma-separated; a token with azp must match
CLERK_JWT_KEY var, dev/e2e only public key for networkless verification
ASSISTANT_LIMITER rate limit binding cloud assistant (MCP connector) requests per account, 120 per minute
PAIRING_CODE_LIMITER rate limit binding short pairing codes typed per account and per IP, 10 per minute, a miss counting twice

RELEASE_GATE_TOKEN is a fine-grained token without expiry. If it's revoked, set a new one with npx wrangler secret put RELEASE_GATE_TOKEN: without a working token the release gate runs only after each release, and only the Worker's cron logs show it (GitHub graphql: 401, release gate dispatch: 403).

New computers are limited to 10 per IP per minute with the Workers Rate Limiting binding REGISTER_LIMITER ([[ratelimits]]; each environment needs its own namespace_id). Public routine webhook deliveries are limited to 60 per sender IP and hook per minute with HOOK_LIMITER (same binding kind, its own namespace_id per environment).

Remote screen relay

POST /v1/host/screen-ice issues one-hour Cloudflare Realtime TURN credentials to a signed host belonging to an active account. The host first checks the calling device's screen permission. The Worker requires TURN_KEY_ID, TURN_KEY_API_TOKEN (server-only secrets) and TURN_LIMITER (12 issuances per account per minute). The credentials are never cached in HTTP caches or stored in D1. See Remote screen setup and verification.