refactor(agent): require complete send options

This commit is contained in:
_Kerman
2026-07-24 16:23:20 +08:00
parent 45fc7fda3d
commit e23960b8ad
15 changed files with 116 additions and 62 deletions

View File

@@ -9,7 +9,14 @@ import AgentRegistry, {
agentInterruptReasonOf,
} from '@deepseek-ai/dsh-agent'
import type { AgentCancelCause, AgentFactory, ContinuationStop, CreateAgentOptions, ResumeAgentOptions } from '@deepseek-ai/dsh-agent'
import type {
AgentCancelCause,
AgentFactory,
ContinuationStop,
CreateAgentOptions,
ResumeAgentOptions,
SendOptions,
} from '@deepseek-ai/dsh-agent'
function stubAgent(rawId: string, overrides: Partial<Agent> = {}): Agent {
const id = SessionId(rawId)
@@ -28,6 +35,28 @@ function stubAgent(rawId: string, overrides: Partial<Agent> = {}): Agent {
})
}
describe('Agent delivery aliases', () => {
it('materializes complete SendOptions for every preset', () => {
const calls: SendOptions[] = []
const agent = stubAgent('aliases', {
send(_content, options) {
if (options !== undefined) calls.push(options)
return AgentMessageId('stub')
},
})
agent.followup([])
agent.steer([])
agent.inject([])
expect(calls).toEqual([
{ target: 'next-turn', wakeup: true, source: { kind: 'user' } },
{ target: 'next-step', wakeup: true, source: { kind: 'user' } },
{ target: 'next-step', wakeup: false, source: { kind: 'plugin', plugin: '' } },
])
})
})
describe('AgentRegistry', () => {
it('allows terminal stop policy to cooperate asynchronously with turn cancellation', () => {
type TurnStopListener = Events['agent/turn-stop']