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.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(desktop): sign dev sandboxes into a Clerk test account
leepokai859b6b14c801
diff --git a/apps/desktop/.gitignore b/apps/desktop/.gitignoreindex 2783f80f..2873bc80 100644--- a/apps/desktop/.gitignore+++ b/apps/desktop/.gitignore@@ -5,3 +5,5 @@ dist/src/renderer/public/symbols/native/speech-macos/.build/resources/account-config.json+# Clerk dev-instance secret key for tools/dev-account.mjs+.env.localdiff --git a/apps/desktop/src/main/account.ts b/apps/desktop/src/main/account.tsindex 1b17a29b..63cae5c3 100644--- a/apps/desktop/src/main/account.ts+++ b/apps/desktop/src/main/account.ts@@ -130,9 +130,22 @@ export class AccountService extends EventEmitter {} catch {// Offline at launch: the saved session still counts; the next call refreshes it.}+ await this.signInWithDevTicket()this.set({ ready: true })}+ /** An unpackaged Codync Dev run with a test account's one-time sign-in token (tools/dev-account.mjs): signs in without a browser. */+ private async signInWithDevTicket() {+ const ticket = process.env.CODYNC_DEV_SIGN_IN_TICKET+ if (!ticket || app.isPackaged || identity.environment !== 'dev' || this.activeSession) return+ try {+ await this.request<SignInResource>('POST', '/v1/client/sign_ins', { strategy: 'ticket', ticket })+ await this.refreshClient()+ } catch (error) {+ this.set({ error: `Test account sign-in failed: ${error instanceof Error ? error.message : String(error)}` })+ }+ }+private async persist() {try {if (!this.deviceToken) return await fs.rm(this.storePath, { force: true })diff --git a/apps/desktop/tools/dev-account.mjs b/apps/desktop/tools/dev-account.mjsnew file mode 100644index 00000000..36b001b8--- /dev/null+++ b/apps/desktop/tools/dev-account.mjs@@ -0,0 +1,40 @@+// A Clerk test account for `npm run dev` sandboxes: finds or creates `sandbox-<name>[email protected]`+// in the Clerk *development* instance and mints a one-time sign-in token the app trades for a session+// (account.ts, `CODYNC_DEV_SIGN_IN_TICKET`). The secret key comes from CLERK_SECRET_KEY or the git-ignored+// apps/desktop/.env.local; only `sk_test_` keys are used, so production is never touched.+import { existsSync, readFileSync } from 'node:fs'+import { dirname, join } from 'node:path'+import { fileURLToPath } from 'node:url'++const API = 'https://api.clerk.com/v1'++export function secretKey() {+ const file = join(dirname(fileURLToPath(import.meta.url)), '..', '.env.local')+ const fromFile = existsSync(file) ? /^CLERK_SECRET_KEY=(.+)$/m.exec(readFileSync(file, 'utf8'))?.[1] : undefined+ const key = (process.env.CLERK_SECRET_KEY ?? fromFile ?? '').trim().replace(/^["']|["']$/g, '')+ if (key && !key.startsWith('sk_test_')) throw new Error('CLERK_SECRET_KEY must be the development instance key (sk_test_...).')+ return key || null+}++async function clerk(key, method, path, body) {+ const res = await fetch(`${API}${path}`, {+ method,+ headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },+ body: body && JSON.stringify(body),+ signal: AbortSignal.timeout(20_000),+ })+ const json = await res.json().catch(() => ({}))+ if (!res.ok) throw new Error(json.errors?.[0]?.long_message ?? `Clerk ${method} ${path}: ${res.status}`)+ return json+}++/** A fresh sign-in token for the sandbox's test account, or null without a secret key. */+export async function mintTicket(sandbox) {+ const key = secretKey()+ if (!key) return null+ const email = `sandbox-${sandbox}[email protected]`+ const found = await clerk(key, 'GET', `/users?email_address=${encodeURIComponent(email)}`)+ const user = found[0] ?? (await clerk(key, 'POST', '/users', { email_address: [email], skip_password_requirement: true }))+ const { token } = await clerk(key, 'POST', '/sign_in_tokens', { user_id: user.id, expires_in_seconds: 600 })+ return { token, email }+}diff --git a/apps/desktop/tools/dev.mjs b/apps/desktop/tools/dev.mjsindex 4755eba1..060a451d 100644--- a/apps/desktop/tools/dev.mjs+++ b/apps/desktop/tools/dev.mjs@@ -14,6 +14,7 @@ import { basename, dirname, join, resolve } from 'node:path'import { setTimeout as delay } from 'node:timers/promises'import { fileURLToPath } from 'node:url'import { parseArgs } from 'node:util'+import { mintTicket } from './dev-account.mjs'import { SANDBOX_PREFIX, sandboxName, sandboxPorts } from '../src/shared/dev-sandbox.ts'const desktop = resolve(dirname(fileURLToPath(import.meta.url)), '..')@@ -152,6 +153,14 @@ async function sandbox() {...(cdp ? { CODYNC_REMOTE_DEBUG: String(cdp) } : {}),...(flags.onboarding ? {} : { CODYNC_DEV_SKIP_ONBOARDING: '1' }),}+ // The saved session lives in desktop/account.bin; a token is only needed while it is missing.+ if (!existsSync(join(home, 'desktop/account.bin'))) {+ const account = await mintTicket(name).catch((e) => console.error(`Test account skipped: ${e.message}`))+ if (account) {+ appEnv.CODYNC_DEV_SIGN_IN_TICKET = account.token+ console.log(` test account ${account.email}\n`)+ }+ }app = startApp(appEnv)app.child.on('exit', (code) => stop(code ?? 0))app.child.on('error', (e) => {diff --git a/docs/guides/dev-app.md b/docs/guides/dev-app.mdindex 7f99b28d..c14f73a0 100644--- a/docs/guides/dev-app.md+++ b/docs/guides/dev-app.md@@ -30,7 +30,7 @@ Xcode configurations separate environment from optimization: `Debug` and `ReleasFlags go after `npm run dev --`: `--shared` takes the default Codync Dev from a worktree (quit the main checkout's first); `--sandbox` runs a sandbox from the main checkout, for a second session on `dev`; `--name <name>` runs the sandbox of that name, for another copy of the same checkout; `--cloud` lets the sandbox host use the dev cloud (each sandbox then shows as another computer); `--cdp` opens the DevTools protocol on the sandbox port + 10000; `--list` shows every sandbox; `--prune` deletes the ones whose worktree is gone, so run it after removing worktrees.-A sandbox starts past onboarding (welcome and computer-access setup, only where the window hasn't chosen yet); `--onboarding` brings the flow back. It still starts signed out: it never borrows Codync Dev's login.+A sandbox starts past onboarding (welcome and computer-access setup, only where the window hasn't chosen yet); `--onboarding` brings the flow back. With `CLERK_SECRET_KEY` (the Clerk **development** instance's `sk_test_...` key) in the git-ignored `apps/desktop/.env.local` or the environment, it also signs in its own Clerk test account `sandbox-<name>[email protected]`: `tools/dev-account.mjs` finds or creates that user through the Backend API and mints a one-time sign-in token, which `account.ts` trades for a session (`ticket` strategy, unpackaged Dev runs only). The session stays in the sandbox's `desktop/`, so the token is minted only while `desktop/account.bin` is missing. Keys that aren't `sk_test_` are refused. Without a key a sandbox starts signed out; it never borrows Codync Dev's login.Still shared: macOS sees every unpackaged run as the same Electron app, so permissions and notifications are shared and a `codync-dev://` sign-in callback may reach another copy (test sign-in on the default Codync Dev); Codync Screen and computer use need the packaged `Codync Dev.app`; a global shortcut (the approval island's) goes to whichever app registered it first.