|
@@ -1,9 +1,8 @@
|
|
|
import { describe, expect, test } from 'bun:test';
|
|
import { describe, expect, test } from 'bun:test';
|
|
|
-import { SLIM_INTERNAL_INITIATOR_MARKER } from '../../utils';
|
|
|
|
|
import { createPhaseReminderHook, PHASE_REMINDER } from './index';
|
|
import { createPhaseReminderHook, PHASE_REMINDER } from './index';
|
|
|
|
|
|
|
|
describe('createPhaseReminderHook', () => {
|
|
describe('createPhaseReminderHook', () => {
|
|
|
- test('prepends reminder for orchestrator sessions', async () => {
|
|
|
|
|
|
|
+ test('does not mutate orchestrator messages', async () => {
|
|
|
const hook = createPhaseReminderHook();
|
|
const hook = createPhaseReminderHook();
|
|
|
const output = {
|
|
const output = {
|
|
|
messages: [
|
|
messages: [
|
|
@@ -16,9 +15,8 @@ describe('createPhaseReminderHook', () => {
|
|
|
|
|
|
|
|
await hook['experimental.chat.messages.transform']({}, output);
|
|
await hook['experimental.chat.messages.transform']({}, output);
|
|
|
|
|
|
|
|
- expect(output.messages[0].parts[0].text).toBe(
|
|
|
|
|
- `${PHASE_REMINDER}\n\n---\n\nhello`,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ expect(output.messages[0].parts[0].text).toBe('hello');
|
|
|
|
|
+ expect(output.messages[0].parts[0].text).not.toContain(PHASE_REMINDER);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
test('skips non-orchestrator sessions', async () => {
|
|
test('skips non-orchestrator sessions', async () => {
|
|
@@ -37,27 +35,22 @@ describe('createPhaseReminderHook', () => {
|
|
|
expect(output.messages[0].parts[0].text).toBe('hello');
|
|
expect(output.messages[0].parts[0].text).toBe('hello');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- test('skips internal notification turns', async () => {
|
|
|
|
|
|
|
+ test('does not mutate internal notification turns', async () => {
|
|
|
const hook = createPhaseReminderHook();
|
|
const hook = createPhaseReminderHook();
|
|
|
|
|
+ const text =
|
|
|
|
|
+ '[Background task "x" completed]\n<!-- slim-internal-initiator -->';
|
|
|
const output = {
|
|
const output = {
|
|
|
messages: [
|
|
messages: [
|
|
|
{
|
|
{
|
|
|
info: { role: 'user' },
|
|
info: { role: 'user' },
|
|
|
- parts: [
|
|
|
|
|
- {
|
|
|
|
|
- type: 'text',
|
|
|
|
|
- text: `[Background task "x" completed]\n${SLIM_INTERNAL_INITIATOR_MARKER}`,
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ parts: [{ type: 'text', text }],
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
await hook['experimental.chat.messages.transform']({}, output);
|
|
await hook['experimental.chat.messages.transform']({}, output);
|
|
|
|
|
|
|
|
- expect(output.messages[0].parts[0].text).toContain(
|
|
|
|
|
- SLIM_INTERNAL_INITIATOR_MARKER,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ expect(output.messages[0].parts[0].text).toBe(text);
|
|
|
expect(output.messages[0].parts[0].text).not.toContain(PHASE_REMINDER);
|
|
expect(output.messages[0].parts[0].text).not.toContain(PHASE_REMINDER);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|