Connect my computer: works from Docker and on Windows

- Docker passes BROKE_HOSTED through (setting it in .env did nothing before)
- the helper finds claude.exe / claude.cmd on Windows (PATH uses ';' there),
  runs a .cmd through cmd.exe with the question on stdin only, and keeps the
  Windows variables Claude needs to find its login; opencode on Windows only as .exe
- the page gives Windows a PowerShell command (curl.exe, file then node)
- Copy works on a plain http LAN address

Tested on Windows end to end with a stand-in claude.cmd: pairing, a question with
quotes, & and %, and every lockdown flag arriving intact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MangaValkandClaude Opus 5.5 committed 2026-11-17 20:50:41 +01:00
1 parent ea53718e5d
commit 0232766260
4 files changed
+54 -12

No files matched your search

+10
View File
@@ -157,6 +157,16 @@ Read what changed (`git show <commit>`). Take everything with `git merge upstrea
Things to check in upstream changes: new outside calls (`fetch(` to a new host), new environment variables, and changes to `scripts/start.mjs` or `src/lib/llm/`.
## Use Claude from your own computer
brokeless runs in Docker, so it can't use a Claude login of its own. Instead, Claude Code keeps running on your PC and brokeless sends it questions:
1. On your PC, install Claude Code (`npm install -g @anthropic-ai/claude-code`, or Anthropic's installer) and run `claude` once to sign in.
2. Add `BROKE_HOSTED=1` to `docker/.env` and run Compose Up again.
3. In brokeless: Connect your AI, **Connect my computer**. Run the command it shows on your PC (in PowerShell on Windows) and leave it open. Then pick Claude.
Claude only answers while that command runs. It starts Claude with every tool off, in an empty folder, so it can't touch your files. Works on Windows, macOS and Linux.
## How AI stays private
Every AI path goes through one gate. A cloud model gets a summary: rounded amounts, names replaced by tokens. Full detail goes only to a local model, which is what Ollama is here. You can turn AI off in Settings. Each answer runs with no way to change your data.
+2
View File
@@ -45,6 +45,8 @@ services:
SUPABASE_SERVICE_ROLE_KEY: ${SERVICE_ROLE_KEY}
# Inside the stack only, so no SSL (broke turns SSL on unless the URL says otherwise).
SUPABASE_DB_URL: postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/postgres?sslmode=disable
# 1 = AI runs on your own computer through "Connect my computer" (Claude Code there). Hides the local model.
BROKE_HOSTED: ${BROKE_HOSTED:-}
LOCAL_LLM_BASE_URL: ${LOCAL_LLM_BASE_URL:-http://ollama:11434/v1}
LOCAL_LLM_MODEL: ${LOCAL_LLM_MODEL:-}
PLAID_CLIENT_ID: ${PLAID_CLIENT_ID:-}
+26 -9
View File
@@ -4,7 +4,9 @@
const { spawn, execFile } = require("node:child_process");
const { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } = require("node:fs");
const { homedir } = require("node:os");
const { join } = require("node:path");
const { delimiter, join } = require("node:path");
const WIN = process.platform === "win32";
const site = (process.argv[2] || "").replace(/\/$/, "");
const code = process.argv[3];
@@ -19,22 +21,37 @@ mkdirSync(WORK, { recursive: true });
// Only what the AI apps need to find their login. Drops API keys, which would switch them to API billing.
const env = { HOME: homedir(), PATH: process.env.PATH, LANG: process.env.LANG || "en_US.UTF-8" };
for (const k of ["USER", "LOGNAME", "TMPDIR", "SHELL"]) if (process.env[k]) env[k] = process.env[k];
const findBin = (name) => {
const dirs = [...(process.env.PATH || "").split(":"), join(homedir(), ".local/bin"), "/opt/homebrew/bin", "/usr/local/bin", join(homedir(), ".npm-global/bin")];
return dirs.map((d) => join(d, name)).find((p) => existsSync(p)) || null;
// Windows: the AI apps find their login and Windows itself through these.
const WIN_VARS = ["USERPROFILE", "APPDATA", "LOCALAPPDATA", "SystemRoot", "SystemDrive", "windir", "TEMP", "TMP", "PATHEXT", "ComSpec", "ProgramData", "ProgramFiles", "HOMEDRIVE", "HOMEPATH"];
for (const k of ["USER", "LOGNAME", "TMPDIR", "SHELL", ...(WIN ? WIN_VARS : [])]) if (process.env[k]) env[k] = process.env[k];
// Windows: claude.exe (native install) or claude.cmd (npm). cmdOk false: only a real .exe, never through cmd.exe.
const findBin = (name, cmdOk = true) => {
const dirs = [...(process.env.PATH || "").split(delimiter).filter(Boolean), join(homedir(), ".local", "bin"),
...(WIN ? [join(process.env.APPDATA || "", "npm")] : ["/opt/homebrew/bin", "/usr/local/bin"]), join(homedir(), ".npm-global", "bin")];
const names = WIN ? [`${name}.exe`, ...(cmdOk ? [`${name}.cmd`] : [])] : [name];
for (const d of dirs) for (const n of names) if (existsSync(join(d, n))) return join(d, n);
return null;
};
// A .cmd only runs through cmd.exe. Safe here because every argument is fixed or checked by safeModel (no quotes, no
// %), and the question itself goes in on stdin, never on the command line.
const viaCmd = (bin) => WIN && /\.cmd$/i.test(bin);
const q = (a) => `"${a.replace(/"/g, '\\"')}"`;
const launch = (bin, args, opts) => viaCmd(bin) ? spawn(q(bin), args.map(q), { ...opts, shell: true, windowsHide: true }) : spawn(bin, args, { ...opts, windowsHide: true });
const OPENCODE_ENV = {
...env, XDG_CONFIG_HOME: join(HOME, "opencode-config"), OPENCODE_DISABLE_CLAUDE_CODE: "1", OPENCODE_DISABLE_EXTERNAL_SKILLS: "1", OPENCODE_DISABLE_PROJECT_CONFIG: "1",
OPENCODE_DISABLE_AUTOUPDATE: "1", OPENCODE_DISABLE_DEFAULT_PLUGINS: "1", OPENCODE_CONFIG_CONTENT: JSON.stringify({ share: "disabled", autoupdate: false, mcp: {}, permission: { "*": "deny" } }),
};
const output = (bin, args, e) => new Promise((res) => execFile(bin, args, { env: e, timeout: 8000 }, (err, out) => res(err ? "" : String(out))));
const output = (bin, args, e) => new Promise((res) => {
const done = (err, out) => res(err ? "" : String(out));
if (viaCmd(bin)) execFile(q(bin), args.map(q), { env: e, timeout: 8000, shell: true, windowsHide: true }, done);
else execFile(bin, args, { env: e, timeout: 8000, windowsHide: true }, done);
});
async function findClis() {
const clis = [];
const claude = findBin("claude");
if (claude && /"loggedIn":\s*true/.test(await output(claude, ["auth", "status"], env))) clis.push({ id: "claude" });
const opencode = findBin("opencode");
const opencode = findBin("opencode", false); // its question goes on the command line, so never through cmd.exe
const models = opencode ? (await output(opencode, ["models"], OPENCODE_ENV)).split("\n").map((s) => s.trim()).filter(Boolean) : [];
if (models.length) clis.push({ id: "opencode", models });
return clis;
@@ -46,7 +63,7 @@ const safeModel = (m) => (typeof m === "string" && /^[\w][\w.:/-]*$/.test(m) ? m
function runClaude(job, onText, stop) {
const model = safeModel(job.model);
const args = ["-p", "--output-format", "text", "--no-session-persistence", "--restricted", "--tools", "", "--strict-mcp-config", "--mcp-config", '{"mcpServers":{}}', "--permission-mode", "dontAsk", ...(model ? ["--model", model] : [])];
const child = spawn(findBin("claude"), args, { cwd: WORK, env, stdio: ["pipe", "pipe", "ignore"] });
const child = launch(findBin("claude"), args, { cwd: WORK, env, stdio: ["pipe", "pipe", "ignore"] });
stop(() => child.kill());
child.stdin.end(job.prompt);
let wrote = false;
@@ -57,7 +74,7 @@ function runClaude(job, onText, stop) {
function runOpencode(job, onText, stop) {
const model = safeModel(job.model);
if (!model) return Promise.resolve(false);
const child = spawn(findBin("opencode"), ["run", job.prompt, "--format", "json", "--print-logs", "--log-level", "ERROR", "-m", model], { cwd: WORK, env: OPENCODE_ENV, stdio: ["ignore", "pipe", "pipe"] });
const child = spawn(findBin("opencode", false), ["run", job.prompt, "--format", "json", "--print-logs", "--log-level", "ERROR", "-m", model], { cwd: WORK, env: OPENCODE_ENV, stdio: ["ignore", "pipe", "pipe"] });
stop(() => child.kill());
let wrote = false, buf = "";
// A rate limit or sign-in error: opencode would wait forever, so stop it and say why.
+16 -3
View File
@@ -42,7 +42,20 @@ export function ConnectAI({ initial, choice: saved, hosted, connected, failed }:
if (!res.ok) return setHelperCmd("");
const { code } = (await res.json()) as { code: string };
const site = window.location.origin;
setHelperCmd(`curl -fsSL ${site}/broke-connect.cjs | node - ${site} ${code}`);
// Windows PowerShell's own "curl" is a different command, and piping a script into node can mangle it there:
// download the file with Windows' curl.exe, then run it.
setHelperCmd(/Windows/.test(navigator.userAgent)
? `curl.exe -fsSL -o broke-connect.cjs ${site}/broke-connect.cjs; node broke-connect.cjs ${site} ${code}`
: `curl -fsSL ${site}/broke-connect.cjs | node - ${site} ${code}`);
}
// navigator.clipboard only exists on https or localhost; a server on the LAN (http://192.168.x.x) needs the old way.
function copy(text: string) {
if (navigator.clipboard) return void navigator.clipboard.writeText(text);
const t = Object.assign(document.createElement("textarea"), { value: text });
document.body.append(t);
t.select();
document.execCommand("copy");
t.remove();
}
const row = (p: Provider) => (
@@ -101,10 +114,10 @@ export function ConnectAI({ initial, choice: saved, hosted, connected, failed }:
{helperCmd === "" && <p className="text-sm text-bad" role="alert">That didn&apos;t work. Try again.</p>}
{helperCmd && (
<div className="space-y-2">
<p className="text-sm">Paste this in Terminal, then press Check again. The code in it works once, for 10 minutes.</p>
<p className="text-sm">Paste this in Terminal (PowerShell on Windows), then press Check again. The code in it works once, for 10 minutes.</p>
<code className="block text-xs break-all rounded-lg border border-line p-3">{helperCmd}</code>
<div className="flex gap-2">
<button className="btn" onClick={() => navigator.clipboard.writeText(helperCmd)}>Copy</button>
<button className="btn" onClick={() => copy(helperCmd)}>Copy</button>
<button className="btn" onClick={recheck}>Check again</button>
</div>
</div>