@jayyuen66/dsh-zvec-grep 0.1.10 → 0.1.12
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 +40 -1
- package/README.md +14 -14
- package/README.zh-CN.md +36 -35
- package/client.js +41 -611
- package/cordis.patch.yml +3 -0
- package/docs/DETAIL.md +2 -2
- package/docs/DETAIL.zh.md +4 -4
- package/host.js +90 -21
- package/package.json +55 -53
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,6 @@ const LOCAL_EMBEDDINGS = Object.freeze([
|
|
|
74
75
|
dimension: 768
|
|
75
76
|
}
|
|
76
77
|
].map((entry) => Object.freeze(entry)));
|
|
77
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-diff.js
|
|
78
|
-
function e$2(t, n, r) {
|
|
79
|
-
if (t == null || n == null) return (t ?? null) === (n ?? null);
|
|
80
|
-
if (Object.is(t, n)) return !0;
|
|
81
|
-
if (typeof t != `object` || typeof n != `object`) return !1;
|
|
82
|
-
if (r.get(t) === n) return !0;
|
|
83
|
-
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$2(t, n[i], r));
|
|
84
|
-
let i = Object.keys(t), a = Object.keys(n);
|
|
85
|
-
return i.length === a.length && i.every((i) => Object.hasOwn(n, i) && e$2(Reflect.get(t, i), Reflect.get(n, i), r));
|
|
86
|
-
}
|
|
87
|
-
function t$2(t, n) {
|
|
88
|
-
let r = [];
|
|
89
|
-
for (let i of Object.keys(t)) e$2(t[i], n[i], /* @__PURE__ */ new WeakMap()) || r.push(i);
|
|
90
|
-
return r;
|
|
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
|
-
}
|
|
624
78
|
// lib/card-draft.ts
|
|
625
79
|
/** 草稿优先取值:touched 有该键(哪怕值是 undefined=待清空)即用草稿。
|
|
626
80
|
* 两层都只判**自有**属性:本函数收任意字段名,`in`/裸下标会沿原型链命中 `toString` /
|
|
@@ -643,6 +97,11 @@ function numberText(raw, fallback) {
|
|
|
643
97
|
* `undefined` 是**必要**的一臂,不是兜底:旧版 host 的应答里没有 `serverReady` 这个字段,
|
|
644
98
|
* 而「应答里没写」与「写了未就绪」是两件事——把前者显示成后者,卡片就在用户眼前谎称了一次
|
|
645
99
|
* 「没有守护进程」。判据收在可单测的这一层,client 只负责渲染它选出来的那一行。
|
|
100
|
+
*
|
|
101
|
+
* 入参写 `unknown` 而不是 `boolean | undefined`:应答里的这一位只有类型声明、没有运行时校验
|
|
102
|
+
* (lib/rebuild-shape.ts),把形状收紧在声明上等于假定畸形值不会出现,而这里的严格判等正是
|
|
103
|
+
* 为了不让 `null` / `"false"` / `0` 这类值被 falsy 判断误收成「未就绪」。调用方交来的仍是
|
|
104
|
+
* `boolean | undefined`,收紧的一侧由它自己保证。
|
|
646
105
|
*/
|
|
647
106
|
function daemonNoteKey(ready) {
|
|
648
107
|
let key;
|
|
@@ -772,10 +231,6 @@ function parseRebuildPoll(body, t) {
|
|
|
772
231
|
output: outputText.length > 0 ? `${reason}\n${outputText}` : reason
|
|
773
232
|
};
|
|
774
233
|
}
|
|
775
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
|
|
776
|
-
function e(e) {
|
|
777
|
-
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
778
|
-
}
|
|
779
234
|
// src/rebuild-reader.ts
|
|
780
235
|
const REBUILD_NAMESPACE = "zvecGrepRebuild";
|
|
781
236
|
/** 网关给命名空间注册的**服务键**:`remote.<namespace>`。它在 `$mount` 完成之后才存在,
|
|
@@ -846,9 +301,9 @@ const REBUILD_DESCRIPTORS = [
|
|
|
846
301
|
}
|
|
847
302
|
];
|
|
848
303
|
/** 这个值能当远程面用吗(只核我们要调的那一位;服务来自别的实现或版本时保守当作没有)。 */
|
|
849
|
-
const isRemoteMounter = (value) =>
|
|
304
|
+
const isRemoteMounter = (value) => (0, _jayyuen66_dsh_plugin_shared_client.isRecord)(value) && typeof value["$mount"] === "function";
|
|
850
305
|
/** 同上:命名空间服务(挂载之后才有,缺它说明网关没认这枚贡献)。 */
|
|
851
|
-
const isRebuildNamespace = (value) =>
|
|
306
|
+
const isRebuildNamespace = (value) => (0, _jayyuen66_dsh_plugin_shared_client.isRecord)(value) && typeof value["roots"] === "function" && typeof value["rebuild"] === "function" && typeof value["status"] === "function";
|
|
852
307
|
/**
|
|
853
308
|
* 线上拒绝(result.ok=false)翻成异常:code 与 message 都来自网关的错误对象。
|
|
854
309
|
* 三个方法同构,收成一个入口——同一份判据,不抄三份。
|
|
@@ -913,10 +368,11 @@ function createRebuildReader(ctx) {
|
|
|
913
368
|
return typeof ctx.get === "function" ? buildRebuildReader(ctx) : void 0;
|
|
914
369
|
}
|
|
915
370
|
// src/ui-messages.ts
|
|
371
|
+
/** 推荐的 embedding 模型镜像(endpointHint 与 client-entry 的 placeholder 共用)。 */
|
|
372
|
+
const EMBEDDING_MIRROR_URL = "https://modelscope.cn/models";
|
|
916
373
|
const UI_MESSAGES = {
|
|
917
374
|
zh: {
|
|
918
375
|
statusReadOnly: "当前作用域只读",
|
|
919
|
-
statusDirty: "有未保存的修改,点「保存」生效",
|
|
920
376
|
statusClean: "无未保存的修改",
|
|
921
377
|
dirtyCount: "已修改 {count} 项",
|
|
922
378
|
save: "保存",
|
|
@@ -936,7 +392,7 @@ const UI_MESSAGES = {
|
|
|
936
392
|
limitInvalid: "请输入 {min}-{max} 的整数",
|
|
937
393
|
limitClamped: "已钳到 {min}-{max} 范围:{value}",
|
|
938
394
|
endpointLabel: "HuggingFace 镜像地址",
|
|
939
|
-
endpointHint:
|
|
395
|
+
endpointHint: `留空走 huggingface.co;国内网络可填 ${EMBEDDING_MIRROR_URL} 等兼容镜像(仅 llama-cpp 后端生效,如 qwen3)`,
|
|
940
396
|
enforceLabel: "强制 search-first(先 zg_search 再 grep/rg)",
|
|
941
397
|
enforceHint: "开启后,已建索引工作区内的 grep/rg 受配额门禁约束:每次成功 zg_search 解锁下方次数的 grep/rg(时效见下),用尽或过期后再次拦截(提高检索覆盖与准确性)",
|
|
942
398
|
budgetLabel: "每次 zg_search 解锁的 grep/rg 次数",
|
|
@@ -944,6 +400,7 @@ const UI_MESSAGES = {
|
|
|
944
400
|
windowLabel: "解锁时效",
|
|
945
401
|
windowHint: "超过该时长未再次 zg_search,配额整体过期;清空恢复默认 {default}(单位:分钟)",
|
|
946
402
|
rebuildLabel: "工作区重建(切换 embedding 并保存后执行)",
|
|
403
|
+
rebuildInputPlaceholder: "/workspace 的绝对路径",
|
|
947
404
|
daemonReadyNote: "守护进程:就绪(zg server 在跑)。",
|
|
948
405
|
daemonOfflineNote: "守护进程:未就绪。守护进程提供的索引增量刷新、refresh=background 与常驻模型池在缺席时都不可用;需要时在终端执行 `zg server on`。",
|
|
949
406
|
rebuildHint: "以当前默认模型重建:{embedding};等价于 zg index --rebuild。{roots}",
|
|
@@ -956,7 +413,7 @@ const UI_MESSAGES = {
|
|
|
956
413
|
rebuildKilled: "重建进程被终止",
|
|
957
414
|
rebuildFailed: "重建作业被宿主注册表判定失败(没拿到进程退出码)",
|
|
958
415
|
rebuildExitCode: "重建进程退出码 {exitCode}(zg 未安装/权限不足/沙箱拒绝都会走到这里)",
|
|
959
|
-
rebuildExitUnknown: "
|
|
416
|
+
rebuildExitUnknown: "重建没有可判定的结果(应答的 status 无法识别,或缺少进程退出码)",
|
|
960
417
|
rebuildMissingJobId: "启动重建失败:应答缺 jobId",
|
|
961
418
|
rebuildRootNotAbsolute: "root 必须是绝对路径(以 / 开头)",
|
|
962
419
|
rebuildUnavailable: "宿主没有提供工作区重建读面(未装远程服务)",
|
|
@@ -967,7 +424,6 @@ const UI_MESSAGES = {
|
|
|
967
424
|
},
|
|
968
425
|
en: {
|
|
969
426
|
statusReadOnly: "This scope is read-only",
|
|
970
|
-
statusDirty: "Unsaved changes — press Save to apply",
|
|
971
427
|
statusClean: "No unsaved changes",
|
|
972
428
|
dirtyCount: "{count} changed",
|
|
973
429
|
save: "Save",
|
|
@@ -987,7 +443,7 @@ const UI_MESSAGES = {
|
|
|
987
443
|
limitInvalid: "enter an integer between {min} and {max}",
|
|
988
444
|
limitClamped: "clamped into the {min}-{max} range: {value}",
|
|
989
445
|
endpointLabel: "HuggingFace mirror URL",
|
|
990
|
-
endpointHint:
|
|
446
|
+
endpointHint: `Leave empty for huggingface.co; on networks that cannot reach HF, fill a compatible mirror such as ${EMBEDDING_MIRROR_URL} (llama-cpp backends only, e.g. qwen3)`,
|
|
991
447
|
enforceLabel: "Enforce search-first (zg_search before grep/rg)",
|
|
992
448
|
enforceHint: "When on, grep/rg inside indexed workspaces is quota-gated: each successful zg_search unlocks the number of grep/rg calls below (valid for the window below), and the gate blocks again once it is spent or expired (better coverage and relevance)",
|
|
993
449
|
budgetLabel: "grep/rg calls unlocked per zg_search",
|
|
@@ -995,6 +451,7 @@ const UI_MESSAGES = {
|
|
|
995
451
|
windowLabel: "Unlock window",
|
|
996
452
|
windowHint: "Without another zg_search inside this window the whole quota expires; clear to restore the default {default} (minutes)",
|
|
997
453
|
rebuildLabel: "Workspace rebuild (run after switching embedding and saving)",
|
|
454
|
+
rebuildInputPlaceholder: "absolute path to a /workspace",
|
|
998
455
|
daemonReadyNote: "Daemon: ready (zg server is running).",
|
|
999
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.",
|
|
1000
457
|
rebuildHint: "Rebuild with the current default model: {embedding}; same as zg index --rebuild. {roots}",
|
|
@@ -1007,7 +464,7 @@ const UI_MESSAGES = {
|
|
|
1007
464
|
rebuildKilled: "the rebuild process was terminated",
|
|
1008
465
|
rebuildFailed: "the host job registry reported the rebuild as failed (no process exit code)",
|
|
1009
466
|
rebuildExitCode: "the rebuild process exited with code {exitCode} (missing zg, insufficient permissions and sandbox denials all land here)",
|
|
1010
|
-
rebuildExitUnknown: "the rebuild
|
|
467
|
+
rebuildExitUnknown: "the rebuild has no determinable outcome (the response status is unrecognized, or its exit code is missing)",
|
|
1011
468
|
rebuildMissingJobId: "failed to start the rebuild: the response has no jobId",
|
|
1012
469
|
rebuildRootNotAbsolute: "root must be an absolute path (starting with /)",
|
|
1013
470
|
rebuildUnavailable: "the host does not expose the rebuild Remote API",
|
|
@@ -1017,33 +474,6 @@ const UI_MESSAGES = {
|
|
|
1017
474
|
backendModel2Vec: "model2vec (pure JS worker, lightest)"
|
|
1018
475
|
}
|
|
1019
476
|
};
|
|
1020
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
|
|
1021
|
-
function t(e) {
|
|
1022
|
-
let t = Object.getOwnPropertyDescriptor(e, `message`);
|
|
1023
|
-
return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
|
|
1024
|
-
}
|
|
1025
|
-
function n(e, r) {
|
|
1026
|
-
if (r.has(e)) return `<circular cause>`;
|
|
1027
|
-
r.add(e);
|
|
1028
|
-
try {
|
|
1029
|
-
if (!(e instanceof Error)) {
|
|
1030
|
-
if (typeof e == `object` && e) {
|
|
1031
|
-
let n = t(e);
|
|
1032
|
-
if (n !== void 0 && n !== ``) return n;
|
|
1033
|
-
}
|
|
1034
|
-
return String(e);
|
|
1035
|
-
}
|
|
1036
|
-
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);
|
|
1037
|
-
return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
|
|
1038
|
-
} catch {
|
|
1039
|
-
return `<unrenderable value>`;
|
|
1040
|
-
} finally {
|
|
1041
|
-
r.delete(e);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
function r(e) {
|
|
1045
|
-
return n(e, /* @__PURE__ */ new Set());
|
|
1046
|
-
}
|
|
1047
477
|
// src/client-entry.ts
|
|
1048
478
|
const NS = "zvec-grep";
|
|
1049
479
|
/**
|
|
@@ -1123,9 +553,9 @@ function numberDisplay(display, schema) {
|
|
|
1123
553
|
/** 检索模型小节:embedding 下拉(按本地后端分组)+ 每组结果数。 */
|
|
1124
554
|
function buildModelSection(deps) {
|
|
1125
555
|
const { editable, fields, setField, t } = deps;
|
|
1126
|
-
const embedding = (0, react.createElement)(
|
|
556
|
+
const embedding = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.SelectField, {
|
|
1127
557
|
label: t("embeddingLabel"),
|
|
1128
|
-
...
|
|
558
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("embeddingHint")),
|
|
1129
559
|
field: "defaultEmbedding",
|
|
1130
560
|
value: fields.embedding,
|
|
1131
561
|
options: embeddingOptions(t),
|
|
@@ -1134,7 +564,7 @@ function buildModelSection(deps) {
|
|
|
1134
564
|
setField("defaultEmbedding", next);
|
|
1135
565
|
}
|
|
1136
566
|
});
|
|
1137
|
-
const limit = (0, react.createElement)(
|
|
567
|
+
const limit = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
|
|
1138
568
|
label: t("limitLabel"),
|
|
1139
569
|
hint: t("limitInvalid", {
|
|
1140
570
|
min: 1,
|
|
@@ -1152,7 +582,7 @@ function buildModelSection(deps) {
|
|
|
1152
582
|
setField("defaultLimit", next);
|
|
1153
583
|
}
|
|
1154
584
|
});
|
|
1155
|
-
return (0, react.createElement)(
|
|
585
|
+
return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Section, { title: t("modelSection") }, embedding, limit);
|
|
1156
586
|
}
|
|
1157
587
|
/** 重建行:root 输入(白名单候选进 <datalist>)+ 触发按钮(在跑时禁用)。 */
|
|
1158
588
|
function buildRebuildField(deps) {
|
|
@@ -1166,7 +596,7 @@ function buildRebuildField(deps) {
|
|
|
1166
596
|
className: "dsu-input zgc-rebuildInput",
|
|
1167
597
|
value: root,
|
|
1168
598
|
list: ROOT_OPTIONS_ID,
|
|
1169
|
-
placeholder: "
|
|
599
|
+
placeholder: t("rebuildInputPlaceholder"),
|
|
1170
600
|
onChange: (ev) => {
|
|
1171
601
|
setRoot(ev.target.value);
|
|
1172
602
|
}
|
|
@@ -1178,9 +608,9 @@ function buildRebuildField(deps) {
|
|
|
1178
608
|
disabled: rebuild.phase === "running",
|
|
1179
609
|
onClick: deps.onRebuild
|
|
1180
610
|
}, rebuild.phase === "running" ? t("rebuildRunning") : t("rebuildButton"));
|
|
1181
|
-
return (0, react.createElement)(
|
|
611
|
+
return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Field, {
|
|
1182
612
|
label: t("rebuildLabel"),
|
|
1183
|
-
...
|
|
613
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(rebuildHintText(t, fields.embedding, roots.length > 0)),
|
|
1184
614
|
wide: true
|
|
1185
615
|
}, rootDatalist, rebuildInput, rebuildButton);
|
|
1186
616
|
}
|
|
@@ -1211,21 +641,21 @@ function buildRebuildStatusRow(deps) {
|
|
|
1211
641
|
/** 网络与索引小节:镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
|
|
1212
642
|
function buildIndexSection(deps) {
|
|
1213
643
|
const { editable, fields, setField, t } = deps;
|
|
1214
|
-
const endpoint = (0, react.createElement)(
|
|
644
|
+
const endpoint = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.TextField, {
|
|
1215
645
|
label: t("endpointLabel"),
|
|
1216
|
-
...
|
|
646
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("endpointHint")),
|
|
1217
647
|
field: "hfEndpoint",
|
|
1218
648
|
value: fields.hfEndpoint,
|
|
1219
|
-
placeholder:
|
|
649
|
+
placeholder: EMBEDDING_MIRROR_URL,
|
|
1220
650
|
monospace: true,
|
|
1221
651
|
disabled: !editable,
|
|
1222
652
|
onChange: (next) => {
|
|
1223
653
|
setField("hfEndpoint", next.trim() === "" ? void 0 : next.trim());
|
|
1224
654
|
}
|
|
1225
655
|
});
|
|
1226
|
-
const enforce = (0, react.createElement)(
|
|
656
|
+
const enforce = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.ToggleField, {
|
|
1227
657
|
label: t("enforceLabel"),
|
|
1228
|
-
...
|
|
658
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("enforceHint")),
|
|
1229
659
|
field: "enforceSearchFirst",
|
|
1230
660
|
checked: fields.enforceSearchFirst,
|
|
1231
661
|
disabled: !editable,
|
|
@@ -1233,9 +663,9 @@ function buildIndexSection(deps) {
|
|
|
1233
663
|
setField("enforceSearchFirst", next);
|
|
1234
664
|
}
|
|
1235
665
|
});
|
|
1236
|
-
const budget = (0, react.createElement)(
|
|
666
|
+
const budget = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
|
|
1237
667
|
label: t("budgetLabel"),
|
|
1238
|
-
...
|
|
668
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("budgetHint", { default: 3 })),
|
|
1239
669
|
field: "grepBudgetPerSearch",
|
|
1240
670
|
value: numberDisplay(fields.grepBudget, BUDGET_SCHEMA),
|
|
1241
671
|
min: BUDGET_SCHEMA.minValue ?? 1,
|
|
@@ -1248,9 +678,9 @@ function buildIndexSection(deps) {
|
|
|
1248
678
|
setField("grepBudgetPerSearch", next);
|
|
1249
679
|
}
|
|
1250
680
|
});
|
|
1251
|
-
const window = (0, react.createElement)(
|
|
681
|
+
const window = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.NumberField, {
|
|
1252
682
|
label: t("windowLabel"),
|
|
1253
|
-
...
|
|
683
|
+
...(0, _jayyuen66_dsh_plugin_shared_client.splitHint)(t("windowHint", { default: 10 })),
|
|
1254
684
|
field: "unlockWindowMin",
|
|
1255
685
|
value: numberDisplay(fields.unlockWindow, WINDOW_SCHEMA),
|
|
1256
686
|
min: WINDOW_SCHEMA.minValue ?? 1,
|
|
@@ -1263,12 +693,12 @@ function buildIndexSection(deps) {
|
|
|
1263
693
|
setField("unlockWindowMin", next);
|
|
1264
694
|
}
|
|
1265
695
|
});
|
|
1266
|
-
return (0, react.createElement)(
|
|
696
|
+
return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.Section, { title: t("indexSection") }, endpoint, enforce, budget, window, buildDaemonNote(deps), buildRebuildField(deps), buildRebuildStatusRow(deps));
|
|
1267
697
|
}
|
|
1268
698
|
/** 卡片主体:检索模型 / 网络与索引两节 + 保存条。 */
|
|
1269
699
|
function buildCardBody(deps) {
|
|
1270
700
|
const { t } = deps;
|
|
1271
|
-
const saveBar = (0, react.createElement)(
|
|
701
|
+
const saveBar = (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.SaveBar, {
|
|
1272
702
|
dirty: deps.dirty,
|
|
1273
703
|
busy: deps.busy,
|
|
1274
704
|
writable: deps.writable,
|
|
@@ -1282,7 +712,7 @@ function buildCardBody(deps) {
|
|
|
1282
712
|
onSave: deps.onSave,
|
|
1283
713
|
onDiscard: deps.onDiscard
|
|
1284
714
|
});
|
|
1285
|
-
return (0, react.createElement)(
|
|
715
|
+
return (0, react.createElement)(_jayyuen66_dsh_plugin_shared_client.CardForm, null, buildModelSection(deps), buildIndexSection(deps), saveBar);
|
|
1286
716
|
}
|
|
1287
717
|
/** 显式字段写入(schema-coverage 门禁按 set('字段名') 字面量识别绑定)。 */
|
|
1288
718
|
function pushFieldWrite(ops, key, draft, set) {
|
|
@@ -1371,7 +801,7 @@ function useRebuild(t, reader) {
|
|
|
1371
801
|
stopPolling();
|
|
1372
802
|
setRebuild({
|
|
1373
803
|
phase: "error",
|
|
1374
|
-
output:
|
|
804
|
+
output: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error)
|
|
1375
805
|
});
|
|
1376
806
|
} finally {
|
|
1377
807
|
pollingRef.current = false;
|
|
@@ -1407,7 +837,7 @@ function useRebuild(t, reader) {
|
|
|
1407
837
|
stopPolling();
|
|
1408
838
|
setRebuild({
|
|
1409
839
|
phase: "error",
|
|
1410
|
-
output:
|
|
840
|
+
output: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error)
|
|
1411
841
|
});
|
|
1412
842
|
}
|
|
1413
843
|
}
|
|
@@ -1431,7 +861,7 @@ function ZgCard(props) {
|
|
|
1431
861
|
const [saveError, setSaveError] = (0, react.useState)(null);
|
|
1432
862
|
const rebuildView = useRebuild(t, props.rebuildRemote);
|
|
1433
863
|
const fields = draftFields(touched, value);
|
|
1434
|
-
const dirtyCount =
|
|
864
|
+
const dirtyCount = (0, _jayyuen66_dsh_plugin_shared_client.diffTouched)(touched, value).length;
|
|
1435
865
|
const dirty = dirtyCount > 0;
|
|
1436
866
|
const setField = (field, draft) => {
|
|
1437
867
|
setTouched((prev) => ({
|
|
@@ -1440,7 +870,7 @@ function ZgCard(props) {
|
|
|
1440
870
|
}));
|
|
1441
871
|
};
|
|
1442
872
|
const save = async () => {
|
|
1443
|
-
const keys =
|
|
873
|
+
const keys = (0, _jayyuen66_dsh_plugin_shared_client.diffTouched)(touched, value);
|
|
1444
874
|
if (keys.length === 0) return;
|
|
1445
875
|
setBusy(true);
|
|
1446
876
|
setSaveError(null);
|
|
@@ -1458,7 +888,7 @@ function ZgCard(props) {
|
|
|
1458
888
|
}
|
|
1459
889
|
} catch (error) {
|
|
1460
890
|
setBusy(false);
|
|
1461
|
-
setSaveError(t("saveFailed", { reason:
|
|
891
|
+
setSaveError(t("saveFailed", { reason: (0, _jayyuen66_dsh_plugin_shared_client.errorText)(error) }));
|
|
1462
892
|
return;
|
|
1463
893
|
}
|
|
1464
894
|
const savedKeys = new Set(keys);
|
|
@@ -1503,7 +933,7 @@ function apply(ctx) {
|
|
|
1503
933
|
ctx.effect(() => {
|
|
1504
934
|
const tag = document.createElement("style");
|
|
1505
935
|
tag.id = "zvec-grep-card-css";
|
|
1506
|
-
tag.textContent = `${CARD_CSS}\n${
|
|
936
|
+
tag.textContent = `${CARD_CSS}\n${_jayyuen66_dsh_plugin_shared_client.CARD_UI_CSS}`;
|
|
1507
937
|
document.head.append(tag);
|
|
1508
938
|
return () => {
|
|
1509
939
|
tag.remove();
|