@clawos-dev/clawd 0.2.615 → 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 +33 -7
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -46330,6 +46330,7 @@ function pushEventToBufferInPlace(next, event, deps) {
46330
46330
  const isTurnEnd = withSeq.kind === "turn_end";
46331
46331
  const isUserText = withSeq.kind === "user_text";
46332
46332
  const isBackgroundEvent = withSeq.kind === "subagent_progress";
46333
+ const isSessionInit = withSeq.kind === "session_init";
46333
46334
  if (isBackgroundEvent) {
46334
46335
  const bg = withSeq;
46335
46336
  const done = bg.status === "completed" || bg.status === "failed";
@@ -46350,7 +46351,7 @@ function pushEventToBufferInPlace(next, event, deps) {
46350
46351
  }
46351
46352
  next.turnOpen = false;
46352
46353
  next.turnStartedAt = null;
46353
- } else if (!isBackgroundEvent && !next.turnOpen) {
46354
+ } else if (!isBackgroundEvent && !(isSessionInit && next.status === "running-idle") && !next.turnOpen) {
46354
46355
  next.turnOpen = true;
46355
46356
  next.turnStartedAt = deps.now();
46356
46357
  }
@@ -46362,7 +46363,7 @@ function pushEventToBufferInPlace(next, event, deps) {
46362
46363
  }
46363
46364
  if (next.freshSpawn) next.freshSpawn = false;
46364
46365
  const effects = [emitSessionEvent(next.file.sessionId, withSeq)];
46365
- if (!isTurnEnd && !isBackgroundEvent && withSeq.kind !== "meta-text" && next.status === "running-idle" && next.procAlive) {
46366
+ if (!isTurnEnd && !isBackgroundEvent && !isSessionInit && withSeq.kind !== "meta-text" && next.status === "running-idle" && next.procAlive) {
46366
46367
  next.status = "running";
46367
46368
  effects.push({ kind: "cancel-idle-kill", sessionId: next.file.sessionId });
46368
46369
  effects.push({
@@ -65834,7 +65835,18 @@ async function queryPiModels(deps = {}) {
65834
65835
  const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args) : (0, import_node_child_process12.spawn)(cmd, args, { stdio: ["pipe", "pipe", "pipe"] });
65835
65836
  proc.stdin?.on("error", () => {
65836
65837
  });
65837
- 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
+ });
65838
65850
  const timeoutMs = deps.timeoutMs ?? 15e3;
65839
65851
  let timer;
65840
65852
  let timedOut = false;
@@ -65847,6 +65859,19 @@ async function queryPiModels(deps = {}) {
65847
65859
  const spawnError = new Promise((_3, reject) => proc.on("error", reject));
65848
65860
  const race = (p3) => Promise.race([p3, timeout, spawnError]);
65849
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
+ }
65850
65875
  const r2 = await race(client.request({ type: "get_available_models" }));
65851
65876
  if (!r2.success) throw new Error(r2.error ?? "get_available_models failed");
65852
65877
  const models = arr(rec2(r2.data)?.models).map(rec2).filter((m3) => m3 !== void 0);
@@ -65896,21 +65921,22 @@ var PiAdapter = class {
65896
65921
  }
65897
65922
  async capabilities(opts) {
65898
65923
  if (opts?.refresh) {
65899
- const fresh = await this.loadCapabilities({ strict: true });
65924
+ const fresh = await this.loadCapabilities({ strict: true, refresh: true });
65900
65925
  this.capsPromise = Promise.resolve(fresh);
65901
65926
  return fresh;
65902
65927
  }
65903
- if (!this.capsPromise) this.capsPromise = this.loadCapabilities({ strict: false });
65928
+ if (!this.capsPromise) this.capsPromise = this.loadCapabilities({ strict: false, refresh: false });
65904
65929
  return this.capsPromise;
65905
65930
  }
65906
65931
  async loadCapabilities(opts) {
65907
65932
  let models = [];
65908
65933
  try {
65909
- 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 }));
65910
65935
  } catch (err) {
65911
65936
  if (opts.strict) throw err;
65912
65937
  this.opts.logger?.warn?.(`pi get_available_models failed: ${err.message}`);
65913
65938
  }
65939
+ if (models.length === 0 && opts.strict) throw new Error("Pi model refresh returned no models");
65914
65940
  if (models.length === 0) models = [PI_DEFAULT_MODEL_ENTRY];
65915
65941
  for (const m3 of models) if (m3.id) this.windows.set(m3.id, m3.contextWindowSize);
65916
65942
  return buildPiCapabilities(models);
@@ -73494,7 +73520,7 @@ function computeMethodAccess(args) {
73494
73520
  }
73495
73521
 
73496
73522
  // src/version.ts
73497
- var version = "0.2.615".length > 0 ? "0.2.615" : "dev";
73523
+ var version = "0.2.617".length > 0 ? "0.2.617" : "dev";
73498
73524
 
73499
73525
  // src/cli-probe/probe.ts
73500
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.615",
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",