Skip to content

Commit 49dcf43

Browse files
joshavantvincentkocjesse-merhi
committed
test(release): repair live matrix expectations
Co-authored-by: Vincent Koc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: jesse-merhi <79823012+jesse-merhi@users.noreply.github.com>
1 parent 3c3705b commit 49dcf43

1 file changed

Lines changed: 62 additions & 34 deletions

File tree

src/gateway/gateway-models.profiles.live.test.ts

Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,51 @@ function createStaticLiveModelRegistry(models: Array<Model>): LiveModelRegistry
21312131
};
21322132
}
21332133

2134+
async function loadAuthBackedLiveModelRegistry(params: {
2135+
agentDir: string;
2136+
cfg: OpenClawConfig;
2137+
providerList: string[] | undefined;
2138+
}): Promise<{
2139+
authProfileStore: AuthProfileStore;
2140+
modelRegistry: LiveModelRegistry;
2141+
all: Array<Model>;
2142+
}> {
2143+
const authProfileStore = await withGatewayLiveSetupTimeout(
2144+
Promise.resolve().then(() =>
2145+
params.providerList
2146+
? ensureAuthProfileStoreWithoutExternalProfiles(params.agentDir, {
2147+
allowKeychainPrompt: false,
2148+
})
2149+
: ensureAuthProfileStore(params.agentDir, {
2150+
allowKeychainPrompt: false,
2151+
}),
2152+
),
2153+
"[all-models] load auth profiles",
2154+
);
2155+
const authStorage = await withGatewayLiveSetupTimeout(
2156+
Promise.resolve().then(() =>
2157+
discoverAuthStorage(params.agentDir, {
2158+
config: params.cfg,
2159+
env: process.env,
2160+
...(params.providerList
2161+
? {
2162+
skipExternalAuthProfiles: true,
2163+
syntheticAuthProviderRefs: [],
2164+
}
2165+
: {}),
2166+
}),
2167+
),
2168+
"[all-models] load auth storage",
2169+
);
2170+
logProgress("[all-models] loading model registry");
2171+
const modelRegistry = discoverModels(authStorage, params.agentDir);
2172+
const all = await withGatewayLiveSetupTimeout(
2173+
Promise.resolve().then(() => modelRegistry.getAll()),
2174+
"[all-models] load model registry",
2175+
);
2176+
return { authProfileStore, modelRegistry, all };
2177+
}
2178+
21342179
function toLiveModelConfig(model: Model): NonNullable<ModelProviderConfig["models"]>[number] {
21352180
return {
21362181
id: model.id,
@@ -3280,42 +3325,25 @@ describeLive("gateway live (dev agent, profile keys)", () => {
32803325
loadProviderScopedModels({ agentDir, providerList: providerScopedModelProviders }),
32813326
"[all-models] load provider-scoped model refs",
32823327
);
3283-
modelRegistry = createStaticLiveModelRegistry(all);
3328+
if (all.length > 0) {
3329+
modelRegistry = createStaticLiveModelRegistry(all);
3330+
} else {
3331+
logProgress("[all-models] provider-scoped model refs empty; loading auth profiles");
3332+
const authBacked = await loadAuthBackedLiveModelRegistry({
3333+
agentDir,
3334+
cfg,
3335+
providerList: providerScopedModelProviders,
3336+
});
3337+
authProfileStore = authBacked.authProfileStore;
3338+
modelRegistry = authBacked.modelRegistry;
3339+
all = authBacked.all;
3340+
}
32843341
} else {
32853342
logProgress("[all-models] loading auth profiles");
3286-
authProfileStore = await withGatewayLiveSetupTimeout(
3287-
Promise.resolve().then(() =>
3288-
providerList
3289-
? ensureAuthProfileStoreWithoutExternalProfiles(agentDir, {
3290-
allowKeychainPrompt: false,
3291-
})
3292-
: ensureAuthProfileStore(agentDir, {
3293-
allowKeychainPrompt: false,
3294-
}),
3295-
),
3296-
"[all-models] load auth profiles",
3297-
);
3298-
const authStorage = await withGatewayLiveSetupTimeout(
3299-
Promise.resolve().then(() =>
3300-
discoverAuthStorage(agentDir, {
3301-
config: cfg,
3302-
env: process.env,
3303-
...(providerList
3304-
? {
3305-
skipExternalAuthProfiles: true,
3306-
syntheticAuthProviderRefs: [],
3307-
}
3308-
: {}),
3309-
}),
3310-
),
3311-
"[all-models] load auth storage",
3312-
);
3313-
logProgress("[all-models] loading model registry");
3314-
modelRegistry = discoverModels(authStorage, agentDir);
3315-
all = await withGatewayLiveSetupTimeout(
3316-
Promise.resolve().then(() => modelRegistry.getAll()),
3317-
"[all-models] load model registry",
3318-
);
3343+
const authBacked = await loadAuthBackedLiveModelRegistry({ agentDir, cfg, providerList });
3344+
authProfileStore = authBacked.authProfileStore;
3345+
modelRegistry = authBacked.modelRegistry;
3346+
all = authBacked.all;
33193347
}
33203348
const maxModels = GATEWAY_LIVE_MAX_MODELS;
33213349
const targetMatcher = createLiveTargetMatcher({

0 commit comments

Comments
 (0)