@liyang8246/dsh-accounts 0.1.10 → 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 +25 -55
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -626,73 +626,48 @@
|
|
|
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
|
-
try {
|
|
674
|
-
filterDirectory(directory, filter);
|
|
675
|
-
} catch {}
|
|
676
|
-
}
|
|
677
|
-
return directory;
|
|
678
|
-
};
|
|
679
|
-
ctx.effect(() => () => {
|
|
680
|
-
models.directoryFor = original;
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
function filterDirectory(directory, filter) {
|
|
684
|
-
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;
|
|
685
662
|
let cache;
|
|
686
663
|
const read = () => {
|
|
687
664
|
const snapshot = source.getSnapshot();
|
|
688
665
|
const key = filter.getSnapshot();
|
|
689
666
|
if (cache === void 0 || cache.snapshot !== snapshot || cache.key !== key) {
|
|
690
|
-
let value;
|
|
667
|
+
let value = snapshot;
|
|
691
668
|
try {
|
|
692
|
-
value =
|
|
693
|
-
} catch {
|
|
694
|
-
value = snapshot;
|
|
695
|
-
}
|
|
669
|
+
value = filterCatalog(snapshot, filter.keywords());
|
|
670
|
+
} catch {}
|
|
696
671
|
cache = {
|
|
697
672
|
snapshot,
|
|
698
673
|
key,
|
|
@@ -711,14 +686,9 @@
|
|
|
711
686
|
stopFilter();
|
|
712
687
|
};
|
|
713
688
|
},
|
|
714
|
-
set: (next) =>
|
|
715
|
-
source.set(next);
|
|
716
|
-
},
|
|
717
|
-
update: (mutator) => {
|
|
718
|
-
source.update(mutator);
|
|
719
|
-
}
|
|
689
|
+
set: (next) => source.set(next)
|
|
720
690
|
};
|
|
721
|
-
Object.defineProperty(
|
|
691
|
+
Object.defineProperty(catalog, "store", {
|
|
722
692
|
configurable: true,
|
|
723
693
|
get: () => wrapped
|
|
724
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": {
|