Initialize LineUp app server
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { ConversationItemFactory, RendererRegistry } = require('./interaction-kernel.js');
|
||||
|
||||
test('decodes plain agent output as a markdown conversation item', () => {
|
||||
const item = new ConversationItemFactory().decode('# 标题\n\n- 一项');
|
||||
assert.equal(item.kind, 'markdown');
|
||||
assert.equal(item.data.markdown, '# 标题\n\n- 一项');
|
||||
});
|
||||
|
||||
test('decodes a v1 surface lifecycle message without treating it as a card', () => {
|
||||
const item = new ConversationItemFactory().decode(JSON.stringify({
|
||||
v: 1, type: 'lineup.v1.ui.open', conversation_id: 'conv-1',
|
||||
payload: { instance_id: 'task.01', app: { id: 'com.lineup.task', version: '1.0.0' }, state: { phase: 'running' } },
|
||||
}));
|
||||
assert.equal(item.kind, 'ui.open');
|
||||
assert.equal(item.data.instance_id, 'task.01');
|
||||
});
|
||||
|
||||
test('uses a safe fallback for an unsupported protocol message', () => {
|
||||
const item = new ConversationItemFactory().decode(JSON.stringify({ v: 1, type: 'lineup.v1.secret.execute', payload: {} }));
|
||||
assert.equal(item.kind, 'protocol-fallback');
|
||||
assert.equal(item.data.reason, 'unsupported_type');
|
||||
});
|
||||
|
||||
test('routes only validated conversation items through registered renderers', () => {
|
||||
const registry = new RendererRegistry().register('markdown', item => item.data.markdown).register('protocol-fallback', () => 'fallback');
|
||||
assert.equal(registry.render(new ConversationItemFactory().decode('hello')), 'hello');
|
||||
});
|
||||
Reference in New Issue
Block a user