feat(agent): add controlled task execution
This commit is contained in:
@@ -93,6 +93,22 @@ export class OpencodeRuntimeAdapter {
|
||||
return requireData(response.data, "global.health");
|
||||
}
|
||||
|
||||
async resolveAvailableModel(preferredModelIds: string[]): Promise<string> {
|
||||
const client = await this.ensureClient();
|
||||
const response = await client.config.providers({});
|
||||
const configured = requireData(response.data, "config.providers");
|
||||
const available = new Set(
|
||||
configured.providers.flatMap((provider) =>
|
||||
Object.keys(provider.models).map((modelId) => `${provider.id}/${modelId}`),
|
||||
),
|
||||
);
|
||||
const selected = preferredModelIds.find((modelId) => available.has(modelId));
|
||||
if (!selected) {
|
||||
throw new Error("no configured operational task model is available from OpenCode");
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
async warmup(): Promise<void> {
|
||||
const client = await this.ensureClient();
|
||||
const healthStartedAt = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user