14a00774d9
- 新增 web 能力并挂载 platform/web(web_search/fetch_url) - 实时查询强制 web skill,router fallback 与 await session Finish - Session Broker 覆盖率/指标、stream replay 与相关单测/E2E 脚本 Co-authored-by: Cursor <cursoragent@cursor.com>
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
formatSessionStreamSseChunk,
|
|
isSessionStreamReplayEnabled,
|
|
isTerminalSessionEvent,
|
|
parseSessionSseBlock,
|
|
parseSessionStreamLastEventId,
|
|
shouldPersistSessionStreamEvent,
|
|
shouldSkipUpstreamAfterSessionReplay,
|
|
} from './session-stream.mjs';
|
|
|
|
test('formatSessionStreamSseChunk includes id for replay cursor', () => {
|
|
const chunk = formatSessionStreamSseChunk({
|
|
id: 'evt-1',
|
|
data: { type: 'Message', message: { role: 'assistant' } },
|
|
});
|
|
assert.match(chunk, /^id: evt-1\n/);
|
|
assert.match(chunk, /"type":"Message"/);
|
|
});
|
|
|
|
test('parseSessionSseBlock extracts id and data', () => {
|
|
const parsed = parseSessionSseBlock('id: upstream-1\ndata: {"type":"Finish"}\n\n');
|
|
assert.equal(parsed.id, 'upstream-1');
|
|
assert.equal(parsed.data, '{"type":"Finish"}');
|
|
});
|
|
|
|
test('terminal detection and upstream skip policy', () => {
|
|
assert.equal(isTerminalSessionEvent({ type: 'Finish' }), true);
|
|
assert.equal(isTerminalSessionEvent({ type: 'Message' }), false);
|
|
assert.equal(
|
|
shouldSkipUpstreamAfterSessionReplay([
|
|
{ payload: { type: 'Message' } },
|
|
{ payload: { type: 'Finish' } },
|
|
]),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
shouldSkipUpstreamAfterSessionReplay([{ payload: { type: 'Message' } }]),
|
|
false,
|
|
);
|
|
assert.equal(shouldPersistSessionStreamEvent({ type: 'Ping' }), false);
|
|
assert.equal(shouldPersistSessionStreamEvent({ type: 'Message' }), true);
|
|
assert.equal(isSessionStreamReplayEnabled({ MEMIND_SESSION_STREAM_REPLAY: '1' }), true);
|
|
assert.equal(parseSessionStreamLastEventId(' abc '), 'abc');
|
|
});
|