dsh-project-mcp 0.2.0 → 0.3.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 +71 -25
- package/lib/client.d.ts +77 -0
- package/lib/client.js +10127 -0
- package/lib/client.js.map +1 -0
- package/lib/index.d.ts +3710 -0
- package/lib/index.js +7461 -0
- package/lib/index.js.map +1 -0
- package/package.json +14 -18
- package/src/activation.ts +6 -1
- package/src/client/design-fixtures.ts +96 -1
- package/src/client/design.ts +64 -51
- package/src/client/index.ts +74 -133
- package/src/client/locales/ui.ts +48 -14
- package/src/client/settings.ts +2 -2
- package/src/client/sidebar-tab.ts +521 -0
- package/src/client/view.ts +780 -80
- package/src/index.ts +18 -3
- package/src/runtime.ts +162 -1
- package/src/shared.ts +9 -3
- package/src/types.ts +65 -0
- package/src/ui.ts +61 -3
package/src/client/index.ts
CHANGED
|
@@ -1,55 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `dsh-project-mcp`, browser half: a DSH sidebar tab that shows which MCP
|
|
2
|
+
* `dsh-project-mcp`, browser half: a DSH right-sidebar tab that shows which MCP
|
|
3
3
|
* servers each project declares and what is currently mounted for its sessions,
|
|
4
|
-
* its own settings
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* its own settings popup in the tab chip's actions menu, a page in DSH's native
|
|
5
|
+
* Settings listing every project with a live session, and a frame-wide toast
|
|
6
|
+
* stack for the servers that come up, fail or are released.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* The tab is a type of DSH's own right sidebar (`./sidebar-tab.ts`, which mirrors
|
|
9
|
+
* the shipped contract structurally), and the popup is an entry of the frame-wide
|
|
10
|
+
* floating layer. The other three seats are the browser-shell slots
|
|
11
|
+
* `settings.section`, `plugins.bundle.config` and `shell.overlay`. Every seat
|
|
12
|
+
* exists in the browser half only. The host half publishes the same data over
|
|
13
|
+
* `/project-mcp/*` (see `src/ui.ts`), so this module never imports host code at
|
|
14
|
+
* runtime.
|
|
13
15
|
*
|
|
14
16
|
* @module dsh-project-mcp/client
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
|
-
import { createElement
|
|
19
|
+
import { createElement } from 'react'
|
|
18
20
|
import type { ReactNode } from 'react'
|
|
19
|
-
import type { BetterSidebarService, TabDescriptor } from 'dsh-better-sidebar'
|
|
20
21
|
import type { Context } from '@deepseek-ai/cordis'
|
|
21
|
-
import { PACKAGE_NAME
|
|
22
|
+
import { PACKAGE_NAME } from '../shared.ts'
|
|
22
23
|
import { designModeEnabled, registerDesignSurfaces } from './design.ts'
|
|
23
24
|
import { en, ru, zh } from './locales/ui.ts'
|
|
24
|
-
import { NS_HOST, en as hostEn, ru as hostRu, zh as hostZh
|
|
25
|
+
import { NS_HOST, en as hostEn, ru as hostRu, zh as hostZh } from './locales/host.ts'
|
|
25
26
|
import { registerPluginConfigCard } from './plugin-config.ts'
|
|
26
27
|
import type { PluginConfigSlotServices } from './plugin-config.ts'
|
|
27
28
|
import { NS, registerSettingsTab } from './settings.ts'
|
|
28
29
|
import type { SettingsSlotServices } from './settings.ts'
|
|
29
|
-
import { localeServiceOf
|
|
30
|
-
import
|
|
30
|
+
import { localeServiceOf } from './tab-locale.ts'
|
|
31
|
+
import { registerSidebarTab } from './sidebar-tab.ts'
|
|
32
|
+
import type { SidebarSettingsProps, SidebarTabBodyProps, SidebarTabServices } from './sidebar-tab.ts'
|
|
31
33
|
import { registerToasts } from './toasts.ts'
|
|
32
34
|
import type { ToastsServices } from './toasts.ts'
|
|
33
|
-
import {
|
|
34
|
-
ProjectMcpPanel,
|
|
35
|
-
ProjectMcpSettings,
|
|
36
|
-
REFRESH_KEY,
|
|
37
|
-
pluginSettingsOf,
|
|
38
|
-
refreshMsOf,
|
|
39
|
-
} from './view.ts'
|
|
35
|
+
import { ProjectMcpPanel, ProjectMcpSettings, createRefreshStore } from './view.ts'
|
|
40
36
|
|
|
41
37
|
/** Plugin name: matches the package name and the host half. */
|
|
42
38
|
export const name = PACKAGE_NAME
|
|
43
39
|
|
|
44
40
|
/**
|
|
45
|
-
* Register the
|
|
41
|
+
* Register the surfaces, each behind the services it actually needs.
|
|
46
42
|
*
|
|
47
|
-
* No module-level dependency is declared, because
|
|
48
|
-
* module-level `inject` would leave this entry **pending** for good in a
|
|
49
|
-
* composition without
|
|
43
|
+
* No module-level dependency is declared, because every one of them is optional:
|
|
44
|
+
* a module-level `inject` would leave this entry **pending** for good in a
|
|
45
|
+
* composition without the right sidebar, and DSH's web boot audit refuses to
|
|
50
46
|
* start while an entry is pending. `ctx.inject(name, …)` waits for the same
|
|
51
|
-
*
|
|
52
|
-
* the native Settings page and the toast stack.
|
|
47
|
+
* services without gating the entry, so a composition without the sidebar keeps
|
|
48
|
+
* the native Settings page, the config card and the toast stack.
|
|
53
49
|
*
|
|
54
50
|
* A service this fiber did not declare must never be read as a property: Cordis
|
|
55
51
|
* throws `cannot get property "…" without inject`, and that throw fails the
|
|
@@ -59,81 +55,46 @@ export const name = PACKAGE_NAME
|
|
|
59
55
|
export const inject: string[] = []
|
|
60
56
|
|
|
61
57
|
/**
|
|
62
|
-
* Register the browser half's surfaces.
|
|
63
|
-
* Cordis runs
|
|
64
|
-
* free of "already registered" failures.
|
|
58
|
+
* Register the browser half's surfaces. Every registration returns a disposer and
|
|
59
|
+
* Cordis runs them on fiber disposal, which is what keeps HMR and plugin
|
|
60
|
+
* disabling free of "already registered" failures.
|
|
65
61
|
* @param ctx - client root context.
|
|
66
62
|
*/
|
|
67
63
|
export function apply(ctx: Context): void {
|
|
68
|
-
// The design-only render mode: when the flag names a picture, the
|
|
64
|
+
// The design-only render mode: when the flag names a picture, the four
|
|
69
65
|
// surfaces below are registered from fixtures instead (`./design.ts`). It is a
|
|
70
|
-
// replacement, never an addition — two registrations of one tab id would
|
|
71
|
-
// over the same sidebar cell. The flag is a browser-local preference, so
|
|
72
|
-
// product and the fixture mode are one bundle apart, not one build apart.
|
|
66
|
+
// replacement, never an addition — two registrations of one tab type id would
|
|
67
|
+
// fight over the same sidebar cell. The flag is a browser-local preference, so
|
|
68
|
+
// the product and the fixture mode are one bundle apart, not one build apart.
|
|
73
69
|
if (designModeEnabled()) {
|
|
74
70
|
registerDesignSurfaces(ctx)
|
|
75
71
|
return
|
|
76
72
|
}
|
|
77
73
|
|
|
78
|
-
// The
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
// falls back to the merged English table
|
|
74
|
+
// The plugin's own translate seat: the slots below are registered without a
|
|
75
|
+
// locale namespace of their own, because the plugin registers its dictionaries
|
|
76
|
+
// itself and wants the tab to repaint on a language switch either way. The
|
|
77
|
+
// shell's locale service is read with `ctx.get` — this fiber does not declare
|
|
78
|
+
// it — and without one the seat falls back to the merged English table
|
|
79
|
+
// composed in ./locales/ui.ts.
|
|
83
80
|
const locale = localeServiceOf(ctx)
|
|
84
|
-
const t = tabTranslate(locale)
|
|
85
81
|
|
|
86
|
-
// The
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// Live copy, the closure shape: the sidebar's `SidebarSettingToggle`
|
|
103
|
-
// declares `title`/`desc` as `string | (() => string)` ("i18n
|
|
104
|
-
// friendly", service.ts), exactly like the descriptor's own title
|
|
105
|
-
// above, so the row re-reads the seat on every render and no
|
|
106
|
-
// re-registration is needed. (The alternative — strings resolved
|
|
107
|
-
// at registration plus a re-register on locale change — would
|
|
108
|
-
// leave the row frozen until then.)
|
|
109
|
-
title: () => t('refreshTitle'),
|
|
110
|
-
desc: () => t('refreshDesc'),
|
|
111
|
-
type: 'number',
|
|
112
|
-
min: 1_000,
|
|
113
|
-
max: 60_000,
|
|
114
|
-
unit: 'ms',
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
render: (props: Parameters<NonNullable<NonNullable<TabDescriptor['settings']>['render']>>[0]) =>
|
|
118
|
-
createElement(LocalizedSettings, {
|
|
119
|
-
pluginSettings: props.pluginSettings,
|
|
120
|
-
updatePluginSetting: props.updatePluginSetting,
|
|
121
|
-
onClose: props.close,
|
|
122
|
-
locale,
|
|
123
|
-
}),
|
|
124
|
-
},
|
|
125
|
-
// `LocalizedPanel` re-binds the seat when the shell's language changes:
|
|
126
|
-
// the descriptor's own title is read again by the sidebar on every render,
|
|
127
|
-
// and the panel below it subscribes to the same service.
|
|
128
|
-
component: (props: Parameters<TabDescriptor['component']>[0]) =>
|
|
129
|
-
createElement(LocalizedPanel, {
|
|
130
|
-
locale,
|
|
131
|
-
visible: props.visible,
|
|
132
|
-
sessionId: props.scope.sessionId,
|
|
133
|
-
refreshMs: refreshMsOf(pluginSettingsOf(betterSidebar.getSnapshot())),
|
|
134
|
-
}),
|
|
135
|
-
}),
|
|
136
|
-
)
|
|
82
|
+
// The panel's poll interval, shared by the tab it paces and the popup that
|
|
83
|
+
// changes it. One store for both, because the two are not in one tree.
|
|
84
|
+
const refresh = createRefreshStore()
|
|
85
|
+
|
|
86
|
+
// The sidebar tab, its chip's settings row and the settings popup itself:
|
|
87
|
+
// `./sidebar-tab.ts` holds the structural contract of DSH's own right sidebar
|
|
88
|
+
// and registers all four seats behind the services they need. `ctx.inject`
|
|
89
|
+
// parks this callback until the slot registry and the tab registry exist, so a
|
|
90
|
+
// composition without a right sidebar still boots everything below.
|
|
91
|
+
ctx.inject(['slots', 'sidebarRightTabs'], (scope) => {
|
|
92
|
+
registerSidebarTab(scope as unknown as SidebarTabServices, {
|
|
93
|
+
locale,
|
|
94
|
+
refresh,
|
|
95
|
+
body: LocalizedPanel,
|
|
96
|
+
settings: LocalizedSettings,
|
|
97
|
+
})
|
|
137
98
|
})
|
|
138
99
|
|
|
139
100
|
// The native Settings page. `ctx.inject` runs this callback only once both
|
|
@@ -196,60 +157,40 @@ export function apply(ctx: Context): void {
|
|
|
196
157
|
}
|
|
197
158
|
|
|
198
159
|
/**
|
|
199
|
-
* The sidebar panel
|
|
160
|
+
* The sidebar panel.
|
|
200
161
|
*
|
|
201
|
-
* `
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* @
|
|
162
|
+
* `./sidebar-tab.ts` already bound the two translate seats — the UI namespace and
|
|
163
|
+
* the host-message one — before calling this, so the adapter has nothing left to
|
|
164
|
+
* do but name the component and let React render it as an element rather than as
|
|
165
|
+
* a bare call.
|
|
166
|
+
* @param props - the body's props, seats included.
|
|
167
|
+
* @returns the panel element.
|
|
206
168
|
*/
|
|
207
|
-
export function LocalizedPanel(props: {
|
|
208
|
-
locale: TabLocale | undefined
|
|
209
|
-
visible: boolean
|
|
210
|
-
sessionId: string | undefined
|
|
211
|
-
refreshMs: number
|
|
212
|
-
}): ReactNode {
|
|
213
|
-
const t = useTabTranslate(props.locale)
|
|
214
|
-
// The host namespace beside the UI one: the Logs tab renders the host's
|
|
215
|
-
// coded events (F-48), and the seat follows the active language the same way
|
|
216
|
-
// `t` does — the repaint rides on `t`'s re-bind.
|
|
217
|
-
const hostT = hostTranslate(props.locale)
|
|
169
|
+
export function LocalizedPanel(props: SidebarTabBodyProps): ReactNode {
|
|
218
170
|
return createElement(ProjectMcpPanel, {
|
|
219
171
|
visible: props.visible,
|
|
220
172
|
sessionId: props.sessionId,
|
|
221
173
|
refreshMs: props.refreshMs,
|
|
222
|
-
t,
|
|
223
|
-
hostT,
|
|
174
|
+
t: props.t,
|
|
175
|
+
hostT: props.hostT,
|
|
224
176
|
})
|
|
225
177
|
}
|
|
226
178
|
|
|
227
179
|
/**
|
|
228
|
-
* The
|
|
180
|
+
* The settings popup's content, with the same two seats.
|
|
229
181
|
*
|
|
230
|
-
* The popup is
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* @
|
|
235
|
-
* @returns the popup element with its translator.
|
|
182
|
+
* The popup is an entry of the frame-wide floating layer, so its chrome has to
|
|
183
|
+
* repaint on a language switch exactly like the tab's: the seats are bound per
|
|
184
|
+
* render by `./sidebar-tab.ts`, and this adapter only names the component.
|
|
185
|
+
* @param props - the popup's props, seats included.
|
|
186
|
+
* @returns the settings panel element.
|
|
236
187
|
*/
|
|
237
|
-
export function LocalizedSettings(props: {
|
|
238
|
-
locale: TabLocale | undefined
|
|
239
|
-
pluginSettings: Record<string, unknown>
|
|
240
|
-
updatePluginSetting: (key: string, value: unknown) => void
|
|
241
|
-
onClose?: (() => void) | undefined
|
|
242
|
-
}): ReactNode {
|
|
243
|
-
const t = useTabTranslate(props.locale)
|
|
244
|
-
// The host namespace beside the UI one: the popup renders the host's coded
|
|
245
|
-
// payload fields (F-48), and the bound seat follows the active language the
|
|
246
|
-
// same way `t` does — the repaint still rides on `t`'s re-bind.
|
|
247
|
-
const hostT = hostTranslate(props.locale)
|
|
188
|
+
export function LocalizedSettings(props: SidebarSettingsProps): ReactNode {
|
|
248
189
|
return createElement(ProjectMcpSettings, {
|
|
249
|
-
|
|
250
|
-
|
|
190
|
+
refreshMs: props.refreshMs,
|
|
191
|
+
onRefreshMs: props.onRefreshMs,
|
|
251
192
|
onClose: props.onClose,
|
|
252
|
-
t,
|
|
253
|
-
hostT,
|
|
193
|
+
t: props.t,
|
|
194
|
+
hostT: props.hostT,
|
|
254
195
|
})
|
|
255
196
|
}
|
package/src/client/locales/ui.ts
CHANGED
|
@@ -138,13 +138,28 @@ export const zh: Record<UiKey, string> = {
|
|
|
138
138
|
idleDay: '闲置 {count} 天',
|
|
139
139
|
idleHour: '闲置 {count} 小时',
|
|
140
140
|
idleMinute: '闲置 {count} 分钟',
|
|
141
|
-
// One tool row's detail block:
|
|
141
|
+
// One tool row's detail block (F-56): the serving server with its state, the
|
|
142
|
+
// tier as a sentence, the two counter readings, then the host's own answer
|
|
143
|
+
// about the definition. The header keeps the name, the clock and the step, and the
|
|
144
|
+
// body prints them again in its fact line: that is what the contract's own probe reads
|
|
145
|
+
// out of the open disclosure (`contracts/surfaces.md` §1.5).
|
|
142
146
|
toolServer: '服务器 {server}',
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
toolServerState: '{server} · {state}',
|
|
148
|
+
toolTierPinned: '已置顶 — 始终在请求中',
|
|
149
|
+
toolTierSession: '由本次会话提供',
|
|
150
|
+
toolTierContext: '由上下文排序提供',
|
|
151
|
+
showTool: '显示此工具的服务器、说明、字段及其提供方式',
|
|
152
|
+
hideTool: '隐藏此工具的详细信息',
|
|
153
|
+
toolCallsSession: '本次会话 {count} 次',
|
|
154
|
+
toolLoading: '正在从宿主读取此定义…',
|
|
155
|
+
toolFailed: '宿主没有对此定义作答',
|
|
156
|
+
toolFieldsLabel: '接受',
|
|
157
|
+
toolFieldRequiredHint: '必填字段',
|
|
158
|
+
toolReasonBudget: '未提供:{chars} 字符,超出 {budget} 字符的预算',
|
|
159
|
+
toolReasonChars: '{chars} 字符',
|
|
160
|
+
toolReasonBudgetOnly: '{budget} 字符的预算',
|
|
161
|
+
toolReasonUsed: '已提供 {used}',
|
|
162
|
+
toolReason: '未提供',
|
|
148
163
|
// The errors and logs blocks, under their own disclosures: the event ring is
|
|
149
164
|
// the plugin's own, one project at a time.
|
|
150
165
|
errorsSection: '问题',
|
|
@@ -245,9 +260,11 @@ export const zh: Record<UiKey, string> = {
|
|
|
245
260
|
toastFailed: '{server} 失败',
|
|
246
261
|
toastReleased: '{server} 已释放',
|
|
247
262
|
toastDetail: '{project} · {detail}',
|
|
248
|
-
// The
|
|
263
|
+
// The poll interval's row in the tab's settings panel.
|
|
249
264
|
refreshTitle: '刷新间隔',
|
|
250
265
|
refreshDesc: '面板重新读取宿主快照的频率',
|
|
266
|
+
// The tab's actions menu: the row that opens the settings popup.
|
|
267
|
+
settingsMenuItem: '面板设置…',
|
|
251
268
|
// The design stand's own tab title and description.
|
|
252
269
|
designTitle: '项目 MCP · 设计 ({variant})',
|
|
253
270
|
designDesc: '设计模式:{variant} 夹具,背后没有宿主',
|
|
@@ -546,13 +563,28 @@ export const ru: Record<UiKey, string> = {
|
|
|
546
563
|
idleDay: 'простой {count}д',
|
|
547
564
|
idleHour: 'простой {count}ч',
|
|
548
565
|
idleMinute: 'простой {count}мин',
|
|
549
|
-
// One tool row's detail block:
|
|
566
|
+
// One tool row's detail block (F-56): the serving server with its state, the
|
|
567
|
+
// tier as a sentence, the two counter readings, then the host's own answer
|
|
568
|
+
// about the definition. The header keeps the name, the clock and the step, and the
|
|
569
|
+
// body prints them again in its fact line: that is what the contract's own probe reads
|
|
570
|
+
// out of the open disclosure (`contracts/surfaces.md` §1.5).
|
|
550
571
|
toolServer: 'сервер {server}',
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
572
|
+
toolServerState: '{server} · {state}',
|
|
573
|
+
toolTierPinned: 'закреплён — всегда в запросе',
|
|
574
|
+
toolTierSession: 'предложен этой сессией',
|
|
575
|
+
toolTierContext: 'предложен ранжированием контекста',
|
|
576
|
+
showTool: 'показать сервер инструмента, описание, поля и способ предложения',
|
|
577
|
+
hideTool: 'скрыть подробности инструмента',
|
|
578
|
+
toolCallsSession: '{count} в этой сессии',
|
|
579
|
+
toolLoading: 'читаем это определение у хоста…',
|
|
580
|
+
toolFailed: 'хост не ответил на это определение',
|
|
581
|
+
toolFieldsLabel: 'принимает',
|
|
582
|
+
toolFieldRequiredHint: 'обязательное поле',
|
|
583
|
+
toolReasonBudget: 'не предложен: {chars} символов при бюджете {budget}',
|
|
584
|
+
toolReasonChars: '{chars} символов',
|
|
585
|
+
toolReasonBudgetOnly: 'бюджет {budget} символов',
|
|
586
|
+
toolReasonUsed: 'уже предложено {used}',
|
|
587
|
+
toolReason: 'не предложен',
|
|
556
588
|
// The errors and logs blocks, under their own disclosures.
|
|
557
589
|
errorsSection: 'Проблемы',
|
|
558
590
|
showErrors: 'показать серверы, требующие внимания',
|
|
@@ -648,9 +680,11 @@ export const ru: Record<UiKey, string> = {
|
|
|
648
680
|
toastFailed: '{server}: сбой',
|
|
649
681
|
toastReleased: '{server} освобождён',
|
|
650
682
|
toastDetail: '{project} · {detail}',
|
|
651
|
-
// The
|
|
683
|
+
// The poll interval's row in the tab's settings panel.
|
|
652
684
|
refreshTitle: 'Интервал обновления',
|
|
653
685
|
refreshDesc: 'Как часто панель перечитывает снимок хоста',
|
|
686
|
+
// The tab's actions menu: the row that opens the settings popup.
|
|
687
|
+
settingsMenuItem: 'Настройки панели…',
|
|
654
688
|
// The design stand's own tab title and description.
|
|
655
689
|
designTitle: 'MCP проекта · дизайн ({variant})',
|
|
656
690
|
designDesc: 'режим дизайна: фикстура {variant}, хоста за ней нет',
|
package/src/client/settings.ts
CHANGED
|
@@ -373,7 +373,7 @@ export interface SettingsTabProps {
|
|
|
373
373
|
* The two client services the settings contribution needs. Both are optional in
|
|
374
374
|
* a composition, which is exactly why registration goes through `ctx.inject`
|
|
375
375
|
* rather than a module-level `inject` list: dropping either one must not take
|
|
376
|
-
* the
|
|
376
|
+
* the sidebar tab down with it.
|
|
377
377
|
*/
|
|
378
378
|
export interface SlotLocale {
|
|
379
379
|
register(namespace: string, dictionaries: Record<string, Record<string, string>>): () => void
|
|
@@ -406,7 +406,7 @@ export interface SlotSlots<Slot extends string = string> {
|
|
|
406
406
|
* The two client services a contribution needs. Both are optional in a
|
|
407
407
|
* composition, which is exactly why registration goes through `ctx.inject`
|
|
408
408
|
* rather than a module-level `inject` list: dropping either one must not take
|
|
409
|
-
* the
|
|
409
|
+
* the sidebar tab down with it.
|
|
410
410
|
*/
|
|
411
411
|
export interface SettingsSlotServices {
|
|
412
412
|
effect(execute: () => unknown, label?: string): unknown
|