// Development fixture provider: one static model that the loopback endpoint in // ./endpoint.mjs serves with a fixed reply. It has no upstream, needs no // credential and declares only transport data. `mosaic dev fixture init` // starts the endpoint; the launcher reaches it through its session proxy // context, so the model entry uses provider "proxy". export const interfaceVersion = 1; export const FIXTURE_MODEL = 'fixture-deterministic'; export const FIXTURE_KEY_NAME = 'fixture-deterministic'; export const FIXTURE_WORD = 'PINEAPPLE'; // A fixed, published value. It is not a secret and grants nothing outside the fixture. export const FIXTURE_KEY = 'mosaic-fixture-key-not-a-secret'; export const FIXTURE_ENTRY = Object.freeze({ provider: 'proxy', model: FIXTURE_MODEL, module: 'fixture', upstream: 'fixture' }); export const FIXTURE_TEMPLATE = Object.freeze({ plugins: { channel: ['cli', 'webui'], harness: ['pi'], 'model-provider': ['fixture'] }, launch: { by: 'chief', instances: ['assistant'], models: { [FIXTURE_KEY_NAME]: FIXTURE_ENTRY } }, assistantVars: { harness: 'pi', model: FIXTURE_KEY_NAME, thinking: 'off' }, vars: { 'bus.tester': true }, }); // Organization setup is supplied by this module, alongside its model route. export function orgPresets() { return [{ name: 'fixture', label: 'Test model', description: 'Canned replies, no cost.', thinking: { levels: ['off'], default: 'off' }, available: () => ({ ok: true }), overlay: ({ thinking }) => ({ ...structuredClone(FIXTURE_TEMPLATE), assistantVars: { ...FIXTURE_TEMPLATE.assistantVars, thinking } }) }]; } const HARNESSES = Object.freeze(['pi']); const TRANSPORT = Object.freeze({ routeId: 'fixture', endpoint: 'root', api: 'anthropic-messages', piProvider: 'mosaic-fixture', compat: null }); const ours = selection => selection?.provider === 'proxy' && selection.model === FIXTURE_MODEL && selection.upstream === 'fixture' && (selection.module === undefined || selection.module === 'fixture'); export async function catalogue({ now } = {}) { return { status: 'ready', observedAt: typeof now === 'function' ? now() : null, notices: [], models: [{ key: FIXTURE_KEY_NAME, module: 'fixture', upstream: 'fixture', provider: 'proxy', model: FIXTURE_MODEL, label: 'fixture / deterministic', available: true, reason: null, harnesses: [...HARNESSES] }], }; } // The model is static, so admission does not depend on a proxy catalogue. export function preflight({ selection, harness }) { if (selection?.upstream !== 'fixture' || selection.model !== FIXTURE_MODEL) return { allow: false, code: 'model-provider-unavailable' }; if (!HARNESSES.includes(harness)) return { allow: false, code: 'model-harness-incompatible' }; return { allow: true }; } export function route({ selection, harness }) { if (!ours(selection)) return { code: 'model-provider-unavailable' }; if (harness && !HARNESSES.includes(harness)) return { code: 'model-harness-incompatible' }; return { provider: 'proxy', model: FIXTURE_MODEL, upstream: 'fixture', ...TRANSPORT }; }