mslxdff 0.1.109 → 0.1.110

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mslxdff",
3
- "version": "0.1.109",
3
+ "version": "0.1.110",
4
4
  "description": "测试项目,请勿使用。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -88,6 +88,8 @@ export async function handleSetto(args) {
88
88
  if (r.action === "inserted") inserted++; else updated++;
89
89
  prunedTotal += r.pruned || 0;
90
90
  console.log(` ${r.action} "${r.id}" -> ${r.internal} @ ${file}`);
91
+ if (r.capsSummaryText) console.log(` ${r.capsSummaryText}`);
92
+ if (r.upgraded) console.log(` 能力补齐 ${r.upgraded} 个旧条目`);
91
93
  }
92
94
  console.log(`synced to opencode: ${inserted} inserted, ${updated} updated, total ${list.length} @ ${file}`);
93
95
  if (prunedTotal) console.log(` pruned ${prunedTotal} 个失效模型(未在 picks,不再于 opencode 显示)`);
@@ -158,6 +160,9 @@ export async function handleSetto(args) {
158
160
  const file = opencodeConfigPath();
159
161
  const r = await syncToOpencode({ id, token, port, file, keep: pruneKeep(), ensureAll: pruneKeep() });
160
162
  console.log(`synced to opencode: ${r.action} "${r.id}" @ ${file}`);
163
+ if (r.capsSummaryText) console.log(` 能力: ${r.capsSummaryText}`);
164
+ else console.log(` 能力: 未收录该模型的能力目录,条目仅含名称(不影响使用)`);
165
+ if (r.upgraded) console.log(` 能力补齐 ${r.upgraded} 个旧条目(此前仅含名称,已注入推理档位/读图/上下文)`);
161
166
  if (r.backfilled) console.log(` backfilled ${r.backfilled} 个 picks 模型(此前 pick 了但未同步过,现已补齐)`);
162
167
  if (r.pruned) console.log(` pruned ${r.pruned} 个失效模型(未在 picks,不再于 opencode 显示)`);
163
168
  console.log(` url: http://127.0.0.1:${port}/v1`);
@@ -0,0 +1,72 @@
1
+ // -setto opencode 条目能力注入(ADR-0016 联动):把 models.dev 能力写进 opencode.json
2
+ // 的 per-model 条目(opencode Model 形状,实测 debug config 原样保留并生效),
3
+ // 并产出一行人话摘要供 CLI 展示。查不到能力(未收录 provider/模型)时原样返回不硬造。
4
+ import { globalCapabilities } from "./index.js";
5
+
6
+ // "bai/glm-5.3-flash" → { provider: "bai", raw: "glm-5.3-flash" };裸 id 归 opencode
7
+ function splitProvider(modelId) {
8
+ const s = String(modelId || "").trim();
9
+ const i = s.indexOf("/");
10
+ if (i > 0) return { provider: s.slice(0, i).toLowerCase(), raw: s.slice(i + 1) };
11
+ return { provider: "opencode", raw: s };
12
+ }
13
+
14
+ // caps → opencode Model 形状增量(只含能力字段,name 等原有键不动)
15
+ function capsToEntryFields(caps) {
16
+ if (!caps) return null;
17
+ const fields = {
18
+ reasoning: Boolean(caps.reasoning),
19
+ tool_call: Boolean(caps.toolCall),
20
+ attachment: Boolean(caps.attachment),
21
+ temperature: Boolean(caps.temperature),
22
+ modalities: { input: caps.inputModalities || ["text"], output: caps.outputModalities || ["text"] },
23
+ limit: { context: Number(caps.context) || 0, output: Number(caps.maxOutput) || 0 },
24
+ };
25
+ if (caps.releaseDate) fields.release_date = caps.releaseDate;
26
+ if (caps.costIn != null || caps.costOut != null) {
27
+ fields.cost = { input: Number(caps.costIn) || 0, output: Number(caps.costOut) || 0 };
28
+ }
29
+ return fields;
30
+ }
31
+
32
+ // entry: 现有条目(含 name 等);modelId: 内部 canonical id;capsSvc: 可注入(默认全局单例)
33
+ // 返回 { entry: 增强后条目, caps: caps|null };服务异常静默降级(同步命令不能因目录拉取失败而挂)
34
+ export async function enrichOpencodeEntry(entry, modelId, capsSvc) {
35
+ const base = entry && typeof entry === "object" && !Array.isArray(entry) ? entry : {};
36
+ const svc = capsSvc === undefined ? globalCapabilities() : capsSvc;
37
+ if (!svc) return { entry: base, caps: null };
38
+ const { provider, raw } = splitProvider(modelId);
39
+ let caps = null;
40
+ try {
41
+ await svc.ready();
42
+ caps = svc.get(provider, raw) || null;
43
+ // 降级匹配:mslxdff 自建目录的 -free/-search-free/-expert-free 后缀在 models.dev 无后缀
44
+ if (!caps && /-free$/.test(raw)) caps = svc.get(provider, raw.replace(/-free$/, "")) || null;
45
+ } catch {
46
+ caps = null; // 目录不可用:降级为无能力条目(staleness 兜底在服务内已做)
47
+ }
48
+ const fields = capsToEntryFields(caps);
49
+ if (!fields) return { entry: base, caps: null };
50
+ return { entry: { ...base, ...fields }, caps };
51
+ }
52
+
53
+ // caps → 一行人话摘要(无有效信息返回 "",调用方按空跳过不噪音)
54
+ export function capsSummary(caps) {
55
+ if (!caps) return "";
56
+ const parts = [];
57
+ if (caps.effortType === "effort" && Array.isArray(caps.effortValues) && caps.effortValues.length) {
58
+ parts.push(`推理档 ${caps.effortValues.join("/")}`);
59
+ } else if (caps.effortType === "toggle") {
60
+ parts.push("推理 开关型");
61
+ } else if (caps.effortType === "budget_tokens") {
62
+ parts.push("推理 budget_tokens");
63
+ } else if (caps.reasoning) {
64
+ parts.push("推理模型");
65
+ }
66
+ if (caps.imageInput) parts.push("📷读图");
67
+ if (caps.context) parts.push(`上下文 ${caps.context >= 1000 ? `${Math.round(caps.context / 1000)}k` : caps.context}`);
68
+ if (caps.costIn != null || caps.costOut != null) {
69
+ parts.push(`$${caps.costIn ?? 0}/${caps.costOut ?? 0} 每M`);
70
+ }
71
+ return parts.join(" · ");
72
+ }
@@ -0,0 +1,130 @@
1
+ // 模型能力目录服务(opencode 官方同源 models.dev):fetch + 磁盘缓存 + TTL + staleness 降级
2
+ // 源:https://models.opencode.ai/api.json(opencode core models-dev.ts:160 同款;备选 https://models.dev/api.json)
3
+ // 形状:{ [providerId]: { models: { [modelId]: raw } } };mslxdff 裸 id 归 opencode,`prov/id` 前缀路由到对应 provider
4
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
+ import { homedir } from "node:os";
6
+ import { dirname, join } from "node:path";
7
+ import { normalizeProviderModels } from "./parse.js";
8
+ import { compatFetch } from "../compat.js";
9
+
10
+ export const DEFAULT_SOURCE_URL = "https://models.opencode.ai/api.json";
11
+
12
+ export function sourceUrl() {
13
+ const raw = process.env.MSLXDFF_MODELS_DEV_URL;
14
+ return raw && String(raw).trim() ? String(raw).trim() : DEFAULT_SOURCE_URL;
15
+ }
16
+
17
+ export function ttlMs() {
18
+ const n = Number(process.env.MSLXDFF_MODELS_DEV_TTL_MS);
19
+ return Number.isInteger(n) && n >= 0 ? n : 86_400_000; // 默认 24h
20
+ }
21
+
22
+ export function createCapabilitiesService({
23
+ fetchImpl = compatFetch,
24
+ cacheFile = "",
25
+ ttlMs: ttl = ttlMs(),
26
+ url = sourceUrl(),
27
+ now = Date.now,
28
+ } = {}) {
29
+ let raw = null; // 原始目录(全 provider)
30
+ let capsIndex = new Map(); // providerId -> { modelId -> caps }
31
+ let loadedAt = 0;
32
+ let inflight = null;
33
+
34
+ function buildIndex(data) {
35
+ const idx = new Map();
36
+ for (const [pid, p] of Object.entries(data || {})) {
37
+ if (!p || typeof p !== "object") continue;
38
+ idx.set(pid, normalizeProviderModels(p.models || {}));
39
+ }
40
+ return idx;
41
+ }
42
+
43
+ function readCache() {
44
+ if (!cacheFile) return null;
45
+ try { return JSON.parse(readFileSync(cacheFile, "utf8")); } catch { return null; }
46
+ }
47
+
48
+ function writeCache(data) {
49
+ if (!cacheFile || !data) return;
50
+ try {
51
+ mkdirSync(dirname(cacheFile), { recursive: true });
52
+ writeFileSync(cacheFile, JSON.stringify(data));
53
+ } catch { /* 缓存失败不致命 */ }
54
+ }
55
+
56
+ async function fetchFresh() {
57
+ const res = await fetchImpl(url, { headers: { Accept: "application/json" } });
58
+ if (!res?.ok) throw new Error(`models.dev fetch ${res?.status || "network"}`);
59
+ return res.json();
60
+ }
61
+
62
+ // ready:缓存新鲜直接用;否则拉新;失败回退旧缓存(含磁盘),完全无数据才抛
63
+ async function ready() {
64
+ const t = now();
65
+ if (raw && t - loadedAt < ttl) return;
66
+ if (inflight) return inflight;
67
+ inflight = (async () => {
68
+ try {
69
+ const data = await fetchFresh();
70
+ raw = data;
71
+ capsIndex = buildIndex(data);
72
+ loadedAt = t;
73
+ writeCache(data);
74
+ } catch (e) {
75
+ if (raw) return; // 内存还有旧的,继续用
76
+ const disk = readCache();
77
+ if (disk) {
78
+ raw = disk;
79
+ capsIndex = buildIndex(disk);
80
+ loadedAt = t; // 视作刚加载,避免每请求都重试打上游
81
+ return;
82
+ }
83
+ throw e;
84
+ } finally {
85
+ inflight = null;
86
+ }
87
+ })();
88
+ return inflight;
89
+ }
90
+
91
+ function capsFor(pid) {
92
+ return capsIndex.get(pid) || null;
93
+ }
94
+
95
+ function get(providerId, modelId) {
96
+ const pid = String(providerId || "opencode").toLowerCase();
97
+ const mid = String(modelId || "");
98
+ const map = capsFor(pid);
99
+ if (!map) return null;
100
+ return map[mid] || null;
101
+ }
102
+
103
+ function list(providerId) {
104
+ const pid = String(providerId || "opencode").toLowerCase();
105
+ const map = capsFor(pid);
106
+ if (!map) return [];
107
+ return Object.entries(map).map(([id, capabilities]) => ({ id, capabilities }));
108
+ }
109
+
110
+ function providers() {
111
+ return [...capsIndex.keys()].sort();
112
+ }
113
+
114
+ return { ready, get, list, providers };
115
+ }
116
+
117
+ // 模块级单例(与 globalDedup 同模式):HTTP handler 懒加载,测试 _reset 后注入
118
+ let _global = null;
119
+ export function globalCapabilities() {
120
+ if (!_global) _global = createCapabilitiesService({ cacheFile: defaultCacheFile() });
121
+ return _global;
122
+ }
123
+ export function _resetGlobalCapabilities() { _global = null; }
124
+
125
+ // 缓存落盘位置:MSLXDFF_MODELS_DEV_CACHE 覆盖 > ~/.config/mslxdff/models-dev.json(与 state 同目录)
126
+ function defaultCacheFile() {
127
+ const override = process.env.MSLXDFF_MODELS_DEV_CACHE;
128
+ if (override && String(override).trim()) return String(override).trim();
129
+ return join(homedir(), ".config", "mslxdff", "models-dev.json");
130
+ }
@@ -0,0 +1,39 @@
1
+ // models.dev 能力目录 → mslxdff 能力形状的纯函数解析层(无 IO,测试接缝 S1)
2
+ // 源数据形态(实测 models.opencode.ai/api.json 2026-09-11):
3
+ // reasoning_options: [{type:"effort",values:["low","medium","high","max"]} | {type:"toggle"} | {type:"budget_tokens",min}]
4
+ // modalities.input 含 "image" 即可读图;limit.context/output;cost.input/output 为 $/M tokens
5
+ export function normalizeModelCaps(_id, m) {
6
+ const opts = Array.isArray(m?.reasoning_options) ? m.reasoning_options : [];
7
+ const effort = opts.find((o) => o?.type === "effort");
8
+ const toggle = opts.some((o) => o?.type === "toggle");
9
+ const budget = opts.find((o) => o?.type === "budget_tokens");
10
+ const input = Array.isArray(m?.modalities?.input) ? m.modalities.input : [];
11
+ return {
12
+ reasoning: Boolean(m?.reasoning),
13
+ effortType: effort ? "effort" : toggle ? "toggle" : budget ? "budget_tokens" : null,
14
+ effortValues: effort && Array.isArray(effort.values) ? effort.values.map(String) : null,
15
+ imageInput: input.includes("image"),
16
+ toolCall: Boolean(m?.tool_call),
17
+ context: Number(m?.limit?.context) || null,
18
+ maxOutput: Number(m?.limit?.output) || null,
19
+ costIn: Number(m?.cost?.input) || null,
20
+ costOut: Number(m?.cost?.output) || null,
21
+ // opencode Model 形状补充字段(-setto opencode 条目注入用)
22
+ attachment: Boolean(m?.attachment),
23
+ temperature: Boolean(m?.temperature),
24
+ releaseDate: typeof m?.release_date === "string" && m.release_date ? m.release_date : null,
25
+ inputModalities: input.length ? input : ["text"],
26
+ outputModalities: Array.isArray(m?.modalities?.output) && m.modalities.output.length ? m.modalities.output : ["text"],
27
+ };
28
+ }
29
+
30
+ // provider.models 对象({ [modelId]: rawModel })→ { [modelId]: caps }
31
+ export function normalizeProviderModels(modelsObj) {
32
+ const out = {};
33
+ if (!modelsObj || typeof modelsObj !== "object") return out;
34
+ for (const [id, m] of Object.entries(modelsObj)) {
35
+ if (!m || typeof m !== "object") continue;
36
+ out[id] = normalizeModelCaps(id, m);
37
+ }
38
+ return out;
39
+ }
@@ -4,7 +4,7 @@ import { json, notFound, authorized } from "./helpers.js";
4
4
  import { chatHandler } from "./chat.js";
5
5
  import { joinHandler, leaveHandler } from "./groups.js";
6
6
  import { heartbeatHandler, pollHandler, resultHandler, forwardHandler, streamHandler } from "./groups-relay.js";
7
- import { modelsHandler, modelsStatusHandler, providerModelsHandler } from "./models-route.js";
7
+ import { modelsHandler, modelsStatusHandler, providerModelsHandler, capabilitiesHandler } from "./models-route.js";
8
8
  import { relayHandler } from "./relay.js";
9
9
  import { responsesHandler } from "./responses-route.js";
10
10
 
@@ -110,6 +110,12 @@ const ROUTES = [
110
110
  requiresAuth: true,
111
111
  handler: modelsStatusHandler,
112
112
  },
113
+ {
114
+ method: "GET",
115
+ path: "/v1/models/capabilities",
116
+ requiresAuth: true,
117
+ handler: capabilitiesHandler,
118
+ },
113
119
  ];
114
120
 
115
121
  // re-export for facade & tests
@@ -1,6 +1,7 @@
1
1
  import { json, errMsg } from "./helpers.js";
2
2
  import { runHook } from "../plugins.js";
3
3
  import { isModelAllowed } from "../state.js";
4
+ import { globalCapabilities } from "../model-capabilities/index.js";
4
5
 
5
6
  // Codex 自定义 provider 拉目录要顶层 `models` 数组(codex-rs endpoint/models.rs 解 ModelsResponse{models}),
6
7
  // 给它 OpenAI 标准 {object,data} 会报 missing field `models`。学 OmniRoute:仅 codex 调用者追加空数组
@@ -83,3 +84,28 @@ export async function providerModelsHandler({ req, res, models }) {
83
84
  json(res, 502, { error: errMsg(err) });
84
85
  }
85
86
  }
87
+
88
+ // GET /v1/models/capabilities[?provider=opencode][&id=big-pickle]
89
+ // 模型能力元数据(reasoning 档位/图片输入/tool_call/上下文/价格),源 = opencode 官方 models.dev 目录
90
+ // jsonFn 注入仅为测试接缝(S3);生产路径用 helpers.json
91
+ export async function capabilitiesHandler({ req, res, capabilities, jsonFn = json }) {
92
+ // 仅未注入(生产)时用全局单例;显式 null 视作服务不可用(测试可复现 502 空状态)
93
+ const svc = capabilities === undefined ? globalCapabilities() : capabilities;
94
+ if (!svc) return jsonFn(res, 502, { error: "capabilities service unavailable" });
95
+ const q = String(req?.url || "").split("?")[1] || "";
96
+ const params = new URLSearchParams(q);
97
+ const provider = (params.get("provider") || "opencode").toLowerCase();
98
+ const id = params.get("id") || "";
99
+ try {
100
+ await svc.ready();
101
+ } catch (err) {
102
+ return jsonFn(res, 502, { error: `capabilities source unavailable: ${errMsg(err)}` });
103
+ }
104
+ if (id) {
105
+ const caps = svc.get(provider, id);
106
+ if (!caps) return jsonFn(res, 404, { error: `model '${id}' not found in capabilities catalog (provider=${provider})` });
107
+ return jsonFn(res, 200, { object: "model.capabilities", id, provider, capabilities: caps });
108
+ }
109
+ const data = svc.list(provider);
110
+ return jsonFn(res, 200, { object: "list", provider, data });
111
+ }
@@ -1,6 +1,7 @@
1
1
  import { readFileSync, writeFileSync, mkdirSync, existsSync, renameSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
3
  import os from "node:os";
4
+ import { enrichOpencodeEntry, capsSummary as capsSummaryText } from "./model-capabilities/enrich.js";
4
5
 
5
6
  export function opencodeConfigPath() {
6
7
  const env = process.env.OPENCODE_CONFIG || process.env.OPENCODE_CONFIG_PATH;
@@ -79,21 +80,35 @@ export function pruneOpencodeModels(models, keep, currentKey) {
79
80
  }
80
81
 
81
82
  // 补齐:把 ensureAll(picks 口径)里缺失的键写入 models(slash → dash + alias 注册)。
82
- // 返回 { nextModels, backfilled };ensureAll 非数组或为空时原样返回(backfilled=0)。
83
+ // 已存在但为旧格式(缺 limit 能力字段)的条目也自动补注能力(upgraded 计数)。
84
+ // 返回 { nextModels, backfilled, upgraded };ensureAll 非数组或为空时原样返回。
83
85
  // 注意:需在剪枝之前调用——先补 picks 缺失,再剪 picks 外旧键,结果集恰为 picks ∪ currentKey。
84
- export async function ensureAllOpencodeModels(models, ensureAll) {
86
+ // capsSvc 透传给能力注入(undefined=全局单例;补齐的条目同样带能力)。
87
+ export async function ensureAllOpencodeModels(models, ensureAll, capsSvc) {
85
88
  if (!Array.isArray(ensureAll) || !ensureAll.length || !models || typeof models !== "object") {
86
- return { nextModels: models, backfilled: 0 };
89
+ return { nextModels: models, backfilled: 0, upgraded: 0 };
87
90
  }
88
91
  const existing = new Set(Object.keys(models).map(normalizeOpencodeKey));
89
92
  let backfilled = 0;
93
+ let upgraded = 0;
90
94
  let aliasDirty = false;
91
95
  for (const raw of ensureAll) {
92
96
  const internal = toInternalId(String(raw || "").trim());
93
97
  if (!internal || internal === "auto") continue;
94
98
  const storageKey = internal.includes("/") ? internal.replace(/\//g, "-") : internal;
95
- if (!storageKey || existing.has(storageKey)) continue;
96
- models[storageKey] = { name: storageKey };
99
+ if (!storageKey) continue;
100
+ if (existing.has(storageKey)) {
101
+ // 已存在:旧格式条目(仅 name、无能力字段)自动升级注入;已带 limit 的新格式不动
102
+ const cur = models[storageKey];
103
+ if (cur && typeof cur === "object" && !Array.isArray(cur) && cur.limit === undefined) {
104
+ const en = await enrichOpencodeEntry(cur, internal, capsSvc);
105
+ models[storageKey] = en.entry;
106
+ if (en.caps) upgraded++;
107
+ }
108
+ continue;
109
+ }
110
+ const enriched = await enrichOpencodeEntry({ name: storageKey }, internal, capsSvc);
111
+ models[storageKey] = enriched.entry;
97
112
  existing.add(storageKey);
98
113
  backfilled++;
99
114
  if (internal.includes("/") && storageKey !== internal) {
@@ -111,10 +126,10 @@ export async function ensureAllOpencodeModels(models, ensureAll) {
111
126
  persistModelAliases();
112
127
  } catch {}
113
128
  }
114
- return { nextModels: models, backfilled };
129
+ return { nextModels: models, backfilled, upgraded };
115
130
  }
116
131
 
117
- export async function syncToOpencode({ id, token, port, file, keep, ensureAll } = {}) {
132
+ export async function syncToOpencode({ id, token, port, file, keep, ensureAll, capabilities } = {}) {
118
133
  const targetFile = file || opencodeConfigPath();
119
134
  const normalizedRaw = String(id || "").trim();
120
135
  if (!normalizedRaw) throw new Error("model id required");
@@ -156,6 +171,8 @@ export async function syncToOpencode({ id, token, port, file, keep, ensureAll }
156
171
  let effectiveId = storageKey;
157
172
  let pruned = 0;
158
173
  let backfilled = 0;
174
+ let upgraded = 0;
175
+ let currentCaps = null;
159
176
  if (oldProvider) {
160
177
  const oldModels = oldProvider.models && typeof oldProvider.models === "object" && !Array.isArray(oldProvider.models)
161
178
  ? oldProvider.models
@@ -187,16 +204,21 @@ export async function syncToOpencode({ id, token, port, file, keep, ensureAll }
187
204
  if (nextModels[legacyAlias]) delete nextModels[legacyAlias];
188
205
  if (legacyInternal !== legacyAlias && nextModels[legacyInternal]) delete nextModels[legacyInternal];
189
206
  }
190
- nextModels[storageKey] = { ...merged, name: storageKey };
207
+ const enriched = await enrichOpencodeEntry({ ...merged, name: storageKey }, internal, capabilities);
208
+ nextModels[storageKey] = enriched.entry;
209
+ currentCaps = enriched.caps;
191
210
  effectiveId = storageKey;
192
211
  action = "updated";
193
212
  } else {
194
- nextModels[storageKey] = { name: storageKey };
213
+ const enriched = await enrichOpencodeEntry({ name: storageKey }, internal, capabilities);
214
+ nextModels[storageKey] = enriched.entry;
215
+ currentCaps = enriched.caps;
195
216
  effectiveId = storageKey;
196
217
  action = "inserted";
197
218
  }
198
- const ensured = await ensureAllOpencodeModels(nextModels, ensureAll);
219
+ const ensured = await ensureAllOpencodeModels(nextModels, ensureAll, capabilities);
199
220
  backfilled = ensured.backfilled;
221
+ upgraded = ensured.upgraded || 0;
200
222
  pruned = pruneOpencodeModels(nextModels, keep, storageKey);
201
223
  const nextProvider = {
202
224
  ...oldProvider,
@@ -216,8 +238,12 @@ export async function syncToOpencode({ id, token, port, file, keep, ensureAll }
216
238
  if (!data.provider.mslxdff.models[storageKey]) {
217
239
  data.provider.mslxdff.models = { [storageKey]: { name: storageKey } };
218
240
  }
219
- const ensured = await ensureAllOpencodeModels(data.provider.mslxdff.models, ensureAll);
241
+ const enrichedNew = await enrichOpencodeEntry(data.provider.mslxdff.models[storageKey], internal, capabilities);
242
+ data.provider.mslxdff.models[storageKey] = enrichedNew.entry;
243
+ currentCaps = enrichedNew.caps;
244
+ const ensured = await ensureAllOpencodeModels(data.provider.mslxdff.models, ensureAll, capabilities);
220
245
  backfilled = ensured.backfilled;
246
+ upgraded = ensured.upgraded || 0;
221
247
  action = "inserted";
222
248
  }
223
249
 
@@ -249,5 +275,5 @@ export async function syncToOpencode({ id, token, port, file, keep, ensureAll }
249
275
  }
250
276
  } catch {}
251
277
 
252
- return { action, file: targetFile, id: effectiveId, alias: storageKey, internal, corrupted, storageKey, pruned, backfilled };
278
+ return { action, file: targetFile, id: effectiveId, alias: storageKey, internal, corrupted, storageKey, pruned, backfilled, upgraded, caps: currentCaps, capsSummaryText: capsSummaryText(currentCaps) };
253
279
  }