@jayyuen66/dsh-zvec-grep 0.1.12 → 0.1.14

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/client.js CHANGED
@@ -8,7 +8,6 @@ window.__ModuleLoader__.load({
8
8
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
9
  let react = require("react");
10
10
  let zod = require("zod");
11
- let _jayyuen66_dsh_plugin_shared_client = require("@jayyuen66/dsh-plugin-shared/client");
12
11
  // lib/embedding-catalog.ts
13
12
  /** 默认模型:本地最强(1024 维 / 8192 上下文 / 中英通用),约 640MB 一次性下载。 */
14
13
  const DEFAULT_EMBEDDING = "local/qwen3-embedding-0.6b";
@@ -75,6 +74,598 @@ const LOCAL_EMBEDDINGS = Object.freeze([
75
74
  dimension: 768
76
75
  }
77
76
  ].map((entry) => Object.freeze(entry)));
77
+ const REMOTE_EMBEDDING_CATALOG = Object.freeze([
78
+ {
79
+ reference: "qwen/qwen3-vl-embedding",
80
+ dimension: 2560
81
+ },
82
+ {
83
+ reference: "qwen/qwen3.7-text-embedding",
84
+ dimension: 1024
85
+ },
86
+ {
87
+ reference: "qwen/text-embedding-v4",
88
+ dimension: 1024
89
+ }
90
+ ].map((entry) => Object.freeze(entry)));
91
+ // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-C1lrHILm.js
92
+ const c = `
93
+ .dsu-form{display:flex;flex-direction:column}
94
+ .dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
95
+ .dsu-form>.dsu-section:first-child{margin-top:0;padding-top:0;border-top:0}
96
+ .dsu-sectionTitle{margin:0;font-size:15px;font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary)}
97
+ .dsu-sectionHint{margin:4px 0 0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
98
+ .dsu-statusbar{display:flex;flex-wrap:wrap;gap:4px 8px;margin-top:8px;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
99
+ .dsu-field{display:grid;grid-template-columns:minmax(0,1fr) minmax(240px,360px);column-gap:32px;align-items:center;padding:12px 0;border-top:.5px solid var(--dsw-alias-border-l2)}
100
+ .dsu-fieldMeta{display:flex;flex-direction:column;gap:4px;min-width:0}
101
+ .dsu-labelRow{display:flex;align-items:center;gap:6px;min-width:0}
102
+ .dsu-label{font-size:13px;font-weight:500;line-height:1.5;color:var(--dsw-alias-label-primary)}
103
+ .dsu-labelMono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}
104
+ .dsu-hint{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
105
+ .dsu-control{min-width:0;display:flex;align-items:center;gap:8px}
106
+ .dsu-fieldWide{grid-template-columns:minmax(0,1fr);align-items:start}
107
+ .dsu-fieldWide .dsu-control{width:100%;max-width:720px;margin-top:2px}
108
+ .dsu-help{display:inline-flex;align-items:center;gap:6px;min-width:0}
109
+ .dsu-helpBtn{appearance:none;border:0;background:transparent;padding:0;width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary);cursor:help;border-radius:50%;flex:none}
110
+ .dsu-help:hover .dsu-helpBtn,.dsu-helpBtn:focus-visible{color:var(--dsw-alias-label-primary)}
111
+ .dsu-helpBtn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
112
+ .dsu-tip{position:fixed;z-index:60;box-sizing:border-box;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere;padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);box-shadow:0 12px 32px rgb(0 0 0 / 45%);font-size:12px;line-height:1.6;font-weight:400;color:var(--dsw-alias-label-secondary)}
113
+ .dsu-input{width:100%;height:34px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px}
114
+ .dsu-input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
115
+ .dsu-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary)}
116
+ .dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
117
+ .dsu-input::placeholder{color:var(--dsw-alias-label-tertiary)}
118
+ .dsu-textarea{height:auto;min-height:96px;padding:8px 12px;line-height:1.6;resize:vertical}
119
+ .dsu-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
120
+ .dsu-numberWrap{display:flex;flex-direction:column;gap:4px;width:100%;min-width:0}
121
+ .dsu-number{display:flex;align-items:center;gap:8px;min-width:0}
122
+ .dsu-number .dsu-input{min-width:0}
123
+ .dsu-unit{flex:none;font-size:12px;color:var(--dsw-alias-label-tertiary)}
124
+ .dsu-error{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-state-error-primary)}
125
+ .dsu-switch{appearance:none;width:36px;height:20px;border-radius:999px;border:0;padding:2px;background:var(--dsw-alias-border-l3);display:flex;align-items:center;cursor:pointer;flex:none;transition:background-color .16s}
126
+ .dsu-knob{width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary);transition:transform .16s,background-color .16s}
127
+ .dsu-switch[aria-checked="true"]{background:var(--dsw-alias-label-primary)}
128
+ .dsu-switch[aria-checked="true"] .dsu-knob{transform:translateX(16px);background:var(--dsw-alias-label-primary-foreground)}
129
+ .dsu-switch:disabled{opacity:.4;cursor:not-allowed}
130
+ .dsu-switch:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}
131
+ .dsu-selectWrap{position:relative;width:100%;min-width:0}
132
+ .dsu-select{display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;cursor:pointer}
133
+ .dsu-select[aria-expanded="true"]{border-color:var(--dsw-alias-state-business-primary)}
134
+ .dsu-selectValue{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
135
+ .dsu-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s}
136
+ .dsu-select[aria-expanded="true"] .dsu-chevron{transform:rotate(180deg)}
137
+ .dsu-menu{position:fixed;z-index:70;padding:4px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);border-radius:12px;box-shadow:0 12px 32px rgb(0 0 0 / 50%);max-height:280px;overflow:auto}
138
+ .dsu-option{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.4;width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 10px;border-radius:8px;cursor:pointer;text-align:left}
139
+ .dsu-option:hover,.dsu-option[data-active="true"]{background:var(--dsw-alias-bg-layer-3)}
140
+ .dsu-option:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
141
+ .dsu-option:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
142
+ .dsu-optionGroup{padding:6px 10px 2px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary)}
143
+ .dsu-check{opacity:0;flex:none}
144
+ .dsu-option[aria-selected="true"] .dsu-check{opacity:1}
145
+ .dsu-savebar{display:flex;align-items:center;gap:8px;padding:12px 0;margin-top:24px;border-top:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base)}
146
+ .dsu-savebar[data-dirty="true"]{position:sticky;bottom:0;z-index:2;box-shadow:0 -12px 24px rgb(0 0 0 / 35%)}
147
+ .dsu-btn{appearance:none;border:.5px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.5;border-radius:var(--dsw-radius-md);padding:5px 14px;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s,filter .12s}
148
+ .dsu-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-border-l3)}
149
+ .dsu-btn:active:not(:disabled){background:var(--dsw-alias-bg-layer-1)}
150
+ .dsu-btn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
151
+ .dsu-btn:disabled{opacity:.4;cursor:not-allowed}
152
+ .dsu-btnPrimary{background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
153
+ .dsu-btnPrimary:hover:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.9)}
154
+ .dsu-btnPrimary:active:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.84)}
155
+ .dsu-btnDanger{color:var(--dsw-alias-state-error-primary)}
156
+ .dsu-btnDanger:hover:not(:disabled){color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary);background:var(--dsw-alias-bg-layer-2)}
157
+ .dsu-status{margin-left:auto;font-size:12px;color:var(--dsw-alias-label-tertiary)}
158
+ .dsu-statusError{color:var(--dsw-alias-state-error-primary)}
159
+ .dsu-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(200px,100%),1fr));gap:0 24px}
160
+ .dsu-grid>.dsu-field{display:flex;flex-direction:column;align-items:stretch;gap:6px;padding:10px 0;border-top:.5px solid var(--dsw-alias-border-l1)}
161
+ .dsu-grid>.dsu-field .dsu-control{width:100%}
162
+ @media (max-width:640px){
163
+ .dsu-field{grid-template-columns:minmax(0,1fr);align-items:start}
164
+ .dsu-control{width:100%;max-width:720px}
165
+ .dsu-section{margin-top:20px;padding-top:20px}
166
+ }
167
+ @media (prefers-reduced-motion:reduce){
168
+ .dsu-switch,.dsu-knob,.dsu-chevron,.dsu-btn{transition:none}
169
+ }
170
+ `;
171
+ function l(e, t = 30) {
172
+ return e.length <= t ? { hint: e } : { detail: e };
173
+ }
174
+ function u(t) {
175
+ return (0, react.createElement)(`div`, { className: `dsu-form` }, t.children);
176
+ }
177
+ function d(t) {
178
+ return (0, react.createElement)(`section`, { className: `dsu-section` }, (0, react.createElement)(`h2`, { className: `dsu-sectionTitle` }, t.title), t.hint === void 0 ? null : (0, react.createElement)(`p`, { className: `dsu-sectionHint` }, t.hint), t.children);
179
+ }
180
+ function m(a) {
181
+ let c = (0, react.useId)(), [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(!1), p = (0, react.useRef)(!1), m = (0, react.useRef)(!1), h = (0, react.useRef)(!1), g = (0, react.useRef)(null), _ = (0, react.useRef)(null), v = (0, react.useRef)(null), y = (0, react.useCallback)(() => {
182
+ v.current !== null && (clearTimeout(v.current), v.current = null);
183
+ }, []), b = (0, react.useCallback)(() => {
184
+ let e = g.current, t = _.current;
185
+ /* v8 ignore next 3 -- place 只在 open 的 layout effect 与挂载期监听器里调用;refs 为空只可能是卸载竞态 */
186
+ if (e === null || t === null) return;
187
+ let n = e.getBoundingClientRect(), r = t.offsetWidth, i = t.offsetHeight, { left: a } = n, o = n.bottom + 8;
188
+ o + i > window.innerHeight - 8 && (o = n.top - i - 8), a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
189
+ let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - i - 8);
190
+ t.style.left = `${Math.min(Math.max(8, a), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
191
+ }, []), x = (0, react.useCallback)(() => {
192
+ y(), h.current = !1, f(!1), u(!1);
193
+ }, [y]), S = (0, react.useCallback)(() => {
194
+ y(), u(!0);
195
+ }, [y]), C = (0, react.useCallback)(() => {
196
+ y(), p.current || m.current || h.current || (v.current = setTimeout(() => {
197
+ /* v8 ignore next 3 -- 任何重新进入/钉住都会 cancelHide;这次复查只防未来的异步路径 */
198
+ v.current = null, p.current || m.current || h.current || u(!1);
199
+ }, 120));
200
+ }, [y]), w = (0, react.useCallback)((e) => {
201
+ h.current = e, f(e);
202
+ }, []);
203
+ (0, react.useLayoutEffect)(() => {
204
+ if (!l) return () => {};
205
+ b();
206
+ let e = (e) => {
207
+ let { target: t } = e;
208
+ t instanceof Node && _.current?.contains(t) === !0 || (h.current ? b() : x());
209
+ }, t = () => {
210
+ b();
211
+ };
212
+ return window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
213
+ window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
214
+ };
215
+ }, [
216
+ l,
217
+ a.detail,
218
+ b,
219
+ x
220
+ ]), (0, react.useEffect)(() => {
221
+ if (!l) return () => {};
222
+ let e = (e) => {
223
+ e.key === `Escape` && x();
224
+ };
225
+ return document.addEventListener(`keydown`, e), () => {
226
+ document.removeEventListener(`keydown`, e);
227
+ };
228
+ }, [l, x]), (0, react.useEffect)(() => y, [y]);
229
+ let T = (0, react.createElement)(`button`, {
230
+ ref: g,
231
+ type: `button`,
232
+ className: `dsu-helpBtn`,
233
+ "aria-label": `${a.label} 说明`,
234
+ "aria-describedby": c,
235
+ "aria-pressed": d,
236
+ onClick: () => {
237
+ h.current ? x() : (w(!0), S());
238
+ }
239
+ }, (0, react.createElement)(`svg`, {
240
+ width: 12,
241
+ height: 12,
242
+ viewBox: `0 0 14 14`,
243
+ "aria-hidden": !0
244
+ }, (0, react.createElement)(`circle`, {
245
+ cx: 7,
246
+ cy: 7,
247
+ r: 6,
248
+ fill: `none`,
249
+ stroke: `currentColor`,
250
+ strokeWidth: 1.2
251
+ }), (0, react.createElement)(`path`, {
252
+ d: `M7 6.2v4`,
253
+ stroke: `currentColor`,
254
+ strokeWidth: 1.3,
255
+ strokeLinecap: `round`
256
+ }), (0, react.createElement)(`circle`, {
257
+ cx: 7,
258
+ cy: 4.3,
259
+ r: .8,
260
+ fill: `currentColor`
261
+ }))), E = (0, react.createElement)(`div`, {
262
+ ref: _,
263
+ id: c,
264
+ role: `tooltip`,
265
+ className: `dsu-tip`,
266
+ hidden: !l
267
+ }, a.detail), D = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
268
+ return (0, react.createElement)(`span`, {
269
+ className: `dsu-help`,
270
+ onMouseEnter: () => {
271
+ p.current = !0, S();
272
+ },
273
+ onMouseLeave: () => {
274
+ p.current = !1, C();
275
+ },
276
+ onFocus: () => {
277
+ m.current = !0, S();
278
+ },
279
+ onBlur: (e) => {
280
+ let t = e.relatedTarget;
281
+ t instanceof Node && e.currentTarget.contains(t) || (m.current = !1, C());
282
+ }
283
+ }, D, T, E);
284
+ }
285
+ function h(t) {
286
+ let n = `dsu-label${t.compact === !0 ? ` dsu-labelMono` : ``}`, r = t.controlId === void 0 ? (0, react.createElement)(`span`, { className: n }, t.label) : (0, react.createElement)(`label`, {
287
+ className: n,
288
+ htmlFor: t.controlId
289
+ }, t.label);
290
+ return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(m, {
291
+ label: t.label,
292
+ detail: t.detail,
293
+ showLabel: !1
294
+ }));
295
+ }
296
+ function g(t) {
297
+ let n = t.controlId === void 0 ? void 0 : `${t.controlId}-hint`;
298
+ return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(h, {
299
+ label: t.label,
300
+ detail: t.detail,
301
+ compact: t.compact,
302
+ controlId: t.controlId
303
+ }), t.hint === void 0 ? null : (0, react.createElement)(`p`, {
304
+ className: `dsu-hint`,
305
+ id: n
306
+ }, t.hint)), (0, react.createElement)(`div`, { className: `dsu-control` }, t.children));
307
+ }
308
+ function _(t) {
309
+ let n = (0, react.useId)(), i = t.hint === void 0 ? void 0 : `${n}-hint`;
310
+ return (0, react.createElement)(g, {
311
+ ...t,
312
+ controlId: n
313
+ }, (0, react.createElement)(`button`, {
314
+ type: `button`,
315
+ role: `switch`,
316
+ id: n,
317
+ className: `dsu-switch`,
318
+ "aria-checked": t.checked,
319
+ "aria-describedby": i,
320
+ "data-field": t.field,
321
+ disabled: t.disabled === !0,
322
+ onClick: () => {
323
+ t.onChange(!t.checked);
324
+ }
325
+ }, (0, react.createElement)(`span`, { className: `dsu-knob` })));
326
+ }
327
+ function v(t) {
328
+ let i = typeof t.value == `number` && Number.isFinite(t.value) ? String(t.value) : ``, [a, c] = (0, react.useState)(i), [l, u] = (0, react.useState)(!1), d = (0, react.useRef)(void 0), f = (0, react.useId)(), p = (0, react.useId)(), m = [t.hint === void 0 ? void 0 : `${f}-hint`, l ? p : void 0].filter((e) => e !== void 0), h = m.length === 0 ? void 0 : m.join(` `);
329
+ (0, react.useEffect)(() => {
330
+ t.value !== d.current && (d.current = t.value, c(i), u(!1));
331
+ }, [t.value, i]);
332
+ let _ = (e) => {
333
+ let n = t.min ?? -1 / 0, r = t.max ?? 1 / 0;
334
+ if (!Number.isFinite(e) || e < n || e > r) return !1;
335
+ let { step: i } = t;
336
+ if (i === void 0 || i <= 0) return !0;
337
+ let a = (e - (t.min ?? 0)) / i;
338
+ return Math.abs(a - Math.round(a)) < 1e-9;
339
+ }, v = (e) => {
340
+ if (c(e), e === ``) {
341
+ u(!1), d.current = void 0, t.onChange(void 0);
342
+ return;
343
+ }
344
+ let n = Number(e);
345
+ _(n) ? (u(!1), d.current = n, t.onChange(n)) : u(!0);
346
+ }, y = () => {
347
+ a === `` || l || c(String(Number(a)));
348
+ };
349
+ return (0, react.createElement)(g, {
350
+ ...t,
351
+ controlId: f
352
+ }, (0, react.createElement)(`div`, { className: `dsu-numberWrap` }, (0, react.createElement)(`div`, { className: `dsu-number` }, (0, react.createElement)(`input`, {
353
+ className: `dsu-input`,
354
+ type: `number`,
355
+ inputMode: `numeric`,
356
+ id: f,
357
+ value: a,
358
+ min: t.min,
359
+ max: t.max,
360
+ step: t.step,
361
+ placeholder: t.placeholder,
362
+ "aria-invalid": l || void 0,
363
+ "aria-describedby": h,
364
+ "data-field": t.field,
365
+ disabled: t.disabled === !0,
366
+ onChange: (e) => {
367
+ v(e.target.value);
368
+ },
369
+ onBlur: y
370
+ }), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), l ? (0, react.createElement)(`p`, {
371
+ className: `dsu-error`,
372
+ id: p
373
+ }, t.invalidHint) : null));
374
+ }
375
+ function y(t) {
376
+ let [i, a] = (0, react.useState)(t.value), [o, c] = (0, react.useState)(!1), l = (0, react.useId)(), u = t.hint === void 0 ? void 0 : `${l}-hint`;
377
+ (0, react.useEffect)(() => {
378
+ o || a(t.value);
379
+ }, [t.value, o]);
380
+ let d = {
381
+ id: l,
382
+ className: `dsu-input${t.multiline === !0 ? ` dsu-textarea` : ``}${t.monospace === !0 ? ` dsu-mono` : ``}`,
383
+ value: i,
384
+ placeholder: t.placeholder,
385
+ "aria-describedby": u,
386
+ "data-field": t.field,
387
+ disabled: t.disabled === !0,
388
+ onFocus: () => {
389
+ c(!0);
390
+ },
391
+ onBlur: () => {
392
+ c(!1);
393
+ },
394
+ onChange: (e) => {
395
+ a(e.target.value), t.onChange(e.target.value);
396
+ }
397
+ };
398
+ return (0, react.createElement)(g, {
399
+ ...t,
400
+ controlId: l
401
+ }, t.multiline === !0 ? (0, react.createElement)(`textarea`, d) : (0, react.createElement)(`input`, d));
402
+ }
403
+ function x(c) {
404
+ let [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(0), p = (0, react.useRef)(null), m = (0, react.useRef)(null), h = (0, react.useId)(), _ = (0, react.useId)(), v = c.hint === void 0 ? void 0 : `${_}-hint`, { disabled: y, value: b, options: x, onChange: S } = c, C = (0, react.useMemo)(() => x.map((e, t) => ({
405
+ option: e,
406
+ index: t
407
+ })).filter((e) => e.option.disabled !== !0), [x]), w = x.find((e) => e.value === b)?.label ?? b, T = x[d], E = T !== void 0 && T.disabled !== !0, D = (0, react.useCallback)(() => {
408
+ let e = p.current, t = m.current;
409
+ /* v8 ignore next 3 -- place 只在 open 的 layout effect 里调用;refs 为空只可能是卸载竞态 */
410
+ if (e === null || t === null) return;
411
+ let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16), { left: i } = n;
412
+ i + r > window.innerWidth - 8 && (i = window.innerWidth - r - 8);
413
+ let a = t.offsetHeight, o = n.bottom + 6;
414
+ o + a > window.innerHeight - 8 && (o = n.top - a - 6);
415
+ let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - a - 8);
416
+ t.style.width = `${r}px`, t.style.left = `${Math.min(Math.max(8, i), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
417
+ }, []), O = (0, react.useCallback)(() => {
418
+ u(!1);
419
+ }, []), k = (0, react.useCallback)(() => {
420
+ if (y === !0) return;
421
+ let e = C.find((e) => e.option.value === b) ?? C.at(0);
422
+ e !== void 0 && (f(e.index), u(!0));
423
+ }, [
424
+ y,
425
+ b,
426
+ C
427
+ ]), A = (0, react.useCallback)((e) => {
428
+ /* v8 ignore next 3 -- 浮层只能经由 openMenu 打开;组件禁用时打不开 */
429
+ if (y === !0) return;
430
+ let t = x[e];
431
+ /* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click;越界下标由调用面保证 */
432
+ t !== void 0 && t.disabled !== !0 && (S(t.value), O(), p.current?.focus());
433
+ }, [
434
+ y,
435
+ x,
436
+ S,
437
+ O
438
+ ]), j = (0, react.useCallback)((e) => {
439
+ let t = C.findIndex((e) => e.index === d);
440
+ /* v8 ignore next 5 -- open 时归一 effect 已保证 enabled 非空且 active 落在可用项上 */
441
+ if (t === -1 || C.length === 0) return;
442
+ let n = (t + e + C.length) % C.length, r = C[n];
443
+ /* v8 ignore next 3 -- next 由取模保证在界内 */
444
+ r !== void 0 && f(r.index);
445
+ }, [d, C]);
446
+ (0, react.useLayoutEffect)(() => {
447
+ if (!l) return () => {};
448
+ D();
449
+ let e = (e) => {
450
+ let t = e.target;
451
+ m.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && O();
452
+ }, t = (e) => {
453
+ let { target: t } = e;
454
+ t instanceof Node && m.current?.contains(t) === !0 || O();
455
+ }, n = () => {
456
+ D();
457
+ };
458
+ return document.addEventListener(`pointerdown`, e, !0), window.addEventListener(`scroll`, t, !0), window.addEventListener(`resize`, n), () => {
459
+ document.removeEventListener(`pointerdown`, e, !0), window.removeEventListener(`scroll`, t, !0), window.removeEventListener(`resize`, n);
460
+ };
461
+ }, [
462
+ l,
463
+ c.options,
464
+ D,
465
+ O
466
+ ]), (0, react.useEffect)(() => {
467
+ if (!l) return;
468
+ if (y === !0 || C.length === 0) {
469
+ O();
470
+ return;
471
+ }
472
+ if (C.some((e) => e.index === d)) return;
473
+ let e = C.find((e) => e.option.value === b) ?? C.at(0);
474
+ /* v8 ignore next 3 -- enabled 非空在上一分支已保证 */
475
+ e !== void 0 && f(e.index);
476
+ }, [
477
+ l,
478
+ y,
479
+ b,
480
+ x,
481
+ d,
482
+ O,
483
+ C
484
+ ]), (0, react.useLayoutEffect)(() => {
485
+ if (!l) return;
486
+ let e = m.current;
487
+ /* v8 ignore next 2 -- 同上,menu 在 open 的 commit 之后必然已挂上 */
488
+ if (e === null) return;
489
+ let t = e.querySelector(`[data-active="true"]`);
490
+ /* v8 ignore next 2 -- active 已由归一 effect 保证落在可用项上 */
491
+ t !== null && (t.offsetTop < e.scrollTop ? e.scrollTop = t.offsetTop : t.offsetTop + t.offsetHeight > e.scrollTop + e.clientHeight && (e.scrollTop = t.offsetTop + t.offsetHeight - e.clientHeight));
492
+ }, [
493
+ l,
494
+ d,
495
+ x
496
+ ]);
497
+ let M = (e) => {
498
+ if (e.key === `ArrowDown` || e.key === `ArrowUp`) {
499
+ if (e.preventDefault(), !l) {
500
+ k();
501
+ return;
502
+ }
503
+ j(e.key === `ArrowDown` ? 1 : -1);
504
+ } else if (e.key === `Home` || e.key === `End`) {
505
+ if (e.preventDefault(), l || k(), C.length === 0) return;
506
+ let t = e.key === `Home` ? C.at(0) : C.at(-1);
507
+ /* v8 ignore next 3 -- enabled 为空已在上一条返回 */
508
+ if (t === void 0) return;
509
+ f(t.index);
510
+ } else if (e.key === `Enter` || e.key === ` `) {
511
+ if (e.preventDefault(), !l) {
512
+ k();
513
+ return;
514
+ }
515
+ A(d);
516
+ } else (e.key === `Tab` || e.key === `Escape`) && O();
517
+ }, N = [], P;
518
+ for (let [t, n] of x.entries()) n.group !== P && (n.group !== void 0 && N.push((0, react.createElement)(`div`, {
519
+ key: `group-${t}-${n.group}`,
520
+ className: `dsu-optionGroup`,
521
+ role: `presentation`
522
+ }, n.group)), P = n.group), N.push((0, react.createElement)(`button`, {
523
+ key: `option-${n.value}`,
524
+ type: `button`,
525
+ role: `option`,
526
+ id: `${h}-${t}`,
527
+ className: `dsu-option`,
528
+ tabIndex: -1,
529
+ "aria-selected": n.value === c.value,
530
+ "data-active": t === d,
531
+ disabled: n.disabled === !0,
532
+ onMouseDown: (e) => {
533
+ e.preventDefault();
534
+ },
535
+ onClick: () => {
536
+ A(t);
537
+ },
538
+ onMouseEnter: () => {
539
+ /* v8 ignore next -- happy-dom 对 disabled 元素不派发 mouse 事件;浏览器实现各有差异,保留禁用检查 */
540
+ n.disabled !== !0 && f(t);
541
+ }
542
+ }, (0, react.createElement)(`span`, null, n.label), (0, react.createElement)(`svg`, {
543
+ className: `dsu-check`,
544
+ width: 14,
545
+ height: 14,
546
+ viewBox: `0 0 14 14`,
547
+ "aria-hidden": !0
548
+ }, (0, react.createElement)(`path`, {
549
+ d: `M2.5 7.5l3 3 6-7`,
550
+ fill: `none`,
551
+ stroke: `currentColor`,
552
+ strokeWidth: 1.5,
553
+ strokeLinecap: `round`,
554
+ strokeLinejoin: `round`
555
+ }))));
556
+ return (0, react.createElement)(g, {
557
+ ...c,
558
+ controlId: _
559
+ }, (0, react.createElement)(`div`, {
560
+ className: `dsu-selectWrap`,
561
+ onBlur: (e) => {
562
+ let t = e.relatedTarget;
563
+ t instanceof Node && e.currentTarget.contains(t) || O();
564
+ }
565
+ }, (0, react.createElement)(`button`, {
566
+ ref: p,
567
+ type: `button`,
568
+ id: _,
569
+ className: `dsu-select dsu-input`,
570
+ role: `combobox`,
571
+ "aria-haspopup": `listbox`,
572
+ "aria-expanded": l,
573
+ "aria-controls": `${h}-list`,
574
+ "aria-activedescendant": l && E ? `${h}-${d}` : void 0,
575
+ "aria-describedby": v,
576
+ "data-field": c.field,
577
+ disabled: y === !0 || x.length === 0,
578
+ onClick: () => {
579
+ l ? O() : k();
580
+ },
581
+ onKeyDown: M
582
+ }, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, w), (0, react.createElement)(`svg`, {
583
+ className: `dsu-chevron`,
584
+ width: 14,
585
+ height: 14,
586
+ viewBox: `0 0 14 14`,
587
+ "aria-hidden": !0
588
+ }, (0, react.createElement)(`path`, {
589
+ d: `M3 5l4 4 4-4`,
590
+ fill: `none`,
591
+ stroke: `currentColor`,
592
+ strokeWidth: 1.5,
593
+ strokeLinecap: `round`,
594
+ strokeLinejoin: `round`
595
+ }))), (0, react.createElement)(`div`, {
596
+ ref: m,
597
+ id: `${h}-list`,
598
+ role: `listbox`,
599
+ className: `dsu-menu`,
600
+ "aria-label": c.label,
601
+ hidden: !l
602
+ }, ...N)));
603
+ }
604
+ function S(t) {
605
+ let n = !t.writable || t.busy || !t.dirty, r;
606
+ return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
607
+ className: `dsu-savebar`,
608
+ "data-dirty": t.dirty
609
+ }, (0, react.createElement)(`button`, {
610
+ type: `button`,
611
+ className: `dsu-btn dsu-btnPrimary`,
612
+ "data-field": `save`,
613
+ disabled: n,
614
+ onClick: t.onSave
615
+ }, t.busy ? t.savingLabel : t.saveLabel), (0, react.createElement)(`button`, {
616
+ type: `button`,
617
+ className: `dsu-btn`,
618
+ "data-field": `discard`,
619
+ disabled: n,
620
+ onClick: t.onDiscard
621
+ }, t.revertLabel), (0, react.createElement)(`span`, { className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError` }, r));
622
+ }
623
+ // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-diff.js
624
+ function e$1(t, n, r) {
625
+ if (t == null || n == null) return (t ?? null) === (n ?? null);
626
+ if (Object.is(t, n)) return !0;
627
+ if (typeof t != `object` || typeof n != `object`) return !1;
628
+ if (r.get(t) === n) return !0;
629
+ if (r.set(t, n), Array.isArray(t) || Array.isArray(n)) return !Array.isArray(t) || !Array.isArray(n) || t.length !== n.length ? !1 : t.every((t, i) => e$1(t, n[i], r));
630
+ let i = Object.keys(t), a = Object.keys(n);
631
+ return i.length === a.length && i.every((i) => Object.hasOwn(n, i) && e$1(Reflect.get(t, i), Reflect.get(n, i), r));
632
+ }
633
+ function t$1(t, n) {
634
+ let r = [];
635
+ for (let i of Object.keys(t)) e$1(t[i], n[i], /* @__PURE__ */ new WeakMap()) || r.push(i);
636
+ return r;
637
+ }
638
+ // node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
639
+ function e(e) {
640
+ return typeof e == `object` && !!e && !Array.isArray(e);
641
+ }
642
+ // node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
643
+ function t(e) {
644
+ let t = Object.getOwnPropertyDescriptor(e, `message`);
645
+ return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
646
+ }
647
+ function n(e, r) {
648
+ if (r.has(e)) return `<circular cause>`;
649
+ r.add(e);
650
+ try {
651
+ if (!(e instanceof Error)) {
652
+ if (typeof e == `object` && e) {
653
+ let n = t(e);
654
+ if (n !== void 0 && n !== ``) return n;
655
+ }
656
+ return String(e);
657
+ }
658
+ let i = e.message === `` ? e.name : e.message, a = typeof globalThis.AggregateError == `function` && e instanceof AggregateError && e.errors.length > 0 ? ` [${e.errors.map((e) => n(e, r)).join(`; `)}]` : ``, o = e.cause === void 0 || e.cause === null ? `` : n(e.cause, r);
659
+ return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
660
+ } catch {
661
+ return `<unrenderable value>`;
662
+ } finally {
663
+ r.delete(e);
664
+ }
665
+ }
666
+ function r(e) {
667
+ return n(e, /* @__PURE__ */ new Set());
668
+ }
78
669
  // lib/card-draft.ts
79
670
  /** 草稿优先取值:touched 有该键(哪怕值是 undefined=待清空)即用草稿。
80
671
  * 两层都只判**自有**属性:本函数收任意字段名,`in`/裸下标会沿原型链命中 `toString` /
@@ -94,7 +685,7 @@ function numberText(raw, fallback) {
94
685
  /**
95
686
  * 引导端点交回的守护进程就绪态该显示哪一行。
96
687
  *
97
- * `undefined` 是**必要**的一臂,不是兜底:旧版 host 的应答里没有 `serverReady` 这个字段,
688
+ * `undefined` 是**必需**的一种取值,不是兜底默认:旧版 host 的应答里没有 `serverReady` 这个字段,
98
689
  * 而「应答里没写」与「写了未就绪」是两件事——把前者显示成后者,卡片就在用户眼前谎称了一次
99
690
  * 「没有守护进程」。判据收在可单测的这一层,client 只负责渲染它选出来的那一行。
100
691
  *
@@ -169,17 +760,19 @@ function endpointFieldDisplay(touched, value) {
169
760
  const committed = value["hfEndpoint"];
170
761
  return typeof committed === "string" && HTTP_URL_SCHEMA.safeParse(committed).success ? committed : "";
171
762
  }
172
- /** 六个字段的草稿显示值(ZgCard 只渲染这里算出来的东西)。 */
763
+ /** 七个字段的草稿显示值(ZgCard 只渲染这里算出来的东西)。 */
173
764
  function draftFields(touched, value) {
174
765
  const embedding = draftOf(touched, value, "defaultEmbedding");
175
766
  const enforce = draftOf(touched, value, "enforceSearchFirst");
767
+ const transport = draftOf(touched, value, "transport");
176
768
  return {
177
769
  embedding: typeof embedding === "string" && embedding.length > 0 ? embedding : DEFAULT_EMBEDDING,
178
770
  limitDisplay: numericFieldDisplay(touched, value, "defaultLimit", String(10)),
179
771
  hfEndpoint: endpointFieldDisplay(touched, value),
180
772
  enforceSearchFirst: enforce !== false,
181
773
  grepBudget: numericFieldDisplay(touched, value, "grepBudgetPerSearch", String(3)),
182
- unlockWindow: numericFieldDisplay(touched, value, "unlockWindowMin", String(10))
774
+ unlockWindow: numericFieldDisplay(touched, value, "unlockWindowMin", String(10)),
775
+ transport: transport === "cli" || transport === "mcp" || transport === "auto" ? transport : "auto"
183
776
  };
184
777
  }
185
778
  const LIMIT_SCHEMA = zod.z.int().min(1).max(50);
@@ -238,7 +831,7 @@ const REBUILD_NAMESPACE = "zvecGrepRebuild";
238
831
  const REBUILD_SERVICE_KEY = `remote.${REBUILD_NAMESPACE}`;
239
832
  /** 卡片所在 bundle 的包名(`$mount` 的 `package` 位与槽位键同源,见 client-entry.ts 的 BUNDLE_PKG)。 */
240
833
  const PACKAGE_NAME = "@jayyuen66/dsh-zvec-grep";
241
- /** strict codec 的统一出口:失败交给 zod 的 `prettifyError`,读到的是一份带字段路径的说明。 */
834
+ /** strict codec 的统一的返回点:失败交给 zod 的 `prettifyError`,读到的是一份带字段路径的说明。 */
242
835
  function parseOrThrow(schema, value) {
243
836
  const parsed = schema.safeParse(value);
244
837
  if (!parsed.success) throw new TypeError(zod.z.prettifyError(parsed.error));
@@ -246,7 +839,7 @@ function parseOrThrow(schema, value) {
246
839
  }
247
840
  const START_SCHEMA = zod.z.object({ root: zod.z.string({ error: "rebuild request requires a string root" }).trim().min(1, { error: "rebuild request requires a non-empty root" }) }, { error: "rebuild request requires a string root" });
248
841
  const STATUS_SCHEMA = zod.z.object({ jobId: zod.z.string({ error: "rebuild status request requires a string jobId" }).trim().min(1, { error: "rebuild status request requires a non-empty jobId" }) }, { error: "rebuild status request requires a string jobId" });
249
- /** 把宿主那三个方法挂到客户端远程面上的描述符(`id` 的形状照生成器:`<包>#<命名空间>/<方法>`)。
842
+ /** 把宿主那三个方法挂到客户端远程通道上的描述符(`id` 的形状照生成器:`<包>#<命名空间>/<方法>`)。
250
843
  * 导出它只为一件事:`test/rebuild-remote.test.ts` 拿它与宿主侧 `remoteMethods()` 的标记对质
251
844
  * —— 两侧分叉时卡片不会报错,只会"读不到",所以那条比较必须在门禁里。 */
252
845
  const REBUILD_DESCRIPTORS = [
@@ -300,10 +893,10 @@ const REBUILD_DESCRIPTORS = [
300
893
  result: { mode: "src-json" }
301
894
  }
302
895
  ];
303
- /** 这个值能当远程面用吗(只核我们要调的那一位;服务来自别的实现或版本时保守当作没有)。 */
304
- const isRemoteMounter = (value) => (0, _jayyuen66_dsh_plugin_shared_client.isRecord)(value) && typeof value["$mount"] === "function";
896
+ /** 这个值能当远程通道用吗(只核我们要调的那一位;服务来自别的实现或版本时保守当作没有)。 */
897
+ const isRemoteMounter = (value) => e(value) && typeof value["$mount"] === "function";
305
898
  /** 同上:命名空间服务(挂载之后才有,缺它说明网关没认这枚贡献)。 */
306
- const isRebuildNamespace = (value) => (0, _jayyuen66_dsh_plugin_shared_client.isRecord)(value) && typeof value["roots"] === "function" && typeof value["rebuild"] === "function" && typeof value["status"] === "function";
899
+ const isRebuildNamespace = (value) => e(value) && typeof value["roots"] === "function" && typeof value["rebuild"] === "function" && typeof value["status"] === "function";
307
900
  /**
308
901
  * 线上拒绝(result.ok=false)翻成异常:code 与 message 都来自网关的错误对象。
309
902
  * 三个方法同构,收成一个入口——同一份判据,不抄三份。
@@ -318,11 +911,11 @@ async function unwrapWire(call) {
318
911
  * @param ctx - 客户端上下文
319
912
  * @returns 读取器
320
913
  */
321
- function buildRebuildReader(ctx) {
914
+ function buildRebuildReader(ctx, messages) {
322
915
  let mounted;
323
916
  const namespaceOf = async () => {
324
917
  const mounter = ctx.get?.("remote");
325
- if (!isRemoteMounter(mounter)) throw new Error("工作区重建读面不可用:宿主网关没有提供 remote 服务");
918
+ if (!isRemoteMounter(mounter)) throw new Error(messages.remoteMissing());
326
919
  try {
327
920
  mounted ??= mounter.$mount({
328
921
  package: PACKAGE_NAME,
@@ -334,7 +927,7 @@ function buildRebuildReader(ctx) {
334
927
  throw error;
335
928
  }
336
929
  const namespace = ctx.get?.(REBUILD_SERVICE_KEY);
337
- if (!isRebuildNamespace(namespace)) throw new Error(`${REBUILD_SERVICE_KEY} 未提供:宿主网关没有挂上这枚命名空间`);
930
+ if (!isRebuildNamespace(namespace)) throw new Error(messages.namespaceMissing(REBUILD_SERVICE_KEY));
338
931
  return namespace;
339
932
  };
340
933
  return {
@@ -364,8 +957,8 @@ function buildRebuildReader(ctx) {
364
957
  * @param ctx - 客户端上下文(只用 `get` 一位)
365
958
  * @returns 读取器;ctx 没有 get 面时 `undefined`
366
959
  */
367
- function createRebuildReader(ctx) {
368
- return typeof ctx.get === "function" ? buildRebuildReader(ctx) : void 0;
960
+ function createRebuildReader(ctx, messages) {
961
+ return typeof ctx.get === "function" ? buildRebuildReader(ctx, messages) : void 0;
369
962
  }
370
963
  // src/ui-messages.ts
371
964
  /** 推荐的 embedding 模型镜像(endpointHint 与 client-entry 的 placeholder 共用)。 */
@@ -386,8 +979,14 @@ const UI_MESSAGES = {
386
979
  unitTimes: "次",
387
980
  unitMinutes: "分钟",
388
981
  outOfRange: "超出允许范围,未保存",
389
- embeddingLabel: "默认本地 embedding",
390
- embeddingHint: "只影响「新建」索引;切换并保存后,已有索引需点下方「重建」重新 embedding",
982
+ embeddingLabel: "默认 embedding",
983
+ embeddingHint: "本地模型直接可选;远程 qwen 模型需在插件部署配置里打开 allowRemoteEmbedding(内容会送往外部端点,首次索引需 zg --auth grant 授权)。只影响「新建」索引;切换并保存后,已有索引需点下方「重建」重新 embedding",
984
+ transportLabel: "检索传输方式",
985
+ transportHint: "自动 = 守护进程在跑时检索走 MCP(常驻模型池、队列调度),否则走 CLI;仅 CLI = 永不碰守护进程;仅 MCP = 检索恒走守护进程,缺席时由插件自动拉起(会开 127.0.0.1:7999 回环端口;拉起失败会明确报错而不是回退 CLI)",
986
+ transportAuto: "自动(守护进程在跑走 MCP,否则 CLI)",
987
+ transportCli: "仅 CLI(每次 spawn zg 进程)",
988
+ transportMcp: "仅 MCP(走守护进程,缺席自动拉起)",
989
+ backendRemote: "qwen 远程(内容出本机,需部署开放并授权)",
391
990
  limitLabel: "默认每组结果数",
392
991
  limitInvalid: "请输入 {min}-{max} 的整数",
393
992
  limitClamped: "已钳到 {min}-{max} 范围:{value}",
@@ -401,9 +1000,9 @@ const UI_MESSAGES = {
401
1000
  windowHint: "超过该时长未再次 zg_search,配额整体过期;清空恢复默认 {default}(单位:分钟)",
402
1001
  rebuildLabel: "工作区重建(切换 embedding 并保存后执行)",
403
1002
  rebuildInputPlaceholder: "/workspace 的绝对路径",
404
- daemonReadyNote: "守护进程:就绪(zg server 在跑)。",
405
- daemonOfflineNote: "守护进程:未就绪。守护进程提供的索引增量刷新、refresh=background 与常驻模型池在缺席时都不可用;需要时在终端执行 `zg server on`。",
406
- rebuildHint: "以当前默认模型重建:{embedding};等价于 zg index --rebuild。{roots}",
1003
+ daemonReadyNote: "守护进程:就绪(zg --server 在跑)。",
1004
+ daemonOfflineNote: "守护进程:未就绪。守护进程提供的索引增量刷新、refresh=background 与常驻模型池在缺席时都不可用;需要时在终端执行 `zg --server on`。",
1005
+ rebuildHint: "以当前默认模型重建:{embedding};等价于 zg --index --rebuild。{roots}",
407
1006
  rootsNoteWith: "候选工作区来自本 daemon 已打开过的会话(服务端白名单)。",
408
1007
  rootsNoteEmpty: "尚无可选工作区:先在该工作区里开一个会话(任一次工具调用即登记)。",
409
1008
  rebuildButton: "重建索引(动作,点击即执行)",
@@ -417,6 +1016,8 @@ const UI_MESSAGES = {
417
1016
  rebuildMissingJobId: "启动重建失败:应答缺 jobId",
418
1017
  rebuildRootNotAbsolute: "root 必须是绝对路径(以 / 开头)",
419
1018
  rebuildUnavailable: "宿主没有提供工作区重建读面(未装远程服务)",
1019
+ rebuildRemoteMissing: "工作区重建读面不可用:宿主网关没有提供 remote 服务",
1020
+ rebuildNamespaceMissing: "{serviceKey} 未提供:宿主网关没有挂上这枚命名空间",
420
1021
  modelOption: "{reference}({dimension}维)",
421
1022
  backendLlamaCpp: "llama-cpp(原生,需 node-llama-cpp)",
422
1023
  backendTransformersJs: "transformers-js(纯 JS ONNX)",
@@ -437,8 +1038,14 @@ const UI_MESSAGES = {
437
1038
  unitTimes: "times",
438
1039
  unitMinutes: "minutes",
439
1040
  outOfRange: "Out of the allowed range — not saved",
440
- embeddingLabel: "Default local embedding",
441
- embeddingHint: "Affects newly built indexes only; after switching and saving, press Rebuild below to re-embed existing indexes",
1041
+ embeddingLabel: "Default embedding",
1042
+ embeddingHint: "Local models are always selectable; the remote qwen models additionally require allowRemoteEmbedding in the deployment config (content leaves the machine, and the first index build needs a zg --auth grant). Affects newly built indexes only; after switching and saving, press Rebuild below to re-embed existing indexes",
1043
+ transportLabel: "Search transport",
1044
+ transportHint: "auto = searches go through the daemon (MCP) when it is running, CLI otherwise; CLI-only = never touch the daemon; MCP-only = searches always go through the daemon, auto-starting it when absent (opens the 127.0.0.1:7999 loopback port; a failed start is reported explicitly, never silently downgraded to CLI)",
1045
+ transportAuto: "auto (daemon → MCP, otherwise CLI)",
1046
+ transportCli: "CLI only (spawn zg each call)",
1047
+ transportMcp: "MCP only (via daemon, auto-started when absent)",
1048
+ backendRemote: "qwen remote (content leaves the machine; needs the deployment switch + grant)",
442
1049
  limitLabel: "Default hits per group",
443
1050
  limitInvalid: "enter an integer between {min} and {max}",
444
1051
  limitClamped: "clamped into the {min}-{max} range: {value}",
@@ -452,9 +1059,9 @@ const UI_MESSAGES = {
452
1059
  windowHint: "Without another zg_search inside this window the whole quota expires; clear to restore the default {default} (minutes)",
453
1060
  rebuildLabel: "Workspace rebuild (run after switching embedding and saving)",
454
1061
  rebuildInputPlaceholder: "absolute path to a /workspace",
455
- daemonReadyNote: "Daemon: ready (zg server is running).",
456
- daemonOfflineNote: "Daemon: not ready. What the daemon provides — incremental index refresh, refresh=background and the resident embedding model pool — is unavailable while it is absent; run `zg server on` in a terminal when you want it.",
457
- rebuildHint: "Rebuild with the current default model: {embedding}; same as zg index --rebuild. {roots}",
1062
+ daemonReadyNote: "Daemon: ready (zg --server is running).",
1063
+ daemonOfflineNote: "Daemon: not ready. What the daemon provides — incremental index refresh, refresh=background and the resident embedding model pool — is unavailable while it is absent; run `zg --server on` in a terminal when you want it.",
1064
+ rebuildHint: "Rebuild with the current default model: {embedding}; same as zg --index --rebuild. {roots}",
458
1065
  rootsNoteWith: "Candidates come from sessions this daemon already opened (server-side whitelist).",
459
1066
  rootsNoteEmpty: "No workspace to pick yet: open a session in that workspace first (any tool call registers it).",
460
1067
  rebuildButton: "Rebuild index (action, runs on click)",
@@ -468,6 +1075,8 @@ const UI_MESSAGES = {
468
1075
  rebuildMissingJobId: "failed to start the rebuild: the response has no jobId",
469
1076
  rebuildRootNotAbsolute: "root must be an absolute path (starting with /)",
470
1077
  rebuildUnavailable: "the host does not expose the rebuild Remote API",
1078
+ rebuildRemoteMissing: "the rebuild Remote API is unavailable: the host gateway provides no remote service",
1079
+ rebuildNamespaceMissing: "{serviceKey} was not provided: the host gateway did not mount this namespace",
471
1080
  modelOption: "{reference} ({dimension} dims)",
472
1081
  backendLlamaCpp: "llama-cpp (native, requires node-llama-cpp)",
473
1082
  backendTransformersJs: "transformers-js (pure JS ONNX)",
@@ -475,6 +1084,10 @@ const UI_MESSAGES = {
475
1084
  }
476
1085
  };
477
1086
  // src/client-entry.ts
1087
+ /** 一个反斜杠字符(客户端不引 lib/platform.ts:那份模块带 Node 的 process 类型)。 */
1088
+ const BACKSLASH = String.fromCodePoint(92);
1089
+ /** 卡片侧只做形状提示:win32 盘符绝对路径(`C:\…` / `C:/…`)。 */
1090
+ const WIN32_ABSOLUTE_ROOT = /^[A-Za-z]:[\\/]/u;
478
1091
  const NS = "zvec-grep";
479
1092
  /**
480
1093
  * `plugins.bundle.config` 的 key = **bundle 的 npm 包名**(不是裸条目 id)。
@@ -535,7 +1148,7 @@ function rebuildHintText(t, embedding, hasRoots) {
535
1148
  roots: t(hasRoots ? "rootsNoteWith" : "rootsNoteEmpty")
536
1149
  });
537
1150
  }
538
- /** embedding 候选的显示文本与分组(供共享 SelectField 的 options)。 */
1151
+ /** embedding 候选的显示文本与分组(供共享 SelectField 的 options):本地按后端三组 + 远程一组。 */
539
1152
  function embeddingOptions(t) {
540
1153
  const options = [];
541
1154
  for (const backend of BACKENDS) for (const entry of LOCAL_EMBEDDINGS) if (entry.backend === backend) options.push({
@@ -543,8 +1156,31 @@ function embeddingOptions(t) {
543
1156
  label: modelOptionText(t, entry.reference, entry.dimension),
544
1157
  group: t(BACKEND_LABEL_KEY[backend])
545
1158
  });
1159
+ for (const entry of REMOTE_EMBEDDING_CATALOG) options.push({
1160
+ value: entry.reference,
1161
+ label: modelOptionText(t, entry.reference, entry.dimension),
1162
+ group: t("backendRemote")
1163
+ });
546
1164
  return options;
547
1165
  }
1166
+ /** 传输三档的闭集(与 host 侧 readTransport 同域;label 取 UI 字典)。 */
1167
+ const TRANSPORT_OPTIONS = [
1168
+ { value: "auto" },
1169
+ { value: "cli" },
1170
+ { value: "mcp" }
1171
+ ];
1172
+ const TRANSPORT_LABEL_KEY = {
1173
+ auto: "transportAuto",
1174
+ cli: "transportCli",
1175
+ mcp: "transportMcp"
1176
+ };
1177
+ /** 传输三档的 SelectField 候选。 */
1178
+ function transportOptions(t) {
1179
+ return TRANSPORT_OPTIONS.map((entry) => ({
1180
+ value: entry.value,
1181
+ label: t(TRANSPORT_LABEL_KEY[entry.value])
1182
+ }));
1183
+ }
548
1184
  /** 数字草稿串 → 控件值:区间由 zod schema 判定;空串是「清空 = 恢复默认」,不是 0。 */
549
1185
  function numberDisplay(display, schema) {
550
1186
  const parsed = schema.safeParse(display === "" ? NaN : Number(display));
@@ -553,9 +1189,9 @@ function numberDisplay(display, schema) {
553
1189
  /** 检索模型小节:embedding 下拉(按本地后端分组)+ 每组结果数。 */
554
1190
  function buildModelSection(deps) {
555
1191
  const { editable, fields, setField, t } = deps;
556
- const embedding = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.SelectField, {
1192
+ const embedding = (0, react.createElement)(x, {
557
1193
  label: t("embeddingLabel"),
558
- ...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("embeddingHint")),
1194
+ ...l(t("embeddingHint")),
559
1195
  field: "defaultEmbedding",
560
1196
  value: fields.embedding,
561
1197
  options: embeddingOptions(t),
@@ -564,7 +1200,7 @@ function buildModelSection(deps) {
564
1200
  setField("defaultEmbedding", next);
565
1201
  }
566
1202
  });
567
- const limit = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
1203
+ const limit = (0, react.createElement)(v, {
568
1204
  label: t("limitLabel"),
569
1205
  hint: t("limitInvalid", {
570
1206
  min: 1,
@@ -582,7 +1218,7 @@ function buildModelSection(deps) {
582
1218
  setField("defaultLimit", next);
583
1219
  }
584
1220
  });
585
- return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Section, { title: t("modelSection") }, embedding, limit);
1221
+ return (0, react.createElement)(d, { title: t("modelSection") }, embedding, limit);
586
1222
  }
587
1223
  /** 重建行:root 输入(白名单候选进 <datalist>)+ 触发按钮(在跑时禁用)。 */
588
1224
  function buildRebuildField(deps) {
@@ -608,14 +1244,14 @@ function buildRebuildField(deps) {
608
1244
  disabled: rebuild.phase === "running",
609
1245
  onClick: deps.onRebuild
610
1246
  }, rebuild.phase === "running" ? t("rebuildRunning") : t("rebuildButton"));
611
- return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Field, {
1247
+ return (0, react.createElement)(g, {
612
1248
  label: t("rebuildLabel"),
613
- ...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(rebuildHintText(t, fields.embedding, roots.length > 0)),
1249
+ ...l(rebuildHintText(t, fields.embedding, roots.length > 0)),
614
1250
  wide: true
615
1251
  }, rootDatalist, rebuildInput, rebuildButton);
616
1252
  }
617
1253
  /**
618
- * 守护进程(`zg server`)就绪态一行,取自 rebuild-roots 引导端点。
1254
+ * 守护进程(`zg --server`)就绪态一行,取自 rebuild-roots 引导端点。
619
1255
  *
620
1256
  * 为什么值得单独占一行:daemon 缺席时检索按直连模式逐次冷加载 embedding 模型,而
621
1257
  * `refresh=background`、索引增量刷新与常驻模型池都不存在——本包因此在命令构造期就拒
@@ -638,12 +1274,23 @@ function buildRebuildStatusRow(deps) {
638
1274
  else displayText = rebuild.output;
639
1275
  return (0, react.createElement)("div", { className: displayClass }, displayText);
640
1276
  }
641
- /** 网络与索引小节:镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
1277
+ /** 网络与索引小节:传输三档、镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
642
1278
  function buildIndexSection(deps) {
643
1279
  const { editable, fields, setField, t } = deps;
644
- const endpoint = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.TextField, {
1280
+ const transport = (0, react.createElement)(x, {
1281
+ label: t("transportLabel"),
1282
+ ...l(t("transportHint")),
1283
+ field: "transport",
1284
+ value: fields.transport,
1285
+ options: transportOptions(t),
1286
+ disabled: !editable,
1287
+ onChange: (next) => {
1288
+ setField("transport", next);
1289
+ }
1290
+ });
1291
+ const endpoint = (0, react.createElement)(y, {
645
1292
  label: t("endpointLabel"),
646
- ...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("endpointHint")),
1293
+ ...l(t("endpointHint")),
647
1294
  field: "hfEndpoint",
648
1295
  value: fields.hfEndpoint,
649
1296
  placeholder: EMBEDDING_MIRROR_URL,
@@ -653,9 +1300,9 @@ function buildIndexSection(deps) {
653
1300
  setField("hfEndpoint", next.trim() === "" ? void 0 : next.trim());
654
1301
  }
655
1302
  });
656
- const enforce = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.ToggleField, {
1303
+ const enforce = (0, react.createElement)(_, {
657
1304
  label: t("enforceLabel"),
658
- ...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("enforceHint")),
1305
+ ...l(t("enforceHint")),
659
1306
  field: "enforceSearchFirst",
660
1307
  checked: fields.enforceSearchFirst,
661
1308
  disabled: !editable,
@@ -663,9 +1310,9 @@ function buildIndexSection(deps) {
663
1310
  setField("enforceSearchFirst", next);
664
1311
  }
665
1312
  });
666
- const budget = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
1313
+ const budget = (0, react.createElement)(v, {
667
1314
  label: t("budgetLabel"),
668
- ...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("budgetHint", { default: 3 })),
1315
+ ...l(t("budgetHint", { default: 3 })),
669
1316
  field: "grepBudgetPerSearch",
670
1317
  value: numberDisplay(fields.grepBudget, BUDGET_SCHEMA),
671
1318
  min: BUDGET_SCHEMA.minValue ?? 1,
@@ -678,9 +1325,9 @@ function buildIndexSection(deps) {
678
1325
  setField("grepBudgetPerSearch", next);
679
1326
  }
680
1327
  });
681
- const window = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
1328
+ const window = (0, react.createElement)(v, {
682
1329
  label: t("windowLabel"),
683
- ...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("windowHint", { default: 10 })),
1330
+ ...l(t("windowHint", { default: 10 })),
684
1331
  field: "unlockWindowMin",
685
1332
  value: numberDisplay(fields.unlockWindow, WINDOW_SCHEMA),
686
1333
  min: WINDOW_SCHEMA.minValue ?? 1,
@@ -693,12 +1340,12 @@ function buildIndexSection(deps) {
693
1340
  setField("unlockWindowMin", next);
694
1341
  }
695
1342
  });
696
- return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Section, { title: t("indexSection") }, endpoint, enforce, budget, window, buildDaemonNote(deps), buildRebuildField(deps), buildRebuildStatusRow(deps));
1343
+ return (0, react.createElement)(d, { title: t("indexSection") }, transport, endpoint, enforce, budget, window, buildDaemonNote(deps), buildRebuildField(deps), buildRebuildStatusRow(deps));
697
1344
  }
698
1345
  /** 卡片主体:检索模型 / 网络与索引两节 + 保存条。 */
699
1346
  function buildCardBody(deps) {
700
1347
  const { t } = deps;
701
- const saveBar = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.SaveBar, {
1348
+ const saveBar = (0, react.createElement)(S, {
702
1349
  dirty: deps.dirty,
703
1350
  busy: deps.busy,
704
1351
  writable: deps.writable,
@@ -712,7 +1359,7 @@ function buildCardBody(deps) {
712
1359
  onSave: deps.onSave,
713
1360
  onDiscard: deps.onDiscard
714
1361
  });
715
- return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.CardForm, null, buildModelSection(deps), buildIndexSection(deps), saveBar);
1362
+ return (0, react.createElement)(u, null, buildModelSection(deps), buildIndexSection(deps), saveBar);
716
1363
  }
717
1364
  /** 显式字段写入(schema-coverage 门禁按 set('字段名') 字面量识别绑定)。 */
718
1365
  function pushFieldWrite(ops, key, draft, set) {
@@ -722,6 +1369,7 @@ function pushFieldWrite(ops, key, draft, set) {
722
1369
  else if (key === "enforceSearchFirst") ops.push(set("enforceSearchFirst", draft));
723
1370
  else if (key === "grepBudgetPerSearch") ops.push(set("grepBudgetPerSearch", draft));
724
1371
  else if (key === "unlockWindowMin") ops.push(set("unlockWindowMin", draft));
1372
+ else if (key === "transport") ops.push(set("transport", draft));
725
1373
  }
726
1374
  /** 读取器缺席时的可行动文案(只剩 ctx.get 缺席这一档;remote/命名空间的缺席由读取器现抛)。 */
727
1375
  function requireReader(reader, t) {
@@ -736,7 +1384,7 @@ const NO_ACCESS = {
736
1384
  * 「工作区重建」状态机:取白名单 → 起一条重建 → 2s 轮询到终态。
737
1385
  * 从 ZgCard 拆出,保持组件体在一屏内可读。
738
1386
  * @param t - 取文案(官方 locale 的 translator,随卡片一起下发)。
739
- * @param reader - 宿主重建读面;`undefined` = 当前部署没有远程面(点重建时报错)。
1387
+ * @param reader - 宿主重建读取接口;`undefined` = 当前部署没有远程通道(点重建时报错)。
740
1388
  */
741
1389
  function useRebuild(t, reader) {
742
1390
  const [root, setRoot] = (0, react.useState)("");
@@ -801,7 +1449,7 @@ function useRebuild(t, reader) {
801
1449
  stopPolling();
802
1450
  setRebuild({
803
1451
  phase: "error",
804
- output: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error)
1452
+ output: r(error)
805
1453
  });
806
1454
  } finally {
807
1455
  pollingRef.current = false;
@@ -819,7 +1467,8 @@ function useRebuild(t, reader) {
819
1467
  }, REBUILD_POLL_MS);
820
1468
  }
821
1469
  async function start() {
822
- if (!root.trim().startsWith("/")) {
1470
+ const trimmedRoot = root.trim();
1471
+ if (!(trimmedRoot.startsWith("/") || WIN32_ABSOLUTE_ROOT.test(trimmedRoot) || trimmedRoot.startsWith(BACKSLASH + BACKSLASH))) {
823
1472
  setRebuild({
824
1473
  phase: "error",
825
1474
  output: t("rebuildRootNotAbsolute")
@@ -837,7 +1486,7 @@ function useRebuild(t, reader) {
837
1486
  stopPolling();
838
1487
  setRebuild({
839
1488
  phase: "error",
840
- output: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error)
1489
+ output: r(error)
841
1490
  });
842
1491
  }
843
1492
  }
@@ -861,7 +1510,7 @@ function ZgCard(props) {
861
1510
  const [saveError, setSaveError] = (0, react.useState)(null);
862
1511
  const rebuildView = useRebuild(t, props.rebuildRemote);
863
1512
  const fields = draftFields(touched, value);
864
- const dirtyCount = (0, _jayyuen66_dsh_plugin_shared_client.diffTouched)(touched, value).length;
1513
+ const dirtyCount = t$1(touched, value).length;
865
1514
  const dirty = dirtyCount > 0;
866
1515
  const setField = (field, draft) => {
867
1516
  setTouched((prev) => ({
@@ -870,7 +1519,7 @@ function ZgCard(props) {
870
1519
  }));
871
1520
  };
872
1521
  const save = async () => {
873
- const keys = (0, _jayyuen66_dsh_plugin_shared_client.diffTouched)(touched, value);
1522
+ const keys = t$1(touched, value);
874
1523
  if (keys.length === 0) return;
875
1524
  setBusy(true);
876
1525
  setSaveError(null);
@@ -888,7 +1537,7 @@ function ZgCard(props) {
888
1537
  }
889
1538
  } catch (error) {
890
1539
  setBusy(false);
891
- setSaveError(t("saveFailed", { reason: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error) }));
1540
+ setSaveError(t("saveFailed", { reason: r(error) }));
892
1541
  return;
893
1542
  }
894
1543
  const savedKeys = new Set(keys);
@@ -933,7 +1582,7 @@ function apply(ctx) {
933
1582
  ctx.effect(() => {
934
1583
  const tag = document.createElement("style");
935
1584
  tag.id = "zvec-grep-card-css";
936
- tag.textContent = `${CARD_CSS}\n${_jayyuen66_dsh_plugin_shared_client.CARD_UI_CSS}`;
1585
+ tag.textContent = `${CARD_CSS}\n${c}`;
937
1586
  document.head.append(tag);
938
1587
  return () => {
939
1588
  tag.remove();
@@ -943,7 +1592,10 @@ function apply(ctx) {
943
1592
  const store = cardStore(scope);
944
1593
  ctx.effect(() => ctx.locale.register(NS, UI_MESSAGES), "zvec-grep-card: locale dictionaries");
945
1594
  const t = ctx.locale.bind(NS);
946
- const rebuildRemote = createRebuildReader(ctx);
1595
+ const rebuildRemote = createRebuildReader(ctx, {
1596
+ remoteMissing: () => t("rebuildRemoteMissing"),
1597
+ namespaceMissing: (serviceKey) => t("rebuildNamespaceMissing", { serviceKey })
1598
+ });
947
1599
  const writeField = async (field, valueDraft) => {
948
1600
  try {
949
1601
  return await scope.set(field, valueDraft);