UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

69 lines • 4.33 kB
/** * The `machine_op` record family (senpi#6752): the local relay host hands the engine the `run` step of one device * operation and gets back its `OpOutcome`, the relay host's own result shape. None of these records is in * `RPC_METHOD_CLASS` (the digest forwarders pin stays as it is); `delegated-connection.ts` answers them only on a * launch-proven connection that declared no delegation. * * `machine_op { op, args, op_id, deadline_ms?, scope: { root, confined }, sender }`: `op_id` is opaque (the relay host * sends `JSON.stringify([sender, batch_id, op_id])`) and its cached answer is bound to `sender`; `deadline_ms` is an absolute * epoch-ms time on this machine's clock, absent for an op with no deadline; `scope` is the relay host's own scope * verdict for the op, `sender` the device it runs for. `machine_op_result` and `machine_op_cancel { op_id, sender }` * read or abort only that sender's op, and the terminal ops act only on that sender's handles: another sender's is * refused (`machine_op_conflict`, `not_owner`) unless the record carries `cross_owner: true`, which the relay host sets * only after its own admin verdict on another sender's op or handle. * `env_overlay` (optional, string values, set only by the relay host) is laid LAST over the environment of a `shell` or * `exec_command` child, over `args.env` too: the relay host tells its children its own state dir this way (#1247). * Byte payloads travel base64 in JSON (`args.bytes`, `response.bytes`); an 8 MiB write fits in one 16 MiB line. */ import { type DelegationResponse } from "../delegation-wire.ts"; declare const MACHINE_OP_COMMANDS: readonly ["machine_op", "machine_op_result", "machine_op_owner", "machine_op_health", "machine_op_cancel"]; export type MachineOpCommand = (typeof MACHINE_OP_COMMANDS)[number]; /** Advertised in `get_protocol_info` by a host that answers these records. */ export declare const MACHINE_OP_CAPABILITY = "machine_op_v1"; export declare const isMachineOpCommand: (type: unknown) => type is MachineOpCommand; export type Args = Readonly<Record<string, unknown>>; export type OpError = Readonly<{ code: string; message: string; }>; export type OpState = "applied" | "failed" | "refused" | "cancelled" | "timed_out"; /** The relay host's `OpOutcome`, answered unchanged as a `machine_op` response's `data`. */ export type OpOutcome = Readonly<{ state: OpState; response?: Readonly<Record<string, unknown>>; error?: OpError; }>; export type OpScope = Readonly<{ root: string; confined: boolean; }>; export interface MachineOpRequest { readonly op: string; readonly args: Args; readonly opId: string; readonly deadlineMs: number | undefined; readonly scope: OpScope; readonly sender: string; readonly envOverlay: Readonly<Record<string, string>>; readonly crossOwner: boolean; } /** `machine_op_result` / `machine_op_cancel`: whose op it is asking about. */ export interface OwnedOpLookup { readonly opId: string; readonly sender: string; readonly crossOwner: boolean; } export declare function machineOpRefusal(id: string | undefined, command: MachineOpCommand): DelegationResponse; export declare function machineOpMalformed(id: string | undefined, command: MachineOpCommand, problem: string): DelegationResponse; export declare function machineOpConflict(id: string | undefined, command: MachineOpCommand): DelegationResponse; /** Retryable: the engine could not run the op now (its state dir, or a host that is ending); nothing ran or is cached. */ export declare function machineOpUnavailable(id: string | undefined, detail: string): DelegationResponse; export declare function machineOpAnswer(id: string | undefined, command: MachineOpCommand, data: unknown): DelegationResponse; export declare const isArgs: (value: unknown) => value is Args; export declare const nonEmptyText: (record: Args, key: string) => string | undefined; /** The op a `machine_op_result` / `machine_op_cancel` names and who asks, or the first problem with them. */ export declare function parseOwnedOpLookup(record: Args): OwnedOpLookup | string; /** The `machine_op` record's fields, or the first problem with them. */ export declare function parseMachineOp(record: Args): MachineOpRequest | string; export {}; //# sourceMappingURL=wire.d.ts.map