70 lines
2.5 KiB
TypeScript
70 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
createGrokAdapters,
|
|
createReplyDelay,
|
|
createTypingDelay,
|
|
generateSchedule,
|
|
ONLINE_AVAILABILITY,
|
|
replyToConversation,
|
|
type BoxBrainFactDraft,
|
|
type SpecialDateProvider,
|
|
type TextModelAdapter,
|
|
} from '../src';
|
|
import { AvailabilityService } from '../src/availability';
|
|
import { ConversationService } from '../src/conversation';
|
|
import { FactDraftMemoryStore } from '../src/memory';
|
|
import { PersonaService } from '../src/persona';
|
|
import { GrokApiClient } from '../src/providers/grok';
|
|
import { ScheduleService } from '../src/schedule';
|
|
import { TimingProfile } from '../src/timing';
|
|
|
|
describe('public API', () => {
|
|
it('exports timing helpers and runtime availability constants', () => {
|
|
expect(createTypingDelay('abcd', { rng: () => 0 })).toBe(0.2);
|
|
expect(createReplyDelay(ONLINE_AVAILABILITY, { isFirstReplyInExchange: false, rng: () => 0 })).toBe(0);
|
|
});
|
|
|
|
it('supports provider-agnostic text model adapters', async () => {
|
|
const adapter: TextModelAdapter = {
|
|
provider: 'fake-provider',
|
|
model: 'fake-model',
|
|
async generateText(request) {
|
|
return `reply:${request.prompt}`;
|
|
},
|
|
};
|
|
|
|
await expect(adapter.generateText({ prompt: 'hello' })).resolves.toBe('reply:hello');
|
|
});
|
|
|
|
it('supports BoxBrain fact drafts for IdentityDB persistence', () => {
|
|
const fact: BoxBrainFactDraft = {
|
|
statement: 'Mina likes quiet cafés.',
|
|
topics: [{ name: 'Mina' }, { name: 'quiet cafés', category: 'preference' }],
|
|
metadata: { domain: 'persona.biography' },
|
|
};
|
|
|
|
expect(fact.topics.map((topic) => topic.name)).toEqual(['Mina', 'quiet cafés']);
|
|
});
|
|
|
|
it('exports grouped service classes and provider runtime helpers', () => {
|
|
const specialDateProvider: SpecialDateProvider = {
|
|
async listSpecialDates() {
|
|
return [{ date: '2026-05-08', title: 'Parents Day' }];
|
|
},
|
|
};
|
|
|
|
expect(typeof generateSchedule).toBe('function');
|
|
expect(typeof replyToConversation).toBe('function');
|
|
expect(typeof createGrokAdapters).toBe('function');
|
|
expect(specialDateProvider.listSpecialDates).toBeTypeOf('function');
|
|
|
|
expect(AvailabilityService).toBeTypeOf('function');
|
|
expect(ConversationService).toBeTypeOf('function');
|
|
expect(FactDraftMemoryStore).toBeTypeOf('function');
|
|
expect(PersonaService).toBeTypeOf('function');
|
|
expect(GrokApiClient).toBeTypeOf('function');
|
|
expect(ScheduleService).toBeTypeOf('function');
|
|
expect(TimingProfile).toBeTypeOf('function');
|
|
});
|
|
});
|