Skip to content

feat(desktop): sign free Auto requests and relay them only for live tasks - #5195

Merged
reachjalil merged 85 commits into
devfrom
feature/desktop-auto-access
Sep 30, 2026
Merged

reachjalil merged 85 commits into
devfrom
feature/desktop-auto-access

Conversation

@reachjalil

@reachjalil reachjalil commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

What is this about?

The desktop signs free Auto requests and relays them while a task the person started is running.

What problem does it solve?

Signing in must use the member allowance, changing accounts must end access for the previous account, and unrelated local callers must not spend it.

What was the situation before?

Guest Auto did not use a member allowance, and its relay accepted callers without a task activation.

How is this implemented?

  • Sign proofs with a keychain Ed25519 key and a salted machine identity; stable builds derive a release tag from DESKTOP_FREE_RELEASE_KEY.
  • Separate local relay settings, activation, proof of work, responses, and service handling in apps/server/src/free-auto/.
  • Activate the relay for an Auto send, with idle and maximum lifetimes; reject inactive requests with auto_not_activated.
  • Cache disabled guest access and respect Retry-After to avoid unnecessary proof work.
  • Allow loopback Den during development and compare current member credentials directly.

What else changed?

The outbound access manifest and guide include the inference host. Release signing prints a fingerprint, and server build metadata includes the current plugin list.

Release note

Desktop Auto uses your signed-in allowance and only allows requests from an active task.

Evidence

No E2E; relay and signer unit tests prove unrestricted local access → rejection until an Auto send activates the relay.

@vercel

vercel Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Skipped Skipped Sep 30, 2026 8:21pm UTC
openwork-den Skipped Skipped Sep 30, 2026 8:21pm UTC
openwork-diagnostics Skipped Skipped Sep 30, 2026 8:21pm UTC
openwork-landing Skipped Skipped Sep 30, 2026 8:21pm UTC

@vercel
vercel Bot temporarily deployed to Preview – openwork-app September 21, 2026 18:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing September 21, 2026 18:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-den September 21, 2026 18:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics September 21, 2026 18:48 Inactive
@reachjalil
reachjalil added this pull request to stack #5197 September 21, 2026 18:48
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3e210f3
Status: ✅  Deploy successful!
Preview URL: https://944354b8.openwork.pages.dev
Branch Preview URL: https://feature-desktop-auto-access.openwork.pages.dev

View logs

reachjalil and others added 19 commits September 23, 2026 16:15
…SHA-256

Free credentials and identities were stored as plain SHA-256 digests, which
code scanning flags as weak hashing of sensitive data. Den and the Gateway now
share one domain-separated helper: identities use a keyed SHA-256 tag and
free credentials use a WebCrypto HMAC, matching the Gateway bearer-key store.
Free access is off by default and unreleased, so no stored tags need migrating.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BMeBni56bB19LwDFqNsQEw
… OpenAI key

Treat signed-out, signed-in and subscribed users as three separate systems:

- Signed-out desktops keep dedicated anonymous_inference_* tables with no
  organization, member, user or key columns. Their allowance is keyed on a
  machine id carried in the signed proof, so reinstalling does not reset it.
- Signed-in members of unsubscribed organizations use their regular
  OpenWork Models (ow_inf_) key on /api/v1. The proxy serves them only Auto,
  within a weekly per-person allowance held in inference_free_* tables.
  The separate ow_auto_ credential and inference_free_keys are removed.
- Subscribed organizations keep the existing paid path unchanged.

Free requests no longer touch OpenRouter. Both free paths call OpenAI Chat
Completions with a single INFERENCE_FREE_OPENAI_API_KEY; revoking that key is
the kill switch, and its OpenAI usage shows the running cost. Allowance cost
is computed from OpenAI token counts, and requests OpenAI refuses (401, 403,
429) release their hold instead of being charged.
- Derive a deterministic machine id from the OS identifier (IOPlatformUUID,
  MachineGuid or /etc/machine-id), salted and hashed on the device, and carry
  it in every signed proof. The guest allowance now follows the machine, so a
  reinstall or cleared app data does not reset it. The session body is empty.
- Signed-in members receive their OpenWork Models (ow_inf_) key and reach
  Auto on the regular /api/v1 routes.
- The engine talks to the local relay through @ai-sdk/openai-compatible
  instead of the OpenRouter adapter.
Guests may use free Auto only from the newest three stable desktop releases,
with every release supported for at least 14 days after it ships. Each stable
release derives its own secret from DESKTOP_FREE_RELEASE_KEY at build time and
tags its signed proof with it (proof v3); the gateway derives the same secret
from the version the proof claims, so a secret lifted from one release cannot
be presented as another and expires with its release.

Knobs: DESKTOP_FREE_SUPPORTED_RELEASE_COUNT, DESKTOP_FREE_SUPPORTED_RELEASE_MIN_DAYS,
DESKTOP_FREE_BLOCKED_RELEASES, DESKTOP_FREE_RELEASE_KEY_PREVIOUS (rotation
overlap), DESKTOP_FREE_FIRST_RELEASE_TAG_VERSION (v2 cutover) and a dev-mode
DESKTOP_FREE_DEV_RELEASE_SECRET for unversioned developer builds. The release
list comes from GitHub and is served stale for up to a day if GitHub fails.
Signed-in members are unaffected.
…y from user sends

Each stable release derives its free Auto secret from DESKTOP_FREE_RELEASE_KEY
in CI (HMAC over the version) and ships it inside the Electron main bundle in
a split, masked form; every signed proof now carries a release tag (proof v3)
so the gateway can hold guests to its release support window. Developer builds
use OPENWORK_DEV_FREE_RELEASE_SECRET in dev mode; untagged builds keep
signing v2. The desktop now reports its real app version instead of
Electron's in development.

The local relay forwards the engine's model calls only while a task the user
started from the app with Auto selected is live: a send opens a window that
idles out after 15 minutes without completed calls and closes after two
hours, on session end, and whenever the engine credential rotates. Engine
calls that name a session must name one the user started.
Guests can assert any machine id, so make a fresh one worth little instead of
trying to prove it: the weekly device allowance ramps with the machine's age
(ANONYMOUS_INSTALL_RAMP, default $0.10 on day 0, $0.25 from day 1, $0.50 from
day 3, full from day 7; a bucket's limit only ever rises within its week),
each IP may introduce only a few never-seen machines a day
(ANONYMOUS_IP_NEW_IDENTITIES_PER_DAY, default 5), and minting a guest session
costs a small proof of work bound to the proof's single-use nonce
(ANONYMOUS_SESSION_POW_BITS, default 20). First sightings live in the guest-only
anonymous_inference_identities table.
The relay picks the proof nonce itself, solves the gateway's proof of work for
that nonce (default 20 bits, OPENWORK_FREE_SESSION_POW_BITS for developer
builds) and asks the signer to sign with it, so the work is bound to a
single-use proof. If the gateway demands more bits than the build assumed, the
relay redoes the work once up to the supported maximum. The signer accepts a
caller-supplied nonce and refuses malformed ones.
The relay starts the proof of work on a worker thread as soon as it
initialises, so the first message finds it done, and begins the next one right
after each mint. Bun (the test runner) falls back to an in-process solve; a
cancelled job never falls back. Default work rises to 23 bits.
…and tighten the proof of work

The device allowance now ramps on active minutes rather than wall-clock age:
every signed guest request is a heartbeat, and the time since the previous one
is credited only when the gap is short enough to mean the app stayed open
(ANONYMOUS_ACTIVITY_MAX_GAP_MS, default 3 minutes). Default tiers: $0.10, then
$0.20 after 10 active minutes, $0.50 after 20, the full $1 after 30.

The session proof of work becomes eight 20-bit puzzles instead of one 23-bit
puzzle, so the time to solve clusters around one to three seconds instead of
occasionally taking many times longer; verification stays eight hashes.
… proof of work

While the app is open and signed out, the relay sends a signed status check
every minute (OPENWORK_FREE_HEARTBEAT_MS) so the gateway can credit time with
the app open toward the guest allowance. The background solver now works the
gateway's multi-round puzzle (rounds and bits both honoured on a
session_pow_required reply).
# Conflicts:
#	ee/packages/den-db/drizzle/meta/0115_snapshot.json
#	ee/packages/den-db/drizzle/meta/_journal.json
#	packages/docs/openapi.json
benjaminshafii
benjaminshafii previously approved these changes Sep 30, 2026
@reachjalil
reachjalil dismissed benjaminshafii’s stale review September 30, 2026 20:15

The merge-base changed after approval.

benjaminshafii
benjaminshafii previously approved these changes Sep 30, 2026
@mintlify

mintlify Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
differentai 🟢 Ready View Preview Sep 30, 2026, 8:21 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

This branch was successfully deployed

1 active and 4 inactive deployments
staging - packages/docs — 9fc2eac6 Deployed Sep 30, 2026 by mintlify[bot]
Preview – openwork-app — 9fc2eac6 Deployed Sep 30, 2026 by vercel[bot]
Preview – openwork-diagnostics — 9fc2eac6 Deployed Sep 30, 2026 by vercel[bot]
Preview – openwork-den — 9fc2eac6 Deployed Sep 30, 2026 by vercel[bot]
Preview – openwork-landing — 9fc2eac6 Deployed Sep 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants