Files
memind/chat-agent-run-gate.test.mjs
john 7f7aced751 feat(runtime): wire personal memory observation and skill runtime config
Hook shadow pipeline observation into session finish and agent runs, and
expose skill runtime settings through auth and runtime status endpoints.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-13 14:00:11 +08:00

65 lines
2.2 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
reconcileSessionEventRequestContext,
resolvePostAgentRunChatState,
shouldPromoteSessionIdToStreaming,
} from './chat-agent-run-gate.mjs';
test('resolvePostAgentRunChatState keeps idle when Finish beat agent-run gate', () => {
assert.equal(
resolvePostAgentRunChatState({ chatState: 'idle', finishedViaPortalDirectChat: false }),
'idle',
);
});
test('resolvePostAgentRunChatState returns streaming while still waiting for session Finish', () => {
assert.equal(resolvePostAgentRunChatState({ chatState: 'waiting' }), 'streaming');
assert.equal(resolvePostAgentRunChatState({ chatState: 'streaming' }), 'streaming');
});
test('resolvePostAgentRunChatState prefers portal direct chat completion', () => {
assert.equal(
resolvePostAgentRunChatState({ chatState: 'streaming', finishedViaPortalDirectChat: true }),
'idle',
);
});
test('resolvePostAgentRunChatState idles after worker-side agent run success', () => {
assert.equal(
resolvePostAgentRunChatState({ chatState: 'waiting', agentRunSucceeded: true }),
'idle',
);
assert.equal(
resolvePostAgentRunChatState({ chatState: 'streaming', agentRunSucceeded: true }),
'idle',
);
});
test('shouldPromoteSessionIdToStreaming skips re-streaming after Finish', () => {
assert.equal(shouldPromoteSessionIdToStreaming('idle'), false);
assert.equal(shouldPromoteSessionIdToStreaming('waiting'), true);
assert.equal(shouldPromoteSessionIdToStreaming('streaming'), true);
});
test('reconcileSessionEventRequestContext adopts Goose request id while agent-run gate waits', () => {
assert.deepEqual(
reconcileSessionEventRequestContext({
activeRequestId: 'portal-req',
chatState: 'waiting',
eventType: 'ActiveRequests',
activeRequestIds: ['goose-req'],
}),
{ activeRequestId: 'goose-req', promoteStreaming: true, allowMissingGrace: false },
);
assert.deepEqual(
reconcileSessionEventRequestContext({
activeRequestId: 'portal-req',
chatState: 'waiting',
eventType: 'Message',
eventRequestId: 'goose-req',
}),
{ activeRequestId: 'goose-req', promoteStreaming: true, allowMissingGrace: false },
);
});