dsh-cline-pass 0.1.0 → 0.1.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 CHANGED
@@ -27,7 +27,7 @@ You can also install a local directory or tarball:
27
27
 
28
28
  ```bash
29
29
  dsh plugin --profile web add /path/to/dsh-cline-pass
30
- dsh plugin --profile web add ./dsh-cline-pass-0.1.0.tgz
30
+ dsh plugin --profile web add ./dsh-cline-pass-<version>.tgz
31
31
  ```
32
32
 
33
33
  Restart dsh after installation.
package/README.md CHANGED
@@ -27,7 +27,7 @@ dsh plugin --profile web add dsh-cline-pass
27
27
 
28
28
  ```bash
29
29
  dsh plugin --profile web add /path/to/dsh-cline-pass
30
- dsh plugin --profile web add ./dsh-cline-pass-0.1.0.tgz
30
+ dsh plugin --profile web add ./dsh-cline-pass-<version>.tgz
31
31
  ```
32
32
 
33
33
  安装后重启 dsh。
@@ -119,6 +119,10 @@ npm run test:live:reasoning
119
119
 
120
120
  上游渠道和故障转移行为参考了 MIT 许可的 [`cline-pass-switcher`](https://github.com/munmunjaklin458-afk/cline-pass-switcher)。
121
121
 
122
+ ## 友情链接
123
+
124
+ [LinuxDo](https://linux.do/) — 真诚、友善、团结、专业,你的品质开源与技术社区
125
+
122
126
  ## License
123
127
 
124
128
  [MIT](LICENSE)
package/lib/protocol.js CHANGED
@@ -65,6 +65,27 @@ export function slugify(value) {
65
65
  /** OpenRouter's names for the three sort metrics. */
66
66
  export const OPENROUTER_SORT = { cost: 'price', ttft: 'latency', tps: 'throughput' }
67
67
 
68
+ /**
69
+ * Normalize a configured sort into a wire value or `null`.
70
+ *
71
+ * Two spellings mean "no sort" and both must be dropped before the request is
72
+ * built: the settings schema stores an empty string, and `none` is the
73
+ * documented "clear it" value the tools and the panel accept. Neither is a
74
+ * metric, and the gateway rejects them with HTTP 400
75
+ * (`Invalid option: expected one of "cost"|"ttft"|"tps"|...`).
76
+ *
77
+ * Any other non-empty value is passed through untouched, so a genuine typo is
78
+ * named by the gateway's own diagnostic instead of being silently ignored.
79
+ *
80
+ * @param value - the configured sort, as stored.
81
+ * @returns the sort, or null when none is set.
82
+ */
83
+ export function normalizeSort(value) {
84
+ if (typeof value !== 'string') return null
85
+ const sort = value.trim()
86
+ return sort.length === 0 || sort === 'none' ? null : sort
87
+ }
88
+
68
89
  /**
69
90
  * Write one attempt's upstream preference into a request body.
70
91
  *
@@ -76,7 +97,10 @@ export const OPENROUTER_SORT = { cost: 'price', ttft: 'latency', tps: 'throughpu
76
97
  */
77
98
  export function injectPrefs(body, meta, attempt) {
78
99
  const next = { ...body }
79
- const { upstream = null, orderRest = [], excludeList = [], strict = true, sort = null } = attempt ?? {}
100
+ const { upstream = null, orderRest = [], excludeList = [], strict = true } = attempt ?? {}
101
+ // Normalized here as well as in buildAttempts: this function is exported, so
102
+ // a caller can hand it an attempt straight from configuration.
103
+ const sort = normalizeSort(attempt?.sort)
80
104
  const excluded = excludeList.filter((name) => name !== upstream)
81
105
  const known = Array.isArray(meta?.upstreams) ? meta.upstreams : []
82
106
  const allowList = excluded.length > 0 ? known.filter((name) => !excluded.includes(name)) : null
@@ -131,7 +155,7 @@ export function buildAttempts(config) {
131
155
  const excluded = new Set(exclude)
132
156
  const wanted = listed.filter((name) => !excluded.has(name))
133
157
  const strict = (config?.pinMode ?? 'strict') === 'strict'
134
- const sort = config?.sort ?? null
158
+ const sort = normalizeSort(config?.sort)
135
159
  const base = { strict, sort, excludeList: exclude }
136
160
  if (wanted.length > 0) {
137
161
  return wanted.map((upstream, index) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cline-pass",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Self-contained Cline Pass provider for dsh: register Cline Pass subscription models on the harness LLM seam, enumerate and validate the upstream channels behind each model, pin or exclude them with failover, and drive an account pool. No proxy process and no external cline-pass-switcher install required.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",