@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
46 lines (45 loc) • 2.23 kB
TypeScript
import type { IncomingMessage } from "node:http";
import { type Json } from "./protocol.js";
/**
* Owner proof for the actions an agent must not take for itself: release
* authority, raising a pane's permission mode, making or stopping the
* conductor, registering for this computer's alerts, linking computers,
* controlling the Mac's windows (GET and POST), and closing an owner inbox
* row.
*
* Agents run as the same Unix user as the Hook, so no header or local file can
* tell the owner's phone from an agent's `nc -U hook.sock`. The phone holds its
* paired SSH key's private half, so it signs these requests with it (the same
* key that already signs approval rules). Once the Hook has seen one valid
* signature, unsigned requests to these routes are refused: older apps keep
* working until the phone starts signing, and after that an agent cannot. The
* Strict owner routes require a signature from their first request and never
* start that migration for the others.
*/
export declare const OWNER_PROOF_HEADER = "x-phren-owner-proof";
export declare const ownerProofRoute: (method: string | undefined, pathname: string) => boolean;
export declare const bodyDigest: (raw: Buffer) => string;
/** Paired phone keys (iPhone and Android) on the restricted dispatch command. Scoped, computer and plain keys cannot sign. */
export declare function deviceKeys(authorizedKeys: string): Set<string>;
export interface OwnerProofOptions {
root?: string;
keys?: () => Promise<Set<string>>;
now?: () => number;
}
export declare class OwnerProof {
private options;
private seen;
private required?;
constructor(options?: OwnerProofOptions);
private get root();
private get file();
private now;
private keys;
/** Whether a phone has signed before, so unsigned owner actions are refused. */
isRequired(): Promise<boolean>;
/**
* Throws 403 unless an owner-only request may go ahead. Requests that carry
* an agent or peer origin are left to the route, which refuses them anyway.
*/
check(request: Pick<IncomingMessage, "headers" | "method">, pathname: string, data: Json, digest: string | undefined, confirm?: () => Promise<void>): Promise<void>;
}