/** * routes/hosted-sessions.ts, the handlers behind `sessions.hosted.*`. * * Thin on purpose: argument reading and error mapping. Everything a hosted * session IS lives in platform/hosted-sessions, so the verbs and the engine * cannot drift into two ideas of what create/attach/detach/kill mean. * * Error mapping is the part worth reading. Each of the engine's refusals has a * distinct wire shape, because "there is no such session", "that session ended * and here is why", "the path you gave is not absolute" and "you are at the * configured cap" want four different reactions from a client, and collapsing * them into one 400 is how a caller ends up retrying the one thing that will * never work. */ import type { GatewayMethodCatalog } from '../method-catalog.js'; import type { GatewayMethodHandler } from '../method-catalog-shared.js'; import type { HostedSessionAttachment } from '../../hosted-sessions/manager.js'; import type { CreateHostedSessionInput, HostedSessionRecord } from '../../hosted-sessions/types.js'; /** * The engine surface these verbs need. Declared here rather than importing the * class so a test drives the routes with a stand-in, and so the routes depend * on five methods instead of the whole engine. */ export interface HostedSessionVerbService { create(input: CreateHostedSessionInput): Promise; attach(sessionId: string, clientId: string, options?: { readonly leaseMs?: number | undefined; }): Promise; detach(sessionId: string, clientId: string): Promise; kill(sessionId: string): Promise; list(options?: { readonly includeTerminated?: boolean | undefined; }): readonly HostedSessionRecord[]; } /** Map an engine refusal onto the wire shape a client can act on. */ export declare function toGatewayVerbError(error: unknown): never; export declare function createHostedSessionCreateHandler(service: HostedSessionVerbService): GatewayMethodHandler; export declare function createHostedSessionAttachHandler(service: HostedSessionVerbService): GatewayMethodHandler; export declare function createHostedSessionDetachHandler(service: HostedSessionVerbService): GatewayMethodHandler; export declare function createHostedSessionKillHandler(service: HostedSessionVerbService): GatewayMethodHandler; export declare function createHostedSessionListHandler(service: HostedSessionVerbService): GatewayMethodHandler; /** Every verb this module owns, in the order a client meets them. */ export declare const HOSTED_SESSION_METHOD_IDS: readonly string[]; /** * Attach the hosted-session handlers to their descriptors. A missing descriptor * is a silent no-op, matching every other route group here. */ export declare function registerHostedSessionGatewayMethods(catalog: GatewayMethodCatalog, service: HostedSessionVerbService): void; /** * Say, in the catalog, that this daemon hosts nothing. * * The descriptors are builtins: they are present whether or not a product * stated how a hosted session's workspace floor is built. With no engine there * is no handler either, and dispatch fell through to the branch for a verb with * neither handler nor route, a 501 whose body carried no code, and a plain * `Error` for anyone calling `catalog.invoke()` directly, which is a 500. Both * read as "this daemon is broken" for a capability that is simply off. * * Marking them uninvokable makes the refusal the one the catalog already * promises for a cataloged-but-not-dispatchable verb: an honest 400 with * `NOT_INVOKABLE`, before any handler lookup, on every path. */ export declare function refuseHostedSessionGatewayMethods(catalog: GatewayMethodCatalog): void; //# sourceMappingURL=hosted-sessions.d.ts.map