dsh-magpie-route 1.0.1 → 1.3.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 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 trace and shows the real result.
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,15 +13,16 @@ 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 settled route; red dot = the gateway is unreachable (click to retry); grey dot = no settled request yet. Hover for the data source.
18
- - Read-only: it sends no model request, changes no routing, and injects no headers.
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
22
23
 
23
24
  - DeepSeek Harness with the composer dock slot (0.2.x).
24
- - A running [magpie](https://usemagpie.ai) gateway on the default `http://127.0.0.1:3425`.
25
+ - A running [magpie](https://usemagpie.ai) gateway. The plugin follows the endpoint DSH already uses for the `magpie` provider, so it tracks whatever host/port your DSH profile configures (default `http://127.0.0.1:3425`).
25
26
 
26
27
  ## Install
27
28
 
@@ -31,20 +32,23 @@ For a local checkout instead, install the bundle directory with `plugin_manager`
31
32
 
32
33
  ## Configuration
33
34
 
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`.
35
+ No configuration is required. The Host half discovers the gateway from DSH itself: every magpie inference reports its resolved endpoint through `llm-pi-ai/request-headers`, and before the first inference it reads `llm-pi-ai`'s `providers.magpie.baseURL` (then `magpie-anthropic`, then `http://127.0.0.1:3425`). An explicit `baseURL` in the plugin row's `config` wins, so you only set it to point at an address DSH does not know about.
35
36
 
36
37
  ## How it works
37
38
 
38
- - The Host half reads `GET {baseURL}/v1/magpie/trace` (real `provider/model` and rule per settled request) and serves it on the package's same-origin route `/plugins/magpie-route/route`.
39
- - The client half renders the composer-dock line by polling that same-origin route, because the magpie gateway sends no CORS headers.
39
+ - The Host half derives the gateway root from the `baseURL` that DSH reports for each magpie inference through the `llm-pi-ai/request-headers` waterfall (no config-file parsing), contributes `X-Magpie-Session: <dsh session id>` (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
+ - Before the first inference it reads `llm-pi-ai`'s configured `providers.magpie.baseURL` from the live Loader config (falling back to `http://127.0.0.1:3425`), so the first paint already uses the right port.
41
+ - `GET {baseURL}/v1/magpie/trace` is the fallback for the first paint, before any inference has happened in this Host process.
42
+ - 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. The route checks DSH's `connection.requestRejection` (Host/Origin trust and browser authentication) before serving data, in addition to rejecting a mismatched `Origin` header.
40
43
 
41
44
  ## Limitations
42
45
 
43
- - Shows the **most recent settled** request, not the request currently in flight: a request still running has no `usage`, so its final route is not known yet. When the dock says "另有 N 条进行中", those are in-flight requests that are counted but not reported.
44
- - The dock line is the latest settled `dsh` request **across all DSH sessions**, because DSH does not send `X-Magpie-Session` and the gateway cannot tie a route to a DSH session.
46
+ - 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.
47
+ - 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
48
  - `trace` keeps a recent window (about 60 rows), not full history. For full history use `magpie usage --csv`.
46
49
  - `trace` reports `provider/model`; the final `served_model` (for example `hy4-free`) appears in `magpie usage --csv`.
47
50
  - Routing groups use session affinity and rules, so the "current real model" can change per turn.
51
+ - The gateway address mirrors whatever DSH has configured for the `magpie` provider. If that DSH value is stale (for example after moving magpie without reconnecting it), the dock shows the same stale endpoint; set `config.baseURL` to correct it.
48
52
 
49
53
  ## Uninstall
50
54
 
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 网关决定,而且可能逐轮变化。本插件读取网关自己的 trace,把真实结果显示出来。
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,15 +13,16 @@ 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
  ## 要求
22
23
 
23
24
  - 带 composer dock slot 的 DeepSeek Harness(0.2.x)。
24
- - 正在运行的 [magpie](https://usemagpie.ai) 网关,默认地址 `http://127.0.0.1:3425`。
25
+ - 正在运行的 [magpie](https://usemagpie.ai) 网关。插件会跟随 DSH 里 `magpie` provider 已经使用的地址,所以 DSH profile 配的是哪个主机/端口就跟哪个(默认 `http://127.0.0.1:3425`)。
25
26
 
26
27
  ## 安装
27
28
 
@@ -31,20 +32,23 @@ DSH 的模型选择器只知道你配置的路由组别名(例如 `magpie/grou
31
32
 
32
33
  ## 配置
33
34
 
34
- 默认无需配置:插件自动连接本地网关 `http://127.0.0.1:3425`,并按 `dsh` agent 过滤。只有网关不在默认地址时,才需要在 profile 的 `cordis.patch.yml` 里覆盖 `baseURL`(以及可选的 `agent`/`limit`)。
35
+ 默认无需配置。Host 半从 DSH 自身取网关地址:每次 magpie 推理都会通过 `llm-pi-ai/request-headers` 报告解析后的 endpoint;首次绘制之前则读 `llm-pi-ai` 的 `providers.magpie.baseURL`(再退 `magpie-anthropic`,最后兜底 `http://127.0.0.1:3425`)。插件行 `config` 里显式设置的 `baseURL` 优先级最高,只有要指向 DSH 不知道的地址时才需要写。
35
36
 
36
37
  ## 工作原理
37
38
 
38
- - Host 半读取 `GET {baseURL}/v1/magpie/trace`(每条已完成请求的真实 `provider/model` 与规则),并挂在同源路由 `/plugins/magpie-route/route` 上。
39
- - Client 半轮询这个同源路由,渲染输入框下方那一行,因为 magpie 网关没有 CORS 头。
39
+ - Host 半从 DSH 为每次 magpie 推理报告的 `baseURL`(`llm-pi-ai/request-headers` waterfall)推导出网关根地址,不解析任何配置文件;同时加上 `X-Magpie-Session: <dsh session id>`(只加请求头,不改请求体、模型或工具集),然后读取 `GET {baseURL}/v1/magpie/route?session=<dsh session id>` 得到本会话当前/最近的路由。
40
+ - 首次推理之前,它从运行中的 Loader 配置读取 `llm-pi-ai` 的 `providers.magpie.baseURL`(兜底 `http://127.0.0.1:3425`),所以首帧就用对端口。
41
+ - `GET {baseURL}/v1/magpie/trace` 只作为首次绘制的兜底(Host 进程里还没有发生过推理时)。
42
+ - Client 半轮询本包 Host 的同源路由 `/plugins/magpie-route/route`,渲染输入框下方那一行,因为 magpie 网关没有 CORS 头。路由入口先检查 DSH 的 `connection.requestRejection`(Host/Origin 信任与浏览器认证),并额外拒绝 `Origin` 不匹配的请求。
40
43
 
41
44
  ## 限制
42
45
 
43
- - 显示的是**最近一次已完成**的请求,不是正在进行中的请求:进行中的请求还没有 `usage`,最终落点还未知。界面显示“另有 N 条进行中”时,那 N 条就是进行中、只计数、不当作结论。
44
- - 界面行显示的是**所有 DSH 会话中最近完成的一条** `dsh` 请求,因为 DSH 不发送 `X-Magpie-Session`,网关无法把路由关联到 DSH 会话。
46
+ - 显示的是**本会话当前/最近**的路由。进行中的请求显示已选定目标并标注“进行中”;最终 served model 仍要等 magpie 完成才能确认。首次绘制(还没发生推理)会退回全局最近一条已完成的 `dsh` trace。
47
+ - Host 半记住最近一次发起 magpie 请求的 DSH 会话。如果你切到一个还没发过请求的新会话,dock 可能仍显示上一个会话的路由,直到新会话真正发起请求。
45
48
  - `trace` 只保留最近窗口(约 60 条),不是完整历史;完整历史用 `magpie usage --csv`。
46
49
  - `trace` 显示 `provider/model`;最终 `served_model`(如 `hy4-free`)只在 `magpie usage --csv` 里出现。
47
50
  - 路由组有会话亲和与规则路由,“当前真实模型”可能逐轮变化。
51
+ - 网关地址跟 DSH 给 `magpie` provider 配的值一致。如果 DSH 里那个值本身过期了(比如 magpie 换了端口但没重新接入),dock 会显示同一个过期地址;此时用 `config.baseURL` 覆盖即可。
48
52
 
49
53
  ## 卸载
50
54
 
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}?limit=1`, { headers: { accept: 'application/json' } })
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({ phase: 'ok', route: (body.routes || [])[0] || null, pending: body.pending || 0 })
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 ? ` · ${t.inFlightPrefix}${state.pending}${t.inFlightSuffix}` : ''
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
@@ -4,13 +4,11 @@ import { collectRoutes, describeError } from './route-query.js'
4
4
  export const name = 'magpie-route'
5
5
 
6
6
  /** Only the same-origin route remains: the plugin has no command and no agent tool. */
7
- export const inject = ['webServer']
7
+ export const inject = ['webServer', 'connection']
8
8
 
9
- const DEFAULTS = {
10
- baseURL: 'http://127.0.0.1:3425',
11
- agent: 'dsh',
12
- limit: 5,
13
- }
9
+ /** Last resort only. The real endpoint comes from the DSH profile's magpie provider. */
10
+ const FALLBACK_BASE_URL = 'http://127.0.0.1:3425'
11
+ const DEFAULT_AGENT = 'dsh'
14
12
 
15
13
  /** Same-origin endpoint for the composer dock; browsers cannot call the gateway directly (no CORS). */
16
14
  const CLIENT_ROUTE = '/plugins/magpie-route/route'
@@ -22,30 +20,160 @@ function jsonResponse(value, status = 200) {
22
20
  })
23
21
  }
24
22
 
23
+ /** Both the OpenAI-compatible and Anthropic routes go through the same magpie gateway. */
24
+ function isMagpieProvider(provider) {
25
+ return typeof provider === 'string' && /^magpie(?:-|$)/u.test(provider)
26
+ }
27
+
28
+ /**
29
+ * Reduce a pi-ai provider endpoint to the magpie gateway root, where the
30
+ * `/v1/magpie/*` read endpoints live.
31
+ *
32
+ * `http://127.0.0.1:3425/v1` -> `http://127.0.0.1:3425`
33
+ * `https://host/prefix/v1` -> `https://host/prefix`
34
+ * `http://127.0.0.1:3425` -> `http://127.0.0.1:3425`
35
+ */
36
+ function gatewayOriginOf(baseURL) {
37
+ if (typeof baseURL !== 'string' || baseURL.trim().length === 0) return undefined
38
+ try {
39
+ const url = new URL(baseURL.trim())
40
+ const path = url.pathname.replace(/\/v1\/?$/u, '').replace(/\/+$/u, '')
41
+ return `${url.origin}${path}`
42
+ } catch {
43
+ return undefined
44
+ }
45
+ }
46
+
47
+ /** Pull `providers.magpie.baseURL` out of a raw `llm-pi-ai` config object. */
48
+ function magpieBaseURLFromConfig(config) {
49
+ if (!config || typeof config !== 'object') return undefined
50
+ const providers = config.providers && typeof config.providers === 'object' ? config.providers : undefined
51
+ if (providers === undefined) return undefined
52
+ const route = providers.magpie ?? providers['magpie-anthropic']
53
+ return route && typeof route === 'object' && typeof route.baseURL === 'string'
54
+ ? route.baseURL
55
+ : undefined
56
+ }
57
+
58
+ /**
59
+ * Read the endpoint from the live Loader entry without touching the profile
60
+ * patch file. `fiber.effectiveConfig` is the config DSH actually activated.
61
+ */
62
+ function readFromLoader(ctx) {
63
+ try {
64
+ const loader = ctx.get('loader')
65
+ if (loader === undefined || typeof loader.entries !== 'function') return undefined
66
+ for (const entry of loader.entries()) {
67
+ if (entry?.options?.id !== 'llm-pi-ai') continue
68
+ const effective = entry.fiber?.effectiveConfig
69
+ if (!effective) continue
70
+ // `providers` is a volatile reference on the resolved Config.
71
+ const providers = effective.providers
72
+ const raw = providers && typeof providers.get === 'function' ? providers.get() : providers
73
+ const found = magpieBaseURLFromConfig({ providers: raw })
74
+ if (found !== undefined) return found
75
+ }
76
+ } catch {
77
+ /* fall through to configEditor */
78
+ }
79
+ return undefined
80
+ }
81
+
82
+ /**
83
+ * Compose the profile the same way the config editor does and read the
84
+ * `llm-pi-ai` row. Used for the first paint, before any inference has run.
85
+ */
86
+ function readFromConfigEditor(ctx) {
87
+ try {
88
+ const editor = ctx.get('configEditor')
89
+ if (editor === undefined || typeof editor.configuration !== 'function') return undefined
90
+ const row = editor.configuration().find(candidate => candidate?.entry?.options?.id === 'llm-pi-ai')
91
+ if (row === undefined) return undefined
92
+ return magpieBaseURLFromConfig(row.override) ?? magpieBaseURLFromConfig(row.inherited)
93
+ } catch {
94
+ return undefined
95
+ }
96
+ }
97
+
25
98
  /**
26
- * Serve the same-origin read route that the client dock polls. The client half
27
- * renders the composer-dock line; this plugin intentionally adds no command and
28
- * no agent tool.
99
+ * Serve the same-origin read route that the client dock polls.
100
+ *
101
+ * The gateway address is discovered from DSH instead of being configured here:
102
+ * every magpie inference reports its resolved endpoint through the
103
+ * `llm-pi-ai/request-headers` waterfall, and before the first inference the
104
+ * plugin reads the `llm-pi-ai` row's `providers.magpie.baseURL`. An explicit
105
+ * `config.baseURL` still wins, and `http://127.0.0.1:3425` is the last resort.
106
+ *
107
+ * The Host half also tags every magpie inference with `X-Magpie-Session`, so
108
+ * the gateway can answer `/v1/magpie/route?session=...` for *this* DSH session
109
+ * (including an in-flight request's already-picked target). The trace endpoint
110
+ * remains the fallback for the first paint and for profiles where no inference
111
+ * has happened yet. The plugin adds no command and no agent tool.
29
112
  */
30
113
  export function apply(ctx, config = {}) {
31
- const settings = { ...DEFAULTS, ...(config && typeof config === 'object' ? config : {}) }
114
+ const raw = config && typeof config === 'object' ? config : {}
115
+ const configuredBaseURL = typeof raw.baseURL === 'string' && raw.baseURL.trim().length > 0
116
+ ? (gatewayOriginOf(raw.baseURL) ?? raw.baseURL.trim())
117
+ : undefined
118
+ const settings = {
119
+ agent: typeof raw.agent === 'string' && raw.agent.trim().length > 0 ? raw.agent.trim() : DEFAULT_AGENT,
120
+ limit: raw.limit,
121
+ }
122
+
123
+ const connection = ctx.connection
124
+ let lastSession
125
+ let eventBaseURL
126
+ let storedBaseURL
127
+
128
+ /** First-paint lookup from DSH config; cached once a value is found. */
129
+ const profileBaseURL = () => {
130
+ if (storedBaseURL !== undefined) return storedBaseURL
131
+ const found = readFromLoader(ctx) ?? readFromConfigEditor(ctx)
132
+ storedBaseURL = gatewayOriginOf(found)
133
+ return storedBaseURL
134
+ }
135
+
136
+ const currentBaseURL = () => configuredBaseURL ?? eventBaseURL ?? profileBaseURL() ?? FALLBACK_BASE_URL
137
+
138
+ // Only a transport header is added; the request body, model, and tool set are untouched.
139
+ ctx.effect(() => ctx.on('llm-pi-ai/request-headers', (request, headers, next) => {
140
+ if (isMagpieProvider(request.provider)) {
141
+ const gateway = gatewayOriginOf(request.baseURL)
142
+ if (gateway !== undefined) eventBaseURL = gateway
143
+ if (typeof request.sessionId === 'string' && request.sessionId.length > 0) {
144
+ lastSession = request.sessionId
145
+ headers.set('x-magpie-session', request.sessionId)
146
+ }
147
+ }
148
+ return next()
149
+ }))
32
150
 
33
151
  ctx.effect(() => ctx.webServer.register({
34
152
  kind: 'exact',
35
153
  path: CLIENT_ROUTE,
36
154
  resource: async (request) => {
155
+ const rejection = connection.requestRejection(request)
156
+ if (rejection !== undefined) return new Response(null, { status: rejection })
157
+
37
158
  const url = new URL(request.url)
38
159
  const origin = request.headers.get('origin')
39
160
  if (origin !== null && origin !== url.origin) {
40
161
  return jsonResponse({ error: 'forbidden origin' }, 403)
41
162
  }
42
- const rawLimit = Number(url.searchParams.get('limit'))
43
- const limit = Number.isFinite(rawLimit) && rawLimit > 0 ? rawLimit : 1
163
+ const baseURL = currentBaseURL()
44
164
  try {
45
- const result = await collectRoutes({ ...settings, limit, signal: request.signal })
46
- return jsonResponse(result)
165
+ let result
166
+ if (lastSession) {
167
+ result = await collectRoutes({ ...settings, baseURL, session: lastSession, signal: request.signal })
168
+ if (result.kind === 'session-empty') {
169
+ result = await collectRoutes({ ...settings, baseURL, limit: 1, signal: request.signal })
170
+ }
171
+ } else {
172
+ result = await collectRoutes({ ...settings, baseURL, limit: 1, signal: request.signal })
173
+ }
174
+ return jsonResponse({ ...result, baseURL })
47
175
  } catch (error) {
48
- return jsonResponse({ error: describeError(error, settings.baseURL) }, 502)
176
+ return jsonResponse({ error: describeError(error, baseURL), baseURL }, 502)
49
177
  }
50
178
  },
51
179
  }))
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. 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."
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; the route checks DSH's connection.requestRejection (Host/Origin trust and browser authentication) and rejects a mismatched Origin. Read-only: it sends no model request and does not change routing; the magpie gateway must be running. No configuration is required: the Host half discovers the gateway from DSH's active magpie provider (each inference's request.baseURL, with llm-pi-ai's providers.magpie.baseURL for the first paint, and http://127.0.0.1:3425 as the last resort); only override config.baseURL when you need an address DSH does not know about. 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”)。界面行每 15 秒自动刷新、点击刷新,读取 Host 半的同源路由 /plugins/magpie-route/route(浏览器无需直连网关)。只读,不发模型请求、不改路由;需要 magpie 网关正在运行,进行中且尚无 usage 的请求只计数、不显示为结论。DSH 不发送 X-Magpie-Session,界面行显示所有 DSH 会话中最近完成的一条。默认无需配置,自动连接 http://127.0.0.1:3425;仅当网关不在默认地址时,才需要在 cordis.patch.yml 中覆盖 baseURL。本插件不提供命令,也不提供 agent 工具。"
4
+ "description": "把 magpie 路由组别名背后的真实上游模型直接显示在输入框下方(文本跟随 DSH 界面语言:中文“magpie 真实路由”,英文“magpie real route”)。Host 半给每次 magpie 推理加上 X-Magpie-Session,并读取 /v1/magpie/route 得到本会话当前/最近的路由(进行中请求显示已选定目标);trace 仅作为首次绘制兜底。界面行每 15 秒自动刷新、点击刷新,读取 Host 半的同源路由 /plugins/magpie-route/route(浏览器无需直连网关);路由入口先经过 DSH connection.requestRejection(Host/Origin 信任与浏览器认证)检查,并拒绝 Origin 不匹配的请求。只读,不发模型请求、不改路由;需要 magpie 网关正在运行。默认无需配置:Host 半会从 DSH 当前生效的 magpie provider 配置里自动取得网关地址——每次推理的 request.baseURL,首帧读 llm-pi-ai 的 providers.magpie.baseURL,最后才兜底 http://127.0.0.1:3425;只有要指向 DSH 之外的地址时才需在插件 config.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.1",
3
+ "version": "1.3.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
@@ -71,6 +71,7 @@ export async function collectRoutes(options = {}) {
71
71
  kind: 'session',
72
72
  source: url,
73
73
  session,
74
+ pending: route.done === false ? 1 : 0,
74
75
  routes: [{
75
76
  time: timeOf(route.time),
76
77
  asked: typeof route.asked === 'string' ? route.asked : '',
@@ -149,5 +150,5 @@ export function formatRoutes(result) {
149
150
 
150
151
  export function describeError(error, baseURL) {
151
152
  const reason = error instanceof Error ? error.message : String(error)
152
- return `查询 magpie 网关失败:${reason}\n请确认 magpie 正在运行并监听 ${normalizeBaseURL(baseURL)}(/v1/magpie/trace、/v1/magpie/route)。`
153
+ return `查询 magpie 网关失败:${reason}\n当前使用的网关地址是 ${normalizeBaseURL(baseURL)}(自动取自 DSH 里 llm-pi-ai 的 magpie baseURL);请确认 magpie 正在运行并监听该地址(/v1/magpie/trace、/v1/magpie/route)。如 DSH 里的地址与实际不符,可在插件 config.baseURL 里覆盖。`
153
154
  }
@@ -0,0 +1,3 @@
1
+ [
2
+ "docs/preview.png"
3
+ ]