refactor(agent): complete inbox lifecycle migration
This commit is contained in:
@@ -30,6 +30,17 @@ export type { SessionSurface, SurfaceFoldReplacement, SurfaceFoldResult } from '
|
||||
export { foldSurface, isAppendSurfaceEvent, isReplacementSurfaceEvent, isSurfaceEvent, isSurfaceEligibleType } from './surface.ts'
|
||||
export { canonicalHeader, foldRequestHeader, headerEquals } from './request-header.ts'
|
||||
|
||||
/**
|
||||
* Find the latest completed model turn in an event sequence.
|
||||
* @param events - session events, or an owned suffix, to inspect.
|
||||
* @returns the latest turn end, or `undefined`.
|
||||
*/
|
||||
export function findLastMessageTurnEnd(
|
||||
events: readonly SessionEvent[],
|
||||
): SessionEvent<'turn/end'> | undefined {
|
||||
return events.findLast(event => event.type === 'turn/end')
|
||||
}
|
||||
|
||||
declare module 'cordis' {
|
||||
interface Context {
|
||||
sessions: SessionStore
|
||||
|
||||
@@ -188,6 +188,12 @@ describe('session-log invariants', () => {
|
||||
skipped.append('step/end', { turn: 1, step: 1 })
|
||||
expect(() => skipped.append('step/start', { turn: 1, step: 3 }))
|
||||
.toThrow(/expected step 2 in turn 1, got 3/)
|
||||
|
||||
expect(() => skipped.append('turn/end', {
|
||||
turn: 1,
|
||||
step: 0,
|
||||
reason: { kind: 'completed' },
|
||||
})).toThrow(/expected last step 1, got 0/)
|
||||
})
|
||||
|
||||
it('requires step-scoped stream and tool events to name the open step', async () => {
|
||||
|
||||
Reference in New Issue
Block a user