fix(agents): copy factory mode to agent config for Desktop 1.14.x compat

OpenCode Desktop 1.14.x filters agents by `mode` field. The `mode` was
only present on the factory function as a static property, but not copied
to the generated AgentConfig object.

This fix copies `source.mode` to `base.mode` in `buildAgent()` when:
- source is a factory function (has `mode` static property)
- the generated config doesn't already define `mode`

Test: agent-builder.test.ts (4 pass)

Closes: #3835
Related: #3762, #3812, #3794, #3475, #3474, #3829, #3831, #3824, #3826, #3721, #3806, #3188
This commit is contained in:
herjarsa
2026-05-07 16:18:41 +02:00
parent 9ab273100d
commit adc6d92a8e
2 changed files with 71 additions and 0 deletions
+4
View File
@@ -33,5 +33,9 @@ export function buildAgent(
}
}
if (isFactory(source) && (base as AgentConfig & { mode?: string }).mode === undefined) {
;(base as AgentConfig & { mode?: string }).mode = source.mode
}
return base
}