@kvman/kvcoder 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/components/call.js +142 -238
- package/dist/web/components/connectors.js +1174 -1549
- package/dist/web/components/conversation.js +1853 -2698
- package/dist/web/components/mcp-sign-in.js +86 -120
- package/dist/web/components/model.js +226 -331
- package/dist/web/components/question.js +129 -185
- package/dist/web/components/sessions.js +90 -138
- package/package.json +3 -3
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, h as c, inject as l, nextTick as u, onBeforeUnmount as d, onMounted as f, openBlock as p, ref as m, renderList as h, shallowRef as g, toDisplayString as _,
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, h as c, inject as l, nextTick as u, onBeforeUnmount as d, onMounted as f, openBlock as p, ref as m, renderList as h, shallowRef as g, toDisplayString as _, unref as v, useTemplateRef as y, vModelText as b, watch as x, withDirectives as S, withKeys as C, withModifiers as w } from "vue";
|
|
2
2
|
//#region web/src/kvman.ts
|
|
3
|
-
function
|
|
3
|
+
function T() {
|
|
4
4
|
let e = l("kvman");
|
|
5
5
|
if (e === void 0) throw Error("kvcoder components run inside kvwebui, which provides kvman.");
|
|
6
6
|
return e;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function E(e) {
|
|
9
9
|
return typeof e == "object" && e && !Array.isArray(e) ? Object.fromEntries(Object.entries(e)) : {};
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function D(e) {
|
|
12
12
|
let t = e.indexOf("/");
|
|
13
13
|
return t < 0 ? `kernel.errors.${e}` : `${e.slice(0, t)}.errors.${e.slice(t + 1)}`;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function O(e) {
|
|
16
16
|
if (!(e instanceof Error) || !("problem" in e)) return;
|
|
17
17
|
let t = e.problem;
|
|
18
18
|
if (typeof t == "object" && t && "code" in t && typeof t.code == "string") return {
|
|
19
19
|
code: t.code,
|
|
20
|
-
params:
|
|
20
|
+
params: k("params" in t ? t.params : void 0)
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return Object.fromEntries(Object.entries(
|
|
23
|
+
function k(e) {
|
|
24
|
+
return Object.fromEntries(Object.entries(E(e)).map(([e, t]) => [e, typeof t == "string" ? t : JSON.stringify(t)]));
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
let n =
|
|
28
|
-
e.toast(n === void 0 ? "kvcoder.ui.failed" :
|
|
26
|
+
function A(e, t) {
|
|
27
|
+
let n = O(t);
|
|
28
|
+
e.toast(n === void 0 ? "kvcoder.ui.failed" : D(n.code), n?.params ?? {}, "error");
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region web/src/model-groups.ts
|
|
32
|
-
function
|
|
32
|
+
function j(e, t, n) {
|
|
33
33
|
let r = new Map(e.map((e) => [e.id, e.title])), i = new Set(e.filter((e) => e.status !== "needsKey").map((e) => e.id)), a = t.filter((e) => i.has(e.provider) || e.id === n), o = /* @__PURE__ */ new Map();
|
|
34
34
|
for (let e of a) {
|
|
35
35
|
let t = o.get(e.provider) ?? {
|
|
@@ -57,7 +57,7 @@ function ee(e, t) {
|
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/shared/src/build/defaultAttributes.mjs
|
|
60
|
-
var
|
|
60
|
+
var M = {
|
|
61
61
|
xmlns: "http://www.w3.org/2000/svg",
|
|
62
62
|
width: 24,
|
|
63
63
|
height: 24,
|
|
@@ -67,25 +67,25 @@ var j = {
|
|
|
67
67
|
"stroke-width": 2,
|
|
68
68
|
"stroke-linecap": "round",
|
|
69
69
|
"stroke-linejoin": "round"
|
|
70
|
-
},
|
|
70
|
+
}, N = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim();
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/shared/src/build/buildLucideIconNode.mjs
|
|
73
|
-
function
|
|
73
|
+
function P(e) {
|
|
74
74
|
return e != null;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
let n = t.attributeNames ?? {}, r = (e) => n[e] ?? e, i = e.size ?? e.width ??
|
|
76
|
+
function F(e, t = {}) {
|
|
77
|
+
let n = t.attributeNames ?? {}, r = (e) => n[e] ?? e, i = e.size ?? e.width ?? M.width, a = e.size ?? e.height ?? M.height, o = e.aliases?.filter((e) => typeof e == "string" && e.trim() !== "").map((e) => `lucide-${e}`) ?? [], s = [...e.name ? [`lucide-${e.name}`] : [], ...o], c = t.className?.split(" ").filter(Boolean) ?? [], l = t.includeDefaultClasses === !1 ? N(...c) : N("lucide", ...s, ...c), u = t.absoluteStrokeWidth ? Number(t.strokeWidth ?? M["stroke-width"]) * Number(e.size ?? e.width ?? M.width) / Number(t.size ?? t.width ?? M.width) : t.strokeWidth ?? M["stroke-width"];
|
|
78
78
|
return [
|
|
79
79
|
"svg",
|
|
80
80
|
{
|
|
81
|
-
...Object.entries(
|
|
81
|
+
...Object.entries(M).reduce((e, [t, n]) => (e[r(t)] = n, e), {}),
|
|
82
82
|
..."color" in t && t.color && { [r("stroke")]: t.color },
|
|
83
|
-
..."size" in t &&
|
|
83
|
+
..."size" in t && P(t.size) && {
|
|
84
84
|
[r("width")]: t.size,
|
|
85
85
|
[r("height")]: t.size
|
|
86
86
|
},
|
|
87
|
-
..."width" in t &&
|
|
88
|
-
..."height" in t &&
|
|
87
|
+
..."width" in t && P(t.width) && { [r("width")]: t.width },
|
|
88
|
+
..."height" in t && P(t.height) && { [r("height")]: t.height },
|
|
89
89
|
[r("stroke-width")]: u,
|
|
90
90
|
...l && { [r("class")]: l },
|
|
91
91
|
[r("viewBox")]: `0 0 ${i} ${a}`,
|
|
@@ -107,24 +107,24 @@ function P(e, t = {}) {
|
|
|
107
107
|
}
|
|
108
108
|
//#endregion
|
|
109
109
|
//#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/shared/src/utils/hasA11yProp.mjs
|
|
110
|
-
var
|
|
110
|
+
var I = (e) => {
|
|
111
111
|
for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
|
|
112
112
|
return !1;
|
|
113
|
-
},
|
|
114
|
-
function
|
|
115
|
-
return l(
|
|
113
|
+
}, L = (e) => e === "", R = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), z = /* @__PURE__ */ Symbol("lucide-icons");
|
|
114
|
+
function B() {
|
|
115
|
+
return l(z, {});
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/Icon.mjs
|
|
119
|
-
var
|
|
120
|
-
name: e &&
|
|
119
|
+
var V = ({ name: e, iconNode: t, "icon-node": n, icon: r = {
|
|
120
|
+
name: e && R(e),
|
|
121
121
|
node: t ?? n ?? [],
|
|
122
122
|
size: 24,
|
|
123
123
|
aliases: []
|
|
124
124
|
}, absoluteStrokeWidth: i, "absolute-stroke-width": a, nonScalingStroke: o, "non-scaling-stroke": s, strokeWidth: l, "stroke-width": u, size: d, width: f = d, height: p = d, color: m, ...h }, { slots: g }) => {
|
|
125
|
-
let { size: _, color: v, strokeWidth: y = 2, absoluteStrokeWidth: b = !1, nonScalingStroke: x = !1, class: S = "" } =
|
|
125
|
+
let { size: _, color: v, strokeWidth: y = 2, absoluteStrokeWidth: b = !1, nonScalingStroke: x = !1, class: S = "" } = B(), C = L(i) || L(a) || i === !0 || a === !0 || b === !0, w = L(o) || L(s) || o === !0 || s === !0 || x === !0;
|
|
126
126
|
delete h.class;
|
|
127
|
-
let T = g.default?.(), [, E, D = []] =
|
|
127
|
+
let T = g.default?.(), [, E, D = []] = F(r, {
|
|
128
128
|
color: m ?? v,
|
|
129
129
|
width: f ?? d ?? _,
|
|
130
130
|
height: p ?? d ?? _,
|
|
@@ -132,38 +132,38 @@ var B = ({ name: e, iconNode: t, "icon-node": n, icon: r = {
|
|
|
132
132
|
absoluteStrokeWidth: C,
|
|
133
133
|
nonScalingStroke: w,
|
|
134
134
|
className: S,
|
|
135
|
-
hasA11yProp: T != null && T.length > 0 ||
|
|
135
|
+
hasA11yProp: T != null && T.length > 0 || I(h),
|
|
136
136
|
attributes: h
|
|
137
137
|
});
|
|
138
138
|
return c("svg", E, [...D.map(([e, t]) => c(e, t)), ...T ?? []]);
|
|
139
139
|
};
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/createLucideIcon.mjs
|
|
142
|
-
function
|
|
142
|
+
function H(e, t = []) {
|
|
143
143
|
let n = typeof e == "string" ? {
|
|
144
144
|
name: e,
|
|
145
145
|
node: t
|
|
146
146
|
} : e;
|
|
147
|
-
return (e, { slots: t }) => c(
|
|
147
|
+
return (e, { slots: t }) => c(V, {
|
|
148
148
|
...e,
|
|
149
149
|
icon: n
|
|
150
150
|
}, t.default ? { default: t.default } : void 0);
|
|
151
151
|
}
|
|
152
|
-
var
|
|
152
|
+
var U = H({
|
|
153
153
|
name: "check",
|
|
154
154
|
size: 24,
|
|
155
155
|
node: [["path", {
|
|
156
156
|
d: "M20 6 9 17l-5-5",
|
|
157
157
|
key: "1gmf2c"
|
|
158
158
|
}]]
|
|
159
|
-
}),
|
|
159
|
+
}), te = H({
|
|
160
160
|
name: "chevron-down",
|
|
161
161
|
size: 24,
|
|
162
162
|
node: [["path", {
|
|
163
163
|
d: "m6 9 6 6 6-6",
|
|
164
164
|
key: "qrunsl"
|
|
165
165
|
}]]
|
|
166
|
-
}),
|
|
166
|
+
}), ne = H({
|
|
167
167
|
name: "search",
|
|
168
168
|
size: 24,
|
|
169
169
|
node: [["path", {
|
|
@@ -175,247 +175,172 @@ var te = V({
|
|
|
175
175
|
r: "8",
|
|
176
176
|
key: "4ej97u"
|
|
177
177
|
}]]
|
|
178
|
-
}),
|
|
179
|
-
__name: "ModelPicker",
|
|
180
|
-
props: {
|
|
181
|
-
groups: {
|
|
182
|
-
type: Array,
|
|
183
|
-
required: !0
|
|
184
|
-
},
|
|
185
|
-
current: {
|
|
186
|
-
type: [String, null],
|
|
187
|
-
required: !0
|
|
188
|
-
},
|
|
189
|
-
empty: {
|
|
190
|
-
type: null,
|
|
191
|
-
required: !1
|
|
192
|
-
},
|
|
193
|
-
none: {
|
|
194
|
-
type: null,
|
|
195
|
-
required: !1
|
|
196
|
-
},
|
|
197
|
-
disabled: {
|
|
198
|
-
type: Boolean,
|
|
199
|
-
required: !1
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
emits: ["pick", "none"],
|
|
203
|
-
setup(e, { expose: n, emit: r }) {
|
|
204
|
-
n();
|
|
205
|
-
let i = e, a = r, o = w(), s = m(!1), c = m(""), l = m(0), f = v("trigger"), p = v("search"), h = v("panel"), g = t(() => ee(i.groups, c.value)), _ = t(() => g.value.groups.flatMap((e) => e.models)), y = t(() => i.groups.flatMap((e) => e.models).find((e) => e.id === i.current)?.name ?? i.current ?? i.empty ?? ""), x = t(() => i.none !== void 0 && c.value.trim() === ""), S = t(() => +!!x.value), C = t(() => _.value.length + S.value), T = (e) => {
|
|
206
|
-
let t = _.value.findIndex((t) => t.id === e);
|
|
207
|
-
return t < 0 ? -1 : t + S.value;
|
|
208
|
-
};
|
|
209
|
-
function E() {
|
|
210
|
-
s.value = !1, f.value?.focus();
|
|
211
|
-
}
|
|
212
|
-
async function D() {
|
|
213
|
-
c.value = "", l.value = Math.max(T(i.current ?? ""), 0), O = 0, s.value = !0, await u(), A(), p.value?.focus(), M();
|
|
214
|
-
}
|
|
215
|
-
let O = 0, k = 0;
|
|
216
|
-
function A() {
|
|
217
|
-
let e = h.value, t = f.value?.closest(".kvc-conversation")?.getBoundingClientRect();
|
|
218
|
-
if (e === null || t === void 0) return;
|
|
219
|
-
let n = e.getBoundingClientRect(), r = t.left + W - (n.left - O), i = t.right - W - (n.right - O), a = r > 0 ? r : i < 0 ? i : 0;
|
|
220
|
-
a !== O && (O = a, e.style.translate = `${a}px 0`);
|
|
221
|
-
}
|
|
222
|
-
function j() {
|
|
223
|
-
A(), k = requestAnimationFrame(j);
|
|
224
|
-
}
|
|
225
|
-
function M() {
|
|
226
|
-
h.value?.querySelector("[data-active=\"true\"]")?.scrollIntoView?.({ block: "nearest" });
|
|
227
|
-
}
|
|
228
|
-
async function N(e) {
|
|
229
|
-
C.value !== 0 && (l.value = (l.value + e + C.value) % C.value, await u(), M());
|
|
230
|
-
}
|
|
231
|
-
function P(e) {
|
|
232
|
-
e !== void 0 && (a("pick", e), E());
|
|
233
|
-
}
|
|
234
|
-
function F() {
|
|
235
|
-
a("none"), E();
|
|
236
|
-
}
|
|
237
|
-
function I() {
|
|
238
|
-
x.value && l.value === 0 ? F() : P(_.value[l.value - S.value]?.id);
|
|
239
|
-
}
|
|
240
|
-
function L(e) {
|
|
241
|
-
e.target instanceof Node && !f.value?.parentElement?.contains(e.target) && (s.value = !1);
|
|
242
|
-
}
|
|
243
|
-
b(c, () => l.value = 0), b(s, (e) => {
|
|
244
|
-
e ? (document.addEventListener("pointerdown", L), k = requestAnimationFrame(j)) : (document.removeEventListener("pointerdown", L), cancelAnimationFrame(k));
|
|
245
|
-
}), d(() => {
|
|
246
|
-
document.removeEventListener("pointerdown", L), cancelAnimationFrame(k);
|
|
247
|
-
});
|
|
248
|
-
let R = {
|
|
249
|
-
props: i,
|
|
250
|
-
emit: a,
|
|
251
|
-
kvman: o,
|
|
252
|
-
open: s,
|
|
253
|
-
query: c,
|
|
254
|
-
highlight: l,
|
|
255
|
-
trigger: f,
|
|
256
|
-
search: p,
|
|
257
|
-
panel: h,
|
|
258
|
-
gutterPx: W,
|
|
259
|
-
found: g,
|
|
260
|
-
models: _,
|
|
261
|
-
label: y,
|
|
262
|
-
offersNone: x,
|
|
263
|
-
first: S,
|
|
264
|
-
count: C,
|
|
265
|
-
indexOf: T,
|
|
266
|
-
close: E,
|
|
267
|
-
show: D,
|
|
268
|
-
get shift() {
|
|
269
|
-
return O;
|
|
270
|
-
},
|
|
271
|
-
set shift(e) {
|
|
272
|
-
O = e;
|
|
273
|
-
},
|
|
274
|
-
get frame() {
|
|
275
|
-
return k;
|
|
276
|
-
},
|
|
277
|
-
set frame(e) {
|
|
278
|
-
k = e;
|
|
279
|
-
},
|
|
280
|
-
keepInside: A,
|
|
281
|
-
follow: j,
|
|
282
|
-
scrollToHighlight: M,
|
|
283
|
-
move: N,
|
|
284
|
-
pick: P,
|
|
285
|
-
pickNone: F,
|
|
286
|
-
pickHighlighted: I,
|
|
287
|
-
outside: L,
|
|
288
|
-
get Check() {
|
|
289
|
-
return te;
|
|
290
|
-
},
|
|
291
|
-
get ChevronDown() {
|
|
292
|
-
return H;
|
|
293
|
-
},
|
|
294
|
-
get Search() {
|
|
295
|
-
return U;
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
return Object.defineProperty(R, "__isScriptSetup", {
|
|
299
|
-
enumerable: !1,
|
|
300
|
-
value: !0
|
|
301
|
-
}), R;
|
|
302
|
-
}
|
|
303
|
-
}), K = (e, t) => {
|
|
304
|
-
let n = e.__vccOpts || e;
|
|
305
|
-
for (let [e, r] of t) n[e] = r;
|
|
306
|
-
return n;
|
|
307
|
-
}, q = { class: "kvc-picker" }, J = [
|
|
178
|
+
}), re = { class: "kvc-picker" }, W = [
|
|
308
179
|
"aria-expanded",
|
|
309
180
|
"aria-label",
|
|
310
181
|
"disabled"
|
|
311
|
-
],
|
|
182
|
+
], ie = { class: "kvc-picker-label" }, ae = ["onKeydown"], oe = { class: "kvc-search" }, se = [
|
|
312
183
|
"placeholder",
|
|
313
184
|
"aria-label",
|
|
314
185
|
"onKeydown"
|
|
315
|
-
],
|
|
186
|
+
], ce = ["aria-label"], le = ["aria-selected", "data-active"], ue = { class: "kvc-model-name" }, de = {
|
|
316
187
|
class: "kvc-group",
|
|
317
188
|
role: "presentation",
|
|
318
189
|
"data-test": "model-group"
|
|
319
|
-
},
|
|
190
|
+
}, fe = [
|
|
320
191
|
"aria-selected",
|
|
321
192
|
"data-active",
|
|
322
193
|
"data-test",
|
|
323
194
|
"onClick",
|
|
324
195
|
"onMousemove"
|
|
325
|
-
],
|
|
196
|
+
], pe = { class: "kvc-model-name" }, me = {
|
|
326
197
|
key: 1,
|
|
327
198
|
class: "kvc-muted kvc-none",
|
|
328
199
|
"data-test": "model-none"
|
|
329
|
-
},
|
|
200
|
+
}, he = {
|
|
330
201
|
class: "kvc-muted kvc-count",
|
|
331
202
|
"data-test": "model-count"
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
203
|
+
}, G = 24, K = /* @__PURE__ */ s({
|
|
204
|
+
__name: "ModelPicker",
|
|
205
|
+
props: {
|
|
206
|
+
groups: {},
|
|
207
|
+
current: {},
|
|
208
|
+
empty: {},
|
|
209
|
+
none: {},
|
|
210
|
+
disabled: { type: Boolean }
|
|
211
|
+
},
|
|
212
|
+
emits: ["pick", "none"],
|
|
213
|
+
setup(s, { emit: c }) {
|
|
214
|
+
let l = s, f = c, g = T(), E = m(!1), D = m(""), O = m(0), k = y("trigger"), A = y("search"), j = y("panel"), M = t(() => ee(l.groups, D.value)), N = t(() => M.value.groups.flatMap((e) => e.models)), P = t(() => l.groups.flatMap((e) => e.models).find((e) => e.id === l.current)?.name ?? l.current ?? l.empty ?? ""), F = t(() => l.none !== void 0 && D.value.trim() === ""), I = t(() => +!!F.value), L = t(() => N.value.length + I.value), R = (e) => {
|
|
215
|
+
let t = N.value.findIndex((t) => t.id === e);
|
|
216
|
+
return t < 0 ? -1 : t + I.value;
|
|
217
|
+
};
|
|
218
|
+
function z() {
|
|
219
|
+
E.value = !1, k.value?.focus();
|
|
220
|
+
}
|
|
221
|
+
async function B() {
|
|
222
|
+
D.value = "", O.value = Math.max(R(l.current ?? ""), 0), V = 0, E.value = !0, await u(), K(), A.value?.focus(), J();
|
|
223
|
+
}
|
|
224
|
+
let V = 0, H = 0;
|
|
225
|
+
function K() {
|
|
226
|
+
let e = j.value, t = k.value?.closest(".kvc-conversation")?.getBoundingClientRect();
|
|
227
|
+
if (e === null || t === void 0) return;
|
|
228
|
+
let n = e.getBoundingClientRect(), r = t.left + G - (n.left - V), i = t.right - G - (n.right - V), a = r > 0 ? r : i < 0 ? i : 0;
|
|
229
|
+
a !== V && (V = a, e.style.translate = `${a}px 0`);
|
|
230
|
+
}
|
|
231
|
+
function q() {
|
|
232
|
+
K(), H = requestAnimationFrame(q);
|
|
233
|
+
}
|
|
234
|
+
function J() {
|
|
235
|
+
j.value?.querySelector("[data-active=\"true\"]")?.scrollIntoView?.({ block: "nearest" });
|
|
236
|
+
}
|
|
237
|
+
async function Y(e) {
|
|
238
|
+
L.value !== 0 && (O.value = (O.value + e + L.value) % L.value, await u(), J());
|
|
239
|
+
}
|
|
240
|
+
function X(e) {
|
|
241
|
+
e !== void 0 && (f("pick", e), z());
|
|
242
|
+
}
|
|
243
|
+
function Z() {
|
|
244
|
+
f("none"), z();
|
|
245
|
+
}
|
|
246
|
+
function Q() {
|
|
247
|
+
F.value && O.value === 0 ? Z() : X(N.value[O.value - I.value]?.id);
|
|
248
|
+
}
|
|
249
|
+
function $(e) {
|
|
250
|
+
e.target instanceof Node && !k.value?.parentElement?.contains(e.target) && (E.value = !1);
|
|
251
|
+
}
|
|
252
|
+
return x(D, () => O.value = 0), x(E, (e) => {
|
|
253
|
+
e ? (document.addEventListener("pointerdown", $), H = requestAnimationFrame(q)) : (document.removeEventListener("pointerdown", $), cancelAnimationFrame(H));
|
|
254
|
+
}), d(() => {
|
|
255
|
+
document.removeEventListener("pointerdown", $), cancelAnimationFrame(H);
|
|
256
|
+
}), (t, s) => (p(), i("div", re, [a("button", {
|
|
257
|
+
ref_key: "trigger",
|
|
258
|
+
ref: k,
|
|
259
|
+
type: "button",
|
|
260
|
+
class: "kvc-button",
|
|
261
|
+
"aria-haspopup": "listbox",
|
|
262
|
+
"aria-expanded": E.value,
|
|
263
|
+
"aria-label": `${v(g).t("kvcoder.ui.model")}: ${P.value}`,
|
|
264
|
+
disabled: l.disabled,
|
|
265
|
+
"data-test": "model-picker",
|
|
266
|
+
onClick: s[0] ||= (e) => E.value ? z() : B()
|
|
267
|
+
}, [a("span", ie, _(P.value), 1), o(v(te), {
|
|
355
268
|
size: 16,
|
|
356
269
|
"aria-hidden": "true"
|
|
357
|
-
}),
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
"
|
|
363
|
-
"
|
|
364
|
-
placeholder: l.kvman.t("kvcoder.ui.searchModels"),
|
|
365
|
-
"aria-label": l.kvman.t("kvcoder.ui.searchModels"),
|
|
366
|
-
"data-test": "model-search",
|
|
367
|
-
onKeydown: [
|
|
368
|
-
s[2] ||= S(C((e) => l.move(1), ["prevent"]), ["down"]),
|
|
369
|
-
s[3] ||= S(C((e) => l.move(-1), ["prevent"]), ["up"]),
|
|
370
|
-
S(C(l.pickHighlighted, ["prevent"]), ["enter"])
|
|
371
|
-
]
|
|
372
|
-
}, null, 40, Q), [[y, l.query]])]),
|
|
373
|
-
a("div", {
|
|
374
|
-
id: "kvc-models",
|
|
375
|
-
class: "kvc-options",
|
|
376
|
-
role: "listbox",
|
|
377
|
-
"aria-label": l.kvman.t("kvcoder.ui.model")
|
|
270
|
+
})], 8, W), E.value ? (p(), i("div", {
|
|
271
|
+
key: 0,
|
|
272
|
+
ref_key: "panel",
|
|
273
|
+
ref: j,
|
|
274
|
+
class: "kvc-popover",
|
|
275
|
+
"data-test": "model-popover",
|
|
276
|
+
onKeydown: C(w(z, ["stop"]), ["esc"])
|
|
378
277
|
}, [
|
|
379
|
-
|
|
380
|
-
key: 0,
|
|
381
|
-
class: "kvc-model",
|
|
382
|
-
role: "option",
|
|
383
|
-
"aria-selected": l.props.current === null,
|
|
384
|
-
"data-active": l.highlight === 0,
|
|
385
|
-
"data-test": "model-none-entry",
|
|
386
|
-
onClick: l.pickNone,
|
|
387
|
-
onMousemove: s[4] ||= (e) => l.highlight = 0
|
|
388
|
-
}, [a("span", ie, _(l.props.none), 1), l.props.current === null ? (p(), n(l.Check, {
|
|
389
|
-
key: 0,
|
|
390
|
-
size: 16,
|
|
391
|
-
"aria-hidden": "true"
|
|
392
|
-
})) : r("v-if", !0)], 40, re)) : r("v-if", !0),
|
|
393
|
-
(p(!0), i(e, null, h(l.found.groups, (t) => (p(), i(e, { key: t.provider }, [a("div", ae, _(t.title), 1), (p(!0), i(e, null, h(t.models, (e) => (p(), i("div", {
|
|
394
|
-
key: e.id,
|
|
395
|
-
class: "kvc-model",
|
|
396
|
-
role: "option",
|
|
397
|
-
"aria-selected": e.id === l.props.current,
|
|
398
|
-
"data-active": l.indexOf(e.id) === l.highlight,
|
|
399
|
-
"data-test": `model-${e.id}`,
|
|
400
|
-
onClick: (t) => l.pick(e.id),
|
|
401
|
-
onMousemove: (t) => l.highlight = l.indexOf(e.id)
|
|
402
|
-
}, [a("span", se, _(e.name), 1), e.id === l.props.current ? (p(), n(l.Check, {
|
|
403
|
-
key: 0,
|
|
278
|
+
a("label", oe, [o(v(ne), {
|
|
404
279
|
size: 16,
|
|
405
280
|
"aria-hidden": "true"
|
|
406
|
-
})
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
281
|
+
}), S(a("input", {
|
|
282
|
+
ref_key: "search",
|
|
283
|
+
ref: A,
|
|
284
|
+
"onUpdate:modelValue": s[1] ||= (e) => D.value = e,
|
|
285
|
+
type: "search",
|
|
286
|
+
role: "combobox",
|
|
287
|
+
"aria-expanded": "true",
|
|
288
|
+
"aria-controls": "kvc-models",
|
|
289
|
+
placeholder: v(g).t("kvcoder.ui.searchModels"),
|
|
290
|
+
"aria-label": v(g).t("kvcoder.ui.searchModels"),
|
|
291
|
+
"data-test": "model-search",
|
|
292
|
+
onKeydown: [
|
|
293
|
+
s[2] ||= C(w((e) => Y(1), ["prevent"]), ["down"]),
|
|
294
|
+
s[3] ||= C(w((e) => Y(-1), ["prevent"]), ["up"]),
|
|
295
|
+
C(w(Q, ["prevent"]), ["enter"])
|
|
296
|
+
]
|
|
297
|
+
}, null, 40, se), [[b, D.value]])]),
|
|
298
|
+
a("div", {
|
|
299
|
+
id: "kvc-models",
|
|
300
|
+
class: "kvc-options",
|
|
301
|
+
role: "listbox",
|
|
302
|
+
"aria-label": v(g).t("kvcoder.ui.model")
|
|
303
|
+
}, [
|
|
304
|
+
F.value ? (p(), i("div", {
|
|
305
|
+
key: 0,
|
|
306
|
+
class: "kvc-model",
|
|
307
|
+
role: "option",
|
|
308
|
+
"aria-selected": l.current === null,
|
|
309
|
+
"data-active": O.value === 0,
|
|
310
|
+
"data-test": "model-none-entry",
|
|
311
|
+
onClick: Z,
|
|
312
|
+
onMousemove: s[4] ||= (e) => O.value = 0
|
|
313
|
+
}, [a("span", ue, _(l.none), 1), l.current === null ? (p(), n(v(U), {
|
|
314
|
+
key: 0,
|
|
315
|
+
size: 16,
|
|
316
|
+
"aria-hidden": "true"
|
|
317
|
+
})) : r("v-if", !0)], 40, le)) : r("v-if", !0),
|
|
318
|
+
(p(!0), i(e, null, h(M.value.groups, (t) => (p(), i(e, { key: t.provider }, [a("div", de, _(t.title), 1), (p(!0), i(e, null, h(t.models, (e) => (p(), i("div", {
|
|
319
|
+
key: e.id,
|
|
320
|
+
class: "kvc-model",
|
|
321
|
+
role: "option",
|
|
322
|
+
"aria-selected": e.id === l.current,
|
|
323
|
+
"data-active": R(e.id) === O.value,
|
|
324
|
+
"data-test": `model-${e.id}`,
|
|
325
|
+
onClick: (t) => X(e.id),
|
|
326
|
+
onMousemove: (t) => O.value = R(e.id)
|
|
327
|
+
}, [a("span", pe, _(e.name), 1), e.id === l.current ? (p(), n(v(U), {
|
|
328
|
+
key: 0,
|
|
329
|
+
size: 16,
|
|
330
|
+
"aria-hidden": "true"
|
|
331
|
+
})) : r("v-if", !0)], 40, fe))), 128))], 64))), 128)),
|
|
332
|
+
M.value.shown === 0 ? (p(), i("p", me, _(v(g).t("kvcoder.ui.noModels")), 1)) : r("v-if", !0)
|
|
333
|
+
], 8, ce),
|
|
334
|
+
a("p", he, _(v(g).t("kvcoder.ui.modelsCount", {
|
|
335
|
+
shown: M.value.shown,
|
|
336
|
+
total: M.value.total
|
|
337
|
+
})), 1)
|
|
338
|
+
], 40, ae)) : r("v-if", !0)]));
|
|
339
|
+
}
|
|
340
|
+
});
|
|
416
341
|
//#endregion
|
|
417
342
|
//#region web/src/use-setting.ts
|
|
418
|
-
function
|
|
343
|
+
function q(e, n) {
|
|
419
344
|
let r = g(null), i = m("default"), a = m(!1), o = async () => {
|
|
420
345
|
let t = (await e.exec("kernel.settings.list", {})).find((e) => e.key === n);
|
|
421
346
|
r.value = t?.value ?? null, i.value = t?.source ?? "default";
|
|
@@ -424,12 +349,12 @@ function fe(e, n) {
|
|
|
424
349
|
try {
|
|
425
350
|
return await t(), await o(), !0;
|
|
426
351
|
} catch (t) {
|
|
427
|
-
return
|
|
352
|
+
return A(e, t), !1;
|
|
428
353
|
} finally {
|
|
429
354
|
a.value = !1;
|
|
430
355
|
}
|
|
431
356
|
};
|
|
432
|
-
return f(o),
|
|
357
|
+
return f(o), x(() => [e.scope.value, e.workspace.value.id], o), {
|
|
433
358
|
value: r,
|
|
434
359
|
saving: a,
|
|
435
360
|
locked: t(() => e.scope.value === "global" && i.value === "workspace"),
|
|
@@ -447,99 +372,69 @@ function fe(e, n) {
|
|
|
447
372
|
}
|
|
448
373
|
//#endregion
|
|
449
374
|
//#region web/src/ModelSetting.vue?vue&type=script&setup=true&lang.ts
|
|
450
|
-
var
|
|
451
|
-
__name: "ModelSetting",
|
|
452
|
-
setup(e, { expose: n }) {
|
|
453
|
-
n();
|
|
454
|
-
let r = w(), i = fe(r, "kvcoder.model"), a = m([]), o = m([]), s = m(null);
|
|
455
|
-
f(async () => {
|
|
456
|
-
try {
|
|
457
|
-
let [e, t, n] = await Promise.all([
|
|
458
|
-
r.exec("kvai.provider.list", {}),
|
|
459
|
-
r.exec("kvai.model.list", {}),
|
|
460
|
-
r.exec("kvai.model.default.get", {})
|
|
461
|
-
]);
|
|
462
|
-
a.value = e, o.value = t, s.value = n.name ?? n.id;
|
|
463
|
-
} catch (e) {
|
|
464
|
-
k(r, e);
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
let c = t(() => typeof i.value.value == "string" ? i.value.value : null), l = {
|
|
468
|
-
kvman: r,
|
|
469
|
-
setting: i,
|
|
470
|
-
providers: a,
|
|
471
|
-
models: o,
|
|
472
|
-
fallback: s,
|
|
473
|
-
current: c,
|
|
474
|
-
groups: t(() => A(a.value, o.value, c.value)),
|
|
475
|
-
empty: t(() => s.value === null ? r.t("kvcoder.config.model.defaultUnset") : r.t("kvcoder.config.model.default", { name: s.value })),
|
|
476
|
-
scoped: (e) => r.t(`${e}.${r.scope.value}`, { name: r.workspace.value.name }),
|
|
477
|
-
ModelPicker: de
|
|
478
|
-
};
|
|
479
|
-
return Object.defineProperty(l, "__isScriptSetup", {
|
|
480
|
-
enumerable: !1,
|
|
481
|
-
value: !0
|
|
482
|
-
}), l;
|
|
483
|
-
}
|
|
484
|
-
}), me = {
|
|
375
|
+
var J = {
|
|
485
376
|
class: "kvc-setting",
|
|
486
377
|
"data-test": "model-setting"
|
|
487
|
-
},
|
|
378
|
+
}, Y = { class: "kvc-setting-text" }, X = {
|
|
488
379
|
class: "kvc-setting-title",
|
|
489
380
|
"data-test": "model-setting-title"
|
|
490
|
-
},
|
|
381
|
+
}, Z = {
|
|
491
382
|
class: "kvc-muted",
|
|
492
383
|
"data-test": "model-setting-description"
|
|
493
|
-
},
|
|
384
|
+
}, Q = { class: "kvc-setting-control" }, $ = {
|
|
494
385
|
key: 0,
|
|
495
386
|
class: "kvc-muted",
|
|
496
387
|
"data-test": "model-own-value"
|
|
497
|
-
},
|
|
388
|
+
}, ge = {
|
|
498
389
|
key: 1,
|
|
499
390
|
class: "kvc-connectors-state"
|
|
500
|
-
},
|
|
391
|
+
}, _e = {
|
|
501
392
|
class: "kvc-chip",
|
|
502
393
|
"data-test": "model-changed"
|
|
503
|
-
},
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
394
|
+
}, ve = ["disabled"], ye = /* @__PURE__ */ s({
|
|
395
|
+
__name: "ModelSetting",
|
|
396
|
+
setup(e) {
|
|
397
|
+
let n = T(), s = q(n, "kvcoder.model"), c = m([]), l = m([]), u = m(null);
|
|
398
|
+
f(async () => {
|
|
399
|
+
try {
|
|
400
|
+
let [e, t, r] = await Promise.all([
|
|
401
|
+
n.exec("kvai.provider.list", {}),
|
|
402
|
+
n.exec("kvai.model.list", {}),
|
|
403
|
+
n.exec("kvai.model.default.get", {})
|
|
404
|
+
]);
|
|
405
|
+
c.value = e, l.value = t, u.value = r.name ?? r.id;
|
|
406
|
+
} catch (e) {
|
|
407
|
+
A(n, e);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
let d = t(() => typeof s.value.value == "string" ? s.value.value : null), h = t(() => j(c.value, l.value, d.value)), g = t(() => u.value === null ? n.t("kvcoder.config.model.defaultUnset") : n.t("kvcoder.config.model.default", { name: u.value })), y = (e) => n.t(`${e}.${n.scope.value}`, { name: n.workspace.value.name });
|
|
411
|
+
return (e, t) => (p(), i("div", J, [a("span", Y, [a("span", X, _(v(n).t("kvcoder.model.title")), 1), a("span", Z, _(v(n).t("kvcoder.model.description")), 1)]), a("span", Q, [o(K, {
|
|
412
|
+
groups: h.value,
|
|
413
|
+
current: d.value,
|
|
414
|
+
empty: g.value,
|
|
415
|
+
none: v(n).t("kvcoder.config.model.useDefault"),
|
|
416
|
+
disabled: v(s).locked.value || v(s).saving.value,
|
|
417
|
+
onPick: t[0] ||= (e) => v(s).set(e),
|
|
418
|
+
onNone: t[1] ||= (e) => v(s).set(null)
|
|
419
|
+
}, null, 8, [
|
|
420
|
+
"groups",
|
|
421
|
+
"current",
|
|
422
|
+
"empty",
|
|
423
|
+
"none",
|
|
424
|
+
"disabled"
|
|
425
|
+
]), v(s).locked.value ? (p(), i("span", $, _(v(n).t("kvcoder.config.model.ownValue", { name: v(n).workspace.value.name })), 1)) : v(s).changed.value ? (p(), i("span", ge, [a("span", _e, _(y("kvcoder.config.model.changed")), 1), a("button", {
|
|
426
|
+
type: "button",
|
|
427
|
+
class: "kvc-text-button",
|
|
428
|
+
disabled: v(s).saving.value,
|
|
429
|
+
"data-test": "model-reset",
|
|
430
|
+
onClick: t[2] ||= (...e) => v(s).reset && v(s).reset(...e)
|
|
431
|
+
}, _(y("kvcoder.config.model.reset")), 9, ve)])) : r("v-if", !0)])]));
|
|
432
|
+
}
|
|
433
|
+
}), be = /* @__PURE__ */ s({
|
|
528
434
|
__name: "model",
|
|
529
|
-
setup(e
|
|
530
|
-
t();
|
|
531
|
-
let n = { ModelSetting: Ce };
|
|
532
|
-
return Object.defineProperty(n, "__isScriptSetup", {
|
|
533
|
-
enumerable: !1,
|
|
534
|
-
value: !0
|
|
535
|
-
}), n;
|
|
435
|
+
setup(e) {
|
|
436
|
+
return (e, t) => (p(), n(ye));
|
|
536
437
|
}
|
|
537
438
|
});
|
|
538
439
|
//#endregion
|
|
539
|
-
|
|
540
|
-
function Te(e, t, r, i, a, o) {
|
|
541
|
-
return p(), n(i.ModelSetting);
|
|
542
|
-
}
|
|
543
|
-
var Ee = /*#__PURE__*/ K(we, [["render", Te], ["__file", "/home/runner/work/kvman/kvman/extensions/kvcoder/web/components/model.vue"]]);
|
|
544
|
-
//#endregion
|
|
545
|
-
export { Ee as default };
|
|
440
|
+
export { be as default };
|