dsh-project-mcp 0.2.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.
@@ -0,0 +1,570 @@
1
+ /**
2
+ * The `projectMcp.host` namespace: the wire contract for every message the
3
+ * plugin's host half produces that a human can read (F-48).
4
+ *
5
+ * Host messages travel as `{ code, params, message }` — a dotted, stable code
6
+ * plus its flat params for translation, and the English `message` always
7
+ * present as the fallback. The keys below are the contract: a code, once
8
+ * shipped, is never renamed, and rewording happens in dictionary values only.
9
+ * That is why this namespace is separate from `settings.projectMcp`, whose
10
+ * camelCase copy is reworded freely.
11
+ *
12
+ * The tables are declared `Record<HostCode, string>`, so the compiler reads
13
+ * every code of the union off each literal and a table that lacks one does not
14
+ * build — the same gate F-46 put on the UI namespace. The `en` values
15
+ * duplicate the emission-time English messages on purpose: intentional
16
+ * redundancy across a wire, not drift (the table serves the harness's own
17
+ * fallback chain, the payload's `message` field serves old clients and the
18
+ * resolver's last step). `tests/host-resolve.spec.ts` asserts the two are
19
+ * byte-identical where a test can see both.
20
+ *
21
+ * The `zh` and `ru` tables reuse the F-46 terminology of `./ui.ts`
22
+ * (deployment → 部署 / установка, document → 文档 / документ) and,
23
+ * like it, are maintainer-authored and pending review.
24
+ *
25
+ * @module src/client/locales/host
26
+ */
27
+
28
+ import type { TabLocale } from '../tab-locale.ts'
29
+ import type { Translate } from '../view.ts'
30
+
31
+ /** Locale namespace the host's coded messages are registered under. */
32
+ export const NS_HOST = 'projectMcp.host'
33
+
34
+ /**
35
+ * Every wire code the host half can emit. The union grows per task of F-48;
36
+ * the tables below are what force per-commit completeness. Each code carries a
37
+ * one-line comment naming the channel that emits it.
38
+ */
39
+ export type HostCode =
40
+ | 'write.blocked.notConfigured'
41
+ | 'write.blocked.notWritable'
42
+ | 'write.blocked.globalDisabled'
43
+ // The parse channel (Task 2): parseDocument's diagnostics, plus the runtime's
44
+ // multi-document merge warning — the code the client compares, never the prose.
45
+ | 'parse.json.invalid'
46
+ | 'parse.doc.notObject'
47
+ | 'parse.server.duplicateName'
48
+ | 'parse.server.badName'
49
+ | 'parse.server.renamedName'
50
+ | 'parse.server.multiDocument'
51
+ | 'parse.entry.notObject'
52
+ | 'parse.entry.badType'
53
+ | 'parse.entry.typeUnknown'
54
+ | 'parse.entry.noCommand'
55
+ | 'parse.entry.badArgs'
56
+ | 'parse.entry.badEnv'
57
+ | 'parse.entry.badCwd'
58
+ | 'parse.entry.noUrl'
59
+ | 'parse.entry.badHeaders'
60
+ | 'parse.ref.empty'
61
+ | 'parse.ref.inputUnset'
62
+ | 'parse.ref.varUnset'
63
+ | 'parse.ref.failedInKey'
64
+ // The lifecycle channel (Task 3): the five logLifecycle events, the two
65
+ // sharing phrases `mount.starting` nests two-level, the twelve unmount
66
+ // reasons `unmounting` nests, and the four idle row details.
67
+ | 'mount.starting'
68
+ | 'mount.sharingShared'
69
+ | 'mount.sharingForwarded'
70
+ | 'mount.failed'
71
+ | 'mount.failedDetail'
72
+ | 'mount.up'
73
+ | 'mount.stalled'
74
+ | 'mount.stalledDetail'
75
+ | 'unmounting'
76
+ | 'unmount.reason.operatorRetry'
77
+ | 'unmount.reason.unloading'
78
+ | 'unmount.reason.sessionGone'
79
+ | 'unmount.reason.sessionUnlisted'
80
+ | 'unmount.reason.sessionMoved'
81
+ | 'unmount.reason.sessionIdle'
82
+ | 'unmount.reason.operatorReleased'
83
+ | 'unmount.reason.profileShown'
84
+ | 'unmount.reason.undeclared'
85
+ | 'unmount.reason.nameChanged'
86
+ | 'unmount.reason.declarationChanged'
87
+ | 'unmount.reason.nothingMountable'
88
+ | 'idle.lazy'
89
+ | 'idle.disabled'
90
+ | 'idle.releasedInactive'
91
+ | 'idle.releasedRequest'
92
+ // The conflict channel (Task 4): the two shapes of the profile-conflict
93
+ // report, the duplicate-document report, the two readings of a shadowed
94
+ // row's detail, and the presentation owner's note.
95
+ | 'conflict.profile'
96
+ | 'conflict.profileAlias'
97
+ | 'conflict.documents'
98
+ | 'conflict.profileDetail'
99
+ | 'conflict.profileAliasDetail'
100
+ | 'present.ownerNote'
101
+ // The save channel (Task 5): every refusal of saveEntry and of the three
102
+ // policy writes (setPin/setPolicy/setConflictChoice). The five
103
+ // SaveErrorCodes stay the HTTP-status axis — these code the messages.
104
+ | 'save.noPolicyStore'
105
+ | 'save.noLiveSession'
106
+ | 'save.unknownMode'
107
+ | 'save.unknownChoice'
108
+ | 'save.serverNotDeclared'
109
+ | 'save.noDeclaringDocument'
110
+ | 'save.notWritable'
111
+ | 'save.needsConsent'
112
+ | 'save.globalDisabled'
113
+ | 'save.declaredElsewhere'
114
+ | 'save.documentGone'
115
+ | 'save.documentChanged'
116
+ | 'save.invalidJson'
117
+ | 'save.noMcpServers'
118
+ | 'save.noLongerDeclared'
119
+ | 'save.entryNotParsed'
120
+ | 'save.writeFailed'
121
+ // The trio applyEntry (src/write.ts) throws as WriteDocError and the save
122
+ // path reuses beside its `invalid` refusal.
123
+ | 'write.doc.invalidJson'
124
+ | 'write.doc.notObject'
125
+ | 'write.doc.noMcpServers'
126
+
127
+ /**
128
+ * English. Byte-identical to the literals `writeScopeFor` (`src/write.ts`)
129
+ * emits as `reason` — the harness's own fallback chain ends here, one step
130
+ * before the resolver falls back to the payload's `message`.
131
+ */
132
+ export const en: Record<HostCode, string> = {
133
+ // writeScopeFor: the document is none the deployment reads, and none is configured to write.
134
+ 'write.blocked.notConfigured':
135
+ '{document} is not a document this deployment reads, and it configures none to write',
136
+ // writeScopeFor: the document is not among the deployment's MCP documents; {writable} lists them.
137
+ 'write.blocked.notWritable':
138
+ "{document} is not one of this deployment's MCP documents; only {writable} can be written",
139
+ // writeScopeFor: a global-tier document with the deployment's allowGlobalWrite off.
140
+ 'write.blocked.globalDisabled':
141
+ 'writing the global tier is disabled by this deployment (allowGlobalWrite: false); {document} stays read-only here',
142
+ // parseDocument: the document's text is not JSON at all.
143
+ 'parse.json.invalid': 'invalid JSON: {error}',
144
+ // parseDocument: no `mcpServers`/`servers` map and not a flat server map either.
145
+ 'parse.doc.notObject': 'expected an object with an "mcpServers" object',
146
+ // parseDocument: two keys sanitize to one serverName inside one document.
147
+ 'parse.server.duplicateName': 'serverName "{name}" is declared twice in this document',
148
+ // sanitizeName: nothing of the key survives slugification.
149
+ 'parse.server.badName': '"{key}" cannot be converted into a valid serverName ({pattern})',
150
+ // sanitizeName: the key mounts under its slug instead.
151
+ 'parse.server.renamedName': 'serverName "{key}" is not a valid mcp-client name; using "{slug}"',
152
+ // The runtime's merge pass: a later document overrode this name's earlier declaration.
153
+ 'parse.server.multiDocument':
154
+ 'serverName "{name}" was declared in more than one document; the highest-priority definition wins',
155
+ // toEntry: the entry's value is not an object.
156
+ 'parse.entry.notObject': 'entry must be an object',
157
+ // toEntry: a `type`/`transport` that is not a string.
158
+ 'parse.entry.badType': '"type" must be a string',
159
+ // toEntry: a `type` outside the four known transports.
160
+ 'parse.entry.typeUnknown': '"type" must be one of "stdio", "http", "streamable-http" or "sse"',
161
+ // buildStdioEntry: no command to run.
162
+ 'parse.entry.noCommand': 'stdio servers require a "command"',
163
+ // buildStdioEntry: `args` present but not a string array.
164
+ 'parse.entry.badArgs': '"args" must be an array of strings',
165
+ // buildStdioEntry: `env` present but not a string map.
166
+ 'parse.entry.badEnv': '"env" must be an object of strings',
167
+ // buildStdioEntry: `cwd` present but not a string.
168
+ 'parse.entry.badCwd': '"cwd" must be a string',
169
+ // buildHttpEntry: no url to connect to.
170
+ 'parse.entry.noUrl': 'http servers require a "url"',
171
+ // buildHttpEntry: `headers` present but not a string map.
172
+ 'parse.entry.badHeaders': '"headers" must be an object of strings',
173
+ // resolveRef: `${input:}` with no name.
174
+ 'parse.ref.empty': 'empty ${input:} reference',
175
+ // resolveRef: an `${input:NAME}` no source answers.
176
+ 'parse.ref.inputUnset':
177
+ 'input "{key}" is not set (looked in plugin inputs, the project .env, the environment, and the credentials file)',
178
+ // resolveRef: a `${NAME}` no source answers.
179
+ 'parse.ref.varUnset':
180
+ 'variable "{name}" is not set (looked in the project .env, the environment, and the credentials file)',
181
+ // expandRecord: a reference failed inside an env/headers value; {name} is the inner message.
182
+ 'parse.ref.failedInKey': '{key}: {name}',
183
+ // mount(): a mount is registered. {sharing} is the two-level nesting of
184
+ // mount.sharingShared / mount.sharingForwarded, substituted from sharingCode.
185
+ 'mount.starting': 'mounting for session {sessionId} (trigger: {trigger}; {sharing})',
186
+ // mount(): the session shares the project's instance directly (parent-linked).
187
+ 'mount.sharingShared': 'one shared instance for every session of this project',
188
+ // mount(): the session's key could not be linked, so the bridge forwards.
189
+ 'mount.sharingForwarded':
190
+ "one shared instance for this project, forwarded into this session's own layer",
191
+ // recordMountFailure(): the activation or the registration threw.
192
+ 'mount.failed': 'mount failed — {error}',
193
+ // failureDetail(): one template, three lines — the name and the error, the
194
+ // endpoint, the declaring document.
195
+ 'mount.failedDetail': '{name}: mount failed — {error}\nendpoint: {endpoint}\ndeclared in: {source}',
196
+ // refreshStatuses(): the mount's tools became visible to the session.
197
+ 'mount.up': 'is up — tools visible to session {sessionId} after {elapsed}',
198
+ // refreshStatuses(): the connect watchdog fired.
199
+ 'mount.stalled': 'no tool appeared in {elapsed}',
200
+ // stallDetail(): the same three facts as mount.failedDetail, for a stall.
201
+ 'mount.stalledDetail': '{name}: no tool appeared in {elapsed}\nendpoint: {endpoint}\ndeclared in: {source}',
202
+ // logUnmount(): a mount is going away. {reason} is the two-level nesting of
203
+ // one of the unmount.reason.* codes, substituted from reasonCode.
204
+ 'unmounting': 'unmounting — {reason} (it ran for {ran})',
205
+ // retry(): the dropped error mount is being replaced by the operator pass.
206
+ 'unmount.reason.operatorRetry': 'an operator retry replaces it',
207
+ // disposeAll(): the whole runtime is going down.
208
+ 'unmount.reason.unloading': 'the plugin is unloading',
209
+ // agent scope event: the session's agent disappeared.
210
+ 'unmount.reason.sessionGone': 'the session went away',
211
+ // session sweep: the host registry dropped the session.
212
+ 'unmount.reason.sessionUnlisted': 'the registry no longer lists the session',
213
+ // syncAgent()/holdProject(): the session's cwd resolved to another root.
214
+ 'unmount.reason.sessionMoved': 'the session moved to another project',
215
+ // evictIdle(): the session was quiet past idleTimeoutMs.
216
+ 'unmount.reason.sessionIdle': 'the session went idle',
217
+ // release(): the operator asked for the release.
218
+ 'unmount.reason.operatorReleased': 'an operator released it',
219
+ // syncAgent(): a reserved name whose shadowing declaration disappeared.
220
+ 'unmount.reason.profileShown': 'this project shows the profile-level copy instead',
221
+ // syncAgent(): the documents stopped declaring the mounted name.
222
+ 'unmount.reason.undeclared': 'the documents no longer declare it',
223
+ // syncAgent(): the chosen local alias changed under a live mount.
224
+ 'unmount.reason.nameChanged': 'its local name changed',
225
+ // syncAgent(): the declaration's fingerprint changed under a live mount.
226
+ 'unmount.reason.declarationChanged': 'its declaration changed',
227
+ // syncAgent(): the declarations left mount nothing.
228
+ 'unmount.reason.nothingMountable': 'nothing it declares is mountable any more',
229
+ // syncAgent(): a declaration `lazy` has not mounted yet.
230
+ 'idle.lazy': 'not mounted yet — this session has not started a turn (lazy mounting is on)',
231
+ // syncAgent(): the entry declares `enabled: false`.
232
+ 'idle.disabled': 'declared with enabled: false',
233
+ // evictIdle() via releaseMounts(): the idle release's row detail.
234
+ 'idle.releasedInactive':
235
+ 'released after {seconds} without activity — {count} server(s) stopped; the next turn mounts them again',
236
+ // release() via releaseMounts(): the requested release's row detail.
237
+ 'idle.releasedRequest':
238
+ 'released on request — {count} server(s) stopped; the next turn mounts them again',
239
+ // conflictsFor(): a profile-level instance owns the name, and this project
240
+ // has no local alias to offer.
241
+ 'conflict.profile':
242
+ '"{name}" is owned by a profile-level mcp-client instance, so the project entry does not mount under it; remove the profile entry to use the project one everywhere, or let this project\'s copy take the name in this project\'s sessions alone.',
243
+ // conflictsFor(): the same, with the local alias the choice would mount under.
244
+ 'conflict.profileAlias':
245
+ '"{name}" is owned by a profile-level mcp-client instance; this project\'s copy mounts as "{alias}" when chosen beside it, or under the contested name when chosen to shadow it in this project\'s sessions, and does not mount at all while the profile\'s copy is the one shown.',
246
+ // conflictsFor(): one name declared by {count} documents; {winner} is the
247
+ // document the merge kept.
248
+ 'conflict.documents':
249
+ '"{name}" is declared in {count} documents; {winner} wins and the other declaration is not mounted.',
250
+ // conflictDetail(): the shadowed row's detail, no alias to offer.
251
+ 'conflict.profileDetail':
252
+ 'serverName "{name}" is already provided by a profile-level mcp-client instance — remove that entry from the profile to use the project one everywhere, or choose this project\'s copy to let it take the name in this project\'s sessions',
253
+ // conflictDetail(): the shadowed row's detail, with the local alias.
254
+ 'conflict.profileAliasDetail':
255
+ 'serverName "{name}" is already provided by a profile-level mcp-client instance — choose this project\'s copy to mount it as "{alias}", or under the contested name to shadow the profile instance here',
256
+ // presentationOwner(): why this plugin and a second owner cannot shape one
257
+ // request. No params — one fixed sentence.
258
+ 'present.ownerNote':
259
+ 'a second presentation owner rewrites assembly.tools after this plugin does, so the two never combine in one request: either this plugin shapes only its own mcp__* entries, or the other owner is unmounted.',
260
+ // setPin/setPolicy/setConflictChoice: the host was built without a policy store.
261
+ 'save.noPolicyStore': 'this host has no tool-policy store',
262
+ // setPin/setPolicy/setConflictChoice: the named project has no live session here.
263
+ 'save.noLiveSession': 'no live session in {projectRoot}',
264
+ // setPolicy: a mode no assembly knows; {mode} is the JSON-stringified value.
265
+ 'save.unknownMode': 'unknown tool mode {mode}',
266
+ // setConflictChoice: an answer no build knows; {choice} is the JSON-stringified value.
267
+ 'save.unknownChoice': 'unknown conflict choice {choice}',
268
+ // saveEntry: no live row of this project carries the name.
269
+ 'save.serverNotDeclared': 'server "{server}" is not declared for {projectRoot}',
270
+ // saveEntry: the row names no declaring document to write to.
271
+ 'save.noDeclaringDocument': 'server "{server}" has no declaring document to write',
272
+ // saveEntry: the defensive readonly fallback — writeScopeFor's own reason
273
+ // arrives coded (write.blocked.*) and is reused instead whenever it exists.
274
+ 'save.notWritable': '{document} is not writable',
275
+ // saveEntry: a global-tier write submitted without the explicit consent.
276
+ 'save.needsConsent': 'writing {document} needs explicit consent',
277
+ // saveEntry: a global-tier write with the deployment's allowGlobalWrite off.
278
+ 'save.globalDisabled': 'writing the global tier is disabled by this deployment (allowGlobalWrite: false)',
279
+ // saveEntry: the editor's document no longer declares the name.
280
+ 'save.declaredElsewhere': 'server "{server}" is now declared by {document}',
281
+ // saveEntry: the declaring document could not be read back at all.
282
+ 'save.documentGone': 'the declaring document {document} is gone',
283
+ // saveEntry: the document's revision moved past the one the editor read.
284
+ 'save.documentChanged': '{document} changed since the entry was read; reload it and edit again',
285
+ // saveEntry: the document read back is not JSON any more.
286
+ 'save.invalidJson': 'the declaring document is not valid JSON: {error}',
287
+ // saveEntry: the document holds no "mcpServers" object to rewrite.
288
+ 'save.noMcpServers': '{document} does not use an "mcpServers" object, so this editor cannot rewrite it',
289
+ // saveEntry: the document parses, but no key of it names the server.
290
+ 'save.noLongerDeclared': 'server "{server}" is no longer declared in {document}',
291
+ // saveEntry: the written-back entry failed the mount path's own parse. When
292
+ // the parse named its failure, that failure's own code (parse.*) is reused
293
+ // instead — this code names only the shapeless fallback.
294
+ 'save.entryNotParsed': 'the edited entry "{server}" did not parse',
295
+ // saveEntry: writeDocument threw (the backup, the temporary write or the rename).
296
+ 'save.writeFailed': 'writing {document} failed: {error}',
297
+ // applyEntry: the document text is not JSON at all.
298
+ 'write.doc.invalidJson': 'the document is not valid JSON: {error}',
299
+ // applyEntry: the document parses to something that is not an object.
300
+ 'write.doc.notObject': 'the document is not a JSON object',
301
+ // applyEntry: the document holds no "mcpServers" object.
302
+ 'write.doc.noMcpServers': 'the document has no "mcpServers" object',
303
+ }
304
+
305
+ /** Chinese, complete across the namespace: the `Record<HostCode, string>` annotation proves it. */
306
+ export const zh: Record<HostCode, string> = {
307
+ 'write.blocked.notConfigured': '{document} 不是此部署读取的文档,它也未配置任何可写入的文档',
308
+ 'write.blocked.notWritable': '{document} 不是此部署的 MCP 文档之一;只能写入 {writable}',
309
+ 'write.blocked.globalDisabled':
310
+ '此部署已禁用全局级的写入(allowGlobalWrite: false);{document} 在此处保持只读',
311
+ 'parse.json.invalid': '无效的 JSON:{error}',
312
+ 'parse.doc.notObject': '预期是一个带有 "mcpServers" 对象的对象',
313
+ 'parse.server.duplicateName': 'serverName "{name}" 在此文档中声明了两次',
314
+ 'parse.server.badName': '"{key}" 无法转换为有效的 serverName({pattern})',
315
+ 'parse.server.renamedName': 'serverName "{key}" 不是有效的 mcp-client 名称;改用 "{slug}"',
316
+ 'parse.server.multiDocument': 'serverName "{name}" 在不止一份文档中声明;优先级最高的定义生效',
317
+ 'parse.entry.notObject': '条目必须是对象',
318
+ 'parse.entry.badType': '"type" 必须是字符串',
319
+ 'parse.entry.typeUnknown': '"type" 必须是 "stdio"、"http"、"streamable-http" 或 "sse" 之一',
320
+ 'parse.entry.noCommand': 'stdio 服务器需要 "command"',
321
+ 'parse.entry.badArgs': '"args" 必须是字符串数组',
322
+ 'parse.entry.badEnv': '"env" 必须是字符串组成的对象',
323
+ 'parse.entry.badCwd': '"cwd" 必须是字符串',
324
+ 'parse.entry.noUrl': 'http 服务器需要 "url"',
325
+ 'parse.entry.badHeaders': '"headers" 必须是字符串组成的对象',
326
+ 'parse.ref.empty': '空的 ${input:} 引用',
327
+ 'parse.ref.inputUnset': '输入 "{key}" 未设置(已在插件 inputs、项目 .env、环境和凭据文件中查找)',
328
+ 'parse.ref.varUnset': '变量 "{name}" 未设置(已在项目 .env、环境和凭据文件中查找)',
329
+ 'parse.ref.failedInKey': '{key}:{name}',
330
+ 'mount.starting': '正在为会话 {sessionId} 挂载(触发方式:{trigger};{sharing})',
331
+ 'mount.sharingShared': '此项目的所有会话共享一个实例',
332
+ 'mount.sharingForwarded': '此项目共享一个实例,已转发进此会话自己的层',
333
+ 'mount.failed': '挂载失败 — {error}',
334
+ 'mount.failedDetail': '{name}:挂载失败 — {error}\n端点:{endpoint}\n声明于:{source}',
335
+ 'mount.up': '已就绪 — {elapsed} 后工具对会话 {sessionId} 可见',
336
+ 'mount.stalled': '{elapsed} 内没有出现任何工具',
337
+ 'mount.stalledDetail': '{name}:{elapsed} 内没有出现任何工具\n端点:{endpoint}\n声明于:{source}',
338
+ 'unmounting': '正在卸载 — {reason}(已运行 {ran})',
339
+ 'unmount.reason.operatorRetry': '操作员发起的重试将取代它',
340
+ 'unmount.reason.unloading': '插件正在退出',
341
+ 'unmount.reason.sessionGone': '会话已消失',
342
+ 'unmount.reason.sessionUnlisted': '注册表不再列出该会话',
343
+ 'unmount.reason.sessionMoved': '会话已移动到另一个项目',
344
+ 'unmount.reason.sessionIdle': '会话已空闲',
345
+ 'unmount.reason.operatorReleased': '操作员释放了它',
346
+ 'unmount.reason.profileShown': '此项目改为显示配置文件级的副本',
347
+ 'unmount.reason.undeclared': '文档不再声明它',
348
+ 'unmount.reason.nameChanged': '它的本地名称已更改',
349
+ 'unmount.reason.declarationChanged': '它的声明已更改',
350
+ 'unmount.reason.nothingMountable': '它声明的内容不再有可挂载的',
351
+ 'idle.lazy': '尚未挂载 — 此会话还没有开始任何一轮对话(惰性挂载已开启)',
352
+ 'idle.disabled': '以 enabled: false 声明',
353
+ 'idle.releasedInactive': '在 {seconds} 无活动后释放 — 已停止 {count} 个服务器;下一轮对话会重新挂载它们',
354
+ 'idle.releasedRequest': '已按请求释放 — 已停止 {count} 个服务器;下一轮对话会重新挂载它们',
355
+ 'conflict.profile':
356
+ '"{name}" 已由配置文件级的 mcp-client 实例占用,因此项目条目不会以该名称挂载;请从配置文件中移除该条目以在各处使用项目副本,或让此项目的副本仅在此项目的会话中使用该名称。',
357
+ 'conflict.profileAlias':
358
+ '"{name}" 已由配置文件级的 mcp-client 实例占用;选择并存时此项目的副本以 "{alias}" 挂载,选择遮蔽时则在此项目的会话中使用被争用的名称,而在显示配置文件副本期间完全不挂载。',
359
+ 'conflict.documents': '"{name}" 在 {count} 份文档中声明;{winner} 生效,另一份声明不会被挂载。',
360
+ 'conflict.profileDetail':
361
+ 'serverName "{name}" 已由配置文件级的 mcp-client 实例提供 — 从配置文件中移除该条目以在各处使用项目副本,或选择此项目的副本让它在此项目的会话中使用该名称',
362
+ 'conflict.profileAliasDetail':
363
+ 'serverName "{name}" 已由配置文件级的 mcp-client 实例提供 — 选择此项目的副本将其挂载为 "{alias}",或选择被争用的名称以在此处遮蔽配置文件实例',
364
+ 'present.ownerNote':
365
+ '第二个呈现所有者会在此插件之后重写 assembly.tools,因此两者永远不会在同一请求中合并:要么此插件只塑造自己的 mcp__* 条目,要么卸载另一个所有者。',
366
+ 'save.noPolicyStore': '此宿主没有工具策略存储',
367
+ 'save.noLiveSession': '{projectRoot} 中没有活跃会话',
368
+ 'save.unknownMode': '未知的工具模式 {mode}',
369
+ 'save.unknownChoice': '未知的冲突选择 {choice}',
370
+ 'save.serverNotDeclared': '服务器 "{server}" 未在 {projectRoot} 中声明',
371
+ 'save.noDeclaringDocument': '服务器 "{server}" 没有可写入的声明文档',
372
+ 'save.notWritable': '{document} 不可写入',
373
+ 'save.needsConsent': '写入 {document} 需要明确同意',
374
+ 'save.globalDisabled': '此部署已禁用全局级的写入(allowGlobalWrite: false)',
375
+ 'save.declaredElsewhere': '服务器 "{server}" 现在由 {document} 声明',
376
+ 'save.documentGone': '声明文档 {document} 已不存在',
377
+ 'save.documentChanged': '{document} 自读取条目后已更改;请重新加载后再编辑',
378
+ 'save.invalidJson': '声明文档不是有效的 JSON:{error}',
379
+ 'save.noMcpServers': '{document} 未使用 "mcpServers" 对象,因此此编辑器无法重写它',
380
+ 'save.noLongerDeclared': '服务器 "{server}" 不再在 {document} 中声明',
381
+ 'save.entryNotParsed': '编辑后的条目 "{server}" 无法解析',
382
+ 'save.writeFailed': '写入 {document} 失败:{error}',
383
+ 'write.doc.invalidJson': '文档不是有效的 JSON:{error}',
384
+ 'write.doc.notObject': '文档不是 JSON 对象',
385
+ 'write.doc.noMcpServers': '文档没有 "mcpServers" 对象',
386
+ }
387
+
388
+ /** Russian, complete across the namespace on the same annotation. */
389
+ export const ru: Record<HostCode, string> = {
390
+ 'write.blocked.notConfigured':
391
+ '{document} — не документ, который читает эта установка, и она не настраивает ни одного для записи',
392
+ 'write.blocked.notWritable':
393
+ '{document} не входит в MCP-документы этой установки; записать можно только {writable}',
394
+ 'write.blocked.globalDisabled':
395
+ 'запись в глобальный уровень отключена этой установкой (allowGlobalWrite: false); {document} остаётся здесь доступным только для чтения',
396
+ 'parse.json.invalid': 'недопустимый JSON: {error}',
397
+ 'parse.doc.notObject': 'ожидался объект с объектом "mcpServers"',
398
+ 'parse.server.duplicateName': 'serverName "{name}" объявлен в этом документе дважды',
399
+ 'parse.server.badName': '"{key}" невозможно преобразовать в допустимый serverName ({pattern})',
400
+ 'parse.server.renamedName':
401
+ 'serverName "{key}" не является допустимым именем mcp-client; используется "{slug}"',
402
+ 'parse.server.multiDocument':
403
+ 'serverName "{name}" объявлен более чем в одном документе; побеждает определение с наивысшим приоритетом',
404
+ 'parse.entry.notObject': 'запись должна быть объектом',
405
+ 'parse.entry.badType': '"type" должно быть строкой',
406
+ 'parse.entry.typeUnknown': '"type" должно быть одним из "stdio", "http", "streamable-http" или "sse"',
407
+ 'parse.entry.noCommand': 'stdio-серверы требуют "command"',
408
+ 'parse.entry.badArgs': '"args" должно быть массивом строк',
409
+ 'parse.entry.badEnv': '"env" должно быть объектом из строк',
410
+ 'parse.entry.badCwd': '"cwd" должно быть строкой',
411
+ 'parse.entry.noUrl': 'http-серверы требуют "url"',
412
+ 'parse.entry.badHeaders': '"headers" должно быть объектом из строк',
413
+ 'parse.ref.empty': 'пустая ссылка ${input:}',
414
+ 'parse.ref.inputUnset':
415
+ 'input "{key}" не задан (искали в inputs плагина, в .env проекта, в окружении и в файле учётных данных)',
416
+ 'parse.ref.varUnset':
417
+ 'переменная "{name}" не задана (искали в .env проекта, в окружении и в файле учётных данных)',
418
+ 'parse.ref.failedInKey': '{key}: {name}',
419
+ 'mount.starting': 'монтирование для сессии {sessionId} (триггер: {trigger}; {sharing})',
420
+ 'mount.sharingShared': 'один общий экземпляр для каждой сессии этого проекта',
421
+ 'mount.sharingForwarded':
422
+ 'один общий экземпляр на этот проект, проброшенный в собственный слой этой сессии',
423
+ 'mount.failed': 'монтирование не удалось — {error}',
424
+ 'mount.failedDetail':
425
+ '{name}: монтирование не удалось — {error}\nэндпоинт: {endpoint}\nобъявлено в: {source}',
426
+ 'mount.up': 'поднят — инструменты видны сессии {sessionId} спустя {elapsed}',
427
+ 'mount.stalled': 'за {elapsed} не появилось ни одного инструмента',
428
+ 'mount.stalledDetail':
429
+ '{name}: за {elapsed} не появилось ни одного инструмента\nэндпоинт: {endpoint}\nобъявлено в: {source}',
430
+ 'unmounting': 'снятие — {reason} (проработал {ran})',
431
+ 'unmount.reason.operatorRetry': 'его заменяет повторная попытка оператора',
432
+ 'unmount.reason.unloading': 'плагин выгружается',
433
+ 'unmount.reason.sessionGone': 'сессия исчезла',
434
+ 'unmount.reason.sessionUnlisted': 'реестр больше не содержит эту сессию',
435
+ 'unmount.reason.sessionMoved': 'сессия перешла в другой проект',
436
+ 'unmount.reason.sessionIdle': 'сессия простаивает',
437
+ 'unmount.reason.operatorReleased': 'оператор освободил его',
438
+ 'unmount.reason.profileShown': 'этот проект вместо него показывает копию уровня профиля',
439
+ 'unmount.reason.undeclared': 'документы больше не объявляют его',
440
+ 'unmount.reason.nameChanged': 'его локальное имя изменилось',
441
+ 'unmount.reason.declarationChanged': 'его объявление изменилось',
442
+ 'unmount.reason.nothingMountable': 'ничего из объявленного им больше нельзя смонтировать',
443
+ 'idle.lazy':
444
+ 'ещё не смонтирован — эта сессия ещё не начала ни одного шага (ленивое монтирование включено)',
445
+ 'idle.disabled': 'объявлен с enabled: false',
446
+ 'idle.releasedInactive':
447
+ 'освобождено после {seconds} без активности — остановлено серверов: {count}; следующий шаг смонтирует их снова',
448
+ 'idle.releasedRequest':
449
+ 'освобождено по запросу — остановлено серверов: {count}; следующий шаг смонтирует их снова',
450
+ 'conflict.profile':
451
+ '"{name}" принадлежит экземпляру mcp-client уровня профиля, поэтому запись проекта не монтируется под этим именем; удалите запись из профиля, чтобы использовать проектную везде, или позвольте копии этого проекта занять имя только в сессиях этого проекта.',
452
+ 'conflict.profileAlias':
453
+ '"{name}" принадлежит экземпляру mcp-client уровня профиля; копия этого проекта монтируется как "{alias}" при выборе рядом с ним или под спорным именем при выборе затенения в сессиях этого проекта и не монтируется вовсе, пока показана копия профиля.',
454
+ 'conflict.documents':
455
+ '"{name}" объявлен в документах: {count}; побеждает {winner}, а другое объявление не монтируется.',
456
+ 'conflict.profileDetail':
457
+ 'serverName "{name}" уже предоставлен экземпляром mcp-client уровня профиля — удалите эту запись из профиля, чтобы использовать проектную везде, или выберите копию этого проекта, чтобы она заняла имя в сессиях этого проекта',
458
+ 'conflict.profileAliasDetail':
459
+ 'serverName "{name}" уже предоставлен экземпляром mcp-client уровня профиля — выберите копию этого проекта, чтобы смонтировать её как "{alias}", или спорное имя, чтобы затенить экземпляр профиля здесь',
460
+ 'present.ownerNote':
461
+ 'второй владелец представления перезаписывает assembly.tools после этого плагина, поэтому оба никогда не объединяются в одном запросе: либо этот плагин формирует только свои записи mcp__*, либо другой владелец выгружается.',
462
+ 'save.noPolicyStore': 'у этого хоста нет хранилища политики инструментов',
463
+ 'save.noLiveSession': 'нет активной сессии в {projectRoot}',
464
+ 'save.unknownMode': 'неизвестный режим инструментов {mode}',
465
+ 'save.unknownChoice': 'неизвестный выбор конфликта {choice}',
466
+ 'save.serverNotDeclared': 'сервер "{server}" не объявлен для {projectRoot}',
467
+ 'save.noDeclaringDocument': 'у сервера "{server}" нет объявляющего документа для записи',
468
+ 'save.notWritable': '{document} недоступен для записи',
469
+ 'save.needsConsent': 'запись {document} требует явного согласия',
470
+ 'save.globalDisabled': 'запись в глобальный уровень отключена этой установкой (allowGlobalWrite: false)',
471
+ 'save.declaredElsewhere': 'сервер "{server}" теперь объявлен в {document}',
472
+ 'save.documentGone': 'объявляющий документ {document} исчез',
473
+ 'save.documentChanged': '{document} изменился с момента чтения записи; перезагрузите его и отредактируйте заново',
474
+ 'save.invalidJson': 'объявляющий документ не является допустимым JSON: {error}',
475
+ 'save.noMcpServers': '{document} не использует объект "mcpServers", поэтому этот редактор не может его переписать',
476
+ 'save.noLongerDeclared': 'сервер "{server}" больше не объявлен в {document}',
477
+ 'save.entryNotParsed': 'изменённая запись "{server}" не разобралась',
478
+ 'save.writeFailed': 'запись {document} не удалась: {error}',
479
+ 'write.doc.invalidJson': 'документ не является допустимым JSON: {error}',
480
+ 'write.doc.notObject': 'документ не является JSON-объектом',
481
+ 'write.doc.noMcpServers': 'в документе нет объекта "mcpServers"',
482
+ }
483
+
484
+ /**
485
+ * The translator of last resort: every code echoes, so {@link resolveHost}
486
+ * reads the harness's miss signal and falls back to the payload's `message`.
487
+ */
488
+ const echo: Translate = (key) => key
489
+
490
+ /**
491
+ * A translator bound to the host namespace — and nothing more.
492
+ *
493
+ * This is deliberately not `uiTranslate`'s shape: the UI seat falls back to
494
+ * the merged English table of its module, but this namespace has no merged
495
+ * English table — the per-message fallback is the design, and it lives in
496
+ * {@link resolveHost}, which detects the echo itself. Without a locale
497
+ * service, or when the service refuses the namespace, the seat echoes, which
498
+ * is exactly the miss signal the resolver reads.
499
+ * @param locale - the shell's locale service, when there is one.
500
+ * @returns a translate seat over `projectMcp.host`.
501
+ */
502
+ export function hostTranslate(locale: TabLocale | undefined): Translate {
503
+ if (locale === undefined) return echo
504
+ try {
505
+ return locale.bind(NS_HOST) as Translate
506
+ } catch {
507
+ // A service that refuses the namespace leaves the payload its own English.
508
+ return echo
509
+ }
510
+ }
511
+
512
+ /**
513
+ * Resolve one host payload to the sentence the screen shows.
514
+ *
515
+ * The chain: the bound namespace answers first (the harness's own fallback —
516
+ * active language, then this namespace's `en` table — rides inside it); a
517
+ * miss, which the harness signals by echoing the code, falls back to the
518
+ * payload's English `message`; a payload without a code renders its `message`
519
+ * directly, so an old host's prose shows exactly as it did before codes
520
+ * existed. The raw code survives only when the payload is malformed (no
521
+ * `message` either) — the documented last resort.
522
+ *
523
+ * Params are flat, with one two-level convention: a param whose name ends in
524
+ * `Code` is itself a wire code, resolved through `bound` first and substituted
525
+ * under the plain name (`reasonCode` → `reason`). A nested lookup that misses —
526
+ * the harness echoes the sub-code, which substituted would put a raw code on
527
+ * screen inside an otherwise translated sentence — fails the whole lookup:
528
+ * the payload's `message` answers instead.
529
+ * @param bound - the host-namespace seat from {@link hostTranslate}.
530
+ * @param code - the payload's wire code, when it carries one.
531
+ * @param params - the payload's flat params, when it carries any.
532
+ * @param message - the payload's English fallback text.
533
+ * @returns the sentence to render.
534
+ */
535
+ export function resolveHost(
536
+ bound: Translate,
537
+ code: string | undefined,
538
+ params: Record<string, string> | undefined,
539
+ message: string | undefined,
540
+ ): string {
541
+ if (code === undefined) return message ?? ''
542
+ const resolved = resolveParams(bound, params)
543
+ if (resolved.missed) return message ?? code
544
+ const text = bound(code, resolved.params)
545
+ return text === code ? (message ?? code) : text
546
+ }
547
+
548
+ /**
549
+ * The params a bound seat is called with: `*Code` values resolved two-level.
550
+ * `missed` is the nested miss signal: a sub-code the namespace does not know
551
+ * echoes, and an echo is never substituted into a sentence.
552
+ */
553
+ function resolveParams(
554
+ bound: Translate,
555
+ params: Record<string, string> | undefined,
556
+ ): { params: Record<string, string> | undefined; missed: boolean } {
557
+ if (params === undefined) return { params: undefined, missed: false }
558
+ const resolved: Record<string, string> = {}
559
+ let missed = false
560
+ for (const [name, value] of Object.entries(params)) {
561
+ if (name.endsWith('Code') && name.length > 'Code'.length) {
562
+ const nested = bound(value)
563
+ if (nested === value) missed = true
564
+ resolved[name.slice(0, -'Code'.length)] = nested
565
+ } else {
566
+ resolved[name] = value
567
+ }
568
+ }
569
+ return { params: resolved, missed }
570
+ }