@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
42 lines • 2.25 kB
TypeScript
import { type Declaration, type Principal } from "./delegation-declaration.ts";
import type { RpcMethodClass } from "./method-classes.ts";
/** What a line captures before its first await and what `bind`/`command` carry to a worker. */
export interface DelegationDescriptor {
readonly principal: Principal;
readonly mode: "legacy" | "host";
/** Host mode: this incarnation's number, also stamped into `authority[1]`. */
readonly incarnation?: number;
/** Host mode: this incarnation's word at index 0. */
readonly authority?: SharedArrayBuffer;
}
export interface DelegationIncarnation {
readonly incarnation: number;
readonly authority: SharedArrayBuffer;
}
export interface DelegationRecord {
readonly principal: Principal;
readonly mode: "legacy" | "host";
granted: ReadonlySet<RpcMethodClass>;
current: DelegationIncarnation | undefined;
lastIncarnation: number;
closed: boolean;
}
export declare function createRecord(principal: Principal, granted: ReadonlySet<RpcMethodClass>, roles: ReadonlySet<string> | undefined): DelegationRecord;
/**
* A later declaration on an existing record: the principal stays, `granted` and `roles` only narrow (`delegation_fixed`
* otherwise; `roles` on a legacy record too). Omitted `roles` keeps the mask. False when it must be refused.
*/
export declare function narrowRecord(record: DelegationRecord, parsed: Declaration): boolean;
/** The `data.roles` echo of a host-mode declaration reply: the mask after it, in canonical order. */
export declare function echoedRoles(record: DelegationRecord): {
roles?: string[];
};
export declare function descriptorOf(record: DelegationRecord): DelegationDescriptor;
/**
* `detach_connection` on a host-mode record: retire k, then issue k+1 with k's mask at epoch 1. Returns false when the
* counter is exhausted: k stays retired, the record is closed, and the caller ends the socket.
*/
export declare function rotateIncarnation(record: DelegationRecord, max?: number): boolean;
/** Physical close: the current word reads retired from now on; the record stays until the socket is forgotten. */
export declare function closeRecord(record: DelegationRecord): void;
//# sourceMappingURL=delegation-record.d.ts.map