fix: command model selection (#2219)
This commit is contained in:
@@ -1171,12 +1171,16 @@ export namespace Session {
|
|||||||
|
|
||||||
export async function command(input: CommandInput) {
|
export async function command(input: CommandInput) {
|
||||||
const command = await Command.get(input.command)
|
const command = await Command.get(input.command)
|
||||||
const agent = input.agent ?? command.agent ?? "build"
|
const agent = command.agent ?? input.agent ?? "build"
|
||||||
|
const fmtModel = (model: { providerID: string; modelID: string }) => `${model.providerID}/${model.modelID}`
|
||||||
|
|
||||||
const model =
|
const model =
|
||||||
input.model ??
|
|
||||||
command.model ??
|
command.model ??
|
||||||
(await Agent.get(agent).then((x) => (x.model ? `${x.model.providerID}/${x.model.modelID}` : undefined))) ??
|
(command.agent && (await Agent.get(command.agent).then((x) => (x.model ? fmtModel(x.model) : undefined)))) ??
|
||||||
(await Provider.defaultModel().then((x) => `${x.providerID}/${x.modelID}`))
|
input.model ??
|
||||||
|
(input.agent && (await Agent.get(input.agent).then((x) => (x.model ? fmtModel(x.model) : undefined)))) ??
|
||||||
|
fmtModel(await Provider.defaultModel())
|
||||||
|
|
||||||
let template = command.template.replace("$ARGUMENTS", input.arguments)
|
let template = command.template.replace("$ARGUMENTS", input.arguments)
|
||||||
|
|
||||||
const bash = Array.from(template.matchAll(bashRegex))
|
const bash = Array.from(template.matchAll(bashRegex))
|
||||||
|
|||||||
@@ -820,6 +820,8 @@ func (a *App) SendCommand(ctx context.Context, command string, args string) (*Ap
|
|||||||
opencode.SessionCommandParams{
|
opencode.SessionCommandParams{
|
||||||
Command: opencode.F(command),
|
Command: opencode.F(command),
|
||||||
Arguments: opencode.F(args),
|
Arguments: opencode.F(args),
|
||||||
|
Agent: opencode.F(a.Agents[a.AgentIndex].Name),
|
||||||
|
Model: opencode.F(a.State.Provider + "/" + a.State.Model),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user