/** * device-peer-work.ts, the wire shape of one device capability request. * * A capability request rides the existing distributed-runtime peer transport as * work of type `device.capability`: the host enqueues it, the node pulls it, * runs it, and completes it. This module is the ONE definition of what goes on * the wire in each direction, so a host and a node written independently, in * different languages, on different platforms, agree without reading each * other's code. That is what makes a native node a drop-in peer rather than a * second implementation to keep in sync. * * Runtime-neutral: importable by a browser node and by the daemon alike. */ import { type DeviceCapabilityId } from './device-capability-contract.js'; /** Work type this contract uses on the peer transport. */ export declare const DEVICE_CAPABILITY_WORK_TYPE = "device.capability"; /** The request payload the host enqueues. */ export interface DeviceCapabilityWorkRequest { readonly contractVersion: number; readonly capabilityId: DeviceCapabilityId; /** Free-form per-capability inputs, validated against the descriptor's fields. */ readonly input: Readonly>; /** Stated reason, shown to the person on the device when it prompts. */ readonly reason: string; /** Host-side deadline in ms; a node that cannot finish in time should fail fast. */ readonly timeoutMs: number; } /** The result payload the node returns on completion. */ export interface DeviceCapabilityWorkResult { readonly contractVersion: number; readonly capabilityId: DeviceCapabilityId; readonly ok: boolean; readonly error?: string | undefined; /** Structured result (a location fix, clipboard text, a command ack). */ readonly data?: unknown | undefined; /** Base64 payload for a capture. Kept out of `data` so a host can stream it. */ readonly mediaBase64?: string | undefined; readonly mediaType?: string | undefined; } /** Why a request payload was rejected before it reached the device. */ export interface DeviceCapabilityInputProblem { readonly field: string; readonly problem: 'missing' | 'wrong-type'; readonly expected: string; } /** * Validate a request's inputs against the capability descriptor's declared * fields. Runs on the host before dispatch AND on the node before it acts, so * neither side has to trust the other's validation. */ export declare function validateDeviceCapabilityInput(capabilityId: string, input: Readonly>): readonly DeviceCapabilityInputProblem[]; /** Build the request payload for the peer work queue. */ export declare function buildDeviceCapabilityWorkRequest(input: { readonly capabilityId: DeviceCapabilityId; readonly input: Readonly>; readonly reason: string; readonly timeoutMs: number; readonly contractVersion: number; }): DeviceCapabilityWorkRequest; /** Parse a work payload a node pulled, or null when it is not a device request. */ export declare function parseDeviceCapabilityWorkRequest(payload: unknown): DeviceCapabilityWorkRequest | null; /** Parse a node's completion payload, or null when it is not one. */ export declare function parseDeviceCapabilityWorkResult(payload: unknown): DeviceCapabilityWorkResult | null; /** * Encode capture bytes the way this contract carries them, the exact inverse * of `decodeDeviceCapabilityMedia`. * * The node encodes a capture to reach the host; the host encodes the same bytes * again to reach a surface that is not on its disk (devices.artifacts.read). * One definition of "base64 of a capture" means those two directions cannot * drift apart, and it stays runtime-neutral: `btoa` exists in a browser node * and in the daemon alike, where `Buffer` does not. */ export declare function encodeDeviceCapabilityMedia(bytes: Uint8Array): string; /** Decode a completion's media payload into bytes, or null when there is none. */ export declare function decodeDeviceCapabilityMedia(result: DeviceCapabilityWorkResult): Uint8Array | null; //# sourceMappingURL=device-peer-work.d.ts.map