import { ResolvedAgentAvailability } from '@happyvertical/smrt-agents'; import { AgentPersonaCollection, personaAppliesToContext } from './agent-persona.js'; /** * The context a persona is being resolved for. */ export interface PersonaContext { /** Context dimension type (e.g. `'site'`). */ contextType?: string | null; /** Context dimension id within `contextType`. */ contextId?: string | null; } /** * Bottom-layer defaults for an agent class, typically derived from its build * manifest. */ export interface ManifestPersonaDefaults { /** Default system instructions when no persona overrides them. */ instructions?: string; /** Default tool identifiers, capped by the availability ceiling. */ allowedTools?: string[]; /** Default memory scope. */ memoryScope?: string; } /** * Middle-layer availability + capability ceiling, projected from a * `TenantAgent` resolution. */ export interface PersonaAvailabilityGate { /** Resolved `TenantAgent` status. `'disabled'` marks the persona unavailable. */ status: 'active' | 'disabled'; /** * Tool identifiers the tenant is permitted to grant. When set, resolved * `allowedTools` are intersected with this ceiling. `undefined` means no * ceiling (tools pass through unchanged). */ toolCeiling?: string[]; /** Tenant the binding was resolved from (provenance only). */ sourceTenantId?: string; } /** * Options for {@link PersonaResolver.resolve}. */ export interface ResolvePersonaOptions { /** * Return ancestor tenant ids for a tenant, nearest parent first through to * the root — mirrors `TenantAgentCollection.resolveForTenant`. Omit for a * single-tenant resolution with no inheritance. */ getAncestorIds?: (tenantId: string) => Promise; /** Bottom-layer manifest defaults for the agent class. */ manifestDefaults?: ManifestPersonaDefaults; /** * Middle-layer `TenantAgent` availability + ceiling. Omit to skip gating * (the result is always `available: true` with no tool ceiling). */ availability?: PersonaAvailabilityGate | null; } /** * A fully resolved persona: the layered, ready-to-use configuration plus * provenance describing how it was resolved. */ export interface ResolvedPersona { /** Canonical qualified agent type the resolution was for. */ agentClass: string; /** Tenant the resolution was requested for. */ tenantId: string; /** Id of the selected persona, or `undefined` for the default fallback. */ personaId?: string; /** Selected persona name, or `'default'` for the fallback. */ name: string; /** Layered instructions (persona → manifest default). */ instructions: string; /** Layered tool ids (persona/manifest tools, capped by the ceiling). */ allowedTools: string[]; /** Run-as user principal, if the selected persona sets one. */ runAsUserId?: string; /** Acting `Bot` profile id, if the selected persona sets one. */ actsAsProfileId?: string | null; /** Resolved memory scope (persona → manifest default → derived default). */ memoryScope: string; /** Selected persona priority (`0` for the default fallback). */ priority: number; /** Context type the resolution was requested for. */ contextType?: string | null; /** Context id the resolution was requested for. */ contextId?: string | null; /** Whether a persona matched (`'persona'`) or the default was used (`'default'`). */ source: 'persona' | 'default'; /** For a matched persona, whether it was the tenant's own or inherited. */ personaSource?: 'explicit' | 'inherited'; /** Tenant the matched persona came from (own tenant or an ancestor). */ sourceTenantId?: string; /** Whether the `TenantAgent` gate reports the agent as available. */ available: boolean; } /** * Project a `TenantAgent` resolution into a {@link PersonaAvailabilityGate}. * * This is the concrete bridge between the `@happyvertical/smrt-agents` * availability layer and the persona layer. Pass `toolPermissionPrefix` to * derive a tool ceiling from granted permission ids (permissions whose id * starts with the prefix become the ceiling, with the prefix stripped); omit it * to leave the ceiling open. * * @param resolved - A `ResolvedAgentAvailability` (or `null`/`undefined`). * @param options.toolPermissionPrefix - Permission-id prefix that marks * tool grants (e.g. `'tool:'`). * @returns A gate, or `null` when `resolved` is nullish. */ export declare function availabilityFromResolvedAgent(resolved: ResolvedAgentAvailability | null | undefined, options?: { toolPermissionPrefix?: string; }): PersonaAvailabilityGate | null; /** * Resolves the active persona for a `(tenant, agentClass, context)` request. */ export declare class PersonaResolver { private readonly personas; constructor(personas: AgentPersonaCollection); /** * Resolve the active persona. * * @param tenantId - Requesting tenant. * @param agentClass - Agent class (canonicalized internally). * @param context - Context dimension being resolved for. * @param options - Hierarchy walk, manifest defaults, and availability gate. * @returns The layered {@link ResolvedPersona} — either a matched persona or * the defined default fallback. */ resolve(tenantId: string, agentClass: string, context?: PersonaContext, options?: ResolvePersonaOptions): Promise; private layerPersona; private defaultResolution; } export { personaAppliesToContext }; //# sourceMappingURL=persona-resolver.d.ts.map