dsh-magpie-route 1.0.0 → 1.0.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.md +5 -12
- package/README.zh.md +5 -12
- package/client.js +88 -16
- package/cordis.patch.yml +1 -4
- package/docs/preview.png +0 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# dsh-magpie-route
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
A DeepSeek Harness (`dsh`) plugin that shows the **real upstream model** behind a [magpie](https://usemagpie.ai) routing-group alias, directly below the composer.
|
|
4
6
|
|
|
5
7
|
DSH's model picker only knows the routing-group alias you configured (for example `magpie/group/daily`). The local magpie gateway decides which upstream provider/model actually serves each request, and that can change from turn to turn. This plugin reads the gateway's own trace and shows the real result.
|
|
@@ -11,6 +13,7 @@ DSH's model picker only knows the routing-group alias you configured (for exampl
|
|
|
11
13
|
## Features
|
|
12
14
|
|
|
13
15
|
- **Composer dock line** — sits below the composer, refreshes every 15 seconds, and refreshes immediately on click. Shows the time, the asked alias, the real `provider/model`, and the matched routing rule.
|
|
16
|
+
- **Follows the DSH UI language** — the line reads `magpie real route` in English and `magpie 真实路由` in Chinese (and switches live when the UI language changes).
|
|
14
17
|
- Green dot = a settled route; red dot = the gateway is unreachable (click to retry); grey dot = no settled request yet. Hover for the data source.
|
|
15
18
|
- Read-only: it sends no model request, changes no routing, and injects no headers.
|
|
16
19
|
- **No command and no agent tool** — this plugin only displays the route.
|
|
@@ -18,7 +21,7 @@ DSH's model picker only knows the routing-group alias you configured (for exampl
|
|
|
18
21
|
## Requirements
|
|
19
22
|
|
|
20
23
|
- DeepSeek Harness with the composer dock slot (0.2.x).
|
|
21
|
-
- A running [magpie](https://usemagpie.ai) gateway
|
|
24
|
+
- A running [magpie](https://usemagpie.ai) gateway on the default `http://127.0.0.1:3425`.
|
|
22
25
|
|
|
23
26
|
## Install
|
|
24
27
|
|
|
@@ -28,17 +31,7 @@ For a local checkout instead, install the bundle directory with `plugin_manager`
|
|
|
28
31
|
|
|
29
32
|
## Configuration
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```yaml
|
|
34
|
-
- id: magpie-route
|
|
35
|
-
config:
|
|
36
|
-
baseURL: http://127.0.0.1:3425
|
|
37
|
-
agent: dsh
|
|
38
|
-
limit: 5
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`agent` is the magpie trace agent name to filter on (default `dsh`); `limit` is the number of recent settled rows the route returns (the dock shows the first).
|
|
34
|
+
No configuration is required: the plugin talks to the default local gateway at `http://127.0.0.1:3425` and filters the `dsh` agent. Only if your gateway runs elsewhere, override `baseURL` (and optionally `agent`/`limit`) in your profile's `cordis.patch.yml`.
|
|
42
35
|
|
|
43
36
|
## How it works
|
|
44
37
|
|
package/README.zh.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# dsh-magpie-route
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
DeepSeek Harness(`dsh`)插件:把 [magpie](https://usemagpie.ai) 路由组别名背后的**真实上游模型**直接显示在输入框下方。
|
|
4
6
|
|
|
5
7
|
DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/group/daily`);请求实际发往哪个上游 provider/model 由本地 magpie 网关决定,而且可能逐轮变化。本插件读取网关自己的 trace,把真实结果显示出来。
|
|
@@ -11,6 +13,7 @@ DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/grou
|
|
|
11
13
|
## 功能
|
|
12
14
|
|
|
13
15
|
- **输入框下方常驻一行**:每 15 秒刷新,点击立即刷新;显示时间、请求别名、真实 `provider/model` 和命中的路由规则。
|
|
16
|
+
- **跟随 DSH 界面语言**:中文界面显示“magpie 真实路由”,英文界面显示“magpie real route”,切换语言时会实时更新。
|
|
14
17
|
- 绿点 = 有已完成结果;红点 = 网关不可用(点击重试);灰点 = 暂无已完成请求;悬停显示数据源。
|
|
15
18
|
- 只读:不发模型请求、不改路由、不注入请求头。
|
|
16
19
|
- **不提供命令,也不提供 agent 工具**,插件只负责界面显示。
|
|
@@ -18,7 +21,7 @@ DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/grou
|
|
|
18
21
|
## 要求
|
|
19
22
|
|
|
20
23
|
- 带 composer dock slot 的 DeepSeek Harness(0.2.x)。
|
|
21
|
-
- 正在运行的 [magpie](https://usemagpie.ai)
|
|
24
|
+
- 正在运行的 [magpie](https://usemagpie.ai) 网关,默认地址 `http://127.0.0.1:3425`。
|
|
22
25
|
|
|
23
26
|
## 安装
|
|
24
27
|
|
|
@@ -28,17 +31,7 @@ DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/grou
|
|
|
28
31
|
|
|
29
32
|
## 配置
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```yaml
|
|
34
|
-
- id: magpie-route
|
|
35
|
-
config:
|
|
36
|
-
baseURL: http://127.0.0.1:3425
|
|
37
|
-
agent: dsh
|
|
38
|
-
limit: 5
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`agent` 是 magpie trace 里的 agent 名(默认 `dsh`);`limit` 是路由返回的最近已完成条数(界面显示第一条)。
|
|
34
|
+
默认无需配置:插件自动连接本地网关 `http://127.0.0.1:3425`,并按 `dsh` agent 过滤。只有网关不在默认地址时,才需要在 profile 的 `cordis.patch.yml` 里覆盖 `baseURL`(以及可选的 `agent`/`limit`)。
|
|
42
35
|
|
|
43
36
|
## 工作原理
|
|
44
37
|
|
package/client.js
CHANGED
|
@@ -4,16 +4,45 @@
|
|
|
4
4
|
* Host half over a same-origin route (the gateway itself sends no CORS headers).
|
|
5
5
|
* Clicking the line refreshes immediately; the row also refreshes every 15s.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* does not depend on
|
|
7
|
+
* The label follows the DSH UI language (Chinese / English). Only the `react`
|
|
8
|
+
* module is required; all styling is inline so the factory does not depend on
|
|
9
|
+
* any other client builtin.
|
|
9
10
|
*/
|
|
10
11
|
window.__ModuleLoader__.load({
|
|
11
|
-
id: '
|
|
12
|
+
id: 'dsh-magpie-route',
|
|
12
13
|
factory(require) {
|
|
13
14
|
const React = require('react')
|
|
14
15
|
const h = React.createElement
|
|
15
16
|
const ROUTE = '/plugins/magpie-route/route'
|
|
16
17
|
const REFRESH_MS = 15000
|
|
18
|
+
const NS = 'magpieRoute'
|
|
19
|
+
|
|
20
|
+
const DICT = {
|
|
21
|
+
zh: {
|
|
22
|
+
label: 'magpie 真实路由',
|
|
23
|
+
loading: '读取中…',
|
|
24
|
+
unreachable: '网关不可用(点击重试)',
|
|
25
|
+
none: '暂无已完成的请求',
|
|
26
|
+
inFlightPrefix: '另有 ',
|
|
27
|
+
inFlightSuffix: ' 条进行中',
|
|
28
|
+
clickRefresh: '点击刷新',
|
|
29
|
+
sourcePrefix: '数据源 ',
|
|
30
|
+
sourceSuffix: ' · 点击刷新',
|
|
31
|
+
aria: 'magpie 真实路由,点击刷新',
|
|
32
|
+
},
|
|
33
|
+
en: {
|
|
34
|
+
label: 'magpie real route',
|
|
35
|
+
loading: 'loading…',
|
|
36
|
+
unreachable: 'gateway unreachable (click to retry)',
|
|
37
|
+
none: 'no settled request yet',
|
|
38
|
+
inFlightPrefix: '',
|
|
39
|
+
inFlightSuffix: ' in flight',
|
|
40
|
+
clickRefresh: 'click to refresh',
|
|
41
|
+
sourcePrefix: 'source ',
|
|
42
|
+
sourceSuffix: ' · click to refresh',
|
|
43
|
+
aria: 'magpie real route, click to refresh',
|
|
44
|
+
},
|
|
45
|
+
}
|
|
17
46
|
|
|
18
47
|
const baseStyle = {
|
|
19
48
|
display: 'flex',
|
|
@@ -45,9 +74,32 @@ window.__ModuleLoader__.load({
|
|
|
45
74
|
return text.length >= 19 ? text.slice(11, 16) : ''
|
|
46
75
|
}
|
|
47
76
|
|
|
48
|
-
function
|
|
77
|
+
function currentLang(ctx) {
|
|
78
|
+
try {
|
|
79
|
+
const snapshot = ctx.locale.getLocale()
|
|
80
|
+
return String((snapshot && snapshot.id) || 'zh').slice(0, 2) === 'en' ? 'en' : 'zh'
|
|
81
|
+
} catch {
|
|
82
|
+
return 'zh'
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function MagpieRouteDock(props) {
|
|
87
|
+
const ctx = props.ctx
|
|
49
88
|
const [state, setState] = React.useState({ phase: 'loading' })
|
|
50
89
|
const [nonce, setNonce] = React.useState(0)
|
|
90
|
+
const [lang, setLang] = React.useState(() => currentLang(ctx))
|
|
91
|
+
|
|
92
|
+
React.useEffect(() => {
|
|
93
|
+
let unsubscribe = null
|
|
94
|
+
try {
|
|
95
|
+
unsubscribe = ctx.locale.subscribe(() => setLang(currentLang(ctx)))
|
|
96
|
+
} catch {
|
|
97
|
+
/* locale is optional for rendering */
|
|
98
|
+
}
|
|
99
|
+
return () => {
|
|
100
|
+
if (typeof unsubscribe === 'function') unsubscribe()
|
|
101
|
+
}
|
|
102
|
+
}, [ctx])
|
|
51
103
|
|
|
52
104
|
React.useEffect(() => {
|
|
53
105
|
let alive = true
|
|
@@ -58,7 +110,7 @@ window.__ModuleLoader__.load({
|
|
|
58
110
|
const body = await response.json()
|
|
59
111
|
if (!alive) return
|
|
60
112
|
if (!response.ok || body.error) {
|
|
61
|
-
setState({ phase: 'error', message: body.error || 'magpie
|
|
113
|
+
setState({ phase: 'error', message: body.error || 'magpie gateway unavailable' })
|
|
62
114
|
} else {
|
|
63
115
|
setState({ phase: 'ok', route: (body.routes || [])[0] || null, pending: body.pending || 0 })
|
|
64
116
|
}
|
|
@@ -74,25 +126,25 @@ window.__ModuleLoader__.load({
|
|
|
74
126
|
}
|
|
75
127
|
}, [nonce])
|
|
76
128
|
|
|
129
|
+
const t = DICT[lang] || DICT.zh
|
|
77
130
|
let dot = 'var(--dsw-alias-state-idle-primary)'
|
|
78
|
-
let text =
|
|
79
|
-
let title =
|
|
131
|
+
let text = `${t.label} · ${t.loading}`
|
|
132
|
+
let title = t.clickRefresh
|
|
80
133
|
if (state.phase === 'error') {
|
|
81
134
|
dot = 'var(--dsw-alias-state-error-primary)'
|
|
82
|
-
text =
|
|
135
|
+
text = `${t.label} · ${t.unreachable}`
|
|
83
136
|
title = state.message || text
|
|
84
137
|
} else if (state.phase === 'ok') {
|
|
85
138
|
const route = state.route
|
|
86
139
|
if (!route) {
|
|
87
|
-
text =
|
|
88
|
-
title = '点击刷新'
|
|
140
|
+
text = `${t.label} · ${t.none}`
|
|
89
141
|
} else {
|
|
90
142
|
dot = 'var(--dsw-alias-state-success-primary)'
|
|
91
143
|
const asked = route.asked ? `${route.asked} → ` : ''
|
|
92
144
|
const rule = route.rule ? ` [${route.rule}]` : ''
|
|
93
|
-
const pending = state.pending > 0 ? ` ·
|
|
94
|
-
text =
|
|
95
|
-
title =
|
|
145
|
+
const pending = state.pending > 0 ? ` · ${t.inFlightPrefix}${state.pending}${t.inFlightSuffix}` : ''
|
|
146
|
+
text = `${t.label} · ${timeOf(route.time)} ${asked}${route.real}${rule}${pending}`
|
|
147
|
+
title = `${t.sourcePrefix}${ROUTE}${t.sourceSuffix}`
|
|
96
148
|
}
|
|
97
149
|
}
|
|
98
150
|
|
|
@@ -100,7 +152,7 @@ window.__ModuleLoader__.load({
|
|
|
100
152
|
type: 'button',
|
|
101
153
|
style: baseStyle,
|
|
102
154
|
title,
|
|
103
|
-
'aria-label':
|
|
155
|
+
'aria-label': t.aria,
|
|
104
156
|
onClick: () => setNonce(value => value + 1),
|
|
105
157
|
},
|
|
106
158
|
h('span', {
|
|
@@ -116,13 +168,33 @@ window.__ModuleLoader__.load({
|
|
|
116
168
|
}
|
|
117
169
|
|
|
118
170
|
return {
|
|
119
|
-
inject: ['slots'],
|
|
171
|
+
inject: ['slots', 'locale'],
|
|
120
172
|
apply(ctx) {
|
|
173
|
+
ctx.effect(() => {
|
|
174
|
+
const disposers = []
|
|
175
|
+
for (const locale of Object.keys(DICT)) {
|
|
176
|
+
try {
|
|
177
|
+
disposers.push(ctx.locale.register(NS, locale, DICT[locale]))
|
|
178
|
+
} catch {
|
|
179
|
+
/* locale registration is best-effort */
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return () => {
|
|
183
|
+
for (const dispose of disposers) {
|
|
184
|
+
try {
|
|
185
|
+
dispose()
|
|
186
|
+
} catch {
|
|
187
|
+
/* ignore */
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}, 'dsh-magpie-route: dictionaries')
|
|
192
|
+
|
|
121
193
|
ctx.slots.inject('conversation.composer.dock', () => ctx.slots.register({
|
|
122
194
|
name: 'conversation.composer.dock',
|
|
123
195
|
id: 'magpie-route-dock',
|
|
124
196
|
order: 40,
|
|
125
|
-
}, MagpieRouteDock))
|
|
197
|
+
}, props => h(MagpieRouteDock, { ...props, ctx })))
|
|
126
198
|
},
|
|
127
199
|
}
|
|
128
200
|
},
|
package/cordis.patch.yml
CHANGED
package/docs/preview.png
ADDED
|
Binary file
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Magpie real route",
|
|
4
|
-
"description": "Show the real upstream model behind a magpie routing group directly below the composer. The dock line refreshes every 15 seconds and on click; it reads the package Host half's same-origin route /plugins/magpie-route/route, so the browser never calls the gateway directly. Read-only: it sends no model request and does not change routing; the magpie gateway must be running. In-flight requests without usage are counted but not reported as a route. The dock shows the latest settled request across DSH sessions because DSH does not send X-Magpie-Session.
|
|
4
|
+
"description": "Show the real upstream model behind a magpie routing group directly below the composer (the text follows the DSH UI language: \"magpie real route\" in English, \"magpie 真实路由\" in Chinese). The dock line refreshes every 15 seconds and on click; it reads the package Host half's same-origin route /plugins/magpie-route/route, so the browser never calls the gateway directly. Read-only: it sends no model request and does not change routing; the magpie gateway must be running. In-flight requests without usage are counted but not reported as a route. The dock shows the latest settled request across DSH sessions because DSH does not send X-Magpie-Session. No configuration is required: it uses the default gateway http://127.0.0.1:3425; only if your gateway runs elsewhere, override baseURL in cordis.patch.yml. This plugin adds no command and no agent tool."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Magpie 真实路由",
|
|
4
|
-
"description": "把 magpie
|
|
4
|
+
"description": "把 magpie 路由组别名背后的真实上游模型直接显示在输入框下方(文本跟随 DSH 界面语言:中文“magpie 真实路由”,英文“magpie real route”)。界面行每 15 秒自动刷新、点击刷新,读取 Host 半的同源路由 /plugins/magpie-route/route(浏览器无需直连网关)。只读,不发模型请求、不改路由;需要 magpie 网关正在运行,进行中且尚无 usage 的请求只计数、不显示为结论。DSH 不发送 X-Magpie-Session,界面行显示所有 DSH 会话中最近完成的一条。默认无需配置,自动连接 http://127.0.0.1:3425;仅当网关不在默认地址时,才需要在 cordis.patch.yml 中覆盖 baseURL。本插件不提供命令,也不提供 agent 工具。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-magpie-route",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "DeepSeek Harness plugin: show the real upstream model behind a magpie routing group directly below the composer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"route-query.js",
|
|
44
44
|
"cordis.patch.yml",
|
|
45
45
|
"locale/*.json",
|
|
46
|
+
"docs",
|
|
46
47
|
"icon.svg",
|
|
47
48
|
"README.md",
|
|
48
49
|
"README.zh.md",
|