mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-11 04:00:38 +00:00
refactor(agent): make runtime identity explicit
This commit is contained in:
@@ -421,15 +421,12 @@ describe('ApiSession create or adoption', () => {
|
||||
.rejects.toBeInstanceOf(ApiSessionCwdConflict)
|
||||
})
|
||||
|
||||
it('surfaces directory creation failure and rejects setup without a scoped Agent', async () => {
|
||||
it('surfaces directory creation failure', async () => {
|
||||
const { agents } = await harness()
|
||||
const parent = mkdtempSync(join(tmpdir(), 'dsh-session-controller-file-'))
|
||||
const file = join(parent, 'file')
|
||||
writeFileSync(file, 'not a directory')
|
||||
await expect(agents.ensureSession(SessionId('mkdir-failure'), join(file, 'child'), false))
|
||||
.rejects.toThrow('failed to ensure project directory')
|
||||
|
||||
const composition = await agents.composeAgent(undefined)
|
||||
expect(() => composition.setup(new Context())).toThrow('Agent setup has no scoped Agent')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -34,9 +34,9 @@ async function composed(workspaces: readonly Workspace[] = []): Promise<Context>
|
||||
...options.meta === undefined ? {} : { meta: options.meta },
|
||||
})
|
||||
const agent = {} as Agent
|
||||
const agentCtx = ownerCtx.extend({ agent })
|
||||
const agentCtx = ownerCtx
|
||||
Object.assign(agent, { id: session.id, session, status: 'idle', ctx: agentCtx })
|
||||
await options.setup?.(agentCtx)
|
||||
await options.setup?.(agentCtx, agent)
|
||||
ctx.agents.register(agent)
|
||||
return { agent, dispose: () => Promise.resolve() }
|
||||
},
|
||||
|
||||
@@ -49,9 +49,8 @@ async function harness(presets?: readonly string[]) {
|
||||
options.meta === undefined ? {} : { meta: options.meta },
|
||||
)
|
||||
const agent = stubAgent(session)
|
||||
const agentCtx = ctx.extend({ agent })
|
||||
;(agent as { ctx?: Context }).ctx = agentCtx
|
||||
await options.setup?.(agentCtx)
|
||||
;(agent as { ctx?: Context }).ctx = ctx
|
||||
await options.setup?.(ctx, agent)
|
||||
const unregister = ctx.agents.register(agent)
|
||||
return { agent, dispose: () => { unregister(); return Promise.resolve() } }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user