dsh-boost 0.2.0 → 0.2.1
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/README.en.md +41 -18
- package/README.md +34 -17
- package/dist/http/mount.js +5 -3
- package/dist/http/mount.js.map +1 -1
- package/dist/http/state.js +8 -1
- package/dist/http/state.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/scope/doc.js +8 -0
- package/dist/scope/doc.js.map +1 -1
- package/dist/scope/store.js +5 -4
- package/dist/scope/store.js.map +1 -1
- package/dist/tools/boost.js +8 -0
- package/dist/tools/boost.js.map +1 -1
- package/lib/client.js +122 -106
- package/locale/en.json +4 -2
- package/locale/zh.json +4 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -20,12 +20,13 @@ window.__ModuleLoader__.load({
|
|
|
20
20
|
const HINT_OVERHEAD$1 = "每次请求的常驻成本:协议段 + 工具 schema。它不随会话变化,也不被任何节省抵消。";
|
|
21
21
|
const HINT_PROJECTION_GROSS_REPLAY$1 = "每条回执的节省乘以它自己的 (1 + horizon) 再求和。这个数才是净额的被减数。";
|
|
22
22
|
const HINT_PROJECTION_NET$1 = "净额 = 重放毛额 − 取回内容成本 − 取回调用成本。回放用每条回执自己的 horizon,不是当前值;所以上面两个毛额不是同一个数,净额只与重放那个对齐。";
|
|
23
|
-
const HINT_PROJECTION_ON_ROLLBACK$1 =
|
|
23
|
+
const HINT_PROJECTION_ON_ROLLBACK$1 = '回滚:把「投影」改回 `shadow` 并保存;或调 `boost` 工具,`cmd: "scope-set"`、`body: {"projection": "shadow"}`。改动对后续请求立即生效,不需要重启宿主。';
|
|
24
24
|
const HINT_PROJECTION_ON_SPILL$1 = "宿主有 spill 后端。没有的话投影会被跳过——`boost status` 的降级项会写 `ERR_HOST_NO_SPILL`,页面上也会显示这一条。";
|
|
25
|
-
const HINT_PROJECTION_ON_THINKING$1 = "第一次真替换之后盯一次 `content[].thinking` 的 400。当前路由是不是 Anthropic 兼容的 thinking 模式,在这台机器上查不出来,只能在真替换时观察;查不出来就不假装查过。";
|
|
26
25
|
const HINT_SAVED_LOWER$1 = "下界是被跳过那次请求自己的总用量:它不含「后续还会回放多少次」,所以真实节省高于这个数。";
|
|
27
26
|
const HINT_SAVED_UPPER$1 = "上界是「下一次请求的输入」:它把被替换调用的结果也算进了节省,所以真实节省低于这个数。";
|
|
28
27
|
const HINT_SHADOW_MEANS$1 = "影子模式:插件照常决策并记账,但不真的改动发给模型的内容。";
|
|
28
|
+
const HINT_SUBSTITUTE_ON_ROLLBACK$1 = "回滚:把「影子模式」勾回去并保存,替换立即停止;投影的设置不受影响。";
|
|
29
|
+
const HINT_SUBSTITUTE_ON_THINKING$1 = "第一次真替换之后盯一次含 `content[].thinking` 的 400。合成回合没有 `replayState`,宿主侧的转换会丢掉 thinking 块;当前路由是不是 Anthropic 兼容的 thinking 模式,在这台机器上查不出来,只能在真替换时观察。";
|
|
29
30
|
const INTRO$1 = "投影裁剪工具回执、确定性替换可推导的调用。下面的数字全部来自收据,不是估算的替代品:区间给出下界与上界,两者都不是精确值。";
|
|
30
31
|
const LABEL_CONFIG_KEY$1 = "键";
|
|
31
32
|
const LABEL_CONFIG_VALUE$1 = "生效值";
|
|
@@ -47,6 +48,7 @@ window.__ModuleLoader__.load({
|
|
|
47
48
|
const LABEL_SAVE_FAILED$1 = "保存没有生效:";
|
|
48
49
|
const LABEL_SHADOW$1 = "影子模式";
|
|
49
50
|
const LABEL_STALE_IDS$1 = "已保存但注册表里没有";
|
|
51
|
+
const LABEL_SUBSTITUTE_ON_PRECONDITIONS$1 = "关掉影子模式前确认一件事";
|
|
50
52
|
const LABEL_UNMATCHED_IDS$1 = "已勾选但注册表里没有";
|
|
51
53
|
const LABEL_WORKSPACES$1 = "工作区";
|
|
52
54
|
const LOADING$1 = "读取中…";
|
|
@@ -116,10 +118,11 @@ window.__ModuleLoader__.load({
|
|
|
116
118
|
HINT_PROJECTION_NET: HINT_PROJECTION_NET$1,
|
|
117
119
|
HINT_PROJECTION_ON_ROLLBACK: HINT_PROJECTION_ON_ROLLBACK$1,
|
|
118
120
|
HINT_PROJECTION_ON_SPILL: HINT_PROJECTION_ON_SPILL$1,
|
|
119
|
-
HINT_PROJECTION_ON_THINKING: HINT_PROJECTION_ON_THINKING$1,
|
|
120
121
|
HINT_SAVED_LOWER: HINT_SAVED_LOWER$1,
|
|
121
122
|
HINT_SAVED_UPPER: HINT_SAVED_UPPER$1,
|
|
122
123
|
HINT_SHADOW_MEANS: HINT_SHADOW_MEANS$1,
|
|
124
|
+
HINT_SUBSTITUTE_ON_ROLLBACK: HINT_SUBSTITUTE_ON_ROLLBACK$1,
|
|
125
|
+
HINT_SUBSTITUTE_ON_THINKING: HINT_SUBSTITUTE_ON_THINKING$1,
|
|
123
126
|
INTRO: INTRO$1,
|
|
124
127
|
LABEL_CONFIG_KEY: LABEL_CONFIG_KEY$1,
|
|
125
128
|
LABEL_CONFIG_VALUE: LABEL_CONFIG_VALUE$1,
|
|
@@ -141,6 +144,7 @@ window.__ModuleLoader__.load({
|
|
|
141
144
|
LABEL_SAVE_FAILED: LABEL_SAVE_FAILED$1,
|
|
142
145
|
LABEL_SHADOW: LABEL_SHADOW$1,
|
|
143
146
|
LABEL_STALE_IDS: LABEL_STALE_IDS$1,
|
|
147
|
+
LABEL_SUBSTITUTE_ON_PRECONDITIONS: LABEL_SUBSTITUTE_ON_PRECONDITIONS$1,
|
|
144
148
|
LABEL_UNMATCHED_IDS: LABEL_UNMATCHED_IDS$1,
|
|
145
149
|
LABEL_WORKSPACES: LABEL_WORKSPACES$1,
|
|
146
150
|
LOADING: LOADING$1,
|
|
@@ -182,6 +186,95 @@ window.__ModuleLoader__.load({
|
|
|
182
186
|
shadow: "PROJECTION_SHADOW",
|
|
183
187
|
on: "PROJECTION_ON"
|
|
184
188
|
};
|
|
189
|
+
const PROJECTIONS = ["off", "shadow", "on"];
|
|
190
|
+
const isMode = (value) => value === "selected" || value === "global";
|
|
191
|
+
const isProjection = (value) => value === "off" || value === "shadow" || value === "on";
|
|
192
|
+
function seedOf(scope) {
|
|
193
|
+
if (scope === null || typeof scope !== "object") return void 0;
|
|
194
|
+
const envelope = scope;
|
|
195
|
+
if (envelope.ok !== true || envelope.data === null || typeof envelope.data !== "object") return void 0;
|
|
196
|
+
const doc = envelope.data;
|
|
197
|
+
const revision = doc.revision;
|
|
198
|
+
const version2 = doc.version;
|
|
199
|
+
const shadow = doc.shadow;
|
|
200
|
+
const workspaceIds = doc.workspaceIds;
|
|
201
|
+
if (typeof revision !== "number" || !Number.isFinite(revision)) return void 0;
|
|
202
|
+
if (typeof version2 !== "number" || !Number.isFinite(version2)) return void 0;
|
|
203
|
+
if (typeof shadow !== "boolean") return void 0;
|
|
204
|
+
if (!Array.isArray(workspaceIds) || !workspaceIds.every((id) => typeof id === "string")) return void 0;
|
|
205
|
+
if (!isMode(doc.mode) || !isProjection(doc.projection)) return void 0;
|
|
206
|
+
return {
|
|
207
|
+
version: version2,
|
|
208
|
+
revision,
|
|
209
|
+
mode: doc.mode,
|
|
210
|
+
workspaceIds: [...workspaceIds],
|
|
211
|
+
shadow,
|
|
212
|
+
projection: doc.projection
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function draftOf(seed) {
|
|
216
|
+
return patchOf(seed);
|
|
217
|
+
}
|
|
218
|
+
function isDirty(draft, seed) {
|
|
219
|
+
if (draft.mode !== seed.mode) return true;
|
|
220
|
+
if (draft.shadow !== seed.shadow) return true;
|
|
221
|
+
if (draft.projection !== seed.projection) return true;
|
|
222
|
+
if (draft.workspaceIds.length !== seed.workspaceIds.length) return true;
|
|
223
|
+
return draft.workspaceIds.some((id) => !seed.workspaceIds.includes(id));
|
|
224
|
+
}
|
|
225
|
+
const VERSION_CODES = /* @__PURE__ */ new Set([
|
|
226
|
+
"ERR_SCOPE_UNKNOWN_VERSION",
|
|
227
|
+
"ERR_SCOPE_FUTURE_VERSION",
|
|
228
|
+
"ERR_SCOPE_PARSE_FAILED"
|
|
229
|
+
]);
|
|
230
|
+
function disableReasons(scope, workspaces) {
|
|
231
|
+
const reasons = [];
|
|
232
|
+
const envelope = scope ?? {};
|
|
233
|
+
const code = typeof envelope.code === "string" ? envelope.code : "";
|
|
234
|
+
const unreadable = envelope.ok !== true;
|
|
235
|
+
if (unreadable && VERSION_CODES.has(code)) {
|
|
236
|
+
reasons.push({ id: "version-unsupported", code });
|
|
237
|
+
} else if (unreadable) {
|
|
238
|
+
reasons.push({ id: "not-writable", code: code === "" ? "ERR_SCOPE_READ_FAILED" : code });
|
|
239
|
+
}
|
|
240
|
+
if (workspaces !== void 0 && workspaces.available === false) {
|
|
241
|
+
reasons.push({ id: "workspaces-unavailable", code: workspaces.code });
|
|
242
|
+
}
|
|
243
|
+
return reasons;
|
|
244
|
+
}
|
|
245
|
+
function staleWorkspaceIds(seed, workspaces) {
|
|
246
|
+
if (seed === void 0 || workspaces === void 0 || workspaces.available !== true) return [];
|
|
247
|
+
const known = new Set(workspaces.entries.map((entry) => entry.id));
|
|
248
|
+
return seed.workspaceIds.filter((id) => !known.has(id));
|
|
249
|
+
}
|
|
250
|
+
function unmatchedDraftIds(draft, workspaces) {
|
|
251
|
+
if (workspaces === void 0 || workspaces.available !== true) return [];
|
|
252
|
+
const known = new Set(workspaces.entries.map((entry) => entry.id));
|
|
253
|
+
return draft.workspaceIds.filter((id) => !known.has(id));
|
|
254
|
+
}
|
|
255
|
+
function patchOf(draft) {
|
|
256
|
+
return {
|
|
257
|
+
mode: draft.mode,
|
|
258
|
+
workspaceIds: [...draft.workspaceIds],
|
|
259
|
+
shadow: draft.shadow,
|
|
260
|
+
projection: draft.projection
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function isTicked(draft, entry) {
|
|
264
|
+
return draft.workspaceIds.includes(entry.id);
|
|
265
|
+
}
|
|
266
|
+
function toggleTicked(draft, entry) {
|
|
267
|
+
const has = draft.workspaceIds.includes(entry.id);
|
|
268
|
+
return {
|
|
269
|
+
...draft,
|
|
270
|
+
workspaceIds: has ? draft.workspaceIds.filter((id) => id !== entry.id) : [...draft.workspaceIds, entry.id]
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function payloadOf(value) {
|
|
274
|
+
if (value === null || typeof value !== "object") return value;
|
|
275
|
+
const envelope = value;
|
|
276
|
+
return envelope.ok === true ? envelope.data : value;
|
|
277
|
+
}
|
|
185
278
|
const ACTION_REREAD = "Re-read";
|
|
186
279
|
const ACTION_SAVE = "Save";
|
|
187
280
|
const CONFIG_READONLY = "This section is read-only. It shows what resolveConfig decided at load (clamps and fallbacks included); to change it, edit the profile's cordis.patch.yml and restart the host.";
|
|
@@ -195,12 +288,13 @@ window.__ModuleLoader__.load({
|
|
|
195
288
|
const HINT_OVERHEAD = "Fixed cost per request: the protocol section plus tool schemas. It does not vary by session and no saving offsets it.";
|
|
196
289
|
const HINT_PROJECTION_GROSS_REPLAY = "Each receipt's saving multiplied by its own (1 + horizon), summed. This is the figure the net is derived from.";
|
|
197
290
|
const HINT_PROJECTION_NET = "Net = replay gross − retrieval content cost − retrieval call cost. Replay uses each receipt's own horizon, not the current one; so the two gross figures above are not the same number, and only the replay one lines up with the net.";
|
|
198
|
-
const HINT_PROJECTION_ON_ROLLBACK =
|
|
291
|
+
const HINT_PROJECTION_ON_ROLLBACK = 'To roll back, set projection back to `shadow` and save; or call the `boost` tool with `cmd: "scope-set"` and `body: {"projection": "shadow"}`. The change applies to subsequent requests with no host restart.';
|
|
199
292
|
const HINT_PROJECTION_ON_SPILL = "The host has a spill backend. Without one, projection is skipped: `boost status` lists `ERR_HOST_NO_SPILL` among the degraded codes and this page shows the same line.";
|
|
200
|
-
const HINT_PROJECTION_ON_THINKING = "Watch for one `content[].thinking` 400 after the first real substitution. Whether this route is an Anthropic-compatible thinking mode cannot be determined on this machine; it only shows up on a real substitution, so the page does not pretend to have checked.";
|
|
201
293
|
const HINT_SAVED_LOWER = "The lower bound is the skipped request's own total usage: it excludes how many more times it would have been replayed, so the true saving is higher.";
|
|
202
294
|
const HINT_SAVED_UPPER = "The upper bound is the next request's input: it counts the replaced call's result as saved, so the true saving is lower.";
|
|
203
295
|
const HINT_SHADOW_MEANS = "Shadow mode: the plugin still decides and records receipts, but never changes what reaches the model.";
|
|
296
|
+
const HINT_SUBSTITUTE_ON_ROLLBACK = "To roll back, tick shadow mode again and save: substitution stops at once and the projection setting is untouched.";
|
|
297
|
+
const HINT_SUBSTITUTE_ON_THINKING = "Watch for one 400 mentioning `content[].thinking` after the first real substitution. Synthesized turns carry no `replayState`, so the host-side conversion drops the thinking block; whether this route is an Anthropic-compatible thinking mode cannot be determined on this machine and only shows up on a real substitution.";
|
|
204
298
|
const INTRO = "Projection trims tool receipts; deterministic substitution replaces derivable calls. Every number below comes from receipts, not from an estimate: the range gives a lower and an upper bound, and neither is exact.";
|
|
205
299
|
const LABEL_CONFIG_KEY = "Key";
|
|
206
300
|
const LABEL_CONFIG_VALUE = "Effective value";
|
|
@@ -222,6 +316,7 @@ window.__ModuleLoader__.load({
|
|
|
222
316
|
const LABEL_SAVE_FAILED = "The save did not take effect:";
|
|
223
317
|
const LABEL_SHADOW = "Shadow mode";
|
|
224
318
|
const LABEL_STALE_IDS = "Saved, but not in the registry";
|
|
319
|
+
const LABEL_SUBSTITUTE_ON_PRECONDITIONS = "One thing to check before switching shadow mode off";
|
|
225
320
|
const LABEL_UNMATCHED_IDS = "Ticked, but not in the registry";
|
|
226
321
|
const LABEL_WORKSPACES = "Workspaces";
|
|
227
322
|
const LOADING = "Loading…";
|
|
@@ -291,10 +386,11 @@ window.__ModuleLoader__.load({
|
|
|
291
386
|
HINT_PROJECTION_NET,
|
|
292
387
|
HINT_PROJECTION_ON_ROLLBACK,
|
|
293
388
|
HINT_PROJECTION_ON_SPILL,
|
|
294
|
-
HINT_PROJECTION_ON_THINKING,
|
|
295
389
|
HINT_SAVED_LOWER,
|
|
296
390
|
HINT_SAVED_UPPER,
|
|
297
391
|
HINT_SHADOW_MEANS,
|
|
392
|
+
HINT_SUBSTITUTE_ON_ROLLBACK,
|
|
393
|
+
HINT_SUBSTITUTE_ON_THINKING,
|
|
298
394
|
INTRO,
|
|
299
395
|
LABEL_CONFIG_KEY,
|
|
300
396
|
LABEL_CONFIG_VALUE,
|
|
@@ -316,6 +412,7 @@ window.__ModuleLoader__.load({
|
|
|
316
412
|
LABEL_SAVE_FAILED,
|
|
317
413
|
LABEL_SHADOW,
|
|
318
414
|
LABEL_STALE_IDS,
|
|
415
|
+
LABEL_SUBSTITUTE_ON_PRECONDITIONS,
|
|
319
416
|
LABEL_UNMATCHED_IDS,
|
|
320
417
|
LABEL_WORKSPACES,
|
|
321
418
|
LOADING,
|
|
@@ -442,90 +539,6 @@ window.__ModuleLoader__.load({
|
|
|
442
539
|
}
|
|
443
540
|
return { ok: true, data: body?.data };
|
|
444
541
|
}
|
|
445
|
-
const PROJECTIONS = ["off", "shadow", "on"];
|
|
446
|
-
const isMode = (value) => value === "selected" || value === "global";
|
|
447
|
-
const isProjection = (value) => value === "off" || value === "shadow" || value === "on";
|
|
448
|
-
function seedOf(scope) {
|
|
449
|
-
if (scope === null || typeof scope !== "object") return void 0;
|
|
450
|
-
const envelope = scope;
|
|
451
|
-
if (envelope.ok !== true || envelope.data === null || typeof envelope.data !== "object") return void 0;
|
|
452
|
-
const doc = envelope.data;
|
|
453
|
-
const revision = doc.revision;
|
|
454
|
-
const version2 = doc.version;
|
|
455
|
-
const shadow = doc.shadow;
|
|
456
|
-
const workspaceIds = doc.workspaceIds;
|
|
457
|
-
if (typeof revision !== "number" || !Number.isFinite(revision)) return void 0;
|
|
458
|
-
if (typeof version2 !== "number" || !Number.isFinite(version2)) return void 0;
|
|
459
|
-
if (typeof shadow !== "boolean") return void 0;
|
|
460
|
-
if (!Array.isArray(workspaceIds) || !workspaceIds.every((id) => typeof id === "string")) return void 0;
|
|
461
|
-
if (!isMode(doc.mode) || !isProjection(doc.projection)) return void 0;
|
|
462
|
-
return {
|
|
463
|
-
version: version2,
|
|
464
|
-
revision,
|
|
465
|
-
mode: doc.mode,
|
|
466
|
-
workspaceIds: [...workspaceIds],
|
|
467
|
-
shadow,
|
|
468
|
-
projection: doc.projection
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
function draftOf(seed) {
|
|
472
|
-
return patchOf(seed);
|
|
473
|
-
}
|
|
474
|
-
function isDirty(draft, seed) {
|
|
475
|
-
if (draft.mode !== seed.mode) return true;
|
|
476
|
-
if (draft.shadow !== seed.shadow) return true;
|
|
477
|
-
if (draft.projection !== seed.projection) return true;
|
|
478
|
-
if (draft.workspaceIds.length !== seed.workspaceIds.length) return true;
|
|
479
|
-
return draft.workspaceIds.some((id) => !seed.workspaceIds.includes(id));
|
|
480
|
-
}
|
|
481
|
-
const VERSION_CODES = /* @__PURE__ */ new Set([
|
|
482
|
-
"ERR_SCOPE_UNKNOWN_VERSION",
|
|
483
|
-
"ERR_SCOPE_FUTURE_VERSION",
|
|
484
|
-
"ERR_SCOPE_PARSE_FAILED"
|
|
485
|
-
]);
|
|
486
|
-
function disableReasons(scope, workspaces) {
|
|
487
|
-
const reasons = [];
|
|
488
|
-
const envelope = scope ?? {};
|
|
489
|
-
const code = typeof envelope.code === "string" ? envelope.code : "";
|
|
490
|
-
const unreadable = envelope.ok !== true;
|
|
491
|
-
if (unreadable && VERSION_CODES.has(code)) {
|
|
492
|
-
reasons.push({ id: "version-unsupported", code });
|
|
493
|
-
} else if (unreadable) {
|
|
494
|
-
reasons.push({ id: "not-writable", code: code === "" ? "ERR_SCOPE_READ_FAILED" : code });
|
|
495
|
-
}
|
|
496
|
-
if (workspaces !== void 0 && workspaces.available === false) {
|
|
497
|
-
reasons.push({ id: "workspaces-unavailable", code: workspaces.code });
|
|
498
|
-
}
|
|
499
|
-
return reasons;
|
|
500
|
-
}
|
|
501
|
-
function staleWorkspaceIds(seed, workspaces) {
|
|
502
|
-
if (seed === void 0 || workspaces === void 0 || workspaces.available !== true) return [];
|
|
503
|
-
const known = new Set(workspaces.entries.map((entry) => entry.id));
|
|
504
|
-
return seed.workspaceIds.filter((id) => !known.has(id));
|
|
505
|
-
}
|
|
506
|
-
function unmatchedDraftIds(draft, workspaces) {
|
|
507
|
-
if (workspaces === void 0 || workspaces.available !== true) return [];
|
|
508
|
-
const known = new Set(workspaces.entries.map((entry) => entry.id));
|
|
509
|
-
return draft.workspaceIds.filter((id) => !known.has(id));
|
|
510
|
-
}
|
|
511
|
-
function patchOf(draft) {
|
|
512
|
-
return {
|
|
513
|
-
mode: draft.mode,
|
|
514
|
-
workspaceIds: [...draft.workspaceIds],
|
|
515
|
-
shadow: draft.shadow,
|
|
516
|
-
projection: draft.projection
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
function isTicked(draft, entry) {
|
|
520
|
-
return draft.workspaceIds.includes(entry.id);
|
|
521
|
-
}
|
|
522
|
-
function toggleTicked(draft, entry) {
|
|
523
|
-
const has = draft.workspaceIds.includes(entry.id);
|
|
524
|
-
return {
|
|
525
|
-
...draft,
|
|
526
|
-
workspaceIds: has ? draft.workspaceIds.filter((id) => id !== entry.id) : [...draft.workspaceIds, entry.id]
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
542
|
const REREAD_CODES = /* @__PURE__ */ new Set([
|
|
530
543
|
"ERR_SCOPE_REVISION_CONFLICT",
|
|
531
544
|
"ERR_SCOPE_LOCKED",
|
|
@@ -665,13 +678,14 @@ window.__ModuleLoader__.load({
|
|
|
665
678
|
] }),
|
|
666
679
|
draft.projection === "on" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "boost-settings__notice", role: "note", "data-notice": "projection-on", children: [
|
|
667
680
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: c.LABEL_PROJECTION_ON_PRECONDITIONS }),
|
|
668
|
-
/* @__PURE__ */ jsxRuntime.
|
|
669
|
-
/* @__PURE__ */ jsxRuntime.jsx("li", { children: c.HINT_PROJECTION_ON_SPILL }),
|
|
670
|
-
/* @__PURE__ */ jsxRuntime.jsx("li", { children: c.HINT_PROJECTION_ON_THINKING })
|
|
671
|
-
] }),
|
|
681
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { children: /* @__PURE__ */ jsxRuntime.jsx("li", { children: c.HINT_PROJECTION_ON_SPILL }) }),
|
|
672
682
|
/* @__PURE__ */ jsxRuntime.jsx("p", { children: c.HINT_PROJECTION_ON_ROLLBACK })
|
|
673
683
|
] }) : null,
|
|
674
|
-
draft.
|
|
684
|
+
draft.shadow ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "boost-settings__muted", children: c.HINT_SHADOW_MEANS }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "boost-settings__notice", role: "note", "data-notice": "substitute-on", children: [
|
|
685
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: c.LABEL_SUBSTITUTE_ON_PRECONDITIONS }),
|
|
686
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { children: /* @__PURE__ */ jsxRuntime.jsx("li", { children: c.HINT_SUBSTITUTE_ON_THINKING }) }),
|
|
687
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: c.HINT_SUBSTITUTE_ON_ROLLBACK })
|
|
688
|
+
] }),
|
|
675
689
|
stale.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "boost-settings__diagnostic", "data-diagnostic": "stale", children: [
|
|
676
690
|
/* @__PURE__ */ jsxRuntime.jsx("h4", { children: c.LABEL_STALE_IDS }),
|
|
677
691
|
/* @__PURE__ */ jsxRuntime.jsx("ul", { children: stale.map((id) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: id }, id)) })
|
|
@@ -772,9 +786,9 @@ window.__ModuleLoader__.load({
|
|
|
772
786
|
return () => controller.abort();
|
|
773
787
|
}, []);
|
|
774
788
|
react.useEffect(load, [load]);
|
|
775
|
-
const status = result?.ok === true ? result.data.status : void 0;
|
|
789
|
+
const status = payloadOf(result?.ok === true ? result.data.status : void 0);
|
|
776
790
|
const scope = result?.ok === true ? result.data.scope : void 0;
|
|
777
|
-
const config = result?.ok === true ? result.data.config : void 0;
|
|
791
|
+
const config = payloadOf(result?.ok === true ? result.data.config : void 0);
|
|
778
792
|
const saved = pick(status, "saved");
|
|
779
793
|
const degraded = pick(status, "degraded");
|
|
780
794
|
const codes = Array.isArray(degraded) ? degraded.filter((code) => typeof code === "string") : [];
|
|
@@ -845,7 +859,8 @@ window.__ModuleLoader__.load({
|
|
|
845
859
|
}
|
|
846
860
|
const styles = "/**\n * The settings page's own styles.\n *\n * SCOPED DELIBERATELY. This stylesheet is injected into the HOST page's\n * document head, not a sandboxed frame, so a bare `button {}` rule restyles\n * every button in the host UI — a plugin must not do that. Every top-level\n * selector in this file is therefore rooted at a plugin-owned class in the\n * `boost-` namespace.\n */\n.boost-settings {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 16px;\n color: inherit;\n font-size: 13px;\n line-height: 1.6;\n}\n\n.boost-settings h2 {\n margin: 0;\n font-size: 16px;\n}\n\n.boost-settings__intro {\n margin: 0 0 1rem;\n color: var(--dsh-text-secondary, #5a5a5f);\n line-height: 1.6;\n}\n\n.boost-settings__section {\n margin: 0 0 1.25rem;\n}\n\n.boost-settings__section h3 {\n margin: 0 0 0.5rem;\n font-size: 0.95rem;\n font-weight: 600;\n}\n\n.boost-settings__row {\n display: grid;\n grid-template-columns: minmax(8rem, 14rem) 1fr;\n gap: 0.5rem 1rem;\n padding: 0.25rem 0;\n border-bottom: 1px solid var(--dsh-border, #e6e6e8);\n}\n\n.boost-settings__row dt {\n color: var(--dsh-text-secondary, #5a5a5f);\n}\n\n.boost-settings__row dd {\n margin: 0;\n font-variant-numeric: tabular-nums;\n}\n\n.boost-settings__hint {\n display: block;\n margin-top: 0.25rem;\n font-size: 0.85rem;\n color: var(--dsh-text-secondary, #5a5a5f);\n font-variant-numeric: normal;\n}\n\n.boost-settings__ok,\n.boost-settings__muted {\n color: var(--dsh-text-secondary, #5a5a5f);\n}\n\n.boost-settings__codes {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.boost-settings__codes li {\n display: flex;\n flex-direction: column;\n gap: 0.15rem;\n padding: 0.4rem 0;\n border-bottom: 1px solid var(--dsh-border, #e6e6e8);\n}\n\n.boost-settings__error {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.5rem;\n padding: 0.6rem 0.75rem;\n border: 1px solid var(--dsh-danger, #c0392b);\n border-radius: 6px;\n}\n\n.boost-settings__workspaces {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.boost-settings__workspaces li {\n display: flex;\n gap: 0.75rem;\n padding: 0.3rem 0;\n}\n\n.boost-settings__workspaces li.is-selected {\n font-weight: 600;\n}\n\n.boost-settings__config {\n width: 100%;\n border-collapse: collapse;\n}\n\n.boost-settings__config th,\n.boost-settings__config td {\n text-align: left;\n padding: 0.25rem 0.5rem 0.25rem 0;\n border-bottom: 1px solid var(--dsh-border, #e6e6e8);\n font-variant-numeric: tabular-nums;\n}\n";
|
|
847
861
|
const SETTINGS_SLOT = "settings.section";
|
|
848
|
-
const
|
|
862
|
+
const WARN_PREFIX = "dsh-boost";
|
|
863
|
+
const SETTINGS_ID = "boost";
|
|
849
864
|
const inject = ["slots"];
|
|
850
865
|
function installStyles() {
|
|
851
866
|
const node = document.createElement("style");
|
|
@@ -857,23 +872,23 @@ window.__ModuleLoader__.load({
|
|
|
857
872
|
function installTranslator(ctx) {
|
|
858
873
|
const locale = ctx.get?.("locale");
|
|
859
874
|
if (locale === void 0) {
|
|
860
|
-
console.warn(`[${
|
|
875
|
+
console.warn(`[${WARN_PREFIX}] host has no locale service; the page stays readable but will not follow the host language`);
|
|
861
876
|
}
|
|
862
877
|
if (locale !== void 0) {
|
|
863
878
|
try {
|
|
864
|
-
ctx.effect?.(() => locale.register(LOCALE_NAMESPACE, DICTIONARIES), `${
|
|
879
|
+
ctx.effect?.(() => locale.register(LOCALE_NAMESPACE, DICTIONARIES), `${WARN_PREFIX}: dictionaries`);
|
|
865
880
|
const bound = locale.bind(LOCALE_NAMESPACE);
|
|
866
881
|
setTranslator(bound);
|
|
867
882
|
ctx.effect?.(
|
|
868
883
|
() => locale.subscribe?.(() => setTranslator(locale.bind(LOCALE_NAMESPACE))) ?? (() => {
|
|
869
884
|
}),
|
|
870
|
-
`${
|
|
885
|
+
`${WARN_PREFIX}: locale subscription`
|
|
871
886
|
);
|
|
872
887
|
return bound;
|
|
873
888
|
} catch (error) {
|
|
874
889
|
const message = error instanceof Error ? error.message : String(error);
|
|
875
890
|
console.warn(
|
|
876
|
-
`[${
|
|
891
|
+
`[${WARN_PREFIX}] host locale service rejected the dictionaries (${message}); registering the section without a locale namespace and using the built-in translator`
|
|
877
892
|
);
|
|
878
893
|
}
|
|
879
894
|
}
|
|
@@ -881,10 +896,10 @@ window.__ModuleLoader__.load({
|
|
|
881
896
|
return fallbackT;
|
|
882
897
|
}
|
|
883
898
|
function apply(ctx) {
|
|
884
|
-
ctx.effect?.(() => installStyles(), `${
|
|
899
|
+
ctx.effect?.(() => installStyles(), `${WARN_PREFIX}: settings styles`);
|
|
885
900
|
const t = installTranslator(ctx);
|
|
886
901
|
if (ctx.slots === void 0) {
|
|
887
|
-
console.warn(`[${
|
|
902
|
+
console.warn(`[${WARN_PREFIX}] client slots service unavailable; settings page not registered`);
|
|
888
903
|
return;
|
|
889
904
|
}
|
|
890
905
|
const slots = ctx.slots;
|
|
@@ -893,7 +908,7 @@ window.__ModuleLoader__.load({
|
|
|
893
908
|
() => slots.register(
|
|
894
909
|
{
|
|
895
910
|
name: SETTINGS_SLOT,
|
|
896
|
-
id:
|
|
911
|
+
id: SETTINGS_ID,
|
|
897
912
|
order: 50,
|
|
898
913
|
// A thunk, not a string: the shell re-reads it when the locale changes,
|
|
899
914
|
// so the nav item follows the language without this plugin subscribing.
|
|
@@ -904,8 +919,9 @@ window.__ModuleLoader__.load({
|
|
|
904
919
|
)
|
|
905
920
|
);
|
|
906
921
|
}
|
|
907
|
-
exports.
|
|
922
|
+
exports.SETTINGS_ID = SETTINGS_ID;
|
|
908
923
|
exports.SETTINGS_SLOT = SETTINGS_SLOT;
|
|
924
|
+
exports.WARN_PREFIX = WARN_PREFIX;
|
|
909
925
|
exports.apply = apply;
|
|
910
926
|
exports.inject = inject;
|
|
911
927
|
return module.exports;
|
package/locale/en.json
CHANGED
|
@@ -47,12 +47,13 @@
|
|
|
47
47
|
"HINT_OVERHEAD": "Fixed cost per request: the protocol section plus tool schemas. It does not vary by session and no saving offsets it.",
|
|
48
48
|
"HINT_PROJECTION_GROSS_REPLAY": "Each receipt's saving multiplied by its own (1 + horizon), summed. This is the figure the net is derived from.",
|
|
49
49
|
"HINT_PROJECTION_NET": "Net = replay gross − retrieval content cost − retrieval call cost. Replay uses each receipt's own horizon, not the current one; so the two gross figures above are not the same number, and only the replay one lines up with the net.",
|
|
50
|
-
"HINT_PROJECTION_ON_ROLLBACK": "To roll back, set projection back to `shadow` and save
|
|
50
|
+
"HINT_PROJECTION_ON_ROLLBACK": "To roll back, set projection back to `shadow` and save; or call the `boost` tool with `cmd: \"scope-set\"` and `body: {\"projection\": \"shadow\"}`. The change applies to subsequent requests with no host restart.",
|
|
51
51
|
"HINT_PROJECTION_ON_SPILL": "The host has a spill backend. Without one, projection is skipped: `boost status` lists `ERR_HOST_NO_SPILL` among the degraded codes and this page shows the same line.",
|
|
52
|
-
"HINT_PROJECTION_ON_THINKING": "Watch for one `content[].thinking` 400 after the first real substitution. Whether this route is an Anthropic-compatible thinking mode cannot be determined on this machine; it only shows up on a real substitution, so the page does not pretend to have checked.",
|
|
53
52
|
"HINT_SAVED_LOWER": "The lower bound is the skipped request's own total usage: it excludes how many more times it would have been replayed, so the true saving is higher.",
|
|
54
53
|
"HINT_SAVED_UPPER": "The upper bound is the next request's input: it counts the replaced call's result as saved, so the true saving is lower.",
|
|
55
54
|
"HINT_SHADOW_MEANS": "Shadow mode: the plugin still decides and records receipts, but never changes what reaches the model.",
|
|
55
|
+
"HINT_SUBSTITUTE_ON_ROLLBACK": "To roll back, tick shadow mode again and save: substitution stops at once and the projection setting is untouched.",
|
|
56
|
+
"HINT_SUBSTITUTE_ON_THINKING": "Watch for one 400 mentioning `content[].thinking` after the first real substitution. Synthesized turns carry no `replayState`, so the host-side conversion drops the thinking block; whether this route is an Anthropic-compatible thinking mode cannot be determined on this machine and only shows up on a real substitution.",
|
|
56
57
|
"INTRO": "Projection trims tool receipts; deterministic substitution replaces derivable calls. Every number below comes from receipts, not from an estimate: the range gives a lower and an upper bound, and neither is exact.",
|
|
57
58
|
"LABEL_CONFIG_KEY": "Key",
|
|
58
59
|
"LABEL_CONFIG_VALUE": "Effective value",
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
"LABEL_SAVE_FAILED": "The save did not take effect:",
|
|
75
76
|
"LABEL_SHADOW": "Shadow mode",
|
|
76
77
|
"LABEL_STALE_IDS": "Saved, but not in the registry",
|
|
78
|
+
"LABEL_SUBSTITUTE_ON_PRECONDITIONS": "One thing to check before switching shadow mode off",
|
|
77
79
|
"LABEL_UNMATCHED_IDS": "Ticked, but not in the registry",
|
|
78
80
|
"LABEL_WORKSPACES": "Workspaces",
|
|
79
81
|
"LOADING": "Loading…",
|
package/locale/zh.json
CHANGED
|
@@ -47,12 +47,13 @@
|
|
|
47
47
|
"HINT_OVERHEAD": "每次请求的常驻成本:协议段 + 工具 schema。它不随会话变化,也不被任何节省抵消。",
|
|
48
48
|
"HINT_PROJECTION_GROSS_REPLAY": "每条回执的节省乘以它自己的 (1 + horizon) 再求和。这个数才是净额的被减数。",
|
|
49
49
|
"HINT_PROJECTION_NET": "净额 = 重放毛额 − 取回内容成本 − 取回调用成本。回放用每条回执自己的 horizon,不是当前值;所以上面两个毛额不是同一个数,净额只与重放那个对齐。",
|
|
50
|
-
"HINT_PROJECTION_ON_ROLLBACK": "回滚:把「投影」改回 `shadow`
|
|
50
|
+
"HINT_PROJECTION_ON_ROLLBACK": "回滚:把「投影」改回 `shadow` 并保存;或调 `boost` 工具,`cmd: \"scope-set\"`、`body: {\"projection\": \"shadow\"}`。改动对后续请求立即生效,不需要重启宿主。",
|
|
51
51
|
"HINT_PROJECTION_ON_SPILL": "宿主有 spill 后端。没有的话投影会被跳过——`boost status` 的降级项会写 `ERR_HOST_NO_SPILL`,页面上也会显示这一条。",
|
|
52
|
-
"HINT_PROJECTION_ON_THINKING": "第一次真替换之后盯一次 `content[].thinking` 的 400。当前路由是不是 Anthropic 兼容的 thinking 模式,在这台机器上查不出来,只能在真替换时观察;查不出来就不假装查过。",
|
|
53
52
|
"HINT_SAVED_LOWER": "下界是被跳过那次请求自己的总用量:它不含「后续还会回放多少次」,所以真实节省高于这个数。",
|
|
54
53
|
"HINT_SAVED_UPPER": "上界是「下一次请求的输入」:它把被替换调用的结果也算进了节省,所以真实节省低于这个数。",
|
|
55
54
|
"HINT_SHADOW_MEANS": "影子模式:插件照常决策并记账,但不真的改动发给模型的内容。",
|
|
55
|
+
"HINT_SUBSTITUTE_ON_ROLLBACK": "回滚:把「影子模式」勾回去并保存,替换立即停止;投影的设置不受影响。",
|
|
56
|
+
"HINT_SUBSTITUTE_ON_THINKING": "第一次真替换之后盯一次含 `content[].thinking` 的 400。合成回合没有 `replayState`,宿主侧的转换会丢掉 thinking 块;当前路由是不是 Anthropic 兼容的 thinking 模式,在这台机器上查不出来,只能在真替换时观察。",
|
|
56
57
|
"INTRO": "投影裁剪工具回执、确定性替换可推导的调用。下面的数字全部来自收据,不是估算的替代品:区间给出下界与上界,两者都不是精确值。",
|
|
57
58
|
"LABEL_CONFIG_KEY": "键",
|
|
58
59
|
"LABEL_CONFIG_VALUE": "生效值",
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
"LABEL_SAVE_FAILED": "保存没有生效:",
|
|
75
76
|
"LABEL_SHADOW": "影子模式",
|
|
76
77
|
"LABEL_STALE_IDS": "已保存但注册表里没有",
|
|
78
|
+
"LABEL_SUBSTITUTE_ON_PRECONDITIONS": "关掉影子模式前确认一件事",
|
|
77
79
|
"LABEL_UNMATCHED_IDS": "已勾选但注册表里没有",
|
|
78
80
|
"LABEL_WORKSPACES": "工作区",
|
|
79
81
|
"LOADING": "读取中…",
|