refactor(agent): make runtime identity explicit

This commit is contained in:
_Kerman
2026-08-28 17:44:56 +08:00
parent 375af94454
commit ebce3a5f04
61 changed files with 281 additions and 396 deletions
+6 -6
View File
@@ -380,12 +380,14 @@ export class ApiSessionAgentController {
readonly setup: AgentSetup
}> {
const presets = this.ctx.get('agentPresets')
if (presets === undefined) return { setup: (agentCtx) => { this.installSelection(agentCtx) } }
if (presets === undefined) {
return { setup: (_agentCtx, agent) => { this.installSelection(agent) } }
}
const resolvedId = (await presets.resolve(presetId)).id
return {
agentPreset: resolvedId,
setup: async (agentCtx) => {
this.installSelection(agentCtx)
setup: async (agentCtx, agent) => {
this.installSelection(agent)
await presets.mount(agentCtx, resolvedId)
},
}
@@ -494,9 +496,7 @@ export class ApiSessionAgentController {
return { provider, model }
}
private installSelection(agentCtx: Context): void {
const agent = agentCtx.agent
if (agent === undefined) throw new Error('api-session: Agent setup has no scoped Agent')
private installSelection(agent: Agent): void {
this.selectionFor(agent)
}