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();
|
||||
|
||||
@@ -10,6 +10,8 @@ export type RuntimeSessionContext = {
|
||||
sessionId: string;
|
||||
traceId: string;
|
||||
capabilities?: string[];
|
||||
purpose?: "ordinary_chat" | "task_execution" | "task_collaboration";
|
||||
taskId?: string;
|
||||
};
|
||||
|
||||
const contexts = new Map<string, RuntimeSessionContext>();
|
||||
|
||||
Reference in New Issue
Block a user