Skip to main content

@svatah/yam-surface-control

Shared surface operation dispatcher, session lifecycle and operation catalogue

Exports

ExportKindSignature
acquireStartLockfunctionexport function acquireStartLock(stateDir?: string): StartLock | undefinedTake the exclusive right to start a broker, or answer that somebody else has
actInputSchemavariableactInputSchema: z.ZodObject<
ACTION_FORMSvariableACTION_FORMS: readonly ActionForm[]The forms, in the order an inspector offers them: the common ones first.
ActionFieldinterfaceinterface ActionField
ActionFieldTypetypealiastype ActionFieldType = "string" | "number" | "boolean" | "url" | "key";How a field is collected, and how it is typed on the way to args.
ActionForminterfaceinterface ActionForm
actionFormForfunctiondeclare function actionFormFor(action: string): ActionForm | undefined;One form by action name.
actOutputSchemavariableactOutputSchema: z.ZodObject<
AdapterFactoryFntypealiasexport type AdapterFactoryFn
AdapterProbeinterfaceexport interface AdapterProbe
AdapterReadinessinterfaceexport interface AdapterReadiness
addSecretLiteralfunctionexport function addSecretLiteral(policy: RedactionPolicy, literal: string): void
addSecretPatternfunctionexport function addSecretPattern(policy: RedactionPolicy, pattern: RegExp): void
AgentClientinterfaceexport interface AgentClientOne connected MCP client, as a person reads it.
brokerAlivefunctionexport async function brokerAlive(descriptor: { url: string; token: string }): Promise<boolean>Whether a broker is answering at this descriptor and speaks this contract.
BrokerDescriptorinterfaceexport interface BrokerDescriptor
brokerHealthfunctionexport async function brokerHealth(What a broker at this descriptor is: alive, and what contract it speaks.
BrokerOperationtypealiasexport type BrokerOperation One operation, by the name the catalogue gives it.
BrokerOptionsinterfaceexport interface BrokerOptions
brokerStatefunctionexport async function brokerState(
BrokerStatetypealiasexport type BrokerState = "serving" | "busy" | "mismatched" | "gone";What the broker at a descriptor is, in the three answers that lead to three
brokerStateDirfunctionexport function brokerStateDir(): string
callBrokerfunctionexport async function callBroker(Ask a running broker to perform one operation.
CAPABILITIESvariableCAPABILITIES: readonly CapabilityFlag[]Every capability flag, so a client can render a readiness list.
capabilitiesInputSchemavariablecapabilitiesInputSchema: z.ZodObject<
capabilitiesOutputSchemavariablecapabilitiesOutputSchema: z.ZodObject<
catalogueFingerprintfunctiondeclare function catalogueFingerprint(): string;A fingerprint of the contract this build serves (T18, SF-03).
checkAdapterReadinessfunctionexport function checkAdapterReadiness(
checkInputSchemavariablecheckInputSchema: z.ZodObject<
checkOutputSchemavariablecheckOutputSchema: z.ZodObject<
CLI_EXIT_CODESvariableCLI_EXIT_CODES:
CLIENT_STALE_MSvariableCLIENT_STALE_MS = 30_000How long a record may go unrefreshed before a reader stops believing it.
CliFlaginterfaceinterface CliFlag
closeInputSchemavariablecloseInputSchema: z.ZodObject<
closeOutputSchemavariablecloseOutputSchema: z.ZodObject<
connectInputSchemavariableconnectInputSchema: z.ZodEffects<z.ZodObject<What connect may be pointed at (SF-04, T18).
ConnectOptionsinterfaceexport interface ConnectOptions
connectOutputSchemavariableconnectOutputSchema: z.ZodObject<
Controlinterfaceexport interface ControlWho holds a target, until they give it up (SF-13, T16).
CoordinationStoreinterfaceexport interface CoordinationStore
createAdapterFactoryfunctionexport function createAdapterFactory(
createCoordinationStorefunctionexport function createCoordinationStore(): CoordinationStore
createEventStorefunctionexport function createEventStore(): EventStore
createPromotionStorefunctionexport function createPromotionStore(): PromotionStore
createRedactionPolicyfunctionexport function createRedactionPolicy(): RedactionPolicy
createReferenceStorefunctionexport function createReferenceStore(): ReferenceStore
createSessionStorefunctionexport function createSessionStore(): SessionStore
DEFAULT_HOLDERvariableDEFAULT_HOLDER = "this client"Who a caller is when it does not say (SF-13).
defaultActionForRolefunctiondeclare function defaultActionForRole(role: string | undefined): string;The action an inspector opens on for an element of this role.
describeInputSchemavariabledescribeInputSchema: z.ZodObject<
describeOutputSchemavariabledescribeOutputSchema: z.ZodObject<
discoverAdaptersfunctionexport function discoverAdapters(registeredAdapters: string[]): AdapterReadiness[]
discoverBrokerfunctionexport function discoverBroker(stateDir?: string): BrokerDescriptor | undefined
DiscoveredTargetinterfaceexport interface DiscoveredTarget
discoverTargetsfunctionexport function discoverTargets(
dispatchActfunctionexport async function dispatchAct(
dispatchCapabilitiesfunctionexport async function dispatchCapabilities(
dispatchCheckfunctionexport async function dispatchCheck(
dispatchClosefunctionexport async function dispatchClose(
dispatchConnectfunctionexport async function dispatchConnect(
DispatchContextinterfaceexport interface DispatchContext
dispatchControlfunctionexport async function dispatchControl(
dispatchDescribefunctionexport async function dispatchDescribe(
dispatchEventsfunctionexport async function dispatchEvents(What this session did, and what of it would compile (T17, SF-19).
dispatchReadfunctionexport async function dispatchRead(
dispatchRequestfunctionexport async function dispatchRequest(Send an HTTP request on an HTTP surface (T15, SF-04).
dispatchScreenshotfunctionexport async function dispatchScreenshot(
dispatchSessionsfunctionexport async function dispatchSessions(
dispatchSnapshotfunctionexport async function dispatchSnapshot(
dispatchTargetsfunctionexport async function dispatchTargets(
DRIVEN_RANGESvariableDRIVEN_RANGES: Readonly<Record<string, string>> The version ranges this repository has driven.
ERROR_CODESvariableERROR_CODES: readonly ["TARGET_AMBIGUOUS", "SESSION_CLOSED", "SESSION_NOT_FOUND", "PERMISSION_REQUIRED", "UNSUPPORTED_OPERATION", "STALE_REFERENCE", "INVALID_AR
ErrorCodetypealiastype ErrorCode = (typeof ERROR_CODES)[number];
EventKindtypealiasexport type EventKind
EventStoreinterfaceexport interface EventStore
failedEnvelopefunctionexport function failedEnvelope(
forgetProbesfunctionexport function forgetProbes(): voidFor a test that wants a fresh answer.
generateJavaClientfunctionexport function generateJavaClient(): string
generateOpenApiDocumentfunctionexport function generateOpenApiDocument(version: string): Record<string, unknown>
generateOpenApiPathsfunctionexport function generateOpenApiPaths(): Record<string, Record<string, unknown>>
generatePythonClientfunctionexport function generatePythonClient(): string
generateTokenfunctionexport function generateToken(): string
generateTypeScriptClientfunctionexport function generateTypeScriptClient(): string
hashInputfunctionfunction hashInput(input: unknown): string
hasSecretfunctionexport function hasSecret(policy: RedactionPolicy, value: string): boolean
IdempotencyRecordinterfaceexport interface IdempotencyRecord
isProcessAlivefunctionexport function isProcessAlive(pid: number): boolean
Leaseinterfaceexport interface Lease
makeRequestIdfunctionexport function makeRequestId(): string
offeredActionsfunctiondeclare function offeredActions(kind: SurfaceKind, capabilities?: Partial<Record<CapabilityFlag, boolean>>): readonly ActionForm[];The actions this surface can actually perform, in offer order (SF-09).
operationByCliSubcommandfunctiondeclare function operationByCliSubcommand(sub: string): OperationDescriptor | undefined;
operationByMcpToolfunctiondeclare function operationByMcpTool(toolName: string): OperationDescriptor | undefined;
operationByNamefunctiondeclare function operationByName(name: string): OperationDescriptor | undefined;
operationByServicePathfunctiondeclare function operationByServicePath(method: string, path: string): OperationDescriptor | undefined;
OperationDescriptorinterfaceinterface OperationDescriptor
OperationOutcometypealiasexport type OperationOutcome = "succeeded" | "failed" | "refused" | "cancelled" | "unknown";
OperationRecordinterfaceexport interface OperationRecord
OPERATIONSvariableOPERATIONS: readonly OperationDescriptor[]
probeAdapterfunctionexport async function probeAdapter(adapter: string): Promise<AdapterProbe>Probe one adapter. Cached: doctor asks for all of them at once.
probeAdaptersfunctionexport async function probeAdapters(registeredAdapters: string[]): Promise<AdapterReadiness[]>Readiness with the host actually asked (T23, SF-09, SF-23).
PromotionStepinterfaceexport interface PromotionStepOne recorded step, shaped as @svatah/yam-trajectory's TrajectoryLine.
PromotionStoreinterfaceexport interface PromotionStore
readBrokerDescriptorfunctionexport function readBrokerDescriptor(stateDir?: string): BrokerDescriptor | undefined
readClientsfunctionexport function readClients(stateDir?: string, now: number = Date.now()): AgentClient[]Everyone connected, newest first, without the ones that have gone quiet.
readInputSchemavariablereadInputSchema: z.ZodObject<
readOutputSchemavariablereadOutputSchema: z.ZodObject<
RedactionPolicyinterfaceexport interface RedactionPolicy
redactObjectfunctionexport function redactObject(policy: RedactionPolicy, obj: unknown): unknown
redactStringfunctionexport function redactString(policy: RedactionPolicy, value: string): string
ReferenceStoreinterfaceexport interface ReferenceStore
RefScopeinterfaceexport interface RefScope
refusedEnvelopefunctionexport function refusedEnvelope(
removeBrokerDescriptorfunctionexport function removeBrokerDescriptor(stateDir?: string): void
removeClientfunctionexport function removeClient(id: string, stateDir?: string): voidForget a client. Missing is not an error: a second disconnect is a disconnect.
ResultEnvelopetypealiastype ResultEnvelope = z.infer<typeof resultEnvelopeSchema>;
resultEnvelopeSchemavariableresultEnvelopeSchema: z.ZodObject<
RunningBrokerinterfaceexport interface RunningBroker
screenshotInputSchemavariablescreenshotInputSchema: z.ZodObject<
screenshotOutputSchemavariablescreenshotOutputSchema: z.ZodObject<
SessionEntryinterfaceexport interface SessionEntry
SessionEventinterfaceexport interface SessionEvent
SessionModetypealiasexport type SessionMode = "launch" | "attach";
sessionsInputSchemavariablesessionsInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>
sessionsOutputSchemavariablesessionsOutputSchema: z.ZodObject<
SessionStatustypealiasexport type SessionStatus = "connecting" | "ready" | "busy" | "disconnected" | "closed";
SessionStoreinterfaceexport interface SessionStore
snapshotInputSchemavariablesnapshotInputSchema: z.ZodObject<
snapshotOutputSchemavariablesnapshotOutputSchema: z.ZodObject<
SnapshotRecordinterfaceexport interface SnapshotRecord
startBrokerfunctionexport async function startBroker(options: BrokerOptions): Promise<RunningBroker>Start the broker on loopback, on a port the OS picks.
StartLockinterfaceexport interface StartLockOne broker to a machine, enforced rather than hoped for (T00, SF-05, SF-13).
startLockHeldfunctionexport function startLockHeld(stateDir?: string): booleanWhether a broker start is in progress in some other process.
successEnvelopefunctionexport function successEnvelope(
SURFACE_CLI_SUBCOMMANDSvariableSURFACE_CLI_SUBCOMMANDS: string[]
SURFACE_TOOL_NAMESvariableSURFACE_TOOL_NAMES: string[]
targetsInputSchemavariabletargetsInputSchema: z.ZodObject<
targetsOutputSchemavariabletargetsOutputSchema: z.ZodObject<
writeBrokerDescriptorfunctionexport function writeBrokerDescriptor(
writeClientfunctionexport function writeClient(client: AgentClient, stateDir?: string): stringRecord a client, or refresh one. Returns the path, for the caller to remove.