Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ jobs:
holmes/tests/run-text-entry-tests.sh
holmes/tests/run-model-json-tests.sh

- name: Test sign in validation and install tracking
run: holmes/tests/run-auth-validation-tests.sh

- name: Test browser bridge reliability
run: |
holmes/tests/run-browser-bridge-extension-tests.sh
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ Holmes picks one automatically based on your Mac's memory. Change it anytime in

## ➤ Privacy

Everything stays on your Mac by default. No telemetry, no analytics, no account.
What you do stays on your Mac. Holmes requires a free account, and the only data it sends is what counts users: your email, region, macOS version, and Holmes version.

- Account: email and password sign in through Appwrite. A daily install ping sends a random install id, the Holmes and macOS versions, Mac model, region and locale. Nothing from your screen, voice or tasks is included
- Screen capture, Accessibility reads, OCR, dictation: on device, always
- Screen context during a task: sent to the local model on your Mac (or wherever you point Ollama)
- Spoken text: sent to ElevenLabs only if you add a key
Expand Down
5 changes: 3 additions & 2 deletions blueprint.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Holmes

Autonomous desktop agent for macOS. Runs entirely on your Mac, no cloud, no account.
Autonomous desktop agent for macOS. Runs on your Mac with a local model; the only cloud piece is your account.

> **Beta.** This is Holmes Local, the open source build. It uses an open weights vision model served by [Ollama](https://ollama.com). The hosted version lives in a separate, private repo.

Expand Down Expand Up @@ -73,8 +73,9 @@ Holmes picks one automatically based on your Mac's memory. Change it anytime in

## Privacy

Everything stays on your Mac by default. No telemetry, no analytics, no account.
What you do stays on your Mac. Holmes requires a free account, and the only data it sends is what counts users: your email, region, macOS version, and Holmes version.

- Account: email and password sign in through Appwrite. A daily install ping sends a random install id, the Holmes and macOS versions, Mac model, region and locale. Nothing from your screen, voice or tasks is included
- Screen capture, Accessibility reads, OCR, dictation: on device, always
- Screen context during a task: sent to the local model on your Mac (or wherever you point Ollama)
- Spoken text: sent to ElevenLabs only if you add a key
Expand Down
19 changes: 19 additions & 0 deletions holmes/cloud/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Holmes cloud

Everything Holmes sends off the Mac lives in one Appwrite Cloud project (`holmes`, region San Francisco).

| Piece | Where it runs | What it does |
|---|---|---|
| `functions/download` | https://holmes-download.appwrite.network | The website's Download buttons open this. It records the click (country, referrer, browser) in the `downloads` table, then redirects to the GitHub releases page. Crawlers are redirected but not counted. |
| `functions/track` | Called by the app through the Appwrite SDK | `install` events keep one row per Mac in `installs` (Holmes version, macOS version, Mac model, Region setting, country, first and last seen, launches). `signin` events also keep one row per account in `users`, reading the email and name from the verified Appwrite account, never from the request. |
| `dashboard` | https://holmes-analytics.appwrite.network | Admin analytics in three sections: website download tracking, accounts (sign ups and sign ins), and installs (current Macs running Holmes), each with regions, versions, and daily charts. Sign in with an emailed code; only members of the `admins` team can see data. |

## Data and access

* Database `holmes` with tables `downloads`, `installs`, `users`, and `sign_ins` (one row per sign in, so sign ins can be counted per day). Each table grants read to `team:admins` only; nothing is readable or writable by the app or the public directly. The functions write with the per execution key Appwrite provides.
* Country comes from Appwrite's country header when present, otherwise from a short lookup of the caller's IP at country.is. The app separately reports the Mac's Region setting.
* Add an admin by adding their account to the `admins` team in the Appwrite console.

## Deploying

Each folder is deployed as is. Functions use the Node 22 runtime with entrypoint `src/main.js` and build command `npm install`. The dashboard is a static site served from its folder root.
Binary file added holmes/cloud/dashboard/holmes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
765 changes: 765 additions & 0 deletions holmes/cloud/dashboard/index.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions holmes/cloud/dashboard/wordmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions holmes/cloud/functions/download/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "holmes-download-counter",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "src/main.js",
"dependencies": {
"node-appwrite": "29.0.0"
}
}
73 changes: 73 additions & 0 deletions holmes/cloud/functions/download/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Client, TablesDB, ID } from 'node-appwrite';

// Every Download button on the Holmes website points here. The click is
// recorded, then the visitor lands on the releases page to pick a version.
const RELEASES_URL = 'https://github.com/tryholmes/holmes-local/releases';

// Link previews and crawlers should still be redirected, but not counted.
const AUTOMATED_AGENT = /bot|crawl|spider|slurp|preview|facebookexternalhit|embedly|curl|wget|python|headless/i;

const clip = (value, max) => {
if (value === undefined || value === null) return null;
const text = String(value).trim().slice(0, max);
return text.length > 0 ? text : null;
};

// Appwrite only fills the country header for some requests, so fall back to
// country.is (open source) using the visitor's IP. Never waits long.
async function countryFor(headers, log) {
const known = clip(headers['x-appwrite-country-code'], 8);
if (known) return known.toUpperCase();
// The CDN puts the real visitor address in its own headers; x-forwarded-for can start with a proxy.
const ip = String(headers['fastly-client-ip'] ?? headers['x-cdn-client-ip'] ?? headers['x-real-ip']
?? headers['x-appwrite-client-ip'] ?? headers['x-forwarded-for'] ?? '').split(',')[0].trim();
if (!ip) {
log('country lookup skipped: no client address header');
return null;
}
try {
const response = await fetch(`https://api.country.is/${encodeURIComponent(ip)}`, { signal: AbortSignal.timeout(2500) });
if (!response.ok) {
log(`country lookup failed: status ${response.status}`);
return null;
}
const { country } = await response.json();
return clip(country, 8);
} catch (err) {
log(`country lookup failed: ${err.name}`);
return null;
}
}

export default async ({ req, res, log, error }) => {
const headers = req.headers ?? {};
const agent = String(headers['user-agent'] ?? '');

if (req.method === 'GET' && !AUTOMATED_AGENT.test(agent)) {
try {
const country = await countryFor(headers, log);
const client = new Client()
.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(headers['x-appwrite-key'] ?? '');

await new TablesDB(client).createRow({
databaseId: 'holmes',
tableId: 'downloads',
rowId: ID.unique(),
data: {
country,
continent: clip(headers['x-appwrite-continent-code'], 8),
referrer: clip(headers['referer'] ?? headers['referrer'], 512),
user_agent: clip(agent, 512),
source: clip(req.query?.source ?? 'website', 64),
},
});
} catch (err) {
// Never block the download because the counter failed.
error(`Could not record the download: ${err.message}`);
}
}

return res.redirect(RELEASES_URL, 302);
};
10 changes: 10 additions & 0 deletions holmes/cloud/functions/track/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "holmes-install-tracker",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "src/main.js",
"dependencies": {
"node-appwrite": "29.0.0"
}
}
139 changes: 139 additions & 0 deletions holmes/cloud/functions/track/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { Client, TablesDB, Users, ID } from 'node-appwrite';

// Holmes calls this on launch ("install") and after signing in ("signin").
// The email always comes from the verified Appwrite account, never the body.
const DATABASE_ID = 'holmes';
const INSTALL_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;

const clip = (value, max) => {
if (value === undefined || value === null) return null;
const text = String(value).trim().slice(0, max);
return text.length > 0 ? text : null;
};

// Same fallback as the download counter: Appwrite's country header when it is
// present, otherwise a short country.is lookup of the caller's IP.
async function countryFor(headers) {
const known = clip(headers['x-appwrite-country-code'], 8);
if (known) return known.toUpperCase();
const ip = String(headers['fastly-client-ip'] ?? headers['x-cdn-client-ip'] ?? headers['x-real-ip']
?? headers['x-appwrite-client-ip'] ?? headers['x-forwarded-for'] ?? '').split(',')[0].trim();
if (!ip) return null;
try {
const response = await fetch(`https://api.country.is/${encodeURIComponent(ip)}`, { signal: AbortSignal.timeout(1500) });
if (!response.ok) return null;
const { country } = await response.json();
return clip(country, 8);
} catch {
return null;
}
}

function parseBody(req) {
if (req.bodyJson && typeof req.bodyJson === 'object') return req.bodyJson;
const raw = req.bodyText ?? req.body ?? '';
if (typeof raw === 'object' && raw !== null) return raw;
return raw ? JSON.parse(raw) : {};
}

// Creates the row the first time and updates it afterwards, so first seen and
// sign up dates are kept while counters and versions move forward.
async function upsert(db, tableId, rowId, build) {
let existing = null;
try {
existing = await db.getRow({ databaseId: DATABASE_ID, tableId, rowId });
} catch (err) {
if (err.code !== 404) throw err;
}
const data = build(existing);
return existing
? db.updateRow({ databaseId: DATABASE_ID, tableId, rowId, data })
: db.createRow({ databaseId: DATABASE_ID, tableId, rowId, data });
}

export default async ({ req, res, error }) => {
if (req.method !== 'POST') return res.json({ ok: false, error: 'Send a POST request.' }, 405);

let body;
try {
body = parseBody(req);
} catch {
return res.json({ ok: false, error: 'The request body must be JSON.' }, 400);
}

const event = body.event;
if (event !== 'install' && event !== 'signin') {
return res.json({ ok: false, error: 'event must be install or signin.' }, 400);
}
const installId = String(body.install_id ?? '').toLowerCase();
if (!INSTALL_ID.test(installId)) {
return res.json({ ok: false, error: 'install_id must be a UUID.' }, 400);
}

const headers = req.headers ?? {};
const userId = clip(headers['x-appwrite-user-id'], 36);
if (event === 'signin' && !userId) {
return res.json({ ok: false, error: 'Sign in before sending a signin event.' }, 401);
}

const client = new Client()
.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(headers['x-appwrite-key'] ?? '');
const db = new TablesDB(client);
const now = new Date().toISOString();

const device = {
holmes_version: clip(body.holmes_version, 32),
macos_version: clip(body.macos_version, 32),
mac_model: clip(body.mac_model, 64),
region: clip(body.region, 8),
country: await countryFor(headers),
};

try {
await upsert(db, 'installs', installId, (existing) => ({
...device,
locale: clip(body.locale, 32),
last_seen: now,
launches: (existing?.launches ?? 0) + 1,
...(existing ? {} : { first_seen: now }),
}));

if (event === 'signin') {
const user = await new Users(client).get(userId);
let isNewAccount = false;
await upsert(db, 'users', userId, (existing) => {
isNewAccount = !existing;
return {
...device,
email: clip(user.email, 320),
name: clip(user.name, 128),
install_id: installId,
last_sign_in_at: now,
sign_ins: (existing?.sign_ins ?? 0) + 1,
...(existing ? {} : { signed_up_at: user.$createdAt ?? now }),
};
});
// One row per sign in, so the dashboard can chart sign ins per day.
await db.createRow({
databaseId: DATABASE_ID,
tableId: 'sign_ins',
rowId: ID.unique(),
data: {
user_id: userId,
new_account: isNewAccount,
region: device.region,
country: device.country,
holmes_version: device.holmes_version,
macos_version: device.macos_version,
},
});
}

return res.json({ ok: true });
} catch (err) {
error(`Could not record the ${event} event: ${err.message}`);
return res.json({ ok: false, error: 'Holmes could not record this event.' }, 500);
}
};
Loading
Loading