feat: bootstrap BoxBrain foundation
This commit is contained in:
37
tests/public-api.test.ts
Normal file
37
tests/public-api.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
createReplyDelay,
|
||||
createTypingDelay,
|
||||
ONLINE_AVAILABILITY,
|
||||
type BoxBrainFactDraft,
|
||||
type TextModelAdapter,
|
||||
} from '../src';
|
||||
|
||||
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']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user