@ckcloudai.com/clawrouter 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -126,7 +126,7 @@ async function loadBaseModels() {
|
|
|
126
126
|
clearTimeout(timeout);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
var BASE_MODELS =
|
|
129
|
+
var BASE_MODELS = [...DEFAULT_BASE_MODELS];
|
|
130
130
|
function resolveModelAlias(model) {
|
|
131
131
|
const normalized = model.trim().toLowerCase();
|
|
132
132
|
const resolved = MODEL_ALIASES[normalized];
|
|
@@ -236,6 +236,23 @@ var OPENCLAW_MODELS = [
|
|
|
236
236
|
...BASE_MODELS.map(toOpenClawModel),
|
|
237
237
|
...buildAliasModels(BASE_MODELS)
|
|
238
238
|
];
|
|
239
|
+
var baseModelsInit = null;
|
|
240
|
+
function rebuildModels(nextBaseModels) {
|
|
241
|
+
BASE_MODELS = nextBaseModels;
|
|
242
|
+
OPENCLAW_MODELS = [
|
|
243
|
+
...BASE_MODELS.map(toOpenClawModel),
|
|
244
|
+
...buildAliasModels(BASE_MODELS)
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
function initBaseModels() {
|
|
248
|
+
if (baseModelsInit) return baseModelsInit;
|
|
249
|
+
baseModelsInit = (async () => {
|
|
250
|
+
const next = await loadBaseModels();
|
|
251
|
+
rebuildModels(next);
|
|
252
|
+
})();
|
|
253
|
+
return baseModelsInit;
|
|
254
|
+
}
|
|
255
|
+
void initBaseModels();
|
|
239
256
|
function buildProviderModels(baseUrl) {
|
|
240
257
|
if (!baseUrl) {
|
|
241
258
|
baseUrl = BASE_API_URL;
|
|
@@ -4635,6 +4652,7 @@ async function startProxy(options) {
|
|
|
4635
4652
|
const walletKey = typeof options.wallet === "string" ? options.wallet : options.wallet.key;
|
|
4636
4653
|
const solanaPrivateKeyBytes = typeof options.wallet === "string" ? void 0 : options.wallet.solanaPrivateKeyBytes;
|
|
4637
4654
|
setPluginLogger(options.logger ?? console);
|
|
4655
|
+
await initBaseModels();
|
|
4638
4656
|
const paymentChain = options.paymentChain ?? await resolvePaymentChain();
|
|
4639
4657
|
const apiBase = options.apiBase ?? (paymentChain === "solana" && solanaPrivateKeyBytes ? CKCLOUD_SOLANA_API : CKCLOUD_API);
|
|
4640
4658
|
if (paymentChain === "solana" && !solanaPrivateKeyBytes) {
|
|
@@ -6249,6 +6267,16 @@ var plugin = {
|
|
|
6249
6267
|
models: OPENCLAW_MODELS
|
|
6250
6268
|
};
|
|
6251
6269
|
api.logger.info("ckcloud provider registered");
|
|
6270
|
+
initBaseModels().then(() => {
|
|
6271
|
+
injectModelsConfig(api.logger);
|
|
6272
|
+
if (api.config.models?.providers?.ckcloud) {
|
|
6273
|
+
api.config.models.providers.ckcloud.models = OPENCLAW_MODELS;
|
|
6274
|
+
}
|
|
6275
|
+
}).catch((err) => {
|
|
6276
|
+
api.logger.warn(
|
|
6277
|
+
`Failed to refresh models list: ${err instanceof Error ? err.message : String(err)}`
|
|
6278
|
+
);
|
|
6279
|
+
});
|
|
6252
6280
|
createStatsCommand().then((statsCommand) => {
|
|
6253
6281
|
api.registerCommand(statsCommand);
|
|
6254
6282
|
}).catch((err) => {
|