Files
hermeven/apps/even-client/scripts/write-manifest.mjs
T
DanandClaude Fable 5.2 e1c02d5266 Address Cody review round 2: all ten findings (CODY-001 to CODY-010)
CODY-001 Bridge URL must be HTTPS (HTTP only to loopback), in the client and
         in manifest generation.
CODY-002 Even host calls stay serialised until the SDK call really settles;
         a microphone start that completes after its timeout is followed by
         a stop.
CODY-003 Request id is stored before the first submit and cleared only on a
         definitive answer; lost replies are treated as ambiguous and
         reconciled under the same id; HUD no longer claims "not sent".
CODY-004 Revoking a device cancels its in-flight turns, aborts
         transcription and asks Hermes to stop, from HTTP and CLI paths.
CODY-005 Speech model pinned to a commit with per-file SHA-256; fetched and
         verified ahead of time; verified on every load; never downloaded
         at run time; no unpinned configuration.
CODY-006 State directory 0700, database/WAL/SHM 0600 regardless of umask.
CODY-007 credential_expired handled like unauthorized on every path.
CODY-008 Approval wait start and paused agent deadline persisted and
         restored across restarts (schema v2).
CODY-009 Exactly one conversation create per epoch, sent in sequence, with
         stale results dropped before persistence.
CODY-010 Wrong pairing guesses no longer consume the outstanding code;
         failures are indistinguishable.

Checks: typecheck clean; npm test 182 passed; client build ok;
test:real-stt 11 passed (including with no network); test:real-hermes 9
passed; test:simulator 6 passed; git diff --check clean.

Not reviewed. No physical-device, droplet or production evidence.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-18 19:49:14 -08:00

44 lines
2.1 KiB
JavaScript

// Writes dist-manifest/app.json from app.template.json.
//
// Even Hub enforces a per-app network whitelist of exact origins, so the bridge
// origin has to be in the packaged manifest. It is supplied at build time and is
// never committed: no deployment hostname lives in this repository.
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const here = dirname(fileURLToPath(import.meta.url));
const raw = process.env.HERMEVEN_BRIDGE_ORIGIN ?? '';
if (!raw) {
console.warn('[manifest] HERMEVEN_BRIDGE_ORIGIN is not set: skipping app.json. Set it before `npm run pack`.');
process.exit(0);
}
let origin;
try {
origin = new URL(raw).origin;
} catch {
console.error('[manifest] HERMEVEN_BRIDGE_ORIGIN is not a URL.');
process.exit(1);
}
if (origin !== raw) {
console.error(`[manifest] HERMEVEN_BRIDGE_ORIGIN must be a bare origin (scheme://host[:port]), got a path or trailing slash.`);
process.exit(1);
}
// Same rule as the app enforces at run time (src/net/bridgeClient.ts): HTTPS, or HTTP to
// loopback for the simulator. A packaged app must never be allowed to send the device
// credential and recordings over plain HTTP to a LAN or public host.
const { protocol, hostname } = new URL(origin);
const loopback = hostname === 'localhost' || hostname === '[::1]' || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(hostname);
if (protocol !== 'https:' && !(protocol === 'http:' && loopback)) {
console.error('[manifest] HERMEVEN_BRIDGE_ORIGIN must be https:// (plain http is accepted only for loopback).');
process.exit(1);
}
if (protocol === 'http:') {
console.warn('[manifest] Loopback HTTP origin: this build is for the simulator only and cannot work on a phone.');
}
const template = readFileSync(resolve(here, '../app.template.json'), 'utf8');
const out = process.env.HERMEVEN_MANIFEST_OUT ?? resolve(here, '../dist-manifest/app.json');
mkdirSync(dirname(out), { recursive: true });
writeFileSync(out, template.replace('__HERMEVEN_BRIDGE_ORIGIN__', origin));
console.log(`[manifest] wrote ${out}`);