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>
98 lines
3.5 KiB
TypeScript
98 lines
3.5 KiB
TypeScript
import { ConfigError, loadConfig } from './config.ts';
|
|
import { openDb } from './db.ts';
|
|
import { Devices } from './devices.ts';
|
|
import { loadEnvFile } from './env.ts';
|
|
import { fetchModel, verifyModel } from './stt/modelStore.mjs';
|
|
|
|
/**
|
|
* Operator CLI. It talks to the SQLite file directly, so there is no admin
|
|
* surface on the network: whoever can run this on the bridge host is the owner.
|
|
*/
|
|
function usage(): never {
|
|
console.error(
|
|
[
|
|
'Usage: npm run bridge:cli -- <command>',
|
|
'',
|
|
' pair Print a single-use pairing code for one new device',
|
|
' devices List paired devices',
|
|
' revoke <device-id> Revoke a device credential immediately',
|
|
' fetch-model Download the pinned speech model and verify every file',
|
|
' verify-model Check the speech model on disk against its pinned hashes',
|
|
].join('\n'),
|
|
);
|
|
process.exit(2);
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
loadEnvFile();
|
|
const config = loadConfig();
|
|
const [command, arg] = process.argv.slice(2);
|
|
|
|
// Model commands run at deploy time, possibly as a different user from the service, and
|
|
// must not create or touch the database.
|
|
if (command === 'fetch-model' || command === 'verify-model') {
|
|
const manifest = config.stt.manifest;
|
|
if (!manifest) {
|
|
console.log('STT_PROVIDER is not "builtin": there is no speech model to manage.');
|
|
return;
|
|
}
|
|
console.log(`${manifest.model} at ${manifest.revision} (${manifest.dtype}) in ${config.stt.modelDir}`);
|
|
if (command === 'fetch-model') {
|
|
const result = await fetchModel(config.stt.modelDir, manifest, {
|
|
onFile: (path, bytes) => console.log(` fetched ${path} (${bytes} bytes)`),
|
|
});
|
|
console.log(`Verified ${result.verified} file(s); downloaded ${result.downloaded}.`);
|
|
return;
|
|
}
|
|
const check = await verifyModel(config.stt.modelDir, manifest);
|
|
if (!check.ok) {
|
|
console.error(`Verification FAILED: ${check.reason} ${check.path}`);
|
|
process.exit(1);
|
|
}
|
|
console.log(`Verified ${manifest.files.length} file(s).`);
|
|
return;
|
|
}
|
|
|
|
const db = openDb(config.dbPath);
|
|
const devices = new Devices(db, config);
|
|
|
|
switch (command) {
|
|
case 'pair': {
|
|
const { code, expiresAt } = devices.createPairingCode();
|
|
const minutes = Math.round((expiresAt - Date.now()) / 60_000);
|
|
console.log(`Pairing code: ${code}`);
|
|
console.log(`Valid for ${minutes} minute(s), one device, one use. Any earlier unused code is now void.`);
|
|
break;
|
|
}
|
|
case 'devices': {
|
|
const rows = devices.list();
|
|
if (!rows.length) console.log('No devices paired.');
|
|
for (const d of rows) {
|
|
const status = d.revoked_at
|
|
? 'revoked'
|
|
: d.pairing_expires_at <= Date.now()
|
|
? 'pairing expired'
|
|
: d.token_expires_at <= Date.now()
|
|
? 'token expired'
|
|
: 'active';
|
|
const seen = d.last_seen_at ? new Date(d.last_seen_at).toISOString() : 'never';
|
|
console.log(`${d.id} ${status.padEnd(15)} last seen ${seen} ${d.name}`);
|
|
}
|
|
break;
|
|
}
|
|
case 'revoke': {
|
|
if (!arg) usage();
|
|
console.log(devices.revoke(arg) ? `Revoked ${arg}.` : `No active device ${arg}.`);
|
|
break;
|
|
}
|
|
default:
|
|
usage();
|
|
}
|
|
db.close();
|
|
}
|
|
|
|
main().catch((err: unknown) => {
|
|
console.error(err instanceof ConfigError ? `Configuration error: ${err.message}` : err instanceof Error ? err.message : err);
|
|
process.exit(1);
|
|
});
|