benignswarm 0.7.3 → 0.7.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/config.js CHANGED
@@ -4,7 +4,7 @@ import { join } from "node:path";
4
4
  import { CliError } from "./errors.js";
5
5
  import { findIdentityFile, readIdentityFile } from "./harness.js";
6
6
  import { resolveModelDetailed } from "./model.js";
7
- import { readState } from "./state.js";
7
+ import { readState, writeState } from "./state.js";
8
8
  import { detectVendor } from "./vendor.js";
9
9
  export const DEFAULT_URL = "https://api.benignswarm.org";
10
10
  export function configRoot(env = process.env) {
@@ -99,6 +99,7 @@ export function resolveModel(flag, env = process.env, cwd = process.cwd(), agent
99
99
  const vendor = detectVendor(env);
100
100
  const identityModel = file && vendor ? readIdentityFile(file).agents[vendor]?.model ?? null : null;
101
101
  let hookModel = null;
102
+ let savedVendor = null;
102
103
  const name = agentName ?? (flag === undefined ? env.BSCHAT_AGENT : undefined) ?? (file && vendor ? readIdentityFile(file).agents[vendor]?.name : undefined);
103
104
  if (name) {
104
105
  try {
@@ -107,6 +108,24 @@ export function resolveModel(flag, env = process.env, cwd = process.cwd(), agent
107
108
  catch {
108
109
  hookModel = null;
109
110
  }
111
+ try {
112
+ savedVendor = loadAgent(name, env).vendor;
113
+ }
114
+ catch {
115
+ savedVendor = null;
116
+ }
117
+ }
118
+ const r = resolveModelDetailed({ flag, env, hookModel, identityModel, cwd, vendor: savedVendor });
119
+ // Remember a detected model so a later call that cannot detect it reports the same value.
120
+ if (name && r.model !== "unknown" && (r.source === "config" || r.source === "hook")) {
121
+ try {
122
+ const st = readState(name, env);
123
+ if (st.model !== r.model)
124
+ writeState(name, { ...st, model: r.model, model_observed_at: Date.now() }, env);
125
+ }
126
+ catch {
127
+ /* state dir unwritable: nothing to remember */
128
+ }
110
129
  }
111
- return resolveModelDetailed({ flag, env, hookModel, identityModel, cwd }).model;
130
+ return r.model;
112
131
  }
package/dist/model.js CHANGED
@@ -88,7 +88,9 @@ export function resolveModelDetailed(opts) {
88
88
  return { model: env.BSCHAT_MODEL, source: "env" };
89
89
  if (opts.hookModel)
90
90
  return { model: opts.hookModel, source: "hook" };
91
- const cfg = modelFromHarnessConfig(detectVendor(env), opts.cwd, env);
91
+ // Env-based vendor detection can fail inside a harness's sandboxed shell; the vendor saved at
92
+ // join time is the stable fallback so the config lookup does not flap between a value and unknown.
93
+ const cfg = modelFromHarnessConfig(detectVendor(env) ?? opts.vendor ?? null, opts.cwd, env);
92
94
  if (cfg)
93
95
  return { model: cfg, source: "config" };
94
96
  if (opts.identityModel)
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.7.3";
1
+ export const CLI_VERSION = "0.7.4";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "bschat: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {