dsh-magpie-route 1.0.1 → 1.1.0
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 +9 -7
- package/README.zh.md +9 -7
- package/client.js +14 -3
- package/index.js +28 -6
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -1
- package/route-query.js +1 -0
- package/screenshots.json +3 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
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.
|
|
6
6
|
|
|
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
|
|
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 route record and shows the real result.
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
● magpie real route · 13:32 magpie/group/daily → workbuddy/glm-5.3
|
|
@@ -13,9 +13,10 @@ DSH's model picker only knows the routing-group alias you configured (for exampl
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
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
|
+
- **Per DSH session** — the Host half tags each magpie inference with `X-Magpie-Session`, so the gateway can report this session's current/last route; an in-flight request shows its already-picked target with a "进行中 / in flight" marker.
|
|
16
17
|
- **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).
|
|
17
|
-
- Green dot = a
|
|
18
|
-
- Read-only: it sends no model request, changes no routing, and
|
|
18
|
+
- Green dot = a route; red dot = the gateway is unreachable (click to retry); grey dot = no route yet.
|
|
19
|
+
- Read-only: it sends no model request, changes no routing, and only adds one transport header.
|
|
19
20
|
- **No command and no agent tool** — this plugin only displays the route.
|
|
20
21
|
|
|
21
22
|
## Requirements
|
|
@@ -35,13 +36,14 @@ No configuration is required: the plugin talks to the default local gateway at `
|
|
|
35
36
|
|
|
36
37
|
## How it works
|
|
37
38
|
|
|
38
|
-
- The Host half
|
|
39
|
-
-
|
|
39
|
+
- The Host half contributes `X-Magpie-Session: <dsh session id>` through DSH's `llm-pi-ai/request-headers` waterfall (a header only; no request-body, model, or tool change), then reads `GET {baseURL}/v1/magpie/route?session=<dsh session id>` for this session's current/last route.
|
|
40
|
+
- `GET {baseURL}/v1/magpie/trace` is the fallback for the first paint, before any inference has happened in this Host process.
|
|
41
|
+
- The client half renders the composer-dock line by polling the package's same-origin route `/plugins/magpie-route/route`, because the magpie gateway sends no CORS headers.
|
|
40
42
|
|
|
41
43
|
## Limitations
|
|
42
44
|
|
|
43
|
-
- Shows
|
|
44
|
-
- The
|
|
45
|
+
- Shows **this session's current/last route**. An in-flight request shows its already-picked target with a "进行中 / in flight" marker; the final served model is still only confirmed after magpie finishes. On the first paint (before any inference), it falls back to the global latest settled `dsh` trace row.
|
|
46
|
+
- The Host half remembers the most recent DSH session that sent a magpie request. If you open another session that has not requested anything yet, the dock may still show the previous session's route until that new session runs.
|
|
45
47
|
- `trace` keeps a recent window (about 60 rows), not full history. For full history use `magpie usage --csv`.
|
|
46
48
|
- `trace` reports `provider/model`; the final `served_model` (for example `hy4-free`) appears in `magpie usage --csv`.
|
|
47
49
|
- Routing groups use session affinity and rules, so the "current real model" can change per turn.
|
package/README.zh.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness(`dsh`)插件:把 [magpie](https://usemagpie.ai) 路由组别名背后的**真实上游模型**直接显示在输入框下方。
|
|
6
6
|
|
|
7
|
-
DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/group/daily`);请求实际发往哪个上游 provider/model 由本地 magpie
|
|
7
|
+
DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/group/daily`);请求实际发往哪个上游 provider/model 由本地 magpie 网关决定,而且可能逐轮变化。本插件读取网关自己的路由记录,把真实结果显示出来。
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
● magpie 真实路由 · 13:32 magpie/group/daily → workbuddy/glm-5.3
|
|
@@ -13,9 +13,10 @@ DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/grou
|
|
|
13
13
|
## 功能
|
|
14
14
|
|
|
15
15
|
- **输入框下方常驻一行**:每 15 秒刷新,点击立即刷新;显示时间、请求别名、真实 `provider/model` 和命中的路由规则。
|
|
16
|
+
- **按 DSH 会话**:Host 半给每次 magpie 推理加上 `X-Magpie-Session`,网关就能返回本会话当前/最近的路由;进行中的请求会显示已选定的目标,并标注“进行中”。
|
|
16
17
|
- **跟随 DSH 界面语言**:中文界面显示“magpie 真实路由”,英文界面显示“magpie real route”,切换语言时会实时更新。
|
|
17
|
-
- 绿点 =
|
|
18
|
-
-
|
|
18
|
+
- 绿点 = 有路由结果;红点 = 网关不可用(点击重试);灰点 = 暂无路由;悬停显示数据源。
|
|
19
|
+
- 只读:不发模型请求、不改路由,只增加一个传输头。
|
|
19
20
|
- **不提供命令,也不提供 agent 工具**,插件只负责界面显示。
|
|
20
21
|
|
|
21
22
|
## 要求
|
|
@@ -35,13 +36,14 @@ DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/grou
|
|
|
35
36
|
|
|
36
37
|
## 工作原理
|
|
37
38
|
|
|
38
|
-
- Host
|
|
39
|
-
-
|
|
39
|
+
- Host 半通过 DSH 的 `llm-pi-ai/request-headers` waterfall 给每次 magpie 推理加上 `X-Magpie-Session: <dsh session id>`(只加请求头,不改请求体、模型或工具集),然后读取 `GET {baseURL}/v1/magpie/route?session=<dsh session id>` 得到本会话当前/最近的路由。
|
|
40
|
+
- `GET {baseURL}/v1/magpie/trace` 只作为首次绘制的兜底(Host 进程里还没有发生过推理时)。
|
|
41
|
+
- Client 半轮询本包 Host 的同源路由 `/plugins/magpie-route/route`,渲染输入框下方那一行,因为 magpie 网关没有 CORS 头。
|
|
40
42
|
|
|
41
43
|
## 限制
|
|
42
44
|
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
+
- 显示的是**本会话当前/最近**的路由。进行中的请求显示已选定目标并标注“进行中”;最终 served model 仍要等 magpie 完成才能确认。首次绘制(还没发生推理)会退回全局最近一条已完成的 `dsh` trace。
|
|
46
|
+
- Host 半记住最近一次发起 magpie 请求的 DSH 会话。如果你切到一个还没发过请求的新会话,dock 可能仍显示上一个会话的路由,直到新会话真正发起请求。
|
|
45
47
|
- `trace` 只保留最近窗口(约 60 条),不是完整历史;完整历史用 `magpie usage --csv`。
|
|
46
48
|
- `trace` 显示 `provider/model`;最终 `served_model`(如 `hy4-free`)只在 `magpie usage --csv` 里出现。
|
|
47
49
|
- 路由组有会话亲和与规则路由,“当前真实模型”可能逐轮变化。
|
package/client.js
CHANGED
|
@@ -23,6 +23,7 @@ window.__ModuleLoader__.load({
|
|
|
23
23
|
loading: '读取中…',
|
|
24
24
|
unreachable: '网关不可用(点击重试)',
|
|
25
25
|
none: '暂无已完成的请求',
|
|
26
|
+
inFlight: '进行中',
|
|
26
27
|
inFlightPrefix: '另有 ',
|
|
27
28
|
inFlightSuffix: ' 条进行中',
|
|
28
29
|
clickRefresh: '点击刷新',
|
|
@@ -35,6 +36,7 @@ window.__ModuleLoader__.load({
|
|
|
35
36
|
loading: 'loading…',
|
|
36
37
|
unreachable: 'gateway unreachable (click to retry)',
|
|
37
38
|
none: 'no settled request yet',
|
|
39
|
+
inFlight: 'in flight',
|
|
38
40
|
inFlightPrefix: '',
|
|
39
41
|
inFlightSuffix: ' in flight',
|
|
40
42
|
clickRefresh: 'click to refresh',
|
|
@@ -106,13 +108,18 @@ window.__ModuleLoader__.load({
|
|
|
106
108
|
let timer = null
|
|
107
109
|
const run = async () => {
|
|
108
110
|
try {
|
|
109
|
-
const response = await fetch(`${ROUTE}
|
|
111
|
+
const response = await fetch(`${ROUTE}`, { headers: { accept: 'application/json' } })
|
|
110
112
|
const body = await response.json()
|
|
111
113
|
if (!alive) return
|
|
112
114
|
if (!response.ok || body.error) {
|
|
113
115
|
setState({ phase: 'error', message: body.error || 'magpie gateway unavailable' })
|
|
114
116
|
} else {
|
|
115
|
-
setState({
|
|
117
|
+
setState({
|
|
118
|
+
phase: 'ok',
|
|
119
|
+
kind: body.kind || 'trace',
|
|
120
|
+
route: (body.routes || [])[0] || null,
|
|
121
|
+
pending: body.pending || 0,
|
|
122
|
+
})
|
|
116
123
|
}
|
|
117
124
|
} catch (error) {
|
|
118
125
|
if (alive) setState({ phase: 'error', message: String((error && error.message) || error) })
|
|
@@ -142,7 +149,11 @@ window.__ModuleLoader__.load({
|
|
|
142
149
|
dot = 'var(--dsw-alias-state-success-primary)'
|
|
143
150
|
const asked = route.asked ? `${route.asked} → ` : ''
|
|
144
151
|
const rule = route.rule ? ` [${route.rule}]` : ''
|
|
145
|
-
const pending = state.pending > 0
|
|
152
|
+
const pending = state.pending > 0
|
|
153
|
+
? (state.kind === 'session'
|
|
154
|
+
? ` · ${t.inFlight}`
|
|
155
|
+
: ` · ${t.inFlightPrefix}${state.pending}${t.inFlightSuffix}`)
|
|
156
|
+
: ''
|
|
146
157
|
text = `${t.label} · ${timeOf(route.time)} ${asked}${route.real}${rule}${pending}`
|
|
147
158
|
title = `${t.sourcePrefix}${ROUTE}${t.sourceSuffix}`
|
|
148
159
|
}
|
package/index.js
CHANGED
|
@@ -23,12 +23,28 @@ function jsonResponse(value, status = 200) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Serve the same-origin read route that the client dock polls.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Serve the same-origin read route that the client dock polls.
|
|
27
|
+
*
|
|
28
|
+
* The Host half also tags every magpie inference with `X-Magpie-Session`, so
|
|
29
|
+
* the gateway can answer `/v1/magpie/route?session=...` for *this* DSH session
|
|
30
|
+
* (including an in-flight request's already-picked target). The trace endpoint
|
|
31
|
+
* remains the fallback for the first paint and for profiles where no inference
|
|
32
|
+
* has happened yet. The plugin adds no command and no agent tool.
|
|
29
33
|
*/
|
|
30
34
|
export function apply(ctx, config = {}) {
|
|
31
35
|
const settings = { ...DEFAULTS, ...(config && typeof config === 'object' ? config : {}) }
|
|
36
|
+
let lastSession
|
|
37
|
+
|
|
38
|
+
// Only a transport header is added; the request body, model, and tool set are untouched.
|
|
39
|
+
ctx.effect(() => ctx.on('llm-pi-ai/request-headers', (request, headers, next) => {
|
|
40
|
+
if (request.provider === 'magpie'
|
|
41
|
+
&& typeof request.sessionId === 'string'
|
|
42
|
+
&& request.sessionId.length > 0) {
|
|
43
|
+
lastSession = request.sessionId
|
|
44
|
+
headers.set('x-magpie-session', request.sessionId)
|
|
45
|
+
}
|
|
46
|
+
return next()
|
|
47
|
+
}))
|
|
32
48
|
|
|
33
49
|
ctx.effect(() => ctx.webServer.register({
|
|
34
50
|
kind: 'exact',
|
|
@@ -39,10 +55,16 @@ export function apply(ctx, config = {}) {
|
|
|
39
55
|
if (origin !== null && origin !== url.origin) {
|
|
40
56
|
return jsonResponse({ error: 'forbidden origin' }, 403)
|
|
41
57
|
}
|
|
42
|
-
const rawLimit = Number(url.searchParams.get('limit'))
|
|
43
|
-
const limit = Number.isFinite(rawLimit) && rawLimit > 0 ? rawLimit : 1
|
|
44
58
|
try {
|
|
45
|
-
|
|
59
|
+
let result
|
|
60
|
+
if (lastSession) {
|
|
61
|
+
result = await collectRoutes({ ...settings, session: lastSession, signal: request.signal })
|
|
62
|
+
if (result.kind === 'session-empty') {
|
|
63
|
+
result = await collectRoutes({ ...settings, limit: 1, signal: request.signal })
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
result = await collectRoutes({ ...settings, limit: 1, signal: request.signal })
|
|
67
|
+
}
|
|
46
68
|
return jsonResponse(result)
|
|
47
69
|
} catch (error) {
|
|
48
70
|
return jsonResponse({ error: describeError(error, settings.baseURL) }, 502)
|
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 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.
|
|
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 Host half tags each magpie inference with X-Magpie-Session and reads /v1/magpie/route for this session's current/last route, including an in-flight request's already-picked target; trace is the first-paint fallback. 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. 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 路由组别名背后的真实上游模型直接显示在输入框下方(文本跟随 DSH 界面语言:中文“magpie 真实路由”,英文“magpie real route
|
|
4
|
+
"description": "把 magpie 路由组别名背后的真实上游模型直接显示在输入框下方(文本跟随 DSH 界面语言:中文“magpie 真实路由”,英文“magpie real route”)。Host 半给每次 magpie 推理加上 X-Magpie-Session,并读取 /v1/magpie/route 得到本会话当前/最近的路由(进行中请求显示已选定目标);trace 仅作为首次绘制兜底。界面行每 15 秒自动刷新、点击刷新,读取 Host 半的同源路由 /plugins/magpie-route/route(浏览器无需直连网关)。只读,不发模型请求、不改路由;需要 magpie 网关正在运行。默认无需配置,自动连接 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.1.0",
|
|
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",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"cordis.patch.yml",
|
|
45
45
|
"locale/*.json",
|
|
46
46
|
"docs",
|
|
47
|
+
"screenshots.json",
|
|
47
48
|
"icon.svg",
|
|
48
49
|
"README.md",
|
|
49
50
|
"README.zh.md",
|
package/route-query.js
CHANGED
package/screenshots.json
ADDED