@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.
Files changed (2) hide show
  1. package/lib/client.js +35 -55
  2. 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.trim();
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 session's model directory snapshot.
629
+ * @param state - the shared catalog snapshot.
630
630
  * @param keywords - lowercase keywords; empty keeps everything.
631
- * @returns the snapshot with filtered provider groups; the selected model stays visible so the composer trigger keeps naming the model in use.
631
+ * @returns the snapshot with filtered provider groups.
632
632
  */
633
- function filterModels(state, keywords) {
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
- groups: groups.filter((group) => group.models.length > 0)
641
+ value: {
642
+ ...state.value,
643
+ groups
644
+ }
655
645
  };
656
646
  }
657
647
  /**
658
- * Filter every session model directory the composer seat and /model popup share.
659
- * Both entries read the directory's store, so the filter sits on the store
660
- * instead of on either surface.
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 models = ctx.get("modelDirectories");
666
- if (models === void 0) return;
667
- const original = models.directoryFor;
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) cache = {
688
- snapshot,
689
- key,
690
- value: filterModels(snapshot, filter.keywords())
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(directory, "store", {
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.9",
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": {