trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
43 lines • 2.03 kB
TypeScript
/**
* Shared helpers for room MCP tools — lanes, rate limits, write context.
*
* @module trellis/mcp
*/
import type { MiddlewareContext } from '../core/kernel/middleware.js';
import type { AuthContext } from '../server/auth.js';
import { type UsageMeter } from '../server/usage-meter.js';
/** Normalize lane / agent attribution for draft writes. */
export declare function resolveWriteAgentId(lane: string | undefined, auth: AuthContext, headerLane?: string | null): string;
export declare function writeContext(lane: string | undefined, auth: AuthContext, headerLane?: string | null): Partial<MiddlewareContext>;
export declare function assertMcpBudget(meter: UsageMeter | null, tenantId: string | null): void;
export declare function playgroundRoomToTenant(slug: string): string;
export interface ResolveMcpTenantOptions {
/** Session default from `?tenantId=` on the MCP HTTP URL or auth JWT. */
defaultTenantId?: string | null;
/** `X-Trellis-Tenant` header on the MCP request. */
headerTenant?: string | null;
/** Per-tool explicit tenant id. */
toolTenantId?: string;
/** Playground `?room=` slug → `embed-{slug}`. */
roomSlug?: string;
}
/**
* Resolve effective tenant for a room MCP tool call.
* Priority: tool `tenantId` → tool `room` → header → URL/auth default → null (showcase).
*/
export declare function resolveMcpTenantId(opts: ResolveMcpTenantOptions): string | null;
export declare function handleMcpError(err: unknown): {
content: {
type: "text";
text: string;
}[];
} | null;
/** Stable CollectionMeta id used by Playground (`collectionMeta:<slug>`). */
export declare const COLLECTION_META_PREFIX: "collectionMeta:";
export declare function collectionMetaIdFromSlug(slug: string): string;
export declare function resolveCollectionId(opts: {
collectionSlug?: string;
collectionId?: string;
}): string;
export declare function collectionSlugFromMetaId(collectionId: string): string | null;
//# sourceMappingURL=room-helpers.d.ts.map