import { describe, expect, test } from 'bun:test'
import {
parseTaskNotificationXml,
shouldForwardTaskNotificationToModel,
} from './taskNotificationPolicy.js'
describe('task notification policy', () => {
test('does not re-enter the model for local agent terminal notifications in structured output', () => {
const notification = parseTaskNotificationXml(`
agent-1
local_agent
/tmp/agent-1.out
completed
Agent "Probe" completed
`)
expect(shouldForwardTaskNotificationToModel(notification, { structuredOutput: true })).toBe(false)
})
test('keeps local agent notifications as model input for plain print mode', () => {
const notification = parseTaskNotificationXml(`
agent-1
local_agent
/tmp/agent-1.out
completed
Agent "Probe" completed
`)
expect(shouldForwardTaskNotificationToModel(notification, { structuredOutput: false })).toBe(true)
})
test('continues forwarding background shell notifications to the model', () => {
const notification = parseTaskNotificationXml(`
bash-1
/tmp/bash-1.out
completed
Background command "bun test" completed
`)
expect(shouldForwardTaskNotificationToModel(notification, { structuredOutput: true })).toBe(true)
})
})