refactor(agent): simplify inbox-driven turn admission

This commit is contained in:
_Kerman
2026-08-02 00:27:37 +08:00
parent d38c8bfaf3
commit dbdf270af0
104 changed files with 550 additions and 511 deletions

View File

@@ -43,8 +43,8 @@ function agent(ctx: Context, cwd?: string): Agent {
const session = new Session(id, undefined, { version: 0, id, createdAt: 0, ...cwd === undefined ? {} : { cwd } })
return {
id, options: {}, session, inbox: new Inbox(session, { inserted: () => {}, discarded: () => {} }),
status: 'idle', acceptsNextStep: false, ctx,
send: () => {}, updateInbox: () => 'not-found', reserveTurnAdmission: () => undefined,
status: 'idle', ctx,
send: () => {},
followup: () => {}, steer: () => {}, inject: () => {}, cancel() {}, whenIdle: () => Promise.resolve(),
}
}
@@ -258,8 +258,8 @@ describe('pty-local plugin shape', () => {
const ownerFiber = await ctx.plugin(() => {})
const owner: Agent = {
id: session.id, options: {}, session, inbox: new Inbox(session, { inserted: () => {}, discarded: () => {} }),
status: 'idle', acceptsNextStep: false, ctx: ownerFiber.ctx,
send: () => {}, updateInbox: () => 'not-found', reserveTurnAdmission: () => undefined,
status: 'idle', ctx: ownerFiber.ctx,
send: () => {},
followup: () => {}, steer: () => {}, inject: () => {}, cancel() {}, whenIdle: () => Promise.resolve(),
}
ctx.agents.register(owner)
@@ -303,8 +303,8 @@ describe('pty-local plugin shape', () => {
const ownerFiber = await ctx.plugin(() => {})
const owner: Agent = {
id: session.id, options: {}, session, inbox: new Inbox(session, { inserted: () => {}, discarded: () => {} }),
status: 'idle', acceptsNextStep: false, ctx: ownerFiber.ctx,
send: () => {}, updateInbox: () => 'not-found', reserveTurnAdmission: () => undefined,
status: 'idle', ctx: ownerFiber.ctx,
send: () => {},
followup: () => {}, steer: () => {}, inject: () => {}, cancel() {}, whenIdle: () => Promise.resolve(),
}
ctx.agents.register(owner)

View File

@@ -36,8 +36,8 @@ function stubAgent(ctx: Context, rawId: string): Agent {
const session = new Session(id)
return {
id, options: {}, session, inbox: new Inbox(session, { inserted: () => {}, discarded: () => {} }),
status: 'idle', acceptsNextStep: false, ctx: scope.ctx,
send: () => {}, updateInbox: () => 'not-found', reserveTurnAdmission: () => undefined,
status: 'idle', ctx: scope.ctx,
send: () => {},
followup: () => {}, steer: () => {}, inject: () => {}, cancel() {}, whenIdle: () => Promise.resolve(),
}
}

View File

@@ -33,8 +33,6 @@ function stubAgent(ctx: Context, rawId: string): Agent {
followup: () => {},
steer: () => {},
inject: () => {},
updateInbox: () => 'not-found',
reserveTurnAdmission: () => undefined,
cancel() {},
whenIdle: () => Promise.resolve(),
}

View File

@@ -50,8 +50,6 @@ function agent(ctx: Context, cwd: string): Agent {
followup: () => {},
steer: () => {},
inject: () => {},
updateInbox: () => 'not-found',
reserveTurnAdmission: () => undefined,
cancel() {},
whenIdle: () => Promise.resolve(),
}

View File

@@ -46,8 +46,6 @@ function agent(ctx: Context, cwd: string | undefined): Agent {
followup: () => {},
steer: () => {},
inject: () => {},
updateInbox: () => 'not-found',
reserveTurnAdmission: () => undefined,
cancel() {},
whenIdle: () => Promise.resolve(),
}

View File

@@ -41,8 +41,8 @@ function agent(ctx: Context): Agent {
const session = new Session(id)
const value: Agent = {
id, options: {}, session, inbox: new Inbox(session, { inserted: () => {}, discarded: () => {} }),
status: 'idle', acceptsNextStep: false, ctx: scope.ctx,
send: () => {}, updateInbox: () => 'not-found', reserveTurnAdmission: () => undefined,
status: 'idle', ctx: scope.ctx,
send: () => {},
followup: () => {}, steer: () => {}, inject: () => {}, cancel() {}, whenIdle: () => Promise.resolve(),
}
ctx.agents.register(value)

View File

@@ -19,8 +19,8 @@ function fakeAgent(ctx: Context, rawId: string): Agent {
const session = new Session(id)
const agent: Agent = {
id, options: {}, session, inbox: new Inbox(session, { inserted: () => {}, discarded: () => {} }),
status: 'idle', acceptsNextStep: false, ctx: scope.ctx,
send: () => {}, updateInbox: () => 'not-found', reserveTurnAdmission: () => undefined,
status: 'idle', ctx: scope.ctx,
send: () => {},
followup: () => {}, steer: () => {}, inject: () => {}, cancel() {}, whenIdle: () => Promise.resolve(),
}
ctx.agents.register(agent)