feat: bootstrap BoxBrain foundation

This commit is contained in:
2026-05-11 15:56:56 +09:00
parent 964c9b3159
commit 7b474ddac3
15 changed files with 960 additions and 0 deletions

37
tests/public-api.test.ts Normal file
View 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']);
});
});