@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
35 lines • 1.87 kB
TypeScript
/**
* `set_session_context`: a patch layer over the context a session was opened with.
*
* The open-time context stays frozen (it is what the session's extensions read as `pi.sessionContext`);
* patches live in a separate overlay the host republishes on `list_sessions { include_workers: true }` and
* on `session_status` for subscribers that asked for context. A `null` value removes the key from the
* published view, including a key the open supplied. The host's own identity keys can never be patched.
*/
import type { SessionContext } from "../../core/extensions/types.ts";
import type { PublishedSessionContext } from "./session-status.ts";
export type SessionContextValue = string | number | boolean;
export type SessionContextOverlay = Readonly<Record<string, SessionContextValue | null>>;
export declare const SESSION_CONTEXT_PATCH_LIMITS: {
readonly keyPattern: RegExp;
readonly valueChars: 256;
readonly overlayBytes: 4096;
};
/**
* Keys a client may never patch: the host's own stamps, and the lineage labels a
* `childrenOf` subscription matches on. Lineage belongs to the frozen open-time context;
* letting a patch rewrite it would let any attached client re-parent a session in every
* supervisor's `childrenOf` view without the subscribers ever being told.
*/
export declare const RESERVED_SESSION_CONTEXT_KEYS: ReadonlySet<string>;
export interface ContextPatchRefusal {
readonly reason: string;
readonly action: string;
}
export declare function applyContextPatch(overlay: SessionContextOverlay | undefined, patch: unknown): {
readonly overlay: SessionContextOverlay;
} | {
readonly refusal: ContextPatchRefusal;
};
export declare function publishedSessionContext(base: SessionContext, overlay: SessionContextOverlay | undefined): PublishedSessionContext;
//# sourceMappingURL=session-context-patch.d.ts.map