Merge remote-tracking branch 'origin/master' into stack/pr-6426
This commit is contained in:
commit
da864e3377
1830 files changed
+34392
-9735
No files matched your search
@@ -107,8 +107,11 @@ describe('sessions.fork', () => {
|
||||
const ctx = await composed()
|
||||
try {
|
||||
const source = ctx.sessions.prepare(sid('current-cold'), { meta: { cwd: '/proj' } })
|
||||
const detach = ctx.effect(() => ctx.sessions.enter(source))
|
||||
ctx.sessions.announce(source)
|
||||
source.append('turn/start', { turn: 1 })
|
||||
source.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
|
||||
await detach()
|
||||
const snapshot: SessionPersistenceSnapshot = {
|
||||
header: source.header,
|
||||
revision: SessionPersistenceRevision('test:cold-source'),
|
||||
|
||||
@@ -122,20 +122,24 @@ async function harness(options: HarnessOptions = {}) {
|
||||
archivedSessionIds: archived,
|
||||
} as never)
|
||||
|
||||
/** Run setup on the unpublished Session, then publish it and its Agent, as the Agent factory does. */
|
||||
/** Enter the Session for setup, then announce creation as the Agent factory does. */
|
||||
const publish = async (
|
||||
session: Session,
|
||||
setup: Parameters<AgentFactory['createAgent']>[1]['setup'],
|
||||
): Promise<{ agent: Agent; dispose: () => Promise<void> }> => {
|
||||
const agent = stubAgent(session)
|
||||
;(agent as { ctx?: Context }).ctx = ctx
|
||||
await setup?.(ctx, agent)
|
||||
ctx.effect(function* () {
|
||||
yield ctx.sessions.enter(session)
|
||||
const detach = ctx.effect(() => ctx.sessions.enter(session))
|
||||
try {
|
||||
ctx.sessions.announce(session)
|
||||
}, 'test: published Session')
|
||||
const unregister = await ctx.agents.register(agent)
|
||||
return { agent, dispose: async () => { await unregister() } }
|
||||
const commit = await setup?.(ctx, agent)
|
||||
commit?.commit()
|
||||
const unregister = await ctx.agents.register(agent)
|
||||
return { agent, dispose: async () => { await unregister(); await detach() } }
|
||||
} catch (error) {
|
||||
await detach()
|
||||
throw error
|
||||
}
|
||||
}
|
||||
const factory: AgentFactory = {
|
||||
async createAgent(_ownerCtx, create) {
|
||||
|
||||
@@ -278,11 +278,6 @@ describe('SessionHistoryController', () => {
|
||||
}
|
||||
const seed = [event('fixture/start', SessionSeq(0))]
|
||||
cold(ctx, header, seed)
|
||||
agentCtx.on('session/created', (session) => {
|
||||
if (session.id !== sessionId) return
|
||||
append(session, 'fixture/setup-one', {})
|
||||
append(session, 'fixture/setup-two', {})
|
||||
})
|
||||
const abort = new AbortController()
|
||||
const iterator = transport.follow({ address: { kind: 'session', sessionId } }, abort.signal)
|
||||
[Symbol.asyncIterator]()
|
||||
@@ -292,6 +287,8 @@ describe('SessionHistoryController', () => {
|
||||
const attached = agentCtx.sessions.prepare(sessionId, { meta: header, seed })
|
||||
agentCtx.sessions.enter(attached)
|
||||
agentCtx.sessions.announce(attached)
|
||||
append(attached, 'fixture/setup-one', {})
|
||||
append(attached, 'fixture/setup-two', {})
|
||||
await expect(iterator.next()).resolves.toMatchObject({
|
||||
done: false,
|
||||
value: { type: 'event', event: { type: 'session/end-seed', seq: 1 } },
|
||||
|
||||
Reference in new issue
Block a user