@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
89 lines • 5.68 kB
TypeScript
import type { ToolRuntimeKind } from "../../cli/tool-runtime.ts";
import type { CreateAgentSessionRuntimeFactory } from "../../core/agent-session-runtime.ts";
import type { SessionContext } from "../../core/extensions/types.ts";
import type { CliRuntimeConfiguration } from "../../main.ts";
import { type HostCoreHooks } from "./host-core-gate.ts";
import { type HostIdleOverrides } from "./host-idle-policy.ts";
import { type HostWatchdogConfig } from "./host-watchdog.ts";
import { MachineOpHandler } from "./machine-op/handler.ts";
import { type RpcBindingFactory, SessionCommandRouter } from "./session-command-router.ts";
import { SessionEventWriter } from "./session-event-writer.ts";
import type { PresenterAccountAuthority } from "./mcp-presenter-account.ts";
import type { AttachLedger } from "./attach-ledger.ts";
import type { HeadlessPresence } from "../headless/presence.ts";
import type { HandSelection } from "../headless/hand-selection.ts";
export { presenterPipePath } from "./mcp-presenter-control-start.ts";
export interface MultiSessionHostOptions {
/** Host deployment policy; never derived from client capabilities or project settings. */
mcpPresenterEnforcement?: boolean;
presenterBootstrapFd?: number;
/** Injected by the distribution at host start (senpi#4249); never derived from RPC, arguments or environment. */
presenterAccountAuthority?: PresenterAccountAuthority;
agentDir: string;
createRuntime: CreateAgentSessionRuntimeFactory;
workerConfiguration?: CliRuntimeConfiguration;
cwd: string;
permissionPreset?: string;
creationModel?: {
provider: string;
modelId: string;
};
initialThinkingLevel?: string;
listen?: string;
/** Resolved `--tool-runtime`; absent means `in-process`. Advertised as `tool_runtime:<value>`. */
toolRuntime?: ToolRuntimeKind;
/** Test seam: defaults to the real shared-session binding. */
createBinding?: RpcBindingFactory;
/**
* Who owns the sessions this host serves. Absent or `"client"` is today's host: a session ends when its
* last client leaves unless that client opened it with `retain_on_disconnect`, and an empty host exits
* after its empty-exit window. `"machine"` (the headless engine, `modes/headless`) keeps every session
* it opens through a client disconnect (an `open_session` with no `retain_on_disconnect` is retained;
* an explicit `false` is honored) and never exits for being empty.
*/
sessionOwner?: "client" | "machine";
/**
* The durable takeover ledger (R21; S37). Honored only with `sessionOwner: "machine"`: `attach_session { takeover,
* holder }` then takes a session over and lets its other clients go quietly. Absent, a takeover is refused.
*/
sessionTakeover?: AttachLedger;
/** Set only by a headless host with a presence binding (`modes/headless`): rows and opens carry presence. */
sessionPresence?: HeadlessPresence;
/** Set only by a headless host with a hand directory (`modes/headless`): `list_hands` and `select_hand`. */
handSelection?: HandSelection;
}
export { DEFAULT_HOST_EMPTY_EXIT_MS, DEFAULT_SESSION_IDLE_EVICTION_MS, RPC_HOST_EMPTY_EXIT_MS_ENV, RPC_SESSION_IDLE_EVICTION_MS_ENV, resolveHostIdlePolicy, } from "./host-idle-policy.ts";
/**
* Socket agent events are delivered only to connections attached to their
* session, tagged with its routing sessionId. Content-free session lifecycle
* events remain visible to every connection. Responses and extension UI
* requests remain requester-only; foreign observation uses attach-on-open.
*/
export declare function runMultiSessionHost(options: MultiSessionHostOptions): Promise<never>;
export declare function createHostCore(options: MultiSessionHostOptions, writer: SessionEventWriter, capabilities?: string[], idle?: HostIdleOverrides, hostContext?: SessionContext, hooks?: HostCoreHooks): {
router: SessionCommandRouter;
handle: (line: string) => Promise<void>;
/** senpi#6752: the host's `machine_op` handler; its terminals end at host shutdown. */
machineOps: MachineOpHandler;
handover: import("./host-idle-handover.ts").HostIdleHandover | undefined;
handoverAnswered: () => Promise<void>;
/** The in-process registry's `warm`; the worker registry has none. */
warm: import("./host-warm.ts").HostWarm | undefined;
/**
* A session's live registry entry by its routing id. Only in-process test fixtures read it today, in place of
* spying on the registry prototype (senpi#5802); the host itself never calls it.
*/
peekSession: (sessionId: string) => import("./session-registry-types.ts").RpcSessionEntry | undefined;
};
/**
* The identity every session on this socket host carries in its context: `host_socket`, the PUBLIC
* endpoint clients address (the supervisor's path for a supervised host, whose own listener is a
* private hop; the bound path for a bare one), realpath-canonicalized so it compares equal however
* the path was spelled; and `host_instance`, this generation. The endpoint is stable across handoffs,
* the instance is not. The FIRST generation runs this before its supervisor has created the socket's
* directory, a successor after, so the directory is canonicalized through its deepest existing
* ancestor: both then stamp the same spelling. `host_socket` is omitted where no public path exists
* (abstract sockets, a supervised host whose supervisor passed none). Exported for tests.
*/
export declare function hostSessionContext(socketPath: string, supervised?: HostWatchdogConfig | undefined): SessionContext;
//# sourceMappingURL=multi-session-host.d.ts.map