@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
81 lines • 4.87 kB
TypeScript
import type { AccountPrincipal, PresenterAccountAuthority } from "./mcp-presenter-account.ts";
import type { Grant } from "./mcp-presenter-grants.ts";
import type { PresenterHostSurface } from "./mcp-presenter-host-surface.ts";
import type { SealedAnswer, SealedAnswerReply, SecretInputOutcome } from "./secret-input-requests.ts";
import { SecretHostTokens } from "./secret-host-token.ts";
import { type SealedAnswerFrame } from "./secret-sealed-answers.ts";
/** A grant that may answer one request on the sealed route; opaque outside this module. */
export type SealedHolder = Grant;
export interface SealedSecretOffer {
readonly uiRequestId: string;
readonly title: string;
readonly placeholder: string | undefined;
readonly deadlineAtMs: number;
readonly hpkePk: string;
}
/** What the secret route reads from the presenter control (D11 secret phase 5.1, 5.2). */
export interface SealedSecretSource {
/** The sealed holders of the session now: the snapshot a request keeps for its whole life. */
holders(sessionId: string): ReadonlySet<SealedHolder>;
/** The holder's grant is still current (5.2 `available`). */
current(holder: SealedHolder): boolean;
connectionOf(holder: SealedHolder): string;
/** Builds `B`, signs it with the host key and sends each holder `mcp_presenter_secret_request` (4.3). */
offer(sessionId: string, holders: ReadonlySet<SealedHolder>, offer: SealedSecretOffer): void;
/** The request settled or was forgotten: it takes no further host token refreshes. */
withdraw(uiRequestId: string): void;
/** A settled request takes no more token records, but stays answerable for `replay` until withdrawn. */
retire(uiRequestId: string): void;
/** Fires whenever a grant on a binding the source has read is acquired or revoked. */
onChange(listener: () => void): () => void;
/** 5.1 conditions 1-5 now: re-checked when an answer arrives (7.1 step 2) and at the claim (step 6). */
eligible(holder: SealedHolder): boolean;
/** The holder's account principal id while it has not lapsed. */
principalOf(holder: SealedHolder): string | undefined;
/** 7.1 steps 4 and 5 for a holder's answer; the latch runs steps 3 and 6 on the result. */
answer(holder: SealedHolder, frame: SealedAnswerFrame): Promise<SealedAnswer | SealedAnswerReply>;
/** Every holder gets the value-free `mcp_presenter_secret_settled`; all but `winner` with `elsewhere: true`. */
settle(holders: ReadonlySet<SealedHolder>, uiRequestId: string, outcome: SecretInputOutcome, winnerGrant?: string): void;
/** The host incarnation's step-up `jti` cache (6.5). */
admitJti(jti: string, exp: number): boolean;
}
/** The control's principals, keyed by id; only an account principal can hold a sealed grant. */
type PrincipalsById = ReadonlyMap<string, AccountPrincipal | {
readonly kind: "inherited";
}>;
/** The control's sealed holders: eligibility, signed requests and token refreshes, all synchronous. */
export declare class SealedSecretHolders implements SealedSecretSource {
readonly tokens: SecretHostTokens;
private readonly host;
private readonly authority;
private readonly account;
private readonly principals;
private readonly offered;
private readonly listeners;
/** Step-up `jti`s of this host incarnation (6.5): kept until `exp + 60`, refusing rather than evicting at 4096. */
private readonly jtis;
private readonly watched;
private readonly detach;
private readonly unsubscribe;
/** `undefined` when the authority cannot mint host tokens and verify step-up tokens: no sealed route at all. */
static create(host: PresenterHostSurface, account: PresenterAccountAuthority | undefined, principals: PrincipalsById): SealedSecretHolders | undefined;
private constructor();
holders(sessionId: string): ReadonlySet<SealedHolder>;
eligible(holder: SealedHolder): boolean;
principalOf(holder: SealedHolder): string | undefined;
answer(holder: SealedHolder, frame: SealedAnswerFrame): Promise<SealedAnswer | SealedAnswerReply>;
/** The host incarnation's step-up `jti` cache (6.5), for in-process latches. */
admitJti(jti: string, exp: number): boolean;
settle(holders: ReadonlySet<SealedHolder>, uiRequestId: string, outcome: SecretInputOutcome, winnerGrant?: string): void;
current(holder: SealedHolder): boolean;
connectionOf(holder: SealedHolder): string;
offer(sessionId: string, holders: ReadonlySet<SealedHolder>, offer: SealedSecretOffer): void;
withdraw(uiRequestId: string): void;
retire(uiRequestId: string): void;
onChange(listener: () => void): () => void;
dispose(): void;
/** 5.1 condition 4: the grant's account principal when it has not lapsed. */
private unlapsed;
}
export {};
//# sourceMappingURL=secret-sealed-holders.d.ts.map