feat: complete mindspace conversation packages

This commit is contained in:
john
2026-07-02 23:46:05 +08:00
parent b084f6d23c
commit b258004dad
31 changed files with 1990 additions and 118 deletions
+35
View File
@@ -125,3 +125,38 @@ test('MindSpace service facade writes manifest.json inside the conversation pack
['ca_report'],
);
});
test('MindSpace service facade prepares conversation package reads through injected hooks', async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'mindspace-service-'));
const calls = [];
const warnings = [];
const service = createMindSpaceServiceFacade({
storageAdapter: createLocalMindSpaceStorageAdapter(root),
publicBaseUrl: 'https://m.tkmind.cn',
conversationPackageBackfill: async (input) => {
calls.push(['backfill', input]);
throw new Error('transient db issue');
},
conversationPackagePublicHtmlHydrator: async (input) => {
calls.push(['hydrate', input]);
return ['artifact-1'];
},
logger: {
warn: (...args) => warnings.push(args),
},
});
const result = await service.prepareConversationPackageRead({
user: { id: 'user-1' },
sessionId: 'session-1',
});
assert.deepEqual(result, ['artifact-1']);
assert.deepEqual(
calls.map(([name]) => name),
['backfill', 'hydrate'],
);
assert.equal(calls[0][1].sessionId, 'session-1');
assert.equal(warnings.length, 1);
assert.equal(warnings[0][0], '[MindSpace] conversation package DB backfill failed:');
});