refactor(agent): expose mutable inbox state

This commit is contained in:
_Kerman
2026-07-30 15:35:18 +08:00
parent c0ef93efc8
commit 4370004360
52 changed files with 534 additions and 913 deletions

View File

@@ -200,10 +200,14 @@ describe('dsh-subagent-spawn', () => {
expect(published).toEqual([])
})
it('a cancel from agent/inbox/enqueue maps a no-turn child log to aborted', async () => {
it('a cancel after the child prompt is queued maps a no-turn child log to aborted', async () => {
const { ctx, parent } = await setup([])
const controller = new AbortController()
ctx.on('agent/inbox/enqueue', () => { controller.abort('queued-window') })
ctx.on('session/event', (_session, event) => {
if (event.type === 'agent/inbox/spliced' && event.data.inserted.length > 0) {
queueMicrotask(() => { controller.abort('queued-window') })
}
})
const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent, signal: controller.signal })
const result = await run.result
expect(result).toMatchObject({ stopReason: 'aborted', output: [] })