@ckcloudai.com/clawrouter 0.0.2 → 0.0.4

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 CHANGED
@@ -126,7 +126,7 @@ async function loadBaseModels() {
126
126
  clearTimeout(timeout);
127
127
  }
128
128
  }
129
- var BASE_MODELS = await loadBaseModels();
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) => {
@@ -6441,12 +6469,7 @@ function injectModelsConfig(logger2) {
6441
6469
  const TOP_MODELS = [
6442
6470
  "free",
6443
6471
  "eco",
6444
- "premium",
6445
- "anthropic/claude-sonnet-4.5",
6446
- "openai/gpt-5.2",
6447
- "deepseek/deepseek-chat",
6448
- "moonshot/kimi-k2.5",
6449
- "minimax/minimax-m2.5"
6472
+ "premium"
6450
6473
  ];
6451
6474
  if (!defaults.models || typeof defaults.models !== "object" || Array.isArray(defaults.models)) {
6452
6475
  defaults.models = {};
@@ -6465,6 +6488,12 @@ function injectModelsConfig(logger2) {
6465
6488
  needsWrite = true;
6466
6489
  logger2.info(`Added ${addedCount} models to allowlist (${TOP_MODELS.length} total)`);
6467
6490
  }
6491
+ for (const m of OPENCLAW_MODELS) {
6492
+ if (!allowlist[m.name]) {
6493
+ allowlist[m.name] = {};
6494
+ addedCount++;
6495
+ }
6496
+ }
6468
6497
  if (needsWrite) {
6469
6498
  try {
6470
6499
  const tmpPath = `${configPath}.tmp.${process.pid}`;