This commit is contained in:
+12
-9
@@ -62,17 +62,20 @@ export default Plugin.define({
|
||||
status: async ({ sessionID }) => (await quota.status(sessionID)) ?? null,
|
||||
});
|
||||
await quota.init();
|
||||
// Subscribe before the first read: configuration can publish its catalog while
|
||||
// Subscribe before the first read: configuration can publish its models while
|
||||
// asynchronous setup is running.
|
||||
const updates = (async () => {
|
||||
for await (const event of context.event.subscribe({ signal: controller.signal })) {
|
||||
if (
|
||||
event.location &&
|
||||
(event.location.directory !== context.location.directory ||
|
||||
event.location.workspaceID !== context.location.workspaceID)
|
||||
)
|
||||
continue;
|
||||
if (event.type === "catalog.updated") {
|
||||
if (event.location) {
|
||||
const workspaceID =
|
||||
"workspaceID" in event.location ? event.location.workspaceID : undefined;
|
||||
if (
|
||||
event.location.directory !== context.location.directory ||
|
||||
workspaceID !== context.location.workspaceID
|
||||
)
|
||||
continue;
|
||||
}
|
||||
if (event.type === "model.updated") {
|
||||
models = await discover(context, selected.provider);
|
||||
await context.agent.reload();
|
||||
} else if (event.type === "agent.updated") {
|
||||
@@ -105,7 +108,7 @@ export default Plugin.define({
|
||||
}
|
||||
})().catch((error) => {
|
||||
if (!controller.signal.aborted)
|
||||
console.error("stanp-opencode catalog update failed", error);
|
||||
console.error("stanp-opencode model update failed", error);
|
||||
});
|
||||
models = await discover(context, selected.provider);
|
||||
const { data: initialAgents } = await context.agent.list();
|
||||
|
||||
+2
-2
@@ -21,8 +21,8 @@ function priority(model: ModelInfo) {
|
||||
}
|
||||
|
||||
export async function discover(context: Plugin.Context, providerID: string) {
|
||||
// Native lists already apply activation, integrations, configuration, and catalog transforms.
|
||||
const { data } = await context.catalog.model.list();
|
||||
// Native lists already apply activation, integrations, configuration, and model transforms.
|
||||
const { data } = await context.model.list();
|
||||
const models = new Map<string, { model: ModelInfo; serviceTier: string | undefined }>();
|
||||
for (const model of data) {
|
||||
if (model.providerID === providerID && model.enabled)
|
||||
|
||||
Reference in New Issue
Block a user