@clawos-dev/clawd 0.2.616 → 0.2.617

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.
Files changed (2) hide show
  1. package/dist/cli.cjs +30 -5
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -65835,7 +65835,18 @@ async function queryPiModels(deps = {}) {
65835
65835
  const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args) : (0, import_node_child_process12.spawn)(cmd, args, { stdio: ["pipe", "pipe", "pipe"] });
65836
65836
  proc.stdin?.on("error", () => {
65837
65837
  });
65838
- const client = new PiRpcClient(piStdioLineStream(proc));
65838
+ let refreshingCliproxy = false;
65839
+ let refreshError;
65840
+ let cliproxyRefreshedCount;
65841
+ const client = new PiRpcClient(piStdioLineStream(proc), {
65842
+ onEvent: (event) => {
65843
+ if (!refreshingCliproxy || event.type !== "extension_ui_request" || event.method !== "notify") return;
65844
+ const message = str2(event.message);
65845
+ if (event.notifyType === "error" && message?.startsWith("Failed to refresh CLIProxyAPI models:")) refreshError = message;
65846
+ const count = /^Refreshed (\d+) CLIProxyAPI models from /.exec(message ?? "");
65847
+ if (count) cliproxyRefreshedCount = Number(count[1]);
65848
+ }
65849
+ });
65839
65850
  const timeoutMs = deps.timeoutMs ?? 15e3;
65840
65851
  let timer;
65841
65852
  let timedOut = false;
@@ -65848,6 +65859,19 @@ async function queryPiModels(deps = {}) {
65848
65859
  const spawnError = new Promise((_3, reject) => proc.on("error", reject));
65849
65860
  const race = (p3) => Promise.race([p3, timeout, spawnError]);
65850
65861
  try {
65862
+ if (deps.refresh) {
65863
+ const commands = await race(client.request({ type: "get_commands" }));
65864
+ if (!commands.success) throw new Error(commands.error ?? "get_commands failed");
65865
+ const hasCliproxyRefresh = arr(rec2(commands.data)?.commands).some((command) => str2(rec2(command)?.name) === "cliproxyapi-refresh");
65866
+ if (hasCliproxyRefresh) {
65867
+ refreshingCliproxy = true;
65868
+ const refreshed = await race(client.request({ type: "prompt", message: "/cliproxyapi-refresh" }));
65869
+ if (!refreshed.success) throw new Error(refreshed.error ?? "cliproxyapi-refresh failed");
65870
+ if (refreshError) throw new Error(refreshError);
65871
+ if (cliproxyRefreshedCount === 0) throw new Error("CLIProxyAPI model refresh returned no models");
65872
+ refreshingCliproxy = false;
65873
+ }
65874
+ }
65851
65875
  const r2 = await race(client.request({ type: "get_available_models" }));
65852
65876
  if (!r2.success) throw new Error(r2.error ?? "get_available_models failed");
65853
65877
  const models = arr(rec2(r2.data)?.models).map(rec2).filter((m3) => m3 !== void 0);
@@ -65897,21 +65921,22 @@ var PiAdapter = class {
65897
65921
  }
65898
65922
  async capabilities(opts) {
65899
65923
  if (opts?.refresh) {
65900
- const fresh = await this.loadCapabilities({ strict: true });
65924
+ const fresh = await this.loadCapabilities({ strict: true, refresh: true });
65901
65925
  this.capsPromise = Promise.resolve(fresh);
65902
65926
  return fresh;
65903
65927
  }
65904
- if (!this.capsPromise) this.capsPromise = this.loadCapabilities({ strict: false });
65928
+ if (!this.capsPromise) this.capsPromise = this.loadCapabilities({ strict: false, refresh: false });
65905
65929
  return this.capsPromise;
65906
65930
  }
65907
65931
  async loadCapabilities(opts) {
65908
65932
  let models = [];
65909
65933
  try {
65910
- models = mapPiModels(this.opts.queryOverride ? await this.opts.queryOverride() : await queryPiModels());
65934
+ models = mapPiModels(this.opts.queryOverride ? await this.opts.queryOverride({ refresh: opts.refresh }) : await queryPiModels({ refresh: opts.refresh }));
65911
65935
  } catch (err) {
65912
65936
  if (opts.strict) throw err;
65913
65937
  this.opts.logger?.warn?.(`pi get_available_models failed: ${err.message}`);
65914
65938
  }
65939
+ if (models.length === 0 && opts.strict) throw new Error("Pi model refresh returned no models");
65915
65940
  if (models.length === 0) models = [PI_DEFAULT_MODEL_ENTRY];
65916
65941
  for (const m3 of models) if (m3.id) this.windows.set(m3.id, m3.contextWindowSize);
65917
65942
  return buildPiCapabilities(models);
@@ -73495,7 +73520,7 @@ function computeMethodAccess(args) {
73495
73520
  }
73496
73521
 
73497
73522
  // src/version.ts
73498
- var version = "0.2.616".length > 0 ? "0.2.616" : "dev";
73523
+ var version = "0.2.617".length > 0 ? "0.2.617" : "dev";
73499
73524
 
73500
73525
  // src/cli-probe/probe.ts
73501
73526
  var fs83 = __toESM(require("fs"), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.616",
3
+ "version": "0.2.617",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",