@jayyuen66/dsh-zvec-grep 0.1.11 → 0.1.13
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/CHANGELOG.md +88 -45
- package/README.md +21 -19
- package/README.zh-CN.md +46 -44
- package/THIRD_PARTY_NOTICES.md +4 -4
- package/client.js +128 -630
- package/cordis.patch.yml +4 -1
- package/docs/DETAIL.md +13 -6
- package/docs/DETAIL.zh.md +14 -7
- package/host.js +1739 -649
- package/package.json +50 -48
package/client.js
CHANGED
|
@@ -8,6 +8,7 @@ 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");
|
|
11
12
|
// lib/embedding-catalog.ts
|
|
12
13
|
/** 默认模型:本地最强(1024 维 / 8192 上下文 / 中英通用),约 640MB 一次性下载。 */
|
|
13
14
|
const DEFAULT_EMBEDDING = "local/qwen3-embedding-0.6b";
|
|
@@ -74,553 +75,20 @@ const LOCAL_EMBEDDINGS = Object.freeze([
|
|
|
74
75
|
dimension: 768
|
|
75
76
|
}
|
|
76
77
|
].map((entry) => Object.freeze(entry)));
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui.js
|
|
93
|
-
const c = `
|
|
94
|
-
.dsu-form{display:flex;flex-direction:column}
|
|
95
|
-
.dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
96
|
-
.dsu-form>.dsu-section:first-child{margin-top:0;padding-top:0;border-top:0}
|
|
97
|
-
.dsu-sectionTitle{margin:0;font-size:15px;font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary)}
|
|
98
|
-
.dsu-sectionHint{margin:4px 0 0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
99
|
-
.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)}
|
|
100
|
-
.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)}
|
|
101
|
-
.dsu-fieldMeta{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
102
|
-
.dsu-labelRow{display:flex;align-items:center;gap:6px;min-width:0}
|
|
103
|
-
.dsu-label{font-size:13px;font-weight:500;line-height:1.5;color:var(--dsw-alias-label-primary)}
|
|
104
|
-
.dsu-labelMono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}
|
|
105
|
-
.dsu-hint{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
106
|
-
.dsu-control{min-width:0;display:flex;align-items:center;gap:8px}
|
|
107
|
-
.dsu-fieldWide{grid-template-columns:minmax(0,1fr);align-items:start}
|
|
108
|
-
.dsu-fieldWide .dsu-control{width:100%;max-width:720px;margin-top:2px}
|
|
109
|
-
.dsu-help{display:inline-flex;align-items:center;gap:6px;min-width:0}
|
|
110
|
-
.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}
|
|
111
|
-
.dsu-help:hover .dsu-helpBtn,.dsu-helpBtn:focus-visible{color:var(--dsw-alias-label-primary)}
|
|
112
|
-
.dsu-helpBtn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
113
|
-
.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)}
|
|
114
|
-
.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}
|
|
115
|
-
.dsu-input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
|
|
116
|
-
.dsu-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary)}
|
|
117
|
-
.dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
118
|
-
.dsu-input::placeholder{color:var(--dsw-alias-label-tertiary)}
|
|
119
|
-
.dsu-textarea{height:auto;min-height:96px;padding:8px 12px;line-height:1.6;resize:vertical}
|
|
120
|
-
.dsu-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
121
|
-
.dsu-numberWrap{display:flex;flex-direction:column;gap:4px;width:100%;min-width:0}
|
|
122
|
-
.dsu-number{display:flex;align-items:center;gap:8px;min-width:0}
|
|
123
|
-
.dsu-number .dsu-input{min-width:0}
|
|
124
|
-
.dsu-unit{flex:none;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
125
|
-
.dsu-error{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-state-error-primary)}
|
|
126
|
-
.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}
|
|
127
|
-
.dsu-knob{width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary);transition:transform .16s,background-color .16s}
|
|
128
|
-
.dsu-switch[aria-checked="true"]{background:var(--dsw-alias-label-primary)}
|
|
129
|
-
.dsu-switch[aria-checked="true"] .dsu-knob{transform:translateX(16px);background:var(--dsw-alias-label-primary-foreground)}
|
|
130
|
-
.dsu-switch:disabled{opacity:.4;cursor:not-allowed}
|
|
131
|
-
.dsu-switch:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}
|
|
132
|
-
.dsu-selectWrap{position:relative;width:100%;min-width:0}
|
|
133
|
-
.dsu-select{display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;cursor:pointer}
|
|
134
|
-
.dsu-select[aria-expanded="true"]{border-color:var(--dsw-alias-state-business-primary)}
|
|
135
|
-
.dsu-selectValue{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
136
|
-
.dsu-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s}
|
|
137
|
-
.dsu-select[aria-expanded="true"] .dsu-chevron{transform:rotate(180deg)}
|
|
138
|
-
.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}
|
|
139
|
-
.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}
|
|
140
|
-
.dsu-option:hover,.dsu-option[data-active="true"]{background:var(--dsw-alias-bg-layer-3)}
|
|
141
|
-
.dsu-option:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
|
|
142
|
-
.dsu-option:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
|
|
143
|
-
.dsu-optionGroup{padding:6px 10px 2px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary)}
|
|
144
|
-
.dsu-check{opacity:0;flex:none}
|
|
145
|
-
.dsu-option[aria-selected="true"] .dsu-check{opacity:1}
|
|
146
|
-
.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)}
|
|
147
|
-
.dsu-savebar[data-dirty="true"]{position:sticky;bottom:0;z-index:2;box-shadow:0 -12px 24px rgb(0 0 0 / 35%)}
|
|
148
|
-
.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}
|
|
149
|
-
.dsu-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-border-l3)}
|
|
150
|
-
.dsu-btn:active:not(:disabled){background:var(--dsw-alias-bg-layer-1)}
|
|
151
|
-
.dsu-btn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
152
|
-
.dsu-btn:disabled{opacity:.4;cursor:not-allowed}
|
|
153
|
-
.dsu-btnPrimary{background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
|
|
154
|
-
.dsu-btnPrimary:hover:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.9)}
|
|
155
|
-
.dsu-btnPrimary:active:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.84)}
|
|
156
|
-
.dsu-btnDanger{color:var(--dsw-alias-state-error-primary)}
|
|
157
|
-
.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)}
|
|
158
|
-
.dsu-status{margin-left:auto;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
159
|
-
.dsu-statusError{color:var(--dsw-alias-state-error-primary)}
|
|
160
|
-
.dsu-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(200px,100%),1fr));gap:0 24px}
|
|
161
|
-
.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)}
|
|
162
|
-
.dsu-grid>.dsu-field .dsu-control{width:100%}
|
|
163
|
-
@media (max-width:640px){
|
|
164
|
-
.dsu-field{grid-template-columns:minmax(0,1fr);align-items:start}
|
|
165
|
-
.dsu-control{width:100%;max-width:720px}
|
|
166
|
-
.dsu-section{margin-top:20px;padding-top:20px}
|
|
167
|
-
}
|
|
168
|
-
@media (prefers-reduced-motion:reduce){
|
|
169
|
-
.dsu-switch,.dsu-knob,.dsu-chevron,.dsu-btn{transition:none}
|
|
170
|
-
}
|
|
171
|
-
`;
|
|
172
|
-
function l(e, t = 30) {
|
|
173
|
-
return e.length <= t ? { hint: e } : { detail: e };
|
|
174
|
-
}
|
|
175
|
-
function u(t) {
|
|
176
|
-
return (0, react.createElement)(`div`, { className: `dsu-form` }, t.children);
|
|
177
|
-
}
|
|
178
|
-
function d(t) {
|
|
179
|
-
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);
|
|
180
|
-
}
|
|
181
|
-
function m(a) {
|
|
182
|
-
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)(() => {
|
|
183
|
-
v.current !== null && (clearTimeout(v.current), v.current = null);
|
|
184
|
-
}, []), b = (0, react.useCallback)(() => {
|
|
185
|
-
let e = g.current, t = _.current;
|
|
186
|
-
/* v8 ignore next 3 -- place 只在 open 的 layout effect 与挂载期监听器里调用;refs 为空只可能是卸载竞态 */
|
|
187
|
-
if (e === null || t === null) return;
|
|
188
|
-
let n = e.getBoundingClientRect(), r = t.offsetWidth, i = t.offsetHeight, { left: a } = n, o = n.bottom + 8;
|
|
189
|
-
o + i > window.innerHeight - 8 && (o = n.top - i - 8), a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
|
|
190
|
-
let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - i - 8);
|
|
191
|
-
t.style.left = `${Math.min(Math.max(8, a), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
|
|
192
|
-
}, []), x = (0, react.useCallback)(() => {
|
|
193
|
-
y(), h.current = !1, f(!1), u(!1);
|
|
194
|
-
}, [y]), S = (0, react.useCallback)(() => {
|
|
195
|
-
y(), u(!0);
|
|
196
|
-
}, [y]), C = (0, react.useCallback)(() => {
|
|
197
|
-
y(), !(p.current || m.current || h.current) && (v.current = setTimeout(() => {
|
|
198
|
-
/* v8 ignore next 3 -- 任何重新进入/钉住都会 cancelHide;这次复查只防未来的异步路径 */
|
|
199
|
-
v.current = null, p.current || m.current || h.current || u(!1);
|
|
200
|
-
}, 120));
|
|
201
|
-
}, [y]), w = (0, react.useCallback)((e) => {
|
|
202
|
-
h.current = e, f(e);
|
|
203
|
-
}, []);
|
|
204
|
-
(0, react.useLayoutEffect)(() => {
|
|
205
|
-
if (!l) return () => {};
|
|
206
|
-
b();
|
|
207
|
-
let e = (e) => {
|
|
208
|
-
let { target: t } = e;
|
|
209
|
-
t instanceof Node && _.current?.contains(t) === !0 || (h.current ? b() : x());
|
|
210
|
-
}, t = () => {
|
|
211
|
-
b();
|
|
212
|
-
};
|
|
213
|
-
return window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
|
|
214
|
-
window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
|
|
215
|
-
};
|
|
216
|
-
}, [
|
|
217
|
-
l,
|
|
218
|
-
a.detail,
|
|
219
|
-
b,
|
|
220
|
-
x
|
|
221
|
-
]), (0, react.useEffect)(() => {
|
|
222
|
-
if (!l) return () => {};
|
|
223
|
-
let e = (e) => {
|
|
224
|
-
e.key === `Escape` && x();
|
|
225
|
-
};
|
|
226
|
-
return document.addEventListener(`keydown`, e), () => {
|
|
227
|
-
document.removeEventListener(`keydown`, e);
|
|
228
|
-
};
|
|
229
|
-
}, [l, x]), (0, react.useEffect)(() => y, [y]);
|
|
230
|
-
let T = (0, react.createElement)(`button`, {
|
|
231
|
-
ref: g,
|
|
232
|
-
type: `button`,
|
|
233
|
-
className: `dsu-helpBtn`,
|
|
234
|
-
"aria-label": `${a.label} 说明`,
|
|
235
|
-
"aria-describedby": c,
|
|
236
|
-
"aria-pressed": d,
|
|
237
|
-
onClick: () => {
|
|
238
|
-
h.current ? x() : (w(!0), S());
|
|
239
|
-
}
|
|
240
|
-
}, (0, react.createElement)(`svg`, {
|
|
241
|
-
width: 12,
|
|
242
|
-
height: 12,
|
|
243
|
-
viewBox: `0 0 14 14`,
|
|
244
|
-
"aria-hidden": !0
|
|
245
|
-
}, (0, react.createElement)(`circle`, {
|
|
246
|
-
cx: 7,
|
|
247
|
-
cy: 7,
|
|
248
|
-
r: 6,
|
|
249
|
-
fill: `none`,
|
|
250
|
-
stroke: `currentColor`,
|
|
251
|
-
strokeWidth: 1.2
|
|
252
|
-
}), (0, react.createElement)(`path`, {
|
|
253
|
-
d: `M7 6.2v4`,
|
|
254
|
-
stroke: `currentColor`,
|
|
255
|
-
strokeWidth: 1.3,
|
|
256
|
-
strokeLinecap: `round`
|
|
257
|
-
}), (0, react.createElement)(`circle`, {
|
|
258
|
-
cx: 7,
|
|
259
|
-
cy: 4.3,
|
|
260
|
-
r: .8,
|
|
261
|
-
fill: `currentColor`
|
|
262
|
-
}))), E = (0, react.createElement)(`div`, {
|
|
263
|
-
ref: _,
|
|
264
|
-
id: c,
|
|
265
|
-
role: `tooltip`,
|
|
266
|
-
className: `dsu-tip`,
|
|
267
|
-
hidden: !l
|
|
268
|
-
}, a.detail), D = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
|
|
269
|
-
return (0, react.createElement)(`span`, {
|
|
270
|
-
className: `dsu-help`,
|
|
271
|
-
onMouseEnter: () => {
|
|
272
|
-
p.current = !0, S();
|
|
273
|
-
},
|
|
274
|
-
onMouseLeave: () => {
|
|
275
|
-
p.current = !1, C();
|
|
276
|
-
},
|
|
277
|
-
onFocus: () => {
|
|
278
|
-
m.current = !0, S();
|
|
279
|
-
},
|
|
280
|
-
onBlur: (e) => {
|
|
281
|
-
let t = e.relatedTarget;
|
|
282
|
-
t instanceof Node && e.currentTarget.contains(t) || (m.current = !1, C());
|
|
283
|
-
}
|
|
284
|
-
}, D, T, E);
|
|
285
|
-
}
|
|
286
|
-
function h(t) {
|
|
287
|
-
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`, {
|
|
288
|
-
className: n,
|
|
289
|
-
htmlFor: t.controlId
|
|
290
|
-
}, t.label);
|
|
291
|
-
return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(m, {
|
|
292
|
-
label: t.label,
|
|
293
|
-
detail: t.detail,
|
|
294
|
-
showLabel: !1
|
|
295
|
-
}));
|
|
296
|
-
}
|
|
297
|
-
function g(t) {
|
|
298
|
-
let n = t.controlId === void 0 ? void 0 : `${t.controlId}-hint`;
|
|
299
|
-
return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(h, {
|
|
300
|
-
label: t.label,
|
|
301
|
-
detail: t.detail,
|
|
302
|
-
compact: t.compact,
|
|
303
|
-
controlId: t.controlId
|
|
304
|
-
}), t.hint === void 0 ? null : (0, react.createElement)(`p`, {
|
|
305
|
-
className: `dsu-hint`,
|
|
306
|
-
id: n
|
|
307
|
-
}, t.hint)), (0, react.createElement)(`div`, { className: `dsu-control` }, t.children));
|
|
308
|
-
}
|
|
309
|
-
function _(t) {
|
|
310
|
-
let n = (0, react.useId)(), i = t.hint === void 0 ? void 0 : `${n}-hint`;
|
|
311
|
-
return (0, react.createElement)(g, {
|
|
312
|
-
...t,
|
|
313
|
-
controlId: n
|
|
314
|
-
}, (0, react.createElement)(`button`, {
|
|
315
|
-
type: `button`,
|
|
316
|
-
role: `switch`,
|
|
317
|
-
id: n,
|
|
318
|
-
className: `dsu-switch`,
|
|
319
|
-
"aria-checked": t.checked,
|
|
320
|
-
"aria-describedby": i,
|
|
321
|
-
"data-field": t.field,
|
|
322
|
-
disabled: t.disabled === !0,
|
|
323
|
-
onClick: () => {
|
|
324
|
-
t.onChange(!t.checked);
|
|
325
|
-
}
|
|
326
|
-
}, (0, react.createElement)(`span`, { className: `dsu-knob` })));
|
|
327
|
-
}
|
|
328
|
-
function v(t) {
|
|
329
|
-
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(` `);
|
|
330
|
-
(0, react.useEffect)(() => {
|
|
331
|
-
t.value !== d.current && (d.current = t.value, c(i), u(!1));
|
|
332
|
-
}, [t.value, i]);
|
|
333
|
-
let _ = (e) => {
|
|
334
|
-
let n = t.min ?? -1 / 0, r = t.max ?? 1 / 0;
|
|
335
|
-
if (!Number.isFinite(e) || e < n || e > r) return !1;
|
|
336
|
-
let { step: i } = t;
|
|
337
|
-
if (i === void 0 || i <= 0) return !0;
|
|
338
|
-
let a = (e - (t.min ?? 0)) / i;
|
|
339
|
-
return Math.abs(a - Math.round(a)) < 1e-9;
|
|
340
|
-
}, v = (e) => {
|
|
341
|
-
if (c(e), e === ``) {
|
|
342
|
-
u(!1), d.current = void 0, t.onChange(void 0);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
let n = Number(e);
|
|
346
|
-
_(n) ? (u(!1), d.current = n, t.onChange(n)) : u(!0);
|
|
347
|
-
}, y = () => {
|
|
348
|
-
a === `` || l || c(String(Number(a)));
|
|
349
|
-
};
|
|
350
|
-
return (0, react.createElement)(g, {
|
|
351
|
-
...t,
|
|
352
|
-
controlId: f
|
|
353
|
-
}, (0, react.createElement)(`div`, { className: `dsu-numberWrap` }, (0, react.createElement)(`div`, { className: `dsu-number` }, (0, react.createElement)(`input`, {
|
|
354
|
-
className: `dsu-input`,
|
|
355
|
-
type: `number`,
|
|
356
|
-
inputMode: `numeric`,
|
|
357
|
-
id: f,
|
|
358
|
-
value: a,
|
|
359
|
-
min: t.min,
|
|
360
|
-
max: t.max,
|
|
361
|
-
step: t.step,
|
|
362
|
-
placeholder: t.placeholder,
|
|
363
|
-
"aria-invalid": l || void 0,
|
|
364
|
-
"aria-describedby": h,
|
|
365
|
-
"data-field": t.field,
|
|
366
|
-
disabled: t.disabled === !0,
|
|
367
|
-
onChange: (e) => {
|
|
368
|
-
v(e.target.value);
|
|
369
|
-
},
|
|
370
|
-
onBlur: y
|
|
371
|
-
}), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), l ? (0, react.createElement)(`p`, {
|
|
372
|
-
className: `dsu-error`,
|
|
373
|
-
id: p
|
|
374
|
-
}, t.invalidHint) : null));
|
|
375
|
-
}
|
|
376
|
-
function y(t) {
|
|
377
|
-
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`;
|
|
378
|
-
(0, react.useEffect)(() => {
|
|
379
|
-
o || a(t.value);
|
|
380
|
-
}, [t.value, o]);
|
|
381
|
-
let d = {
|
|
382
|
-
id: l,
|
|
383
|
-
className: `dsu-input${t.multiline === !0 ? ` dsu-textarea` : ``}${t.monospace === !0 ? ` dsu-mono` : ``}`,
|
|
384
|
-
value: i,
|
|
385
|
-
placeholder: t.placeholder,
|
|
386
|
-
"aria-describedby": u,
|
|
387
|
-
"data-field": t.field,
|
|
388
|
-
disabled: t.disabled === !0,
|
|
389
|
-
onFocus: () => {
|
|
390
|
-
c(!0);
|
|
391
|
-
},
|
|
392
|
-
onBlur: () => {
|
|
393
|
-
c(!1);
|
|
394
|
-
},
|
|
395
|
-
onChange: (e) => {
|
|
396
|
-
a(e.target.value), t.onChange(e.target.value);
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
return (0, react.createElement)(g, {
|
|
400
|
-
...t,
|
|
401
|
-
controlId: l
|
|
402
|
-
}, t.multiline === !0 ? (0, react.createElement)(`textarea`, d) : (0, react.createElement)(`input`, d));
|
|
403
|
-
}
|
|
404
|
-
function x(c) {
|
|
405
|
-
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) => ({
|
|
406
|
-
option: e,
|
|
407
|
-
index: t
|
|
408
|
-
})).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)(() => {
|
|
409
|
-
let e = p.current, t = m.current;
|
|
410
|
-
/* v8 ignore next 3 -- place 只在 open 的 layout effect 里调用;refs 为空只可能是卸载竞态 */
|
|
411
|
-
if (e === null || t === null) return;
|
|
412
|
-
let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16), { left: i } = n;
|
|
413
|
-
i + r > window.innerWidth - 8 && (i = window.innerWidth - r - 8);
|
|
414
|
-
let a = t.offsetHeight, o = n.bottom + 6;
|
|
415
|
-
o + a > window.innerHeight - 8 && (o = n.top - a - 6);
|
|
416
|
-
let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - a - 8);
|
|
417
|
-
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`;
|
|
418
|
-
}, []), O = (0, react.useCallback)(() => {
|
|
419
|
-
u(!1);
|
|
420
|
-
}, []), k = (0, react.useCallback)(() => {
|
|
421
|
-
if (y === !0) return;
|
|
422
|
-
let e = C.find((e) => e.option.value === b) ?? C.at(0);
|
|
423
|
-
e !== void 0 && (f(e.index), u(!0));
|
|
424
|
-
}, [
|
|
425
|
-
y,
|
|
426
|
-
b,
|
|
427
|
-
C
|
|
428
|
-
]), A = (0, react.useCallback)((e) => {
|
|
429
|
-
/* v8 ignore next 3 -- 浮层只能经由 openMenu 打开;组件禁用时打不开 */
|
|
430
|
-
if (y === !0) return;
|
|
431
|
-
let t = x[e];
|
|
432
|
-
/* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click;越界下标由调用面保证 */
|
|
433
|
-
t !== void 0 && t.disabled !== !0 && (S(t.value), O(), p.current?.focus());
|
|
434
|
-
}, [
|
|
435
|
-
y,
|
|
436
|
-
x,
|
|
437
|
-
S,
|
|
438
|
-
O
|
|
439
|
-
]), j = (0, react.useCallback)((e) => {
|
|
440
|
-
let t = C.findIndex((e) => e.index === d);
|
|
441
|
-
/* v8 ignore next 5 -- open 时归一 effect 已保证 enabled 非空且 active 落在可用项上 */
|
|
442
|
-
if (t === -1 || C.length === 0) return;
|
|
443
|
-
let n = (t + e + C.length) % C.length, r = C[n];
|
|
444
|
-
/* v8 ignore next 3 -- next 由取模保证在界内 */
|
|
445
|
-
r !== void 0 && f(r.index);
|
|
446
|
-
}, [d, C]);
|
|
447
|
-
(0, react.useLayoutEffect)(() => {
|
|
448
|
-
if (!l) return () => {};
|
|
449
|
-
D();
|
|
450
|
-
let e = (e) => {
|
|
451
|
-
let t = e.target;
|
|
452
|
-
m.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && O();
|
|
453
|
-
}, t = (e) => {
|
|
454
|
-
let { target: t } = e;
|
|
455
|
-
t instanceof Node && m.current?.contains(t) === !0 || O();
|
|
456
|
-
}, n = () => {
|
|
457
|
-
D();
|
|
458
|
-
};
|
|
459
|
-
return document.addEventListener(`pointerdown`, e, !0), window.addEventListener(`scroll`, t, !0), window.addEventListener(`resize`, n), () => {
|
|
460
|
-
document.removeEventListener(`pointerdown`, e, !0), window.removeEventListener(`scroll`, t, !0), window.removeEventListener(`resize`, n);
|
|
461
|
-
};
|
|
462
|
-
}, [
|
|
463
|
-
l,
|
|
464
|
-
c.options,
|
|
465
|
-
D,
|
|
466
|
-
O
|
|
467
|
-
]), (0, react.useEffect)(() => {
|
|
468
|
-
if (!l) return;
|
|
469
|
-
if (y === !0 || C.length === 0) {
|
|
470
|
-
O();
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
if (C.some((e) => e.index === d)) return;
|
|
474
|
-
let e = C.find((e) => e.option.value === b) ?? C.at(0);
|
|
475
|
-
/* v8 ignore next 3 -- enabled 非空在上一分支已保证 */
|
|
476
|
-
e !== void 0 && f(e.index);
|
|
477
|
-
}, [
|
|
478
|
-
l,
|
|
479
|
-
y,
|
|
480
|
-
b,
|
|
481
|
-
x,
|
|
482
|
-
d,
|
|
483
|
-
O,
|
|
484
|
-
C
|
|
485
|
-
]), (0, react.useLayoutEffect)(() => {
|
|
486
|
-
if (!l) return;
|
|
487
|
-
let e = m.current;
|
|
488
|
-
/* v8 ignore next 2 -- 同上,menu 在 open 的 commit 之后必然已挂上 */
|
|
489
|
-
if (e === null) return;
|
|
490
|
-
let t = e.querySelector(`[data-active="true"]`);
|
|
491
|
-
/* v8 ignore next 2 -- active 已由归一 effect 保证落在可用项上 */
|
|
492
|
-
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));
|
|
493
|
-
}, [
|
|
494
|
-
l,
|
|
495
|
-
d,
|
|
496
|
-
x
|
|
497
|
-
]);
|
|
498
|
-
let M = (e) => {
|
|
499
|
-
if (e.key === `ArrowDown` || e.key === `ArrowUp`) {
|
|
500
|
-
if (e.preventDefault(), !l) {
|
|
501
|
-
k();
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
j(e.key === `ArrowDown` ? 1 : -1);
|
|
505
|
-
} else if (e.key === `Home` || e.key === `End`) {
|
|
506
|
-
if (e.preventDefault(), l || k(), C.length === 0) return;
|
|
507
|
-
let t = e.key === `Home` ? C.at(0) : C.at(-1);
|
|
508
|
-
/* v8 ignore next 3 -- enabled 为空已在上一条返回 */
|
|
509
|
-
if (t === void 0) return;
|
|
510
|
-
f(t.index);
|
|
511
|
-
} else if (e.key === `Enter` || e.key === ` `) {
|
|
512
|
-
if (e.preventDefault(), !l) {
|
|
513
|
-
k();
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
A(d);
|
|
517
|
-
} else (e.key === `Tab` || e.key === `Escape`) && O();
|
|
518
|
-
}, N = [], P;
|
|
519
|
-
for (let [t, n] of x.entries()) n.group !== P && (n.group !== void 0 && N.push((0, react.createElement)(`div`, {
|
|
520
|
-
key: `group-${t}-${n.group}`,
|
|
521
|
-
className: `dsu-optionGroup`,
|
|
522
|
-
role: `presentation`
|
|
523
|
-
}, n.group)), P = n.group), N.push((0, react.createElement)(`button`, {
|
|
524
|
-
key: `option-${n.value}`,
|
|
525
|
-
type: `button`,
|
|
526
|
-
role: `option`,
|
|
527
|
-
id: `${h}-${t}`,
|
|
528
|
-
className: `dsu-option`,
|
|
529
|
-
tabIndex: -1,
|
|
530
|
-
"aria-selected": n.value === c.value,
|
|
531
|
-
"data-active": t === d,
|
|
532
|
-
disabled: n.disabled === !0,
|
|
533
|
-
onMouseDown: (e) => {
|
|
534
|
-
e.preventDefault();
|
|
535
|
-
},
|
|
536
|
-
onClick: () => {
|
|
537
|
-
A(t);
|
|
538
|
-
},
|
|
539
|
-
onMouseEnter: () => {
|
|
540
|
-
/* v8 ignore next -- happy-dom 对 disabled 元素不派发 mouse 事件;浏览器实现各有差异,保留禁用检查 */
|
|
541
|
-
n.disabled !== !0 && f(t);
|
|
542
|
-
}
|
|
543
|
-
}, (0, react.createElement)(`span`, null, n.label), (0, react.createElement)(`svg`, {
|
|
544
|
-
className: `dsu-check`,
|
|
545
|
-
width: 14,
|
|
546
|
-
height: 14,
|
|
547
|
-
viewBox: `0 0 14 14`,
|
|
548
|
-
"aria-hidden": !0
|
|
549
|
-
}, (0, react.createElement)(`path`, {
|
|
550
|
-
d: `M2.5 7.5l3 3 6-7`,
|
|
551
|
-
fill: `none`,
|
|
552
|
-
stroke: `currentColor`,
|
|
553
|
-
strokeWidth: 1.5,
|
|
554
|
-
strokeLinecap: `round`,
|
|
555
|
-
strokeLinejoin: `round`
|
|
556
|
-
}))));
|
|
557
|
-
return (0, react.createElement)(g, {
|
|
558
|
-
...c,
|
|
559
|
-
controlId: _
|
|
560
|
-
}, (0, react.createElement)(`div`, {
|
|
561
|
-
className: `dsu-selectWrap`,
|
|
562
|
-
onBlur: (e) => {
|
|
563
|
-
let t = e.relatedTarget;
|
|
564
|
-
t instanceof Node && e.currentTarget.contains(t) || O();
|
|
565
|
-
}
|
|
566
|
-
}, (0, react.createElement)(`button`, {
|
|
567
|
-
ref: p,
|
|
568
|
-
type: `button`,
|
|
569
|
-
id: _,
|
|
570
|
-
className: `dsu-select dsu-input`,
|
|
571
|
-
role: `combobox`,
|
|
572
|
-
"aria-haspopup": `listbox`,
|
|
573
|
-
"aria-expanded": l,
|
|
574
|
-
"aria-controls": `${h}-list`,
|
|
575
|
-
"aria-activedescendant": l && E ? `${h}-${d}` : void 0,
|
|
576
|
-
"aria-describedby": v,
|
|
577
|
-
"data-field": c.field,
|
|
578
|
-
disabled: y === !0 || x.length === 0,
|
|
579
|
-
onClick: () => {
|
|
580
|
-
l ? O() : k();
|
|
581
|
-
},
|
|
582
|
-
onKeyDown: M
|
|
583
|
-
}, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, w), (0, react.createElement)(`svg`, {
|
|
584
|
-
className: `dsu-chevron`,
|
|
585
|
-
width: 14,
|
|
586
|
-
height: 14,
|
|
587
|
-
viewBox: `0 0 14 14`,
|
|
588
|
-
"aria-hidden": !0
|
|
589
|
-
}, (0, react.createElement)(`path`, {
|
|
590
|
-
d: `M3 5l4 4 4-4`,
|
|
591
|
-
fill: `none`,
|
|
592
|
-
stroke: `currentColor`,
|
|
593
|
-
strokeWidth: 1.5,
|
|
594
|
-
strokeLinecap: `round`,
|
|
595
|
-
strokeLinejoin: `round`
|
|
596
|
-
}))), (0, react.createElement)(`div`, {
|
|
597
|
-
ref: m,
|
|
598
|
-
id: `${h}-list`,
|
|
599
|
-
role: `listbox`,
|
|
600
|
-
className: `dsu-menu`,
|
|
601
|
-
"aria-label": c.label,
|
|
602
|
-
hidden: !l
|
|
603
|
-
}, ...N)));
|
|
604
|
-
}
|
|
605
|
-
function S(t) {
|
|
606
|
-
let n = !t.writable || t.busy || !t.dirty, r;
|
|
607
|
-
return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
|
|
608
|
-
className: `dsu-savebar`,
|
|
609
|
-
"data-dirty": t.dirty
|
|
610
|
-
}, (0, react.createElement)(`button`, {
|
|
611
|
-
type: `button`,
|
|
612
|
-
className: `dsu-btn dsu-btnPrimary`,
|
|
613
|
-
"data-field": `save`,
|
|
614
|
-
disabled: n,
|
|
615
|
-
onClick: t.onSave
|
|
616
|
-
}, t.busy ? t.savingLabel : t.saveLabel), (0, react.createElement)(`button`, {
|
|
617
|
-
type: `button`,
|
|
618
|
-
className: `dsu-btn`,
|
|
619
|
-
"data-field": `discard`,
|
|
620
|
-
disabled: n,
|
|
621
|
-
onClick: t.onDiscard
|
|
622
|
-
}, t.revertLabel), (0, react.createElement)(`span`, { className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError` }, r));
|
|
623
|
-
}
|
|
78
|
+
const REMOTE_EMBEDDING_CATALOG = Object.freeze([
|
|
79
|
+
{
|
|
80
|
+
reference: "qwen/qwen3-vl-embedding",
|
|
81
|
+
dimension: 2560
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
reference: "qwen/qwen3.7-text-embedding",
|
|
85
|
+
dimension: 1024
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
reference: "qwen/text-embedding-v4",
|
|
89
|
+
dimension: 1024
|
|
90
|
+
}
|
|
91
|
+
].map((entry) => Object.freeze(entry)));
|
|
624
92
|
// lib/card-draft.ts
|
|
625
93
|
/** 草稿优先取值:touched 有该键(哪怕值是 undefined=待清空)即用草稿。
|
|
626
94
|
* 两层都只判**自有**属性:本函数收任意字段名,`in`/裸下标会沿原型链命中 `toString` /
|
|
@@ -640,7 +108,7 @@ function numberText(raw, fallback) {
|
|
|
640
108
|
/**
|
|
641
109
|
* 引导端点交回的守护进程就绪态该显示哪一行。
|
|
642
110
|
*
|
|
643
|
-
* `undefined`
|
|
111
|
+
* `undefined` 是**必需**的一种取值,不是兜底默认:旧版 host 的应答里没有 `serverReady` 这个字段,
|
|
644
112
|
* 而「应答里没写」与「写了未就绪」是两件事——把前者显示成后者,卡片就在用户眼前谎称了一次
|
|
645
113
|
* 「没有守护进程」。判据收在可单测的这一层,client 只负责渲染它选出来的那一行。
|
|
646
114
|
*
|
|
@@ -715,17 +183,19 @@ function endpointFieldDisplay(touched, value) {
|
|
|
715
183
|
const committed = value["hfEndpoint"];
|
|
716
184
|
return typeof committed === "string" && HTTP_URL_SCHEMA.safeParse(committed).success ? committed : "";
|
|
717
185
|
}
|
|
718
|
-
/**
|
|
186
|
+
/** 七个字段的草稿显示值(ZgCard 只渲染这里算出来的东西)。 */
|
|
719
187
|
function draftFields(touched, value) {
|
|
720
188
|
const embedding = draftOf(touched, value, "defaultEmbedding");
|
|
721
189
|
const enforce = draftOf(touched, value, "enforceSearchFirst");
|
|
190
|
+
const transport = draftOf(touched, value, "transport");
|
|
722
191
|
return {
|
|
723
192
|
embedding: typeof embedding === "string" && embedding.length > 0 ? embedding : DEFAULT_EMBEDDING,
|
|
724
193
|
limitDisplay: numericFieldDisplay(touched, value, "defaultLimit", String(10)),
|
|
725
194
|
hfEndpoint: endpointFieldDisplay(touched, value),
|
|
726
195
|
enforceSearchFirst: enforce !== false,
|
|
727
196
|
grepBudget: numericFieldDisplay(touched, value, "grepBudgetPerSearch", String(3)),
|
|
728
|
-
unlockWindow: numericFieldDisplay(touched, value, "unlockWindowMin", String(10))
|
|
197
|
+
unlockWindow: numericFieldDisplay(touched, value, "unlockWindowMin", String(10)),
|
|
198
|
+
transport: transport === "cli" || transport === "mcp" || transport === "auto" ? transport : "auto"
|
|
729
199
|
};
|
|
730
200
|
}
|
|
731
201
|
const LIMIT_SCHEMA = zod.z.int().min(1).max(50);
|
|
@@ -777,10 +247,6 @@ function parseRebuildPoll(body, t) {
|
|
|
777
247
|
output: outputText.length > 0 ? `${reason}\n${outputText}` : reason
|
|
778
248
|
};
|
|
779
249
|
}
|
|
780
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
|
|
781
|
-
function e(e) {
|
|
782
|
-
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
783
|
-
}
|
|
784
250
|
// src/rebuild-reader.ts
|
|
785
251
|
const REBUILD_NAMESPACE = "zvecGrepRebuild";
|
|
786
252
|
/** 网关给命名空间注册的**服务键**:`remote.<namespace>`。它在 `$mount` 完成之后才存在,
|
|
@@ -788,7 +254,7 @@ const REBUILD_NAMESPACE = "zvecGrepRebuild";
|
|
|
788
254
|
const REBUILD_SERVICE_KEY = `remote.${REBUILD_NAMESPACE}`;
|
|
789
255
|
/** 卡片所在 bundle 的包名(`$mount` 的 `package` 位与槽位键同源,见 client-entry.ts 的 BUNDLE_PKG)。 */
|
|
790
256
|
const PACKAGE_NAME = "@jayyuen66/dsh-zvec-grep";
|
|
791
|
-
/** strict codec
|
|
257
|
+
/** strict codec 的统一的返回点:失败交给 zod 的 `prettifyError`,读到的是一份带字段路径的说明。 */
|
|
792
258
|
function parseOrThrow(schema, value) {
|
|
793
259
|
const parsed = schema.safeParse(value);
|
|
794
260
|
if (!parsed.success) throw new TypeError(zod.z.prettifyError(parsed.error));
|
|
@@ -796,7 +262,7 @@ function parseOrThrow(schema, value) {
|
|
|
796
262
|
}
|
|
797
263
|
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" });
|
|
798
264
|
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" });
|
|
799
|
-
/**
|
|
265
|
+
/** 把宿主那三个方法挂到客户端远程通道上的描述符(`id` 的形状照生成器:`<包>#<命名空间>/<方法>`)。
|
|
800
266
|
* 导出它只为一件事:`test/rebuild-remote.test.ts` 拿它与宿主侧 `remoteMethods()` 的标记对质
|
|
801
267
|
* —— 两侧分叉时卡片不会报错,只会"读不到",所以那条比较必须在门禁里。 */
|
|
802
268
|
const REBUILD_DESCRIPTORS = [
|
|
@@ -850,10 +316,10 @@ const REBUILD_DESCRIPTORS = [
|
|
|
850
316
|
result: { mode: "src-json" }
|
|
851
317
|
}
|
|
852
318
|
];
|
|
853
|
-
/**
|
|
854
|
-
const isRemoteMounter = (value) =>
|
|
319
|
+
/** 这个值能当远程通道用吗(只核我们要调的那一位;服务来自别的实现或版本时保守当作没有)。 */
|
|
320
|
+
const isRemoteMounter = (value) => (0, _jayyuen66_dsh_plugin_shared_client.isRecord)(value) && typeof value["$mount"] === "function";
|
|
855
321
|
/** 同上:命名空间服务(挂载之后才有,缺它说明网关没认这枚贡献)。 */
|
|
856
|
-
const isRebuildNamespace = (value) =>
|
|
322
|
+
const isRebuildNamespace = (value) => (0, _jayyuen66_dsh_plugin_shared_client.isRecord)(value) && typeof value["roots"] === "function" && typeof value["rebuild"] === "function" && typeof value["status"] === "function";
|
|
857
323
|
/**
|
|
858
324
|
* 线上拒绝(result.ok=false)翻成异常:code 与 message 都来自网关的错误对象。
|
|
859
325
|
* 三个方法同构,收成一个入口——同一份判据,不抄三份。
|
|
@@ -868,11 +334,11 @@ async function unwrapWire(call) {
|
|
|
868
334
|
* @param ctx - 客户端上下文
|
|
869
335
|
* @returns 读取器
|
|
870
336
|
*/
|
|
871
|
-
function buildRebuildReader(ctx) {
|
|
337
|
+
function buildRebuildReader(ctx, messages) {
|
|
872
338
|
let mounted;
|
|
873
339
|
const namespaceOf = async () => {
|
|
874
340
|
const mounter = ctx.get?.("remote");
|
|
875
|
-
if (!isRemoteMounter(mounter)) throw new Error(
|
|
341
|
+
if (!isRemoteMounter(mounter)) throw new Error(messages.remoteMissing());
|
|
876
342
|
try {
|
|
877
343
|
mounted ??= mounter.$mount({
|
|
878
344
|
package: PACKAGE_NAME,
|
|
@@ -884,7 +350,7 @@ function buildRebuildReader(ctx) {
|
|
|
884
350
|
throw error;
|
|
885
351
|
}
|
|
886
352
|
const namespace = ctx.get?.(REBUILD_SERVICE_KEY);
|
|
887
|
-
if (!isRebuildNamespace(namespace)) throw new Error(
|
|
353
|
+
if (!isRebuildNamespace(namespace)) throw new Error(messages.namespaceMissing(REBUILD_SERVICE_KEY));
|
|
888
354
|
return namespace;
|
|
889
355
|
};
|
|
890
356
|
return {
|
|
@@ -914,8 +380,8 @@ function buildRebuildReader(ctx) {
|
|
|
914
380
|
* @param ctx - 客户端上下文(只用 `get` 一位)
|
|
915
381
|
* @returns 读取器;ctx 没有 get 面时 `undefined`
|
|
916
382
|
*/
|
|
917
|
-
function createRebuildReader(ctx) {
|
|
918
|
-
return typeof ctx.get === "function" ? buildRebuildReader(ctx) : void 0;
|
|
383
|
+
function createRebuildReader(ctx, messages) {
|
|
384
|
+
return typeof ctx.get === "function" ? buildRebuildReader(ctx, messages) : void 0;
|
|
919
385
|
}
|
|
920
386
|
// src/ui-messages.ts
|
|
921
387
|
/** 推荐的 embedding 模型镜像(endpointHint 与 client-entry 的 placeholder 共用)。 */
|
|
@@ -936,8 +402,14 @@ const UI_MESSAGES = {
|
|
|
936
402
|
unitTimes: "次",
|
|
937
403
|
unitMinutes: "分钟",
|
|
938
404
|
outOfRange: "超出允许范围,未保存",
|
|
939
|
-
embeddingLabel: "
|
|
940
|
-
embeddingHint: "
|
|
405
|
+
embeddingLabel: "默认 embedding",
|
|
406
|
+
embeddingHint: "本地模型直接可选;远程 qwen 模型需在插件部署配置里打开 allowRemoteEmbedding(内容会送往外部端点,首次索引需 zg --auth grant 授权)。只影响「新建」索引;切换并保存后,已有索引需点下方「重建」重新 embedding",
|
|
407
|
+
transportLabel: "检索传输方式",
|
|
408
|
+
transportHint: "自动 = 守护进程在跑时检索走 MCP(常驻模型池、队列调度),否则走 CLI;仅 CLI = 永不碰守护进程;仅 MCP = 检索恒走守护进程,缺席时由插件自动拉起(会开 127.0.0.1:7999 回环端口;拉起失败会明确报错而不是回退 CLI)",
|
|
409
|
+
transportAuto: "自动(守护进程在跑走 MCP,否则 CLI)",
|
|
410
|
+
transportCli: "仅 CLI(每次 spawn zg 进程)",
|
|
411
|
+
transportMcp: "仅 MCP(走守护进程,缺席自动拉起)",
|
|
412
|
+
backendRemote: "qwen 远程(内容出本机,需部署开放并授权)",
|
|
941
413
|
limitLabel: "默认每组结果数",
|
|
942
414
|
limitInvalid: "请输入 {min}-{max} 的整数",
|
|
943
415
|
limitClamped: "已钳到 {min}-{max} 范围:{value}",
|
|
@@ -951,9 +423,9 @@ const UI_MESSAGES = {
|
|
|
951
423
|
windowHint: "超过该时长未再次 zg_search,配额整体过期;清空恢复默认 {default}(单位:分钟)",
|
|
952
424
|
rebuildLabel: "工作区重建(切换 embedding 并保存后执行)",
|
|
953
425
|
rebuildInputPlaceholder: "/workspace 的绝对路径",
|
|
954
|
-
daemonReadyNote: "守护进程:就绪(zg server 在跑)。",
|
|
955
|
-
daemonOfflineNote: "守护进程:未就绪。守护进程提供的索引增量刷新、refresh=background 与常驻模型池在缺席时都不可用;需要时在终端执行 `zg server on`。",
|
|
956
|
-
rebuildHint: "以当前默认模型重建:{embedding};等价于 zg index --rebuild。{roots}",
|
|
426
|
+
daemonReadyNote: "守护进程:就绪(zg --server 在跑)。",
|
|
427
|
+
daemonOfflineNote: "守护进程:未就绪。守护进程提供的索引增量刷新、refresh=background 与常驻模型池在缺席时都不可用;需要时在终端执行 `zg --server on`。",
|
|
428
|
+
rebuildHint: "以当前默认模型重建:{embedding};等价于 zg --index --rebuild。{roots}",
|
|
957
429
|
rootsNoteWith: "候选工作区来自本 daemon 已打开过的会话(服务端白名单)。",
|
|
958
430
|
rootsNoteEmpty: "尚无可选工作区:先在该工作区里开一个会话(任一次工具调用即登记)。",
|
|
959
431
|
rebuildButton: "重建索引(动作,点击即执行)",
|
|
@@ -967,6 +439,8 @@ const UI_MESSAGES = {
|
|
|
967
439
|
rebuildMissingJobId: "启动重建失败:应答缺 jobId",
|
|
968
440
|
rebuildRootNotAbsolute: "root 必须是绝对路径(以 / 开头)",
|
|
969
441
|
rebuildUnavailable: "宿主没有提供工作区重建读面(未装远程服务)",
|
|
442
|
+
rebuildRemoteMissing: "工作区重建读面不可用:宿主网关没有提供 remote 服务",
|
|
443
|
+
rebuildNamespaceMissing: "{serviceKey} 未提供:宿主网关没有挂上这枚命名空间",
|
|
970
444
|
modelOption: "{reference}({dimension}维)",
|
|
971
445
|
backendLlamaCpp: "llama-cpp(原生,需 node-llama-cpp)",
|
|
972
446
|
backendTransformersJs: "transformers-js(纯 JS ONNX)",
|
|
@@ -987,8 +461,14 @@ const UI_MESSAGES = {
|
|
|
987
461
|
unitTimes: "times",
|
|
988
462
|
unitMinutes: "minutes",
|
|
989
463
|
outOfRange: "Out of the allowed range — not saved",
|
|
990
|
-
embeddingLabel: "Default
|
|
991
|
-
embeddingHint: "Affects newly built indexes only; after switching and saving, press Rebuild below to re-embed existing indexes",
|
|
464
|
+
embeddingLabel: "Default embedding",
|
|
465
|
+
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",
|
|
466
|
+
transportLabel: "Search transport",
|
|
467
|
+
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)",
|
|
468
|
+
transportAuto: "auto (daemon → MCP, otherwise CLI)",
|
|
469
|
+
transportCli: "CLI only (spawn zg each call)",
|
|
470
|
+
transportMcp: "MCP only (via daemon, auto-started when absent)",
|
|
471
|
+
backendRemote: "qwen remote (content leaves the machine; needs the deployment switch + grant)",
|
|
992
472
|
limitLabel: "Default hits per group",
|
|
993
473
|
limitInvalid: "enter an integer between {min} and {max}",
|
|
994
474
|
limitClamped: "clamped into the {min}-{max} range: {value}",
|
|
@@ -1002,9 +482,9 @@ const UI_MESSAGES = {
|
|
|
1002
482
|
windowHint: "Without another zg_search inside this window the whole quota expires; clear to restore the default {default} (minutes)",
|
|
1003
483
|
rebuildLabel: "Workspace rebuild (run after switching embedding and saving)",
|
|
1004
484
|
rebuildInputPlaceholder: "absolute path to a /workspace",
|
|
1005
|
-
daemonReadyNote: "Daemon: ready (zg server is running).",
|
|
1006
|
-
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.",
|
|
1007
|
-
rebuildHint: "Rebuild with the current default model: {embedding}; same as zg index --rebuild. {roots}",
|
|
485
|
+
daemonReadyNote: "Daemon: ready (zg --server is running).",
|
|
486
|
+
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.",
|
|
487
|
+
rebuildHint: "Rebuild with the current default model: {embedding}; same as zg --index --rebuild. {roots}",
|
|
1008
488
|
rootsNoteWith: "Candidates come from sessions this daemon already opened (server-side whitelist).",
|
|
1009
489
|
rootsNoteEmpty: "No workspace to pick yet: open a session in that workspace first (any tool call registers it).",
|
|
1010
490
|
rebuildButton: "Rebuild index (action, runs on click)",
|
|
@@ -1018,40 +498,19 @@ const UI_MESSAGES = {
|
|
|
1018
498
|
rebuildMissingJobId: "failed to start the rebuild: the response has no jobId",
|
|
1019
499
|
rebuildRootNotAbsolute: "root must be an absolute path (starting with /)",
|
|
1020
500
|
rebuildUnavailable: "the host does not expose the rebuild Remote API",
|
|
501
|
+
rebuildRemoteMissing: "the rebuild Remote API is unavailable: the host gateway provides no remote service",
|
|
502
|
+
rebuildNamespaceMissing: "{serviceKey} was not provided: the host gateway did not mount this namespace",
|
|
1021
503
|
modelOption: "{reference} ({dimension} dims)",
|
|
1022
504
|
backendLlamaCpp: "llama-cpp (native, requires node-llama-cpp)",
|
|
1023
505
|
backendTransformersJs: "transformers-js (pure JS ONNX)",
|
|
1024
506
|
backendModel2Vec: "model2vec (pure JS worker, lightest)"
|
|
1025
507
|
}
|
|
1026
508
|
};
|
|
1027
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
|
|
1028
|
-
function t(e) {
|
|
1029
|
-
let t = Object.getOwnPropertyDescriptor(e, `message`);
|
|
1030
|
-
return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
|
|
1031
|
-
}
|
|
1032
|
-
function n(e, r) {
|
|
1033
|
-
if (r.has(e)) return `<circular cause>`;
|
|
1034
|
-
r.add(e);
|
|
1035
|
-
try {
|
|
1036
|
-
if (!(e instanceof Error)) {
|
|
1037
|
-
if (typeof e == `object` && e) {
|
|
1038
|
-
let n = t(e);
|
|
1039
|
-
if (n !== void 0 && n !== ``) return n;
|
|
1040
|
-
}
|
|
1041
|
-
return String(e);
|
|
1042
|
-
}
|
|
1043
|
-
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);
|
|
1044
|
-
return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
|
|
1045
|
-
} catch {
|
|
1046
|
-
return `<unrenderable value>`;
|
|
1047
|
-
} finally {
|
|
1048
|
-
r.delete(e);
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
function r(e) {
|
|
1052
|
-
return n(e, /* @__PURE__ */ new Set());
|
|
1053
|
-
}
|
|
1054
509
|
// src/client-entry.ts
|
|
510
|
+
/** 一个反斜杠字符(客户端不引 lib/platform.ts:那份模块带 Node 的 process 类型)。 */
|
|
511
|
+
const BACKSLASH = String.fromCodePoint(92);
|
|
512
|
+
/** 卡片侧只做形状提示:win32 盘符绝对路径(`C:\…` / `C:/…`)。 */
|
|
513
|
+
const WIN32_ABSOLUTE_ROOT = /^[A-Za-z]:[\\/]/u;
|
|
1055
514
|
const NS = "zvec-grep";
|
|
1056
515
|
/**
|
|
1057
516
|
* `plugins.bundle.config` 的 key = **bundle 的 npm 包名**(不是裸条目 id)。
|
|
@@ -1112,7 +571,7 @@ function rebuildHintText(t, embedding, hasRoots) {
|
|
|
1112
571
|
roots: t(hasRoots ? "rootsNoteWith" : "rootsNoteEmpty")
|
|
1113
572
|
});
|
|
1114
573
|
}
|
|
1115
|
-
/** embedding 候选的显示文本与分组(供共享 SelectField 的 options
|
|
574
|
+
/** embedding 候选的显示文本与分组(供共享 SelectField 的 options):本地按后端三组 + 远程一组。 */
|
|
1116
575
|
function embeddingOptions(t) {
|
|
1117
576
|
const options = [];
|
|
1118
577
|
for (const backend of BACKENDS) for (const entry of LOCAL_EMBEDDINGS) if (entry.backend === backend) options.push({
|
|
@@ -1120,8 +579,31 @@ function embeddingOptions(t) {
|
|
|
1120
579
|
label: modelOptionText(t, entry.reference, entry.dimension),
|
|
1121
580
|
group: t(BACKEND_LABEL_KEY[backend])
|
|
1122
581
|
});
|
|
582
|
+
for (const entry of REMOTE_EMBEDDING_CATALOG) options.push({
|
|
583
|
+
value: entry.reference,
|
|
584
|
+
label: modelOptionText(t, entry.reference, entry.dimension),
|
|
585
|
+
group: t("backendRemote")
|
|
586
|
+
});
|
|
1123
587
|
return options;
|
|
1124
588
|
}
|
|
589
|
+
/** 传输三档的闭集(与 host 侧 readTransport 同域;label 取 UI 字典)。 */
|
|
590
|
+
const TRANSPORT_OPTIONS = [
|
|
591
|
+
{ value: "auto" },
|
|
592
|
+
{ value: "cli" },
|
|
593
|
+
{ value: "mcp" }
|
|
594
|
+
];
|
|
595
|
+
const TRANSPORT_LABEL_KEY = {
|
|
596
|
+
auto: "transportAuto",
|
|
597
|
+
cli: "transportCli",
|
|
598
|
+
mcp: "transportMcp"
|
|
599
|
+
};
|
|
600
|
+
/** 传输三档的 SelectField 候选。 */
|
|
601
|
+
function transportOptions(t) {
|
|
602
|
+
return TRANSPORT_OPTIONS.map((entry) => ({
|
|
603
|
+
value: entry.value,
|
|
604
|
+
label: t(TRANSPORT_LABEL_KEY[entry.value])
|
|
605
|
+
}));
|
|
606
|
+
}
|
|
1125
607
|
/** 数字草稿串 → 控件值:区间由 zod schema 判定;空串是「清空 = 恢复默认」,不是 0。 */
|
|
1126
608
|
function numberDisplay(display, schema) {
|
|
1127
609
|
const parsed = schema.safeParse(display === "" ? NaN : Number(display));
|
|
@@ -1130,9 +612,9 @@ function numberDisplay(display, schema) {
|
|
|
1130
612
|
/** 检索模型小节:embedding 下拉(按本地后端分组)+ 每组结果数。 */
|
|
1131
613
|
function buildModelSection(deps) {
|
|
1132
614
|
const { editable, fields, setField, t } = deps;
|
|
1133
|
-
const embedding = (0, react.createElement)(
|
|
615
|
+
const embedding = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.SelectField, {
|
|
1134
616
|
label: t("embeddingLabel"),
|
|
1135
|
-
...
|
|
617
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("embeddingHint")),
|
|
1136
618
|
field: "defaultEmbedding",
|
|
1137
619
|
value: fields.embedding,
|
|
1138
620
|
options: embeddingOptions(t),
|
|
@@ -1141,7 +623,7 @@ function buildModelSection(deps) {
|
|
|
1141
623
|
setField("defaultEmbedding", next);
|
|
1142
624
|
}
|
|
1143
625
|
});
|
|
1144
|
-
const limit = (0, react.createElement)(
|
|
626
|
+
const limit = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
|
|
1145
627
|
label: t("limitLabel"),
|
|
1146
628
|
hint: t("limitInvalid", {
|
|
1147
629
|
min: 1,
|
|
@@ -1159,7 +641,7 @@ function buildModelSection(deps) {
|
|
|
1159
641
|
setField("defaultLimit", next);
|
|
1160
642
|
}
|
|
1161
643
|
});
|
|
1162
|
-
return (0, react.createElement)(
|
|
644
|
+
return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Section, { title: t("modelSection") }, embedding, limit);
|
|
1163
645
|
}
|
|
1164
646
|
/** 重建行:root 输入(白名单候选进 <datalist>)+ 触发按钮(在跑时禁用)。 */
|
|
1165
647
|
function buildRebuildField(deps) {
|
|
@@ -1185,14 +667,14 @@ function buildRebuildField(deps) {
|
|
|
1185
667
|
disabled: rebuild.phase === "running",
|
|
1186
668
|
onClick: deps.onRebuild
|
|
1187
669
|
}, rebuild.phase === "running" ? t("rebuildRunning") : t("rebuildButton"));
|
|
1188
|
-
return (0, react.createElement)(
|
|
670
|
+
return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Field, {
|
|
1189
671
|
label: t("rebuildLabel"),
|
|
1190
|
-
...
|
|
672
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(rebuildHintText(t, fields.embedding, roots.length > 0)),
|
|
1191
673
|
wide: true
|
|
1192
674
|
}, rootDatalist, rebuildInput, rebuildButton);
|
|
1193
675
|
}
|
|
1194
676
|
/**
|
|
1195
|
-
* 守护进程(`zg server`)就绪态一行,取自 rebuild-roots 引导端点。
|
|
677
|
+
* 守护进程(`zg --server`)就绪态一行,取自 rebuild-roots 引导端点。
|
|
1196
678
|
*
|
|
1197
679
|
* 为什么值得单独占一行:daemon 缺席时检索按直连模式逐次冷加载 embedding 模型,而
|
|
1198
680
|
* `refresh=background`、索引增量刷新与常驻模型池都不存在——本包因此在命令构造期就拒
|
|
@@ -1215,12 +697,23 @@ function buildRebuildStatusRow(deps) {
|
|
|
1215
697
|
else displayText = rebuild.output;
|
|
1216
698
|
return (0, react.createElement)("div", { className: displayClass }, displayText);
|
|
1217
699
|
}
|
|
1218
|
-
/**
|
|
700
|
+
/** 网络与索引小节:传输三档、镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
|
|
1219
701
|
function buildIndexSection(deps) {
|
|
1220
702
|
const { editable, fields, setField, t } = deps;
|
|
1221
|
-
const
|
|
703
|
+
const transport = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.SelectField, {
|
|
704
|
+
label: t("transportLabel"),
|
|
705
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("transportHint")),
|
|
706
|
+
field: "transport",
|
|
707
|
+
value: fields.transport,
|
|
708
|
+
options: transportOptions(t),
|
|
709
|
+
disabled: !editable,
|
|
710
|
+
onChange: (next) => {
|
|
711
|
+
setField("transport", next);
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
const endpoint = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.TextField, {
|
|
1222
715
|
label: t("endpointLabel"),
|
|
1223
|
-
...
|
|
716
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("endpointHint")),
|
|
1224
717
|
field: "hfEndpoint",
|
|
1225
718
|
value: fields.hfEndpoint,
|
|
1226
719
|
placeholder: EMBEDDING_MIRROR_URL,
|
|
@@ -1230,9 +723,9 @@ function buildIndexSection(deps) {
|
|
|
1230
723
|
setField("hfEndpoint", next.trim() === "" ? void 0 : next.trim());
|
|
1231
724
|
}
|
|
1232
725
|
});
|
|
1233
|
-
const enforce = (0, react.createElement)(
|
|
726
|
+
const enforce = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.ToggleField, {
|
|
1234
727
|
label: t("enforceLabel"),
|
|
1235
|
-
...
|
|
728
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("enforceHint")),
|
|
1236
729
|
field: "enforceSearchFirst",
|
|
1237
730
|
checked: fields.enforceSearchFirst,
|
|
1238
731
|
disabled: !editable,
|
|
@@ -1240,9 +733,9 @@ function buildIndexSection(deps) {
|
|
|
1240
733
|
setField("enforceSearchFirst", next);
|
|
1241
734
|
}
|
|
1242
735
|
});
|
|
1243
|
-
const budget = (0, react.createElement)(
|
|
736
|
+
const budget = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
|
|
1244
737
|
label: t("budgetLabel"),
|
|
1245
|
-
...
|
|
738
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("budgetHint", { default: 3 })),
|
|
1246
739
|
field: "grepBudgetPerSearch",
|
|
1247
740
|
value: numberDisplay(fields.grepBudget, BUDGET_SCHEMA),
|
|
1248
741
|
min: BUDGET_SCHEMA.minValue ?? 1,
|
|
@@ -1255,9 +748,9 @@ function buildIndexSection(deps) {
|
|
|
1255
748
|
setField("grepBudgetPerSearch", next);
|
|
1256
749
|
}
|
|
1257
750
|
});
|
|
1258
|
-
const window = (0, react.createElement)(
|
|
751
|
+
const window = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
|
|
1259
752
|
label: t("windowLabel"),
|
|
1260
|
-
...
|
|
753
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("windowHint", { default: 10 })),
|
|
1261
754
|
field: "unlockWindowMin",
|
|
1262
755
|
value: numberDisplay(fields.unlockWindow, WINDOW_SCHEMA),
|
|
1263
756
|
min: WINDOW_SCHEMA.minValue ?? 1,
|
|
@@ -1270,12 +763,12 @@ function buildIndexSection(deps) {
|
|
|
1270
763
|
setField("unlockWindowMin", next);
|
|
1271
764
|
}
|
|
1272
765
|
});
|
|
1273
|
-
return (0, react.createElement)(
|
|
766
|
+
return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Section, { title: t("indexSection") }, transport, endpoint, enforce, budget, window, buildDaemonNote(deps), buildRebuildField(deps), buildRebuildStatusRow(deps));
|
|
1274
767
|
}
|
|
1275
768
|
/** 卡片主体:检索模型 / 网络与索引两节 + 保存条。 */
|
|
1276
769
|
function buildCardBody(deps) {
|
|
1277
770
|
const { t } = deps;
|
|
1278
|
-
const saveBar = (0, react.createElement)(
|
|
771
|
+
const saveBar = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.SaveBar, {
|
|
1279
772
|
dirty: deps.dirty,
|
|
1280
773
|
busy: deps.busy,
|
|
1281
774
|
writable: deps.writable,
|
|
@@ -1289,7 +782,7 @@ function buildCardBody(deps) {
|
|
|
1289
782
|
onSave: deps.onSave,
|
|
1290
783
|
onDiscard: deps.onDiscard
|
|
1291
784
|
});
|
|
1292
|
-
return (0, react.createElement)(
|
|
785
|
+
return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.CardForm, null, buildModelSection(deps), buildIndexSection(deps), saveBar);
|
|
1293
786
|
}
|
|
1294
787
|
/** 显式字段写入(schema-coverage 门禁按 set('字段名') 字面量识别绑定)。 */
|
|
1295
788
|
function pushFieldWrite(ops, key, draft, set) {
|
|
@@ -1299,6 +792,7 @@ function pushFieldWrite(ops, key, draft, set) {
|
|
|
1299
792
|
else if (key === "enforceSearchFirst") ops.push(set("enforceSearchFirst", draft));
|
|
1300
793
|
else if (key === "grepBudgetPerSearch") ops.push(set("grepBudgetPerSearch", draft));
|
|
1301
794
|
else if (key === "unlockWindowMin") ops.push(set("unlockWindowMin", draft));
|
|
795
|
+
else if (key === "transport") ops.push(set("transport", draft));
|
|
1302
796
|
}
|
|
1303
797
|
/** 读取器缺席时的可行动文案(只剩 ctx.get 缺席这一档;remote/命名空间的缺席由读取器现抛)。 */
|
|
1304
798
|
function requireReader(reader, t) {
|
|
@@ -1313,7 +807,7 @@ const NO_ACCESS = {
|
|
|
1313
807
|
* 「工作区重建」状态机:取白名单 → 起一条重建 → 2s 轮询到终态。
|
|
1314
808
|
* 从 ZgCard 拆出,保持组件体在一屏内可读。
|
|
1315
809
|
* @param t - 取文案(官方 locale 的 translator,随卡片一起下发)。
|
|
1316
|
-
* @param reader -
|
|
810
|
+
* @param reader - 宿主重建读取接口;`undefined` = 当前部署没有远程通道(点重建时报错)。
|
|
1317
811
|
*/
|
|
1318
812
|
function useRebuild(t, reader) {
|
|
1319
813
|
const [root, setRoot] = (0, react.useState)("");
|
|
@@ -1378,7 +872,7 @@ function useRebuild(t, reader) {
|
|
|
1378
872
|
stopPolling();
|
|
1379
873
|
setRebuild({
|
|
1380
874
|
phase: "error",
|
|
1381
|
-
output:
|
|
875
|
+
output: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error)
|
|
1382
876
|
});
|
|
1383
877
|
} finally {
|
|
1384
878
|
pollingRef.current = false;
|
|
@@ -1396,7 +890,8 @@ function useRebuild(t, reader) {
|
|
|
1396
890
|
}, REBUILD_POLL_MS);
|
|
1397
891
|
}
|
|
1398
892
|
async function start() {
|
|
1399
|
-
|
|
893
|
+
const trimmedRoot = root.trim();
|
|
894
|
+
if (!(trimmedRoot.startsWith("/") || WIN32_ABSOLUTE_ROOT.test(trimmedRoot) || trimmedRoot.startsWith(BACKSLASH + BACKSLASH))) {
|
|
1400
895
|
setRebuild({
|
|
1401
896
|
phase: "error",
|
|
1402
897
|
output: t("rebuildRootNotAbsolute")
|
|
@@ -1414,7 +909,7 @@ function useRebuild(t, reader) {
|
|
|
1414
909
|
stopPolling();
|
|
1415
910
|
setRebuild({
|
|
1416
911
|
phase: "error",
|
|
1417
|
-
output:
|
|
912
|
+
output: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error)
|
|
1418
913
|
});
|
|
1419
914
|
}
|
|
1420
915
|
}
|
|
@@ -1438,7 +933,7 @@ function ZgCard(props) {
|
|
|
1438
933
|
const [saveError, setSaveError] = (0, react.useState)(null);
|
|
1439
934
|
const rebuildView = useRebuild(t, props.rebuildRemote);
|
|
1440
935
|
const fields = draftFields(touched, value);
|
|
1441
|
-
const dirtyCount =
|
|
936
|
+
const dirtyCount = (0, _jayyuen66_dsh_plugin_shared_client.diffTouched)(touched, value).length;
|
|
1442
937
|
const dirty = dirtyCount > 0;
|
|
1443
938
|
const setField = (field, draft) => {
|
|
1444
939
|
setTouched((prev) => ({
|
|
@@ -1447,7 +942,7 @@ function ZgCard(props) {
|
|
|
1447
942
|
}));
|
|
1448
943
|
};
|
|
1449
944
|
const save = async () => {
|
|
1450
|
-
const keys =
|
|
945
|
+
const keys = (0, _jayyuen66_dsh_plugin_shared_client.diffTouched)(touched, value);
|
|
1451
946
|
if (keys.length === 0) return;
|
|
1452
947
|
setBusy(true);
|
|
1453
948
|
setSaveError(null);
|
|
@@ -1465,7 +960,7 @@ function ZgCard(props) {
|
|
|
1465
960
|
}
|
|
1466
961
|
} catch (error) {
|
|
1467
962
|
setBusy(false);
|
|
1468
|
-
setSaveError(t("saveFailed", { reason:
|
|
963
|
+
setSaveError(t("saveFailed", { reason: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error) }));
|
|
1469
964
|
return;
|
|
1470
965
|
}
|
|
1471
966
|
const savedKeys = new Set(keys);
|
|
@@ -1510,7 +1005,7 @@ function apply(ctx) {
|
|
|
1510
1005
|
ctx.effect(() => {
|
|
1511
1006
|
const tag = document.createElement("style");
|
|
1512
1007
|
tag.id = "zvec-grep-card-css";
|
|
1513
|
-
tag.textContent = `${CARD_CSS}\n${
|
|
1008
|
+
tag.textContent = `${CARD_CSS}\n${_jayyuen66_dsh_plugin_shared_client.CARD_UI_CSS}`;
|
|
1514
1009
|
document.head.append(tag);
|
|
1515
1010
|
return () => {
|
|
1516
1011
|
tag.remove();
|
|
@@ -1520,7 +1015,10 @@ function apply(ctx) {
|
|
|
1520
1015
|
const store = cardStore(scope);
|
|
1521
1016
|
ctx.effect(() => ctx.locale.register(NS, UI_MESSAGES), "zvec-grep-card: locale dictionaries");
|
|
1522
1017
|
const t = ctx.locale.bind(NS);
|
|
1523
|
-
const rebuildRemote = createRebuildReader(ctx
|
|
1018
|
+
const rebuildRemote = createRebuildReader(ctx, {
|
|
1019
|
+
remoteMissing: () => t("rebuildRemoteMissing"),
|
|
1020
|
+
namespaceMissing: (serviceKey) => t("rebuildNamespaceMissing", { serviceKey })
|
|
1021
|
+
});
|
|
1524
1022
|
const writeField = async (field, valueDraft) => {
|
|
1525
1023
|
try {
|
|
1526
1024
|
return await scope.set(field, valueDraft);
|