@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
48 lines • 2.06 kB
TypeScript
import type { IAgentBuilder, BuilderModelPolicy, DefaultModelEntry, ProviderModelEntry } from './types.js';
/**
* Inputs for the shared {@link isBuilderModelPolicyActive} predicate.
*
* Lives separately from {@link BuilderModelPolicy} because we need to ask the
* "is the model slice active?" question at config-validation time, *before*
* a `BuilderModelPolicy` has been built.
*/
export interface BuilderModelPolicyInputs {
/** `AgentBuilderOptions.enabled` (defaulted: missing = `true`). */
enabled: boolean;
/** `features.agent.model` — `true` means picker visible. */
pickerVisible: boolean;
/** `configuration.agent.models.allowed`. */
allowed?: ProviderModelEntry[];
/** `configuration.agent.models.default`. */
default?: DefaultModelEntry;
}
/**
* Single source of truth for whether the admin has actually configured a model
* policy. Reused by:
* - {@link builderToModelPolicy} (UI / runtime derivation)
* - `EditorAgentBuilder` config validation (Phase 4)
* - Server-side enforcement gate (Phase 6)
*
* "Active" means the admin opted into the model slice in some way:
* - the picker is visible (open-mode), OR
* - an allowlist was set, OR
* - a default model was set.
*
* If the builder is `enabled: false`, the slice is never active.
*/
export declare function isBuilderModelPolicyActive(inputs: BuilderModelPolicyInputs): boolean;
/**
* Pure derivation of the {@link BuilderModelPolicy} from an `IAgentBuilder`.
* No `Mastra` / `IEditor` dependency — server and editor wrappers feed it
* a builder instance through their own resolution paths.
*
* Returns `{ active: false }` when:
* - the builder is missing,
* - the builder is disabled, or
* - none of the model-slice signals are present.
*
* In every active case, `allowed` and `default` are passed through verbatim
* so locked-mode UI still has the data it needs to render the chosen model.
*/
export declare function builderToModelPolicy(builder: IAgentBuilder | undefined): BuilderModelPolicy;
//# sourceMappingURL=policy.d.ts.map