@liyang8246/dsh-accounts 0.1.9 → 0.1.11
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/lib/client.js +35 -55
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -600,7 +600,7 @@
|
|
|
600
600
|
publish();
|
|
601
601
|
},
|
|
602
602
|
setText(next) {
|
|
603
|
-
const value = next.
|
|
603
|
+
const value = next.replace(/[\r\n\t]+/g, " ");
|
|
604
604
|
dirty = true;
|
|
605
605
|
if (value === text) return;
|
|
606
606
|
text = value;
|
|
@@ -609,7 +609,7 @@
|
|
|
609
609
|
if (timer !== void 0) clearTimeout(timer);
|
|
610
610
|
timer = setTimeout(() => {
|
|
611
611
|
timer = void 0;
|
|
612
|
-
save?.(value);
|
|
612
|
+
save?.(value.trim());
|
|
613
613
|
}, saveDelay);
|
|
614
614
|
},
|
|
615
615
|
keywords: () => parsed,
|
|
@@ -626,69 +626,54 @@
|
|
|
626
626
|
}
|
|
627
627
|
/**
|
|
628
628
|
* Keep only models whose name contains one of the keywords.
|
|
629
|
-
* @param state - the
|
|
629
|
+
* @param state - the shared catalog snapshot.
|
|
630
630
|
* @param keywords - lowercase keywords; empty keeps everything.
|
|
631
|
-
* @returns the snapshot with filtered provider groups
|
|
631
|
+
* @returns the snapshot with filtered provider groups.
|
|
632
632
|
*/
|
|
633
|
-
function
|
|
634
|
-
if (!keywords.length) return state;
|
|
635
|
-
const groups = state.groups.map((group) => ({
|
|
633
|
+
function filterCatalog(state, keywords) {
|
|
634
|
+
if (!keywords.length || state.value === null) return state;
|
|
635
|
+
const groups = state.value.groups.map((group) => ({
|
|
636
636
|
...group,
|
|
637
637
|
models: group.models.filter((model) => matches(model.name, keywords))
|
|
638
|
-
}));
|
|
639
|
-
const { current } = state;
|
|
640
|
-
if (current !== null) {
|
|
641
|
-
const source = state.groups.find((group) => group.id === current.provider);
|
|
642
|
-
const model = source?.models.find((item) => item.id === current.model);
|
|
643
|
-
if (source !== void 0 && model !== void 0) {
|
|
644
|
-
const target = groups.find((group) => group.id === source.id);
|
|
645
|
-
if (target === void 0) groups.push({
|
|
646
|
-
...source,
|
|
647
|
-
models: [model]
|
|
648
|
-
});
|
|
649
|
-
else if (!target.models.some((item) => item.id === model.id)) target.models = [...target.models, model];
|
|
650
|
-
}
|
|
651
|
-
}
|
|
638
|
+
})).filter((group) => group.models.length > 0);
|
|
652
639
|
return {
|
|
653
640
|
...state,
|
|
654
|
-
|
|
641
|
+
value: {
|
|
642
|
+
...state.value,
|
|
643
|
+
groups
|
|
644
|
+
}
|
|
655
645
|
};
|
|
656
646
|
}
|
|
657
647
|
/**
|
|
658
|
-
* Filter
|
|
659
|
-
*
|
|
660
|
-
*
|
|
648
|
+
* Filter the one Host-generation model catalog that every session directory copies,
|
|
649
|
+
* so the composer seat and the /model popup share the filtered list.
|
|
650
|
+
*
|
|
651
|
+
* The resolver's own `directoryFor` is NOT wrapped: any method reached through
|
|
652
|
+
* `ctx.get` becomes callable only under this plugin's inject set, where the
|
|
653
|
+
* resolver's `this.ctx.remote.session` read is illegal and takes the composer
|
|
654
|
+
* seat down with it.
|
|
661
655
|
* @param ctx - client root context.
|
|
662
656
|
* @param filter - the page-owned keyword filter.
|
|
663
657
|
*/
|
|
664
658
|
function installModelFilter(ctx, filter) {
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
const patched = /* @__PURE__ */ new WeakSet();
|
|
669
|
-
models.directoryFor = (sessionId) => {
|
|
670
|
-
const directory = original.call(models, sessionId);
|
|
671
|
-
if (!patched.has(directory)) {
|
|
672
|
-
patched.add(directory);
|
|
673
|
-
filterDirectory(directory, filter);
|
|
674
|
-
}
|
|
675
|
-
return directory;
|
|
676
|
-
};
|
|
677
|
-
ctx.effect(() => () => {
|
|
678
|
-
models.directoryFor = original;
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
function filterDirectory(directory, filter) {
|
|
682
|
-
const source = directory.store;
|
|
659
|
+
const catalog = ctx.get("modelDirectories")?.catalog;
|
|
660
|
+
const source = catalog?.store;
|
|
661
|
+
if (catalog === void 0 || source === void 0) return;
|
|
683
662
|
let cache;
|
|
684
663
|
const read = () => {
|
|
685
664
|
const snapshot = source.getSnapshot();
|
|
686
665
|
const key = filter.getSnapshot();
|
|
687
|
-
if (cache === void 0 || cache.snapshot !== snapshot || cache.key !== key)
|
|
688
|
-
snapshot
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
666
|
+
if (cache === void 0 || cache.snapshot !== snapshot || cache.key !== key) {
|
|
667
|
+
let value = snapshot;
|
|
668
|
+
try {
|
|
669
|
+
value = filterCatalog(snapshot, filter.keywords());
|
|
670
|
+
} catch {}
|
|
671
|
+
cache = {
|
|
672
|
+
snapshot,
|
|
673
|
+
key,
|
|
674
|
+
value
|
|
675
|
+
};
|
|
676
|
+
}
|
|
692
677
|
return cache.value;
|
|
693
678
|
};
|
|
694
679
|
const wrapped = {
|
|
@@ -701,14 +686,9 @@
|
|
|
701
686
|
stopFilter();
|
|
702
687
|
};
|
|
703
688
|
},
|
|
704
|
-
set: (next) =>
|
|
705
|
-
source.set(next);
|
|
706
|
-
},
|
|
707
|
-
update: (mutator) => {
|
|
708
|
-
source.update(mutator);
|
|
709
|
-
}
|
|
689
|
+
set: (next) => source.set(next)
|
|
710
690
|
};
|
|
711
|
-
Object.defineProperty(
|
|
691
|
+
Object.defineProperty(catalog, "store", {
|
|
712
692
|
configurable: true,
|
|
713
693
|
get: () => wrapped
|
|
714
694
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liyang8246/dsh-accounts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.11",
|
|
5
5
|
"description": "Independent multi-account Codex, OpenCode Go and CommandCode Go plugin for DeepSeek Harness.",
|
|
6
6
|
"repository": { "type": "git", "url": "https://github.com/liyang8246/dsh-zolin.git", "directory": "packages/dsh-accounts" },
|
|
7
7
|
"exports": {
|