@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
69 lines • 4.87 kB
TypeScript
/**
* Delegated connections (senpi#5632): the engine enforces its own method-class table on a connection that speaks for
* someone else, so a forwarder (a relay host forwarding a remote viewer's records) keeps no table of its own.
*
* A connection that proved the endpoint's launch key may declare, before any record other than `get_protocol_info`
* or `authenticate`, that it acts for a principal with a set of granted classes (`declare_delegation`). A later
* declaration may only narrow it. From then on every inbound record on that connection is classified
* (`classifyRpcMethod`) and checked against the grant here, synchronously at line receipt and before anything else
* sees it: lines of one connection are not serialized, so a declaration and the record written right behind it are
* decided in order. A permitted record then runs exactly as on a local connection, schema problems included: only what
* the local path also refuses before dispatch (not an object, no string `type`) is refused here as malformed, so a
* delegated connection accepts exactly what a local one accepts.
*
* `connection_local` records follow `CONNECTION_LOCAL_REQUIREMENT`. A connection that never declares is not affected: the
* only records this module answers on it are the two methods it adds (`declare_delegation`, `classify_record`).
*
* Neither method is in `RPC_METHOD_CLASS`: adding them would change `RPC_METHOD_CLASSES_DIGEST`, and a forwarder that
* pins the digest would then refuse every record (senpi#5632 rollout split, S1a).
*
* senpi#4249 R-1b: on a delegated connection a private presenter record (`mcp_form_*`, `mcp_presenter_*`) is decided
* by `delegated-presenter-records.ts` and always answered in the private reply shape; `mcp_presenter_control_info`
* is answered only on a launch-proven connection that is not delegated.
*
* senpi#6752: the `machine_op` records (`machine-op/wire.ts`) are, like these two, outside `RPC_METHOD_CLASS`. They run
* device operations for the local relay host, so they are answered only on a launch-proven connection that has not
* declared a delegation; any other connection gets `machine_op_not_authorized` and nothing runs.
*/
import type { DelegatedConnectionView } from "./connection-roles.ts";
import { type DelegationDescriptor, type DelegationRecord } from "./delegation-record.ts";
import { type DelegationResponse, type DelegationVerdict } from "./delegation-wire.ts";
export type { DelegationRefusal, DelegationResponse, DelegationVerdict } from "./delegation-wire.ts";
/**
* How a connection's transport proves the launch key: `proven` at admission (the Windows socket secret), `in_band`
* when the public-key filter in front of it delivers `RPC_LAUNCH_PROOF_RECORD` after a successful `authenticate`
* (the bare host's own filter, or the supervisor's for a relayed connection; both refuse that record from a client).
*/
export type LaunchProofSource = "proven" | "in_band";
/** Per-connection delegation state of one host; keyed by the connection id the writer runs each line under. */
export declare class ConnectionDelegations {
private readonly connections;
private readonly incarnationMax;
/** Ends a socket whose incarnations are exhausted (omo-relay-daemon#307); the socket host wires it. */
endConnection: ((id: string) => void) | undefined;
constructor(options?: {
readonly incarnationMax?: number;
readonly endConnection?: (id: string) => void;
});
admit(id: string, proofSource: LaunchProofSource | undefined): void;
/**
* Physical close (omo-relay-daemon#307): a delegated record's current word reads retired from now on, and the record
* stays, so a record still in flight never reads "not delegated". Only `forget`, once the socket is gone, deletes it.
*/
close(id: string): void;
forget(id: string): void;
recordOf(id: string): DelegationRecord | undefined;
/** What a line of connection `id` captures before its first await; undefined for a connection that never declared. */
descriptorOf(id: string): DelegationDescriptor | undefined;
viewOf(id: string): DelegatedConnectionView | undefined;
/** After a line's answer is enqueued: ends the socket whose `detach_connection` exhausted its incarnations. */
lineAnswered(id: string | undefined): void;
isDelegated(id: string | undefined): boolean;
/** The answer to a line that is not JSON: today's parse error, typed `malformed` on a delegated connection. */
unparsable(id: string | undefined, error: string): DelegationResponse;
/** Decides one parsed inbound record of connection `id`. Synchronous: it runs before any await of the line. */
inspect(id: string | undefined, record: unknown): DelegationVerdict;
private state;
private declaration;
}
//# sourceMappingURL=delegated-connection.d.ts.map