@alanzhao/dsh-memory-lite 0.2.4 → 0.2.5
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.md +1 -0
- package/lib/client.js +58 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ The plugin row in `cordis.patch.yml` carries **no configuration** (mount only);
|
|
|
58
58
|
Effect timing:
|
|
59
59
|
|
|
60
60
|
- **Live** (apply on save): `extraction.*`, `index.maxTokens`, `defaultPeer`, `workspacePeers.*`, `ui.headerOrder` (after a refresh for the slot order).
|
|
61
|
+
- **Reasoning effort**: the list comes from the selected extraction model; with the route left on *跟随全局默认* it comes from the current `agent-default-model` model, so an effort can be pinned without pinning a model.
|
|
61
62
|
- **Stale model values**: if `extraction.llm.route` (or `reasoningEffort`) points at a model the provider has renamed or removed, the panel shows it as a flagged *已失效* option with a warning instead of silently displaying *跟随全局默认*. The plugin never rewrites it for you — extraction keeps failing until you pick a new value.
|
|
62
63
|
- **Restart** (persisted, apply on next boot): `root`, `sharing.*` — `MemoryStore` pins them at construction; the panel labels them accordingly.
|
|
63
64
|
|
package/lib/client.js
CHANGED
|
@@ -237,7 +237,7 @@ window.__ModuleLoader__.load({
|
|
|
237
237
|
// - routeOptions: [['', '跟随全局默认(当前:<provider> / <model>)'], ...all '<provider> / <model>']
|
|
238
238
|
// - effortOptionsFor(route): efforts of the selected model, prefixed with the
|
|
239
239
|
// '跟随全局默认' empty option (the model's defaultEffort when absent).
|
|
240
|
-
function useModelOptions(connection, agentDefaultScope) {
|
|
240
|
+
function useModelOptions(connection, agentDefaultScope, selectedRoute) {
|
|
241
241
|
const [catalog, setCatalog] = useState(null); // { groups: [{id,name,models:[{id,name}]}] }
|
|
242
242
|
const [efforts, setEfforts] = useState(null); // { efforts: [], defaultEffort } for the selected route
|
|
243
243
|
const [effortRoute, setEffortRoute] = useState('');
|
|
@@ -274,32 +274,6 @@ window.__ModuleLoader__.load({
|
|
|
274
274
|
return () => { alive = false; };
|
|
275
275
|
}, [connection]);
|
|
276
276
|
|
|
277
|
-
// Reasoning efforts are resolved lazily per selected route through
|
|
278
|
-
// /memory-model-efforts (host resolveModelInfo), not embedded in the
|
|
279
|
-
// catalog (that would be N host calls per mount).
|
|
280
|
-
useEffect(() => {
|
|
281
|
-
if (!connection || effortRoute === '') { setEfforts(null); return; }
|
|
282
|
-
let alive = true;
|
|
283
|
-
const load = async () => {
|
|
284
|
-
try {
|
|
285
|
-
const res = await connection.rpc.call('/api', 'memory-model-efforts/snapshot', { route: effortRoute });
|
|
286
|
-
if (!alive) return;
|
|
287
|
-
if (res && res.ok && res.value) {
|
|
288
|
-
setEfforts(res.value);
|
|
289
|
-
} else {
|
|
290
|
-
setEfforts({ efforts: [], defaultEffort: undefined });
|
|
291
|
-
}
|
|
292
|
-
} catch (err) {
|
|
293
|
-
if (alive) {
|
|
294
|
-
console.error('[memory-lite] /memory-model-efforts failed:', err);
|
|
295
|
-
setEfforts({ efforts: [], defaultEffort: undefined });
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
void load();
|
|
300
|
-
return () => { alive = false; };
|
|
301
|
-
}, [connection, effortRoute]);
|
|
302
|
-
|
|
303
277
|
useEffect(() => {
|
|
304
278
|
if (!agentDefaultScope) return undefined;
|
|
305
279
|
return agentDefaultScope.subscribe(() => { force((n) => n + 1); });
|
|
@@ -311,6 +285,36 @@ window.__ModuleLoader__.load({
|
|
|
311
285
|
const defModel = defValue ? defValue.model : undefined;
|
|
312
286
|
const defRoute = (defProvider && defModel) ? defProvider + '/' + defModel : '';
|
|
313
287
|
|
|
288
|
+
// Reasoning efforts belong to one concrete model route. An empty
|
|
289
|
+
// selection means 跟随全局默认: that route IS the live global default
|
|
290
|
+
// model, so the dropdown must offer its efforts, not just the empty
|
|
291
|
+
// option (which is what the field hint already promises).
|
|
292
|
+
const selectedKey = typeof selectedRoute === 'string' ? selectedRoute : '';
|
|
293
|
+
const effortRouteTarget = selectedKey === '' ? defRoute : selectedKey;
|
|
294
|
+
|
|
295
|
+
// Resolved lazily per target route through /memory-model-efforts (host
|
|
296
|
+
// resolveModelInfo), not embedded in the catalog (N host calls/mount).
|
|
297
|
+
// effortRoute remembers which route the fetched `efforts` describe.
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
if (!connection || effortRouteTarget === '') { setEfforts(null); setEffortRoute(''); return; }
|
|
300
|
+
let alive = true;
|
|
301
|
+
const load = async () => {
|
|
302
|
+
try {
|
|
303
|
+
const res = await connection.rpc.call('/api', 'memory-model-efforts/snapshot', { route: effortRouteTarget });
|
|
304
|
+
if (!alive) return;
|
|
305
|
+
setEffortRoute(effortRouteTarget);
|
|
306
|
+
setEfforts(res && res.ok && res.value ? res.value : { efforts: [], defaultEffort: undefined });
|
|
307
|
+
} catch (err) {
|
|
308
|
+
if (!alive) return;
|
|
309
|
+
console.error('[memory-lite] /memory-model-efforts failed:', err);
|
|
310
|
+
setEffortRoute(effortRouteTarget);
|
|
311
|
+
setEfforts({ efforts: [], defaultEffort: undefined });
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
void load();
|
|
315
|
+
return () => { alive = false; };
|
|
316
|
+
}, [connection, effortRouteTarget]);
|
|
317
|
+
|
|
314
318
|
const routeOptions = [];
|
|
315
319
|
if (defRoute !== '') {
|
|
316
320
|
routeOptions.push(['', '跟随全局默认(当前:' + defRoute + ')']);
|
|
@@ -325,16 +329,13 @@ window.__ModuleLoader__.load({
|
|
|
325
329
|
}
|
|
326
330
|
}
|
|
327
331
|
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
// Selected route drives the lazy efforts fetch (see the effortRoute
|
|
332
|
-
// effect above). effortOptionsFor renders from the fetched efforts;
|
|
333
|
-
// while the fetch is in flight only the default option shows.
|
|
334
|
-
const selectRoute = (route) => { setEffortRoute(route || ''); };
|
|
332
|
+
// Options for the effort dropdown: the efforts of the route the value
|
|
333
|
+
// belongs to, where '' means the live global default model (resolved
|
|
334
|
+
// above). While that route's fetch is in flight only the default shows.
|
|
335
335
|
const effortOptionsFor = (route) => {
|
|
336
336
|
const opts = [['', '跟随全局默认']];
|
|
337
|
-
|
|
337
|
+
const target = route === undefined || route === null || route === '' ? defRoute : String(route);
|
|
338
|
+
if (target === '' || target !== effortRoute) return opts;
|
|
338
339
|
const list = (efforts && efforts.efforts) || [];
|
|
339
340
|
for (const eff of list) {
|
|
340
341
|
opts.push([eff.id, eff.name + (eff.description ? '(' + eff.description + ')' : '')]);
|
|
@@ -345,8 +346,11 @@ window.__ModuleLoader__.load({
|
|
|
345
346
|
// A list is authoritative only once its fetch answered; until then a
|
|
346
347
|
// stored value missing from the options is not yet known to be stale.
|
|
347
348
|
const catalogReady = catalog !== null && !failed;
|
|
348
|
-
const effortsReadyFor = (route) =>
|
|
349
|
-
|
|
349
|
+
const effortsReadyFor = (route) => {
|
|
350
|
+
const target = route === undefined || route === null || route === '' ? defRoute : String(route);
|
|
351
|
+
return target !== '' && target === effortRoute && efforts !== null;
|
|
352
|
+
};
|
|
353
|
+
return { routeOptions, effortOptionsFor, failed, catalogReady, effortsReadyFor };
|
|
350
354
|
}
|
|
351
355
|
|
|
352
356
|
/* ---- 共享挂载 peer 列表 (16.9 补: 勾选式编辑) ---- */
|
|
@@ -444,12 +448,9 @@ window.__ModuleLoader__.load({
|
|
|
444
448
|
: null;
|
|
445
449
|
control = jsx('select', {
|
|
446
450
|
value: String(shown ?? ''),
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
if (isRoute && modelOptions && modelOptions.selectRoute) modelOptions.selectRoute(next);
|
|
451
|
-
onChange(key, next);
|
|
452
|
-
},
|
|
451
|
+
// The lazy efforts fetch follows the selected route on its own
|
|
452
|
+
// (useModelOptions takes it as an argument), so nothing to re-target.
|
|
453
|
+
onChange: (e) => { onChange(key, e.target.value); },
|
|
453
454
|
style: inputStyle,
|
|
454
455
|
children: (resolved.options || []).map(([optValue, optLabel]) =>
|
|
455
456
|
jsx('option', { value: optValue, children: optLabel, key: optValue })),
|
|
@@ -504,27 +505,26 @@ window.__ModuleLoader__.load({
|
|
|
504
505
|
// Sharing-mount checkbox state: a Set of peer names checked for sharing.
|
|
505
506
|
const [mountDraft, setMountDraft] = useState(null); // null = untouched
|
|
506
507
|
|
|
507
|
-
const modelOptions = useModelOptions(connection, agentDefaultScope);
|
|
508
|
-
const peerList = usePeerList(connection);
|
|
509
|
-
|
|
510
|
-
useEffect(() => {
|
|
511
|
-
if (!scope) return undefined;
|
|
512
|
-
return scope.subscribe(() => { force((n) => n + 1); });
|
|
513
|
-
}, [scope]);
|
|
514
|
-
|
|
515
508
|
const snapshot = scope ? scope.getSnapshot() : null;
|
|
516
509
|
const value = snapshot && snapshot.status === 'ready' ? snapshot.value : undefined;
|
|
517
510
|
const writable = snapshot ? snapshot.writable : false;
|
|
518
511
|
|
|
519
|
-
//
|
|
520
|
-
//
|
|
521
|
-
//
|
|
512
|
+
// The route the effort dropdown belongs to: the staged edit wins, then
|
|
513
|
+
// the stored value. '' = 跟随全局默认, which useModelOptions resolves to
|
|
514
|
+
// the live default model for the efforts fetch.
|
|
515
|
+
const draftRoute = draft['extraction.llm.route'];
|
|
522
516
|
const storedRoute = readPath(value, ['extraction', 'llm', 'route']);
|
|
523
|
-
const
|
|
517
|
+
const selectedRoute = draftRoute !== undefined
|
|
518
|
+
? (typeof draftRoute === 'string' ? draftRoute : '')
|
|
519
|
+
: (typeof storedRoute === 'string' ? storedRoute : '');
|
|
520
|
+
|
|
521
|
+
const modelOptions = useModelOptions(connection, agentDefaultScope, selectedRoute);
|
|
522
|
+
const peerList = usePeerList(connection);
|
|
523
|
+
|
|
524
524
|
useEffect(() => {
|
|
525
|
-
if (
|
|
526
|
-
|
|
527
|
-
}, [
|
|
525
|
+
if (!scope) return undefined;
|
|
526
|
+
return scope.subscribe(() => { force((n) => n + 1); });
|
|
527
|
+
}, [scope]);
|
|
528
528
|
|
|
529
529
|
const setField = (key, val) => {
|
|
530
530
|
setDraft((d) => ({ ...d, [key]: val }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alanzhao/dsh-memory-lite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Lightweight zero-dependency memory plugin for DeepSeek Harness: Markdown-file memory store, L0 catalog injection, and 5 model-facing tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|