wildcrane-runner 0.6.86 → 0.6.87

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/runner.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.86 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.87 — built by runner/scripts/build.mjs. Do not edit.
2
2
  import { createRequire as __ai4kanbanRequire } from 'node:module'
3
3
  const require = __ai4kanbanRequire(import.meta.url)
4
4
  var __create = Object.create;
@@ -69671,7 +69671,7 @@ var require_trace_mapping_umd = __commonJS({
69671
69671
  return a2[COLUMN] - b2[COLUMN];
69672
69672
  }
69673
69673
  function buildBySources(decoded, memos) {
69674
- const sources2 = memos.map(() => []);
69674
+ const sources3 = memos.map(() => []);
69675
69675
  for (let i = 0; i < decoded.length; i++) {
69676
69676
  const line = decoded[i];
69677
69677
  for (let j2 = 0; j2 < line.length; j2++) {
@@ -69680,19 +69680,19 @@ var require_trace_mapping_umd = __commonJS({
69680
69680
  const sourceIndex2 = seg[SOURCES_INDEX];
69681
69681
  const sourceLine = seg[SOURCE_LINE];
69682
69682
  const sourceColumn = seg[SOURCE_COLUMN];
69683
- const source2 = sources2[sourceIndex2];
69683
+ const source2 = sources3[sourceIndex2];
69684
69684
  const segs = source2[sourceLine] || (source2[sourceLine] = []);
69685
69685
  segs.push([sourceColumn, i, seg[COLUMN]]);
69686
69686
  }
69687
69687
  }
69688
- for (let i = 0; i < sources2.length; i++) {
69689
- const source2 = sources2[i];
69688
+ for (let i = 0; i < sources3.length; i++) {
69689
+ const source2 = sources3[i];
69690
69690
  for (let j2 = 0; j2 < source2.length; j2++) {
69691
69691
  const line = source2[j2];
69692
69692
  if (line) line.sort(sortComparator);
69693
69693
  }
69694
69694
  }
69695
- return sources2;
69695
+ return sources3;
69696
69696
  }
69697
69697
  var found = false;
69698
69698
  function binarySearch(haystack, needle, low, high) {
@@ -69759,7 +69759,7 @@ var require_trace_mapping_umd = __commonJS({
69759
69759
  return new TraceMap(parsed, mapUrl);
69760
69760
  }
69761
69761
  const mappings = [];
69762
- const sources2 = [];
69762
+ const sources3 = [];
69763
69763
  const sourcesContent = [];
69764
69764
  const names2 = [];
69765
69765
  const ignoreList = [];
@@ -69767,7 +69767,7 @@ var require_trace_mapping_umd = __commonJS({
69767
69767
  parsed,
69768
69768
  mapUrl,
69769
69769
  mappings,
69770
- sources2,
69770
+ sources3,
69771
69771
  sourcesContent,
69772
69772
  names2,
69773
69773
  ignoreList,
@@ -69780,14 +69780,14 @@ var require_trace_mapping_umd = __commonJS({
69780
69780
  version: 3,
69781
69781
  file: parsed.file,
69782
69782
  names: names2,
69783
- sources: sources2,
69783
+ sources: sources3,
69784
69784
  sourcesContent,
69785
69785
  mappings,
69786
69786
  ignoreList
69787
69787
  };
69788
69788
  return presortedDecodedMap(joined);
69789
69789
  };
69790
- function recurse(input, mapUrl, mappings, sources2, sourcesContent, names2, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
69790
+ function recurse(input, mapUrl, mappings, sources3, sourcesContent, names2, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
69791
69791
  const { sections } = input;
69792
69792
  for (let i = 0; i < sections.length; i++) {
69793
69793
  const { map: map2, offset } = sections[i];
@@ -69806,7 +69806,7 @@ var require_trace_mapping_umd = __commonJS({
69806
69806
  map2,
69807
69807
  mapUrl,
69808
69808
  mappings,
69809
- sources2,
69809
+ sources3,
69810
69810
  sourcesContent,
69811
69811
  names2,
69812
69812
  ignoreList,
@@ -69817,15 +69817,15 @@ var require_trace_mapping_umd = __commonJS({
69817
69817
  );
69818
69818
  }
69819
69819
  }
69820
- function addSection(input, mapUrl, mappings, sources2, sourcesContent, names2, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
69820
+ function addSection(input, mapUrl, mappings, sources3, sourcesContent, names2, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
69821
69821
  const parsed = parse3(input);
69822
69822
  if ("sections" in parsed) return recurse(...arguments);
69823
69823
  const map2 = new TraceMap(parsed, mapUrl);
69824
- const sourcesOffset = sources2.length;
69824
+ const sourcesOffset = sources3.length;
69825
69825
  const namesOffset = names2.length;
69826
69826
  const decoded = decodedMappings(map2);
69827
69827
  const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map2;
69828
- append(sources2, resolvedSources);
69828
+ append(sources3, resolvedSources);
69829
69829
  append(names2, map2.names);
69830
69830
  if (contents) append(sourcesContent, contents);
69831
69831
  else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null);
@@ -69869,16 +69869,16 @@ var require_trace_mapping_umd = __commonJS({
69869
69869
  const isString = typeof map2 === "string";
69870
69870
  if (!isString && map2._decodedMemo) return map2;
69871
69871
  const parsed = parse3(map2);
69872
- const { version, file: file3, names: names2, sourceRoot, sources: sources2, sourcesContent } = parsed;
69872
+ const { version, file: file3, names: names2, sourceRoot, sources: sources3, sourcesContent } = parsed;
69873
69873
  this.version = version;
69874
69874
  this.file = file3;
69875
69875
  this.names = names2 || [];
69876
69876
  this.sourceRoot = sourceRoot;
69877
- this.sources = sources2;
69877
+ this.sources = sources3;
69878
69878
  this.sourcesContent = sourcesContent;
69879
69879
  this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
69880
69880
  const resolve2 = resolver(mapUrl, sourceRoot);
69881
- this.resolvedSources = sources2.map(resolve2);
69881
+ this.resolvedSources = sources3.map(resolve2);
69882
69882
  const { mappings } = parsed;
69883
69883
  if (typeof mappings === "string") {
69884
69884
  this._encoded = mappings;
@@ -69985,8 +69985,8 @@ var require_trace_mapping_umd = __commonJS({
69985
69985
  }
69986
69986
  }
69987
69987
  function sourceIndex(map2, source2) {
69988
- const { sources: sources2, resolvedSources } = map2;
69989
- let index = sources2.indexOf(source2);
69988
+ const { sources: sources3, resolvedSources } = map2;
69989
+ let index = sources3.indexOf(source2);
69990
69990
  if (index === -1) index = resolvedSources.indexOf(source2);
69991
69991
  return index;
69992
69992
  }
@@ -70058,11 +70058,11 @@ var require_trace_mapping_umd = __commonJS({
70058
70058
  line--;
70059
70059
  if (line < 0) throw new Error(LINE_GTR_ZERO);
70060
70060
  if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
70061
- const { sources: sources2, resolvedSources } = map2;
70062
- let sourceIndex2 = sources2.indexOf(source2);
70061
+ const { sources: sources3, resolvedSources } = map2;
70062
+ let sourceIndex2 = sources3.indexOf(source2);
70063
70063
  if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source2);
70064
70064
  if (sourceIndex2 === -1) return all2 ? [] : GMapping(null, null);
70065
- const bySourceMemos = (_a2 = cast(map2))._bySourceMemos || (_a2._bySourceMemos = sources2.map(memoizedState));
70065
+ const bySourceMemos = (_a2 = cast(map2))._bySourceMemos || (_a2._bySourceMemos = sources3.map(memoizedState));
70066
70066
  const generated = (_b = cast(map2))._bySources || (_b._bySources = buildBySources(decodedMappings(map2), bySourceMemos));
70067
70067
  const segments = generated[sourceIndex2][line];
70068
70068
  if (segments == null) return all2 ? [] : GMapping(null, null);
@@ -70242,21 +70242,21 @@ var require_gen_mapping_umd = __commonJS({
70242
70242
  };
70243
70243
  function setSourceContent(map2, source2, content) {
70244
70244
  const {
70245
- _sources: sources2,
70245
+ _sources: sources3,
70246
70246
  _sourcesContent: sourcesContent
70247
70247
  // _originalScopes: originalScopes,
70248
70248
  } = cast2(map2);
70249
- const index = put(sources2, source2);
70249
+ const index = put(sources3, source2);
70250
70250
  sourcesContent[index] = content;
70251
70251
  }
70252
70252
  function setIgnore(map2, source2, ignore = true) {
70253
70253
  const {
70254
- _sources: sources2,
70254
+ _sources: sources3,
70255
70255
  _sourcesContent: sourcesContent,
70256
70256
  _ignoreList: ignoreList
70257
70257
  // _originalScopes: originalScopes,
70258
70258
  } = cast2(map2);
70259
- const index = put(sources2, source2);
70259
+ const index = put(sources3, source2);
70260
70260
  if (index === sourcesContent.length) sourcesContent[index] = null;
70261
70261
  if (ignore) put(ignoreList, index);
70262
70262
  else remove(ignoreList, index);
@@ -70264,7 +70264,7 @@ var require_gen_mapping_umd = __commonJS({
70264
70264
  function toDecodedMap(map2) {
70265
70265
  const {
70266
70266
  _mappings: mappings,
70267
- _sources: sources2,
70267
+ _sources: sources3,
70268
70268
  _sourcesContent: sourcesContent,
70269
70269
  _names: names2,
70270
70270
  _ignoreList: ignoreList
@@ -70277,7 +70277,7 @@ var require_gen_mapping_umd = __commonJS({
70277
70277
  file: map2.file || void 0,
70278
70278
  names: names2.array,
70279
70279
  sourceRoot: map2.sourceRoot || void 0,
70280
- sources: sources2.array,
70280
+ sources: sources3.array,
70281
70281
  sourcesContent,
70282
70282
  mappings,
70283
70283
  // originalScopes,
@@ -70305,7 +70305,7 @@ var require_gen_mapping_umd = __commonJS({
70305
70305
  }
70306
70306
  function allMappings(map2) {
70307
70307
  const out = [];
70308
- const { _mappings: mappings, _sources: sources2, _names: names2 } = cast2(map2);
70308
+ const { _mappings: mappings, _sources: sources3, _names: names2 } = cast2(map2);
70309
70309
  for (let i = 0; i < mappings.length; i++) {
70310
70310
  const line = mappings[i];
70311
70311
  for (let j2 = 0; j2 < line.length; j2++) {
@@ -70315,7 +70315,7 @@ var require_gen_mapping_umd = __commonJS({
70315
70315
  let original = void 0;
70316
70316
  let name = void 0;
70317
70317
  if (seg.length !== 1) {
70318
- source2 = sources2.array[seg[SOURCES_INDEX]];
70318
+ source2 = sources3.array[seg[SOURCES_INDEX]];
70319
70319
  original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };
70320
70320
  if (seg.length === 5) name = names2.array[seg[NAMES_INDEX]];
70321
70321
  }
@@ -70327,7 +70327,7 @@ var require_gen_mapping_umd = __commonJS({
70327
70327
  function addSegmentInternal(skipable, map2, genLine, genColumn, source2, sourceLine, sourceColumn, name, content) {
70328
70328
  const {
70329
70329
  _mappings: mappings,
70330
- _sources: sources2,
70330
+ _sources: sources3,
70331
70331
  _sourcesContent: sourcesContent,
70332
70332
  _names: names2
70333
70333
  // _originalScopes: originalScopes,
@@ -70340,7 +70340,7 @@ var require_gen_mapping_umd = __commonJS({
70340
70340
  }
70341
70341
  assert(sourceLine);
70342
70342
  assert(sourceColumn);
70343
- const sourcesIndex = put(sources2, source2);
70343
+ const sourcesIndex = put(sources3, source2);
70344
70344
  const namesIndex = name ? put(names2, name) : NO_NAME;
70345
70345
  if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null;
70346
70346
  if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
@@ -112193,8 +112193,8 @@ function status(line) {
112193
112193
  }
112194
112194
 
112195
112195
  // src/protocol.ts
112196
- var VERSION = true ? "0.6.86" : "0.0.0";
112197
- var AKB_VERSION = true ? "0.11.69" : "0.0.0";
112196
+ var VERSION = true ? "0.6.87" : "0.0.0";
112197
+ var AKB_VERSION = true ? "0.11.70" : "0.0.0";
112198
112198
  var AKB_CONTRACT = true ? 17 : 0;
112199
112199
  var EXIT_REFUSED = 10;
112200
112200
  var EXIT_OUTDATED = 11;
@@ -112573,8 +112573,7 @@ function modelsIn(file3, pick2, salt = "") {
112573
112573
  const stat = statSync(file3);
112574
112574
  stamp3 = `${stat.mtimeMs}:${stat.size}:${salt}`;
112575
112575
  } catch {
112576
- cached.delete(file3);
112577
- return [];
112576
+ return cached.get(file3)?.found ?? [];
112578
112577
  }
112579
112578
  const hit = cached.get(file3);
112580
112579
  if (hit?.stamp === stamp3) return hit.found;
@@ -112584,8 +112583,8 @@ function modelsIn(file3, pick2, salt = "") {
112584
112583
  } catch {
112585
112584
  found = [];
112586
112585
  }
112587
- cached.set(file3, { stamp: stamp3, found });
112588
- return found;
112586
+ if (found.length) cached.set(file3, { stamp: stamp3, found });
112587
+ return found.length ? found : hit?.found ?? [];
112589
112588
  }
112590
112589
 
112591
112590
  // ../cli/src/lib/agent/harnesses/types.ts
@@ -113042,11 +113041,21 @@ function createAntigravityRenderer(expectedSession) {
113042
113041
  }
113043
113042
 
113044
113043
  // ../cli/src/lib/agent/harnesses/antigravity.ts
113044
+ var EFFORT_ID = /-(?:low|medium|high|xhigh|max)$/i;
113045
+ var EFFORT_NAME = /\s*\((?:low|medium|high|xhigh|max)\)$/i;
113045
113046
  function antigravityModels(output2) {
113046
- return output2.split("\n").flatMap((line) => {
113047
+ const seen = /* @__PURE__ */ new Set();
113048
+ const models = [];
113049
+ for (const line of output2.split("\n")) {
113047
113050
  const match = /^([^\s]+)\t(.+)$/.exec(line.trim());
113048
- return match ? [{ id: match[1], name: match[2] }] : [];
113049
- });
113051
+ if (!match) continue;
113052
+ const id = match[1].replace(EFFORT_ID, "");
113053
+ const name = match[2].replace(EFFORT_NAME, "").trim();
113054
+ if (seen.has(id)) continue;
113055
+ seen.add(id);
113056
+ models.push({ id, name });
113057
+ }
113058
+ return models;
113050
113059
  }
113051
113060
  function args(argv, resume) {
113052
113061
  if (namesFlag(argv, ["--continue", "-c", "--conversation", "--remote-agent"])) throw new Error(translating() ? "\u8BF7\u901A\u8FC7 WildCrane \u9009\u62E9 Antigravity \u4F1A\u8BDD\uFF0C\u4E0D\u8981\u5728\u989D\u5916\u53C2\u6570\u4E2D\u6307\u5B9A\u4F1A\u8BDD\u6216\u8FDC\u7A0B\u6267\u884C\u3002" : "Antigravity: select a session through WildCrane, not extra arguments.");
@@ -113073,6 +113082,22 @@ var ANTIGRAVITY = {
113073
113082
  flags: ["--model"],
113074
113083
  placeholder: "model-id",
113075
113084
  help: "A model from agy models. Empty uses the CLI default; an invalid model fails the run."
113085
+ }, {
113086
+ key: "reasoning",
113087
+ agentOwned: true,
113088
+ label: "Reasoning effort",
113089
+ kind: "select",
113090
+ choices: [
113091
+ { value: "", label: "Agent's default" },
113092
+ { value: "low", label: "Low" },
113093
+ { value: "medium", label: "Medium" },
113094
+ { value: "high", label: "High" },
113095
+ { value: "xhigh", label: "Extra high (xhigh)" },
113096
+ { value: "max", label: "Max" }
113097
+ ],
113098
+ flags: ["--effort"],
113099
+ help: "Lower is quicker and cheaper, higher is slower and more careful.",
113100
+ overriddenHelp: `Not in effect: this agent's "command" in your ui.config.json already names an effort level, and that wins.`
113076
113101
  }],
113077
113102
  models() {
113078
113103
  const copy2 = locate(ANTIGRAVITY);
@@ -114328,7 +114353,7 @@ function createTail(log) {
114328
114353
  // ../cli/package.json
114329
114354
  var package_default = {
114330
114355
  name: "wildcrane",
114331
- version: "0.11.69",
114356
+ version: "0.11.70",
114332
114357
  akbContract: 17,
114333
114358
  description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
114334
114359
  keywords: [
@@ -114585,9 +114610,9 @@ async function oneTurn(io, options) {
114585
114610
  }
114586
114611
  let model = modelOf(opened);
114587
114612
  if (options.model) {
114588
- const listed2 = obj2(opened.models).currentModelId !== void 0;
114589
- const picked = listed2 ? pickedModel(opened, options.model) : void 0;
114590
- const set = listed2 ? await bounded(rpc.call("session/set_model", { sessionId, modelId: picked?.modelId ?? options.model }), preparingUntil - Date.now(), "ACP session/set_model timed out.") : await bounded(rpc.call("session/set_config_option", { sessionId, configId: "model", value: options.model }), preparingUntil - Date.now(), "ACP session/set_config_option timed out.");
114613
+ const listed = obj2(opened.models).currentModelId !== void 0;
114614
+ const picked = listed ? pickedModel(opened, options.model) : void 0;
114615
+ const set = listed ? await bounded(rpc.call("session/set_model", { sessionId, modelId: picked?.modelId ?? options.model }), preparingUntil - Date.now(), "ACP session/set_model timed out.") : await bounded(rpc.call("session/set_config_option", { sessionId, configId: "model", value: options.model }), preparingUntil - Date.now(), "ACP session/set_config_option timed out.");
114591
114616
  model = picked?.name ?? modelOf(set) ?? options.model;
114592
114617
  }
114593
114618
  if (model) io.gotModel(model);
@@ -117340,6 +117365,74 @@ function withSystemLanguage(harness, argv, env2, language) {
117340
117365
  return { argv: [...argv.slice(0, at2), ...added?.args ?? [], ...argv.slice(at2)], env: { ...env2, ...added?.env } };
117341
117366
  }
117342
117367
 
117368
+ // src/model-list.ts
117369
+ var MODEL_REFRESH_MS = 3e4;
117370
+ var MODEL_TIMEOUT_MS = 15e3;
117371
+ var ModelLists = class {
117372
+ constructor(sources3, interval = MODEL_REFRESH_MS, timeout = MODEL_TIMEOUT_MS) {
117373
+ this.sources = sources3;
117374
+ this.interval = interval;
117375
+ this.timeout = timeout;
117376
+ }
117377
+ sources;
117378
+ interval;
117379
+ timeout;
117380
+ listeners = /* @__PURE__ */ new Set();
117381
+ subscribe(listener) {
117382
+ this.listeners.add(listener);
117383
+ return () => {
117384
+ this.listeners.delete(listener);
117385
+ };
117386
+ }
117387
+ entries = /* @__PURE__ */ new Map();
117388
+ async read(key, previous = [], wait3 = false) {
117389
+ const source2 = this.sources[key];
117390
+ if (!source2) return previous;
117391
+ let entry = this.entries.get(key);
117392
+ if (!entry) {
117393
+ entry = { models: normalizeModels(previous), next: 0 };
117394
+ this.entries.set(key, entry);
117395
+ }
117396
+ if (!entry.models.length && previous.length) entry.models = normalizeModels(previous);
117397
+ if (!entry.pending && Date.now() >= entry.next) {
117398
+ const held5 = entry;
117399
+ const controller = new AbortController();
117400
+ held5.next = Date.now() + this.interval;
117401
+ let changed = false;
117402
+ held5.pending = new Promise((resolve2) => {
117403
+ let done = false;
117404
+ const finish2 = (models) => {
117405
+ if (done) return;
117406
+ done = true;
117407
+ clearTimeout(timer);
117408
+ controller.abort();
117409
+ const found = normalizeModels(models);
117410
+ if (found.length) {
117411
+ changed = JSON.stringify(found) !== JSON.stringify(held5.models);
117412
+ held5.models = found;
117413
+ }
117414
+ resolve2(held5.models);
117415
+ };
117416
+ const timer = setTimeout(() => finish2([]), this.timeout);
117417
+ Promise.resolve().then(() => source2(controller.signal)).then(finish2, () => finish2([]));
117418
+ }).finally(() => {
117419
+ held5.pending = void 0;
117420
+ if (changed) for (const listener of this.listeners) listener();
117421
+ });
117422
+ }
117423
+ return wait3 && entry.pending ? entry.pending : entry.models;
117424
+ }
117425
+ };
117426
+ function normalizeModels(models) {
117427
+ const seen = /* @__PURE__ */ new Set();
117428
+ return models.flatMap((model) => {
117429
+ const id = model.id.trim();
117430
+ if (!id || seen.has(id)) return [];
117431
+ seen.add(id);
117432
+ return [{ id, name: model.name.trim() || id }];
117433
+ });
117434
+ }
117435
+
117343
117436
  // src/api.ts
117344
117437
  var api_exports = {};
117345
117438
  __export(api_exports, {
@@ -117943,7 +118036,6 @@ var previewOperation = (machineId2, job, agent, fields) => request("POST", `/v1/
117943
118036
  // src/runtimes.ts
117944
118037
  var HARNESSES2 = Object.fromEntries(RUNTIMES.map((name) => [name, HARNESSES.find((h3) => h3.name === name)]));
117945
118038
  var LOGIN_PROBE_MS = 5e3;
117946
- var MODELS_MS = 3e4;
117947
118039
  var LABELS = Object.fromEntries(RUNTIMES.map((name) => [name, HARNESSES2[name].label]));
117948
118040
  var settingKeys = (runtime) => HARNESSES2[runtime].settings.map((s) => s.key);
117949
118041
  var secretKeys = (runtime) => HARNESSES2[runtime].settings.filter((s) => s.kind === "secret").map((s) => s.key);
@@ -118041,43 +118133,37 @@ async function detectRuntimes(quick = false, only) {
118041
118133
  const copy2 = locate(harness);
118042
118134
  if (!copy2) return { name, installed: false, settings };
118043
118135
  const loggedIn = harness.login ? await probeLogin(spawnName(copy2, splitCommand(harness.command)[0]), harness) : void 0;
118044
- const models = loggedIn === false || quick && SLOW.has(name) ? [] : await readModels(name);
118136
+ const models = await modelLists.read(name, name === "claude-code" ? CLAUDE_DEFAULTS : [], !quick);
118045
118137
  return { name, installed: true, ...copy2.version ? { version: copy2.version } : {}, ...loggedIn === void 0 ? {} : { loggedIn }, ...models.length ? { models } : {}, settings };
118046
118138
  })
118047
118139
  );
118048
118140
  }
118049
118141
  function refreshModels(found) {
118050
- return Promise.all(
118051
- found.map(async (report2) => {
118052
- if (!report2.installed || report2.loggedIn === false || SLOW.has(report2.name)) return report2;
118053
- const { models: _2, settings, ...rest } = report2;
118054
- const models = await readModels(report2.name);
118055
- return { ...rest, ...models.length ? { models } : {}, ...settings ? { settings } : {} };
118056
- })
118057
- );
118142
+ return Promise.all(found.map(async (report2) => {
118143
+ if (!report2.installed) return report2;
118144
+ const models = await modelLists.read(report2.name, report2.models ?? (report2.name === "claude-code" ? CLAUDE_DEFAULTS : []));
118145
+ return { ...report2, ...models.length ? { models } : {} };
118146
+ }));
118058
118147
  }
118059
- var SLOW = /* @__PURE__ */ new Set(["opencode", "cursor", "antigravity"]);
118060
- var listed = (harness) => async () => (harness.models?.() ?? []).map((id) => ({ id, name: id }));
118061
- var readModels = (name) => (MODELS[name] ?? listed(HARNESSES2[name]))().catch(() => []);
118062
- var MODELS = {
118063
- "claude-code": async () => {
118064
- const cached2 = claudeModels(path23.join(process.env.CLAUDE_CONFIG_DIR || path23.join(os6.homedir(), ".claude"), "cache", "model-catalog"));
118065
- return cached2.length ? cached2 : [
118066
- { id: "opus", name: "Opus" },
118067
- { id: "sonnet", name: "Sonnet" },
118068
- { id: "haiku", name: "Haiku" }
118069
- ];
118070
- },
118071
- codex: async () => codexModels(path23.join(process.env.CODEX_HOME || path23.join(os6.homedir(), ".codex"), "models_cache.json")),
118072
- opencode: async () => opencodeModels(await output(commandOf(HARNESSES2.opencode)[0], ["models"])),
118073
- cursor: () => cursorModels(),
118074
- antigravity: async () => antigravityModels(await output(commandOf(HARNESSES2.antigravity)[0], ["models"]))
118075
- };
118148
+ var CLAUDE_DEFAULTS = ["opus", "sonnet", "haiku"].map((id) => ({ id, name: id[0].toUpperCase() + id.slice(1) }));
118149
+ var sources = Object.fromEntries(
118150
+ Object.entries(HARNESSES2).filter(([, harness]) => harness.models).map(([name, harness]) => [
118151
+ name,
118152
+ () => (harness.models?.() ?? []).map((id) => ({ id, name: id }))
118153
+ ])
118154
+ );
118155
+ Object.assign(sources, {
118156
+ "claude-code": () => claudeModels(path23.join(process.env.CLAUDE_CONFIG_DIR || path23.join(os6.homedir(), ".claude"), "cache", "model-catalog")),
118157
+ codex: () => codexModels(path23.join(process.env.CODEX_HOME || path23.join(os6.homedir(), ".codex"), "models_cache.json")),
118158
+ opencode: async (signal2) => opencodeModels(await output(commandOf(HARNESSES2.opencode)[0], ["models"], signal2)),
118159
+ cursor: (signal2) => cursorModels(signal2),
118160
+ antigravity: async (signal2) => antigravityModels(await output(commandOf(HARNESSES2.antigravity)[0], ["models"], signal2))
118161
+ });
118162
+ var modelLists = new ModelLists(sources);
118076
118163
  function opencodeModels(out) {
118077
118164
  return out.split("\n").map((l2) => l2.trim()).filter((l2) => /^\S+\/\S+$/.test(l2)).map((id) => ({ id, name: id }));
118078
118165
  }
118079
- function cursorModels() {
118080
- const argv = commandOf(HARNESSES2.cursor);
118166
+ function cursorModels(signal2, argv = commandOf(HARNESSES2.cursor)) {
118081
118167
  return new Promise((resolve2) => {
118082
118168
  let child;
118083
118169
  try {
@@ -118086,13 +118172,19 @@ function cursorModels() {
118086
118172
  } catch {
118087
118173
  return resolve2([]);
118088
118174
  }
118175
+ let finished = false;
118089
118176
  const done = (models) => {
118090
- clearTimeout(timer);
118177
+ if (finished) return;
118178
+ finished = true;
118179
+ signal2.removeEventListener("abort", aborted);
118091
118180
  child.kill();
118092
118181
  resolve2(models);
118093
118182
  };
118094
- const timer = setTimeout(() => done([]), MODELS_MS);
118183
+ const aborted = () => done([]);
118184
+ signal2.addEventListener("abort", aborted, { once: true });
118185
+ if (signal2.aborted) return done([]);
118095
118186
  child.on("error", () => done([]));
118187
+ child.on("close", () => done([]));
118096
118188
  const rpc = connect(child.stdout, child.stdin, (msg) => msg.id !== void 0 && rpc.refuse(msg.id, "no"), { jsonrpc: true });
118097
118189
  rpc.call("initialize", { protocolVersion: 1, clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false } }).then(() => rpc.call("session/new", { cwd: os6.tmpdir(), mcpServers: [] })).then((opened) => done(acpModels(opened))).catch(() => done([]));
118098
118190
  });
@@ -118104,7 +118196,7 @@ function acpModels(opened) {
118104
118196
  return id && id !== "default[]" ? [{ id, name: str2(m.name) || id }] : [];
118105
118197
  });
118106
118198
  }
118107
- function output(command, args2) {
118199
+ function output(command, args2, signal2) {
118108
118200
  return new Promise((resolve2) => {
118109
118201
  let out = "";
118110
118202
  let child;
@@ -118114,16 +118206,20 @@ function output(command, args2) {
118114
118206
  } catch {
118115
118207
  return resolve2("");
118116
118208
  }
118117
- const timer = setTimeout(() => {
118209
+ let finished = false;
118210
+ const done = (value) => {
118211
+ if (finished) return;
118212
+ finished = true;
118213
+ signal2.removeEventListener("abort", aborted);
118118
118214
  child.kill();
118119
- resolve2("");
118120
- }, MODELS_MS);
118215
+ resolve2(value);
118216
+ };
118217
+ const aborted = () => done("");
118218
+ signal2.addEventListener("abort", aborted, { once: true });
118219
+ if (signal2.aborted) return done("");
118121
118220
  child.stdout?.on("data", (d2) => out += d2);
118122
- child.on("error", () => resolve2(""));
118123
- child.on("close", (code) => {
118124
- clearTimeout(timer);
118125
- resolve2(code === 0 ? out : "");
118126
- });
118221
+ child.on("error", () => done(""));
118222
+ child.on("close", (code) => done(code === 0 ? out : ""));
118127
118223
  });
118128
118224
  }
118129
118225
  function codexModels(file3) {
@@ -119151,7 +119247,6 @@ import path26 from "node:path";
119151
119247
  var STUDIO_FILE = "STUDIO.md";
119152
119248
  var MCP_FILE = "mcp.json";
119153
119249
  var CARD_TEMPLATE_FILE = "CARD.md";
119154
- var SHARED_DIR = "shared/";
119155
119250
  var VERSION_FILE = "version.json";
119156
119251
  var KB = 1024;
119157
119252
  var FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
@@ -119296,32 +119391,12 @@ var OFFICIAL = path27.dirname(fileURLToPath2(import.meta.url));
119296
119391
  var dirs = (dir) => fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
119297
119392
  var hashOf = (files) => crypto3.createHash("sha256").update(hashInput(files)).digest("hex");
119298
119393
  function packOfficial(root2 = OFFICIAL, loose = false) {
119299
- const agentsDir = path27.join(root2, "agents");
119300
- const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
119301
- const dir = path27.join(agentsDir, name);
119302
- return [name, readStudioFolder(dir)];
119303
- }));
119304
- for (const [name, own2] of Object.entries(loose ? {} : agentFiles)) {
119305
- const read5 = parseSpecAgent(own2["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own2[p2] ?? null, true);
119306
- if ("problem" in read5) throw new Error(read5.problem);
119307
- }
119308
119394
  const studiosDir = path27.join(root2, "studios");
119309
119395
  return dirs(studiosDir).map((folder) => {
119310
- const dir = path27.join(studiosDir, folder);
119311
- const files = {};
119312
- for (const f2 of filesOf(dir).sort()) {
119313
- if (f2 === STUDIO_FILE || f2 === CARD_TEMPLATE_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || f2.startsWith(SHARED_DIR) || isAboutFile(f2)) files[f2] = readStudioFile(dir, f2);
119314
- }
119315
- const read5 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
119316
- Object.entries(agentFiles).flatMap(([name, own2]) => Object.entries(own2).map(([f2, t2]) => [`agents/${name}/${f2}`, t2]))
119317
- ) });
119318
- if (!read5.ok && !loose) throw new Error(`official/studios/${folder}: ${read5.file}: ${read5.reason}`);
119396
+ const files = readStudioFolder(path27.join(studiosDir, folder));
119319
119397
  const parsed = parseStudioFile(folder, files[STUDIO_FILE] ?? "", STUDIO_FILE);
119320
119398
  if ("problem" in parsed) throw new Error(parsed.problem);
119321
119399
  const def = parsed.def;
119322
- for (const name of [...new Set([...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent))].sort()) {
119323
- for (const [f2, text4] of Object.entries(agentFiles[name] ?? {})) files[`agents/${name}/${f2}`] = text4;
119324
- }
119325
119400
  const checked = loose ? { ok: true } : checkStudioFiles(files, true);
119326
119401
  if (!checked.ok) throw new Error(`official/studios/${folder}: ${checked.file}: ${checked.reason}`);
119327
119402
  if (!def.names?.zh && !loose) throw new Error(`official/studios/${folder}/${STUDIO_FILE}: add its Chinese name under \`names: zh\``);
@@ -119454,13 +119529,13 @@ function readFlows() {
119454
119529
  if (!mine) return flows2;
119455
119530
  return [mine, ...flows2.filter((f2) => f2.cloudId !== mine.cloudId)];
119456
119531
  }
119457
- var sources = () => {
119532
+ var sources2 = () => {
119458
119533
  if (devFolder()) return [devFolder()];
119459
119534
  const project = boardProject();
119460
119535
  const task = workspaceTask();
119461
119536
  return [sessionFile(), ...project ? [listFile(project)] : [], ...task ? [pinFile(task)] : []];
119462
119537
  };
119463
- var flows = memoByFiles(sources, readFlows);
119538
+ var flows = memoByFiles(sources2, readFlows);
119464
119539
  var cloudFlows = () => flows();
119465
119540
  function cloudAgentFiles() {
119466
119541
  const files = {};
@@ -120003,9 +120078,9 @@ async function reviewChats(machineId2, runtimes, now = Date.now()) {
120003
120078
  const sent = await dispatchReview(machineId2, project, tasks, runtime, replied?.model ?? null);
120004
120079
  if (!sent.ok) console.error(`runner: the chats of ${project} were not sent for review: ${sent.error}`);
120005
120080
  }
120006
- const listed2 = new Set(owned.value.chats.map((c2) => c2.task));
120081
+ const listed = new Set(owned.value.chats.map((c2) => c2.task));
120007
120082
  const held5 = readReviewed();
120008
- writeReviewed({ checkedAt: now, tasks: Object.fromEntries(Object.entries(held5.tasks).filter(([t2]) => listed2.has(t2))) });
120083
+ writeReviewed({ checkedAt: now, tasks: Object.fromEntries(Object.entries(held5.tasks).filter(([t2]) => listed.has(t2))) });
120009
120084
  }
120010
120085
 
120011
120086
  // src/board-watch.ts
@@ -120334,7 +120409,7 @@ var kindAt = (src, types) => extOf(src) === ".json" ? types.includes("asset") ?
120334
120409
  function collect(body, card, host) {
120335
120410
  return collectSources(bodyReferences(body), card, host);
120336
120411
  }
120337
- function collectSources(sources2, card, host) {
120412
+ function collectSources(sources3, card, host) {
120338
120413
  const nodes = /* @__PURE__ */ new Map();
120339
120414
  const active = /* @__PURE__ */ new Set();
120340
120415
  const out = [];
@@ -120403,7 +120478,7 @@ function collectSources(sources2, card, host) {
120403
120478
  out.push(node);
120404
120479
  return { key, error: node.error };
120405
120480
  };
120406
- for (const ref of sources2) visit(ref.src, ref.types, card);
120481
+ for (const ref of sources3) visit(ref.src, ref.types, card);
120407
120482
  const sorted = [];
120408
120483
  const done = /* @__PURE__ */ new Set();
120409
120484
  const order = (node) => {
@@ -122194,18 +122269,18 @@ function markedInPs(entry, roots) {
122194
122269
  });
122195
122270
  if (ps.status !== 0 || !ps.stdout) throw new Error("\u65E0\u6CD5\u67E5\u8BE2\u8FDB\u7A0B\u6811\u3002");
122196
122271
  const children = /* @__PURE__ */ new Map();
122197
- const listed2 = /* @__PURE__ */ new Set();
122272
+ const listed = /* @__PURE__ */ new Set();
122198
122273
  const found = /* @__PURE__ */ new Set();
122199
122274
  for (const line of ps.stdout.split("\n")) {
122200
122275
  const m = /^\s*(\d+)\s+(\d+)\s(.*)$/.exec(line);
122201
122276
  if (!m) continue;
122202
122277
  const pid = Number(m[1]);
122203
122278
  const ppid = Number(m[2]);
122204
- listed2.add(pid);
122279
+ listed.add(pid);
122205
122280
  children.set(ppid, [...children.get(ppid) ?? [], pid]);
122206
122281
  if (`${m[3]} `.includes(` ${entry} `)) found.add(pid);
122207
122282
  }
122208
- const queue = [...found, ...roots.filter((pid) => listed2.has(pid))];
122283
+ const queue = [...found, ...roots.filter((pid) => listed.has(pid))];
122209
122284
  for (const pid of queue) {
122210
122285
  found.add(pid);
122211
122286
  for (const child of children.get(pid) ?? []) if (!found.has(child)) queue.push(child);
@@ -124287,6 +124362,9 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
124287
124362
  const finishClaimed = (outcome, reason = "", said2) => {
124288
124363
  const before = spent();
124289
124364
  let report2 = before ? { ...before, ...said2 } : said2;
124365
+ if (reply && outcome === "failed" && !report2?.reply && checkpoint.partialReply) {
124366
+ report2 = { ...report2, reply: checkpoint.partialReply };
124367
+ }
124290
124368
  if (reply && outcome === "failed" && checkpoint.started === false && checkpoint.effects === false && !checkpoint.pending.length && !checkpoint.opaque && (!(job.recoveryOf || job.manualRecovery) || previous || job.retryReplay === true)) {
124291
124369
  report2 = { ...report2, recovery: { safe: true, stopped: true, resumable: false } };
124292
124370
  saveCheckpoint(id, checkpoint);
@@ -124309,6 +124387,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
124309
124387
  if (manual && !local && checkpoint.completed?.outcome === "failed") {
124310
124388
  delete checkpoint.completed;
124311
124389
  delete checkpoint.attempts;
124390
+ delete checkpoint.partialReply;
124312
124391
  }
124313
124392
  checkpoint.session ??= job.resume ?? void 0;
124314
124393
  if (reply && previous?.started && checkpoint.completed?.outcome !== "done" && !await stopReply(readCheckpoint(id) ? id : job.recoveryOf ?? id, deps.stopMs)) {
@@ -124426,7 +124505,7 @@ async function runClaimedStep(job, deps, track, keep2, lease, scope, replyStream
124426
124505
  This task came out of a discussion. Read it for what the card leaves out: ${file3}` : "";
124427
124506
  const promptOf = (said2) => {
124428
124507
  const lines = (head2 + said2).trim();
124429
- const prompt = recovering && !replay && (checkpoint.started || job.recoveryOf) ? "\u8FDE\u63A5\u6062\u590D\u540E\u7EE7\u7EED\u4E4B\u524D\u4E2D\u65AD\u7684\u56DE\u590D\u3002\u5148\u6838\u5BF9\u5DF2\u6709\u8FDB\u5EA6\u548C\u7ED3\u679C\uFF0C\u4FDD\u7559\u5B8C\u6210\u7684\u5DE5\u4F5C\uFF0C\u4E0D\u8981\u91CD\u590D\u5DF2\u7ECF\u6267\u884C\u7684\u64CD\u4F5C\u3002" : job.prompt;
124508
+ const prompt = recovering && !replay && (checkpoint.started || job.recoveryOf) ? "\u8FDE\u63A5\u6062\u590D\u540E\u7EE7\u7EED\u4E4B\u524D\u4E2D\u65AD\u7684\u56DE\u590D\u3002\u5148\u6838\u5BF9\u5DF2\u6709\u8FDB\u5EA6\u548C\u64CD\u4F5C\u7ED3\u679C\uFF0C\u4FDD\u7559\u5B8C\u6210\u7684\u5DE5\u4F5C\u4E0E\u7528\u6237\u51B3\u5B9A\uFF0C\u4E0D\u8981\u91CD\u590D\u5DF2\u7ECF\u6267\u884C\u7684\u64CD\u4F5C\uFF1B\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\u65F6\u5148\u68C0\u67E5\u5B9E\u9645\u72B6\u6001\u3002" : job.prompt;
124430
124509
  return lines ? `${lines}
124431
124510
 
124432
124511
  ---
@@ -124495,6 +124574,16 @@ ${prompt}` : prompt;
124495
124574
  return { ...rest, ...replySpent(checkpoint, job.runtime) };
124496
124575
  };
124497
124576
  let replyProgress = false;
124577
+ const messages = [];
124578
+ const retainReply = (report2, failed) => {
124579
+ if (!reply) return report2;
124580
+ const text4 = report2.reply?.trim() ? report2.reply : messages.join("\n\n") || (failed ? checkpoint.partialReply : void 0);
124581
+ if (text4) {
124582
+ checkpoint.partialReply = text4;
124583
+ persist();
124584
+ }
124585
+ return text4 ? { ...report2, reply: text4 } : report2;
124586
+ };
124498
124587
  const account = readSession()?.subject;
124499
124588
  const generation = accountGeneration();
124500
124589
  const evidence = scope.progress = conversationProgress(checkpoint.retry?.attempt ?? 1, async (progress) => {
@@ -124514,6 +124603,10 @@ ${prompt}` : prompt;
124514
124603
  evidence.observe(event2, at2);
124515
124604
  subagents.event(event2);
124516
124605
  checkpointEvent(checkpoint, event2);
124606
+ if (reply && event2.kind === "message" && event2.data.text.trim()) {
124607
+ messages.push(event2.data.text);
124608
+ checkpoint.partialReply = messages.join("\n\n");
124609
+ }
124517
124610
  const session = run3?.session();
124518
124611
  if (session) checkpoint.session = session;
124519
124612
  if (attempt && !run3?.converse) measure(report(job, run3));
@@ -124522,15 +124615,13 @@ ${prompt}` : prompt;
124522
124615
  };
124523
124616
  const retry2 = async (reason) => {
124524
124617
  if (!reply || !reason || stream.asked() || stream.lost()) return false;
124525
- if ((checkpoint.retry?.attempt ?? 1) >= 2 || !/timed out|ECONNRESET|ETIMEDOUT|temporar|overload|capacity|rate.limit|429|503|network|connection.*(reset|closed)/i.test(reason)) return false;
124526
- if (/timed out|start_unconfirmed/i.test(reason) && (!/initialize|session\/(new|load)|thread\/(start|resume|fork)/i.test(reason) || Date.now() >= checkpoint.retry.since + CONVERSATION_MS.prepare)) return false;
124618
+ const at2 = replyRetry(checkpoint, reason, Date.now(), deps.replyBackoff);
124619
+ if (at2 === null) return false;
124527
124620
  checkpoint.approvalCancelled = true;
124528
124621
  persist();
124529
124622
  if (job.chat && checkpoint.approvalRequested) await cancelReplyApproval(deps.machineId, id);
124530
124623
  const safe3 = replayable(checkpoint);
124531
- if (checkpoint.pending.length || checkpoint.opaque || !safe3 && (!checkpoint.session || sessionMissing(reason))) return false;
124532
- const at2 = replyRetry(checkpoint, reason, Date.now(), deps.replyBackoff);
124533
- if (at2 === null) return false;
124624
+ if (checkpoint.opaque || !safe3 && (!checkpoint.session || sessionMissing(reason))) return false;
124534
124625
  if (!await stopReply(id, deps.stopMs) || !await stream.confirmed()) return false;
124535
124626
  checkpoint.retry.at = at2;
124536
124627
  persist();
@@ -124549,7 +124640,7 @@ ${prompt}` : prompt;
124549
124640
  persist();
124550
124641
  stream.event({ kind: "log", data: { text: "[chat-recovery] running" } });
124551
124642
  evidence.cancel();
124552
- await runClaimed({ ...job, manualRecovery: false, retryReplay: safe3 }, deps, track, keep2, lease, stream);
124643
+ await runClaimed({ ...job, manualRecovery: false, retryReplay: safe3 && !job.resume }, deps, track, keep2, lease, stream);
124553
124644
  await stream.end();
124554
124645
  return true;
124555
124646
  };
@@ -124589,12 +124680,12 @@ ${prompt}` : prompt;
124589
124680
  if (chat.ok) keepCloudChat(task2, chat.value.messages);
124590
124681
  await keepDecisions(task2, deps.api.readDecisions);
124591
124682
  }
124592
- const listed2 = await deps.api.listChats(deps.machineId);
124593
- if (!listed2.ok) {
124683
+ const listed = await deps.api.listChats(deps.machineId);
124684
+ if (!listed.ok) {
124594
124685
  await stream.end();
124595
- return finishClaimed("failed", listed2.error);
124686
+ return finishClaimed("failed", listed.error);
124596
124687
  }
124597
- const tasks = listed2.value.chats.filter((c2) => job.review.tasks.includes(c2.task));
124688
+ const tasks = listed.value.chats.filter((c2) => job.review.tasks.includes(c2.task));
124598
124689
  const marks = reviewMarks(tasks);
124599
124690
  const refs = tasks.map((c2) => `${c2.task}:${c2.number}`);
124600
124691
  const ended3 = refs.length ? await runReview(job, ws, refs, deps, io) : { ok: true, report: {} };
@@ -124681,7 +124772,8 @@ ${prompt}` : prompt;
124681
124772
  checkpoint.session = void 0;
124682
124773
  persist();
124683
124774
  }
124684
- if (await retry2(end.ok ? void 0 : end.error)) return;
124775
+ measured2 = retainReply(measured2, !end.ok);
124776
+ if (await retry2(end.ok ? void 0 : end.error ?? "The agent did not complete the reply.")) return;
124685
124777
  await evidence.drain(deps.endMs);
124686
124778
  const stopped3 = await stopReply(id, deps.stopMs);
124687
124779
  stop(child, plan3.managedProcess);
@@ -124787,6 +124879,7 @@ ${plan2.renderer.failure?.() ?? ""}`)) && (checkpoint.retry?.attempt ?? 1) < 3 &
124787
124879
  if (parts) measured = { ...measured, parts, reply: parts.filter((p2) => p2.type === "text").map((p2) => p2.text).join("") };
124788
124880
  }
124789
124881
  const rawFailure = ended2.error ?? renderer.failure?.() ?? (ended2.code === 0 ? void 0 : `Exited with code ${ended2.code}.`);
124882
+ measured = retainReply(measured, !!rawFailure);
124790
124883
  if (job.runtime !== "antigravity" && sessionMissing(rawFailure ?? "") && !replayable(checkpoint)) {
124791
124884
  checkpoint.session = void 0;
124792
124885
  persist();
@@ -125709,6 +125802,36 @@ function startRunner(options) {
125709
125802
  await register2();
125710
125803
  return found;
125711
125804
  };
125805
+ let refreshingModels = false;
125806
+ let modelsAgain = false;
125807
+ const updateModels = async () => {
125808
+ if (refreshingModels) {
125809
+ modelsAgain = true;
125810
+ return;
125811
+ }
125812
+ if (closed || !connected || !ownsExecution || !registration || !validAccount()) return;
125813
+ refreshingModels = true;
125814
+ try {
125815
+ do {
125816
+ modelsAgain = false;
125817
+ const was = registration.runtimes;
125818
+ const found = await refreshModels(was);
125819
+ if (registration.runtimes !== was) modelsAgain = true;
125820
+ else await redetected(found);
125821
+ } while (modelsAgain && !closed);
125822
+ } catch (error) {
125823
+ console.error("runner: model refresh failed:", error instanceof Error ? error.message : String(error));
125824
+ } finally {
125825
+ refreshingModels = false;
125826
+ }
125827
+ };
125828
+ const stopModels = modelLists.subscribe(() => {
125829
+ void updateModels();
125830
+ });
125831
+ const modelsTimer = setInterval(() => {
125832
+ void updateModels();
125833
+ }, MODEL_REFRESH_MS);
125834
+ modelsTimer.unref?.();
125712
125835
  const idle2 = () => running.size ? t.running(running.size) : t.connected(registration.machineName);
125713
125836
  const schedule = (ms) => {
125714
125837
  if (closed || !ownsExecution) return;
@@ -125858,8 +125981,8 @@ function startRunner(options) {
125858
125981
  try {
125859
125982
  const list3 = await listJobs(registration.machineId);
125860
125983
  if (!list3.ok || closed) return;
125861
- const listed2 = new Set(list3.value.jobs.map((job) => job.id));
125862
- for (const id of attempted) if (!listed2.has(id) && !running.has(id)) attempted.delete(id);
125984
+ const listed = new Set(list3.value.jobs.map((job) => job.id));
125985
+ for (const id of attempted) if (!listed.has(id) && !running.has(id)) attempted.delete(id);
125863
125986
  for (const job of list3.value.jobs) {
125864
125987
  if (closed || preparing) break;
125865
125988
  if (workerEntry && canKeepFlow(job) && !running.has(job.id) && (job.state === "waiting" || job.state === "claimed") && !attempted.has(job.id)) {
@@ -126014,6 +126137,8 @@ function startRunner(options) {
126014
126137
  }
126015
126138
  if (timer) clearTimeout(timer);
126016
126139
  if (agentsTimer) clearTimeout(agentsTimer);
126140
+ clearInterval(modelsTimer);
126141
+ stopModels();
126017
126142
  clearInterval(sweepTimer);
126018
126143
  live?.close();
126019
126144
  presence?.close();