@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
45 lines • 2.77 kB
TypeScript
import { type McpMrtrPresentation } from "../../../mcp-mrtr-presentations.ts";
import type { ExtensionUIContext } from "../../types.ts";
import type { ResolvedMcpConfig } from "./config-schema.ts";
import { type McpRequestOrigin } from "./request-origin.ts";
import type { McpConnectionEntry, McpSessionContext } from "./service-types.ts";
type McpScopeUi = Pick<ExtensionUIContext, "input" | "select" | "confirm"> & Partial<Pick<ExtensionUIContext, "notify">>;
type McpCaller = {
readonly sessionManager?: object;
};
/**
* One execution scope a binding serves beside its own context (brain/hand S16c): a runtime that serves several
* scopes keeps each one's MCP forms, presentation and control inventory instead of the latest scope taking them.
*/
interface McpBindingScope {
readonly sessionId: string | undefined;
presentation: McpMrtrPresentation | undefined;
readonly ui: () => McpScopeUi | undefined;
}
export interface McpScopedBinding {
readonly lifetime: AbortController;
presentation?: McpMrtrPresentation;
readonly context: McpSessionContext;
readonly config: ResolvedMcpConfig;
/** Further scopes of one runtime this binding also serves, by session manager; empty for one session. */
readonly scopes: Map<object, McpBindingScope>;
/** Its own context's elicitation UI, so a scoped call of that context opens its form there and not in a peer's. */
readonly ui: () => McpScopeUi | undefined;
}
/** A context's elicitation UI, read per request: a host that offers none answers no form (`hasUI` false). */
export declare function elicitationUiOf(ctx: McpSessionContext): () => McpScopeUi | undefined;
/**
* A further scope joins the binding and returns its session id; the binding's own context, or a context with no
* session manager, joins nothing.
*/
export declare function joinBindingScope(binding: McpScopedBinding, ctx: McpSessionContext): {
sessionId?: string;
} | undefined;
/** A joined scope presents its own forms; the binding's own context keeps the binding's presentation. */
export declare function bindScopePresentation(binding: McpScopedBinding, presentation: McpMrtrPresentation, sessionManager: object | undefined): void;
export declare function bindingServesScope(binding: McpScopedBinding, sessionManager: object | undefined): boolean;
export declare function bindingServesScopeSession(binding: McpScopedBinding, sessionId: string): boolean;
/** A request's origin for `caller`: its scope's presentation and form UI, under the binding's own lifetime. */
export declare function scopedRequestOrigin(binding: McpScopedBinding, entry: McpConnectionEntry, caller: McpCaller | undefined, isCurrent: () => boolean): McpRequestOrigin;
export {};
//# sourceMappingURL=service-scopes.d.ts.map