@inkandswitch/patchwork-pkg-base 0.0.71 → 0.0.73
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/module-settings-url +1 -1
- package/modules.json +1 -0
- package/package.json +1 -1
- package/packages/llm-host/dist/LlmConfigTray-BPL_cmra.js +591 -0
- package/packages/llm-host/dist/client-VAkC0nI7.js +114 -0
- package/packages/llm-host/dist/index.js +39 -0
- package/packages/llm-host/dist/patchwork-llm-h1ZevlV6.js +83 -0
- package/packages/llm-host/dist/worker-spec-ceN4G8JW.js +187 -0
- package/packages/llm-host/package.json +34 -0
- package/packages/threepane/dist/index.js +1 -1
- package/packages/threepane/dist/index.js.map +2 -2
- package/plugin-registry-url +1 -1
package/module-settings-url
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
automerge:
|
|
1
|
+
automerge:3FPouBEb1w7xuq25eMGyHyR6u4bp
|
package/modules.json
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import { ensureConfig as ve, dom as be, writeScopeOverride as Ee, readScopedConfig as Se, readConfig as oe, writeConfig as xe } from "./patchwork-llm-h1ZevlV6.js";
|
|
2
|
+
const Ce = !1, Ae = (e, t) => e === t, L = {
|
|
3
|
+
equals: Ae
|
|
4
|
+
};
|
|
5
|
+
let fe = he;
|
|
6
|
+
const E = 1, O = 2, ce = {
|
|
7
|
+
owned: null,
|
|
8
|
+
cleanups: null,
|
|
9
|
+
context: null,
|
|
10
|
+
owner: null
|
|
11
|
+
};
|
|
12
|
+
var a = null;
|
|
13
|
+
let G = null, ke = null, u = null, g = null, b = null, V = 0;
|
|
14
|
+
function ue(e, t) {
|
|
15
|
+
const n = u, o = a, i = e.length === 0, r = t === void 0 ? o : t, l = i ? ce : {
|
|
16
|
+
owned: null,
|
|
17
|
+
cleanups: null,
|
|
18
|
+
context: r ? r.context : null,
|
|
19
|
+
owner: r
|
|
20
|
+
}, s = i ? e : () => e(() => x(() => T(l)));
|
|
21
|
+
a = l, u = null;
|
|
22
|
+
try {
|
|
23
|
+
return A(s, !0);
|
|
24
|
+
} finally {
|
|
25
|
+
u = n, a = o;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function k(e, t) {
|
|
29
|
+
t = t ? Object.assign({}, L, t) : L;
|
|
30
|
+
const n = {
|
|
31
|
+
value: e,
|
|
32
|
+
observers: null,
|
|
33
|
+
observerSlots: null,
|
|
34
|
+
comparator: t.equals || void 0
|
|
35
|
+
}, o = (i) => (typeof i == "function" && (i = i(n.value)), de(n, i));
|
|
36
|
+
return [ae.bind(n), o];
|
|
37
|
+
}
|
|
38
|
+
function _(e, t, n) {
|
|
39
|
+
const o = I(e, t, !1, E);
|
|
40
|
+
$(o);
|
|
41
|
+
}
|
|
42
|
+
function Te(e, t, n) {
|
|
43
|
+
fe = Oe;
|
|
44
|
+
const o = I(e, t, !1, E);
|
|
45
|
+
n || (o.user = !0), b ? b.push(o) : $(o);
|
|
46
|
+
}
|
|
47
|
+
function N(e, t, n) {
|
|
48
|
+
n = n ? Object.assign({}, L, n) : L;
|
|
49
|
+
const o = I(e, t, !0, 0);
|
|
50
|
+
return o.observers = null, o.observerSlots = null, o.comparator = n.equals || void 0, $(o), ae.bind(o);
|
|
51
|
+
}
|
|
52
|
+
function x(e) {
|
|
53
|
+
if (u === null) return e();
|
|
54
|
+
const t = u;
|
|
55
|
+
u = null;
|
|
56
|
+
try {
|
|
57
|
+
return e();
|
|
58
|
+
} finally {
|
|
59
|
+
u = t;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function se(e) {
|
|
63
|
+
return a === null || (a.cleanups === null ? a.cleanups = [e] : a.cleanups.push(e)), e;
|
|
64
|
+
}
|
|
65
|
+
function $e() {
|
|
66
|
+
return a;
|
|
67
|
+
}
|
|
68
|
+
function Pe(e, t) {
|
|
69
|
+
const n = a, o = u;
|
|
70
|
+
a = e, u = null;
|
|
71
|
+
try {
|
|
72
|
+
return A(t, !0);
|
|
73
|
+
} catch (i) {
|
|
74
|
+
q(i);
|
|
75
|
+
} finally {
|
|
76
|
+
a = n, u = o;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function ae() {
|
|
80
|
+
if (this.sources && this.state)
|
|
81
|
+
if (this.state === E) $(this);
|
|
82
|
+
else {
|
|
83
|
+
const e = g;
|
|
84
|
+
g = null, A(() => B(this), !1), g = e;
|
|
85
|
+
}
|
|
86
|
+
if (u) {
|
|
87
|
+
const e = this.observers;
|
|
88
|
+
if (!e || e[e.length - 1] !== u) {
|
|
89
|
+
const t = e ? e.length : 0;
|
|
90
|
+
u.sources ? (u.sources.push(this), u.sourceSlots.push(t)) : (u.sources = [this], u.sourceSlots = [t]), e ? (e.push(u), this.observerSlots.push(u.sources.length - 1)) : (this.observers = [u], this.observerSlots = [u.sources.length - 1]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return this.value;
|
|
94
|
+
}
|
|
95
|
+
function de(e, t, n) {
|
|
96
|
+
let o = e.value;
|
|
97
|
+
return (!e.comparator || !e.comparator(o, t)) && (e.value = t, e.observers && e.observers.length && A(() => {
|
|
98
|
+
for (let i = 0; i < e.observers.length; i += 1) {
|
|
99
|
+
const r = e.observers[i], l = G && G.running;
|
|
100
|
+
l && G.disposed.has(r), (l ? !r.tState : !r.state) && (r.pure ? g.push(r) : b.push(r), r.observers && pe(r)), l || (r.state = E);
|
|
101
|
+
}
|
|
102
|
+
if (g.length > 1e6)
|
|
103
|
+
throw g = [], new Error();
|
|
104
|
+
}, !1)), t;
|
|
105
|
+
}
|
|
106
|
+
function $(e) {
|
|
107
|
+
if (!e.fn) return;
|
|
108
|
+
T(e);
|
|
109
|
+
const t = V;
|
|
110
|
+
Ne(e, e.value, t);
|
|
111
|
+
}
|
|
112
|
+
function Ne(e, t, n) {
|
|
113
|
+
let o;
|
|
114
|
+
const i = a, r = u;
|
|
115
|
+
u = a = e;
|
|
116
|
+
try {
|
|
117
|
+
o = e.fn(t);
|
|
118
|
+
} catch (l) {
|
|
119
|
+
return e.pure && (e.state = E, e.owned && e.owned.forEach(T), e.owned = null), e.updatedAt = n + 1, q(l);
|
|
120
|
+
} finally {
|
|
121
|
+
u = r, a = i;
|
|
122
|
+
}
|
|
123
|
+
(!e.updatedAt || e.updatedAt <= n) && (e.updatedAt != null && "observers" in e ? de(e, o) : e.value = o, e.updatedAt = n);
|
|
124
|
+
}
|
|
125
|
+
function I(e, t, n, o = E, i) {
|
|
126
|
+
const r = {
|
|
127
|
+
fn: e,
|
|
128
|
+
state: o,
|
|
129
|
+
updatedAt: null,
|
|
130
|
+
owned: null,
|
|
131
|
+
sources: null,
|
|
132
|
+
sourceSlots: null,
|
|
133
|
+
cleanups: null,
|
|
134
|
+
value: t,
|
|
135
|
+
owner: a,
|
|
136
|
+
context: a ? a.context : null,
|
|
137
|
+
pure: n
|
|
138
|
+
};
|
|
139
|
+
return a === null || a !== ce && (a.owned ? a.owned.push(r) : a.owned = [r]), r;
|
|
140
|
+
}
|
|
141
|
+
function M(e) {
|
|
142
|
+
if (e.state === 0) return;
|
|
143
|
+
if (e.state === O) return B(e);
|
|
144
|
+
if (e.suspense && x(e.suspense.inFallback)) return e.suspense.effects.push(e);
|
|
145
|
+
const t = [e];
|
|
146
|
+
for (; (e = e.owner) && (!e.updatedAt || e.updatedAt < V); )
|
|
147
|
+
e.state && t.push(e);
|
|
148
|
+
for (let n = t.length - 1; n >= 0; n--)
|
|
149
|
+
if (e = t[n], e.state === E)
|
|
150
|
+
$(e);
|
|
151
|
+
else if (e.state === O) {
|
|
152
|
+
const o = g;
|
|
153
|
+
g = null, A(() => B(e, t[0]), !1), g = o;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function A(e, t) {
|
|
157
|
+
if (g) return e();
|
|
158
|
+
let n = !1;
|
|
159
|
+
t || (g = []), b ? n = !0 : b = [], V++;
|
|
160
|
+
try {
|
|
161
|
+
const o = e();
|
|
162
|
+
return Le(n), o;
|
|
163
|
+
} catch (o) {
|
|
164
|
+
n || (b = null), g = null, q(o);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function Le(e) {
|
|
168
|
+
if (g && (he(g), g = null), e) return;
|
|
169
|
+
const t = b;
|
|
170
|
+
b = null, t.length && A(() => fe(t), !1);
|
|
171
|
+
}
|
|
172
|
+
function he(e) {
|
|
173
|
+
for (let t = 0; t < e.length; t++) M(e[t]);
|
|
174
|
+
}
|
|
175
|
+
function Oe(e) {
|
|
176
|
+
let t, n = 0;
|
|
177
|
+
for (t = 0; t < e.length; t++) {
|
|
178
|
+
const o = e[t];
|
|
179
|
+
o.user ? e[n++] = o : M(o);
|
|
180
|
+
}
|
|
181
|
+
for (t = 0; t < n; t++) M(e[t]);
|
|
182
|
+
}
|
|
183
|
+
function B(e, t) {
|
|
184
|
+
e.state = 0;
|
|
185
|
+
for (let n = 0; n < e.sources.length; n += 1) {
|
|
186
|
+
const o = e.sources[n];
|
|
187
|
+
if (o.sources) {
|
|
188
|
+
const i = o.state;
|
|
189
|
+
i === E ? o !== t && (!o.updatedAt || o.updatedAt < V) && M(o) : i === O && B(o, t);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function pe(e) {
|
|
194
|
+
for (let t = 0; t < e.observers.length; t += 1) {
|
|
195
|
+
const n = e.observers[t];
|
|
196
|
+
n.state || (n.state = O, n.pure ? g.push(n) : b.push(n), n.observers && pe(n));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function T(e) {
|
|
200
|
+
let t;
|
|
201
|
+
if (e.sources)
|
|
202
|
+
for (; e.sources.length; ) {
|
|
203
|
+
const n = e.sources.pop(), o = e.sourceSlots.pop(), i = n.observers;
|
|
204
|
+
if (i && i.length) {
|
|
205
|
+
const r = i.pop(), l = n.observerSlots.pop();
|
|
206
|
+
o < i.length && (r.sourceSlots[l] = o, i[o] = r, n.observerSlots[o] = l);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (e.tOwned) {
|
|
210
|
+
for (t = e.tOwned.length - 1; t >= 0; t--) T(e.tOwned[t]);
|
|
211
|
+
delete e.tOwned;
|
|
212
|
+
}
|
|
213
|
+
if (e.owned) {
|
|
214
|
+
for (t = e.owned.length - 1; t >= 0; t--) T(e.owned[t]);
|
|
215
|
+
e.owned = null;
|
|
216
|
+
}
|
|
217
|
+
if (e.cleanups) {
|
|
218
|
+
for (t = e.cleanups.length - 1; t >= 0; t--) e.cleanups[t]();
|
|
219
|
+
e.cleanups = null;
|
|
220
|
+
}
|
|
221
|
+
e.state = 0;
|
|
222
|
+
}
|
|
223
|
+
function _e(e) {
|
|
224
|
+
return e instanceof Error ? e : new Error(typeof e == "string" ? e : "Unknown error", {
|
|
225
|
+
cause: e
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
function q(e, t = a) {
|
|
229
|
+
throw _e(e);
|
|
230
|
+
}
|
|
231
|
+
function ie(e, t) {
|
|
232
|
+
return x(() => e(t || {}));
|
|
233
|
+
}
|
|
234
|
+
const Me = (e) => `Stale read from <${e}>.`;
|
|
235
|
+
function Be(e) {
|
|
236
|
+
const t = e.keyed, n = N(() => e.when, void 0, void 0), o = t ? n : N(n, void 0, {
|
|
237
|
+
equals: (i, r) => !i == !r
|
|
238
|
+
});
|
|
239
|
+
return N(() => {
|
|
240
|
+
const i = o();
|
|
241
|
+
if (i) {
|
|
242
|
+
const r = e.children;
|
|
243
|
+
return typeof r == "function" && r.length > 0 ? x(() => r(t ? i : () => {
|
|
244
|
+
if (!x(o)) throw Me("Show");
|
|
245
|
+
return n();
|
|
246
|
+
})) : r;
|
|
247
|
+
}
|
|
248
|
+
return e.fallback;
|
|
249
|
+
}, void 0, void 0);
|
|
250
|
+
}
|
|
251
|
+
function De(e, t, n) {
|
|
252
|
+
let o = n.length, i = t.length, r = o, l = 0, s = 0, f = t[i - 1].nextSibling, d = null;
|
|
253
|
+
for (; l < i || s < r; ) {
|
|
254
|
+
if (t[l] === n[s]) {
|
|
255
|
+
l++, s++;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
for (; t[i - 1] === n[r - 1]; )
|
|
259
|
+
i--, r--;
|
|
260
|
+
if (i === l) {
|
|
261
|
+
const h = r < o ? s ? n[s - 1].nextSibling : n[r - s] : f;
|
|
262
|
+
for (; s < r; ) e.insertBefore(n[s++], h);
|
|
263
|
+
} else if (r === s)
|
|
264
|
+
for (; l < i; )
|
|
265
|
+
(!d || !d.has(t[l])) && t[l].remove(), l++;
|
|
266
|
+
else if (t[l] === n[r - 1] && n[s] === t[i - 1]) {
|
|
267
|
+
const h = t[--i].nextSibling;
|
|
268
|
+
e.insertBefore(n[s++], t[l++].nextSibling), e.insertBefore(n[--r], h), t[i] = n[r];
|
|
269
|
+
} else {
|
|
270
|
+
if (!d) {
|
|
271
|
+
d = /* @__PURE__ */ new Map();
|
|
272
|
+
let m = s;
|
|
273
|
+
for (; m < r; ) d.set(n[m], m++);
|
|
274
|
+
}
|
|
275
|
+
const h = d.get(t[l]);
|
|
276
|
+
if (h != null)
|
|
277
|
+
if (s < h && h < r) {
|
|
278
|
+
let m = l, y = 1, S;
|
|
279
|
+
for (; ++m < i && m < r && !((S = d.get(t[m])) == null || S !== h + y); )
|
|
280
|
+
y++;
|
|
281
|
+
if (y > h - s) {
|
|
282
|
+
const j = t[l];
|
|
283
|
+
for (; s < h; ) e.insertBefore(n[s++], j);
|
|
284
|
+
} else e.replaceChild(n[s++], t[l++]);
|
|
285
|
+
} else l++;
|
|
286
|
+
else t[l++].remove();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const re = "_$DX_DELEGATE";
|
|
291
|
+
function Ue(e, t, n, o = {}) {
|
|
292
|
+
let i;
|
|
293
|
+
return ue((r) => {
|
|
294
|
+
i = r, t === document ? e() : D(t, e(), t.firstChild ? null : void 0, n);
|
|
295
|
+
}, o.owner), () => {
|
|
296
|
+
i(), t.textContent = "";
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function ge(e, t, n, o) {
|
|
300
|
+
let i;
|
|
301
|
+
const r = () => {
|
|
302
|
+
const s = o ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
303
|
+
return s.innerHTML = e, n ? s.content.firstChild.firstChild : o ? s.firstChild : s.content.firstChild;
|
|
304
|
+
}, l = t ? () => x(() => document.importNode(i || (i = r()), !0)) : () => (i || (i = r())).cloneNode(!0);
|
|
305
|
+
return l.cloneNode = l, l;
|
|
306
|
+
}
|
|
307
|
+
function Ve(e, t = window.document) {
|
|
308
|
+
const n = t[re] || (t[re] = /* @__PURE__ */ new Set());
|
|
309
|
+
for (let o = 0, i = e.length; o < i; o++) {
|
|
310
|
+
const r = e[o];
|
|
311
|
+
n.has(r) || (n.add(r), t.addEventListener(r, je));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function H(e, t, n) {
|
|
315
|
+
n != null ? e.style.setProperty(t, n) : e.style.removeProperty(t);
|
|
316
|
+
}
|
|
317
|
+
function R(e, t, n) {
|
|
318
|
+
return x(() => e(t, n));
|
|
319
|
+
}
|
|
320
|
+
function D(e, t, n, o) {
|
|
321
|
+
if (n !== void 0 && !o && (o = []), typeof t != "function") return U(e, t, o, n);
|
|
322
|
+
_((i) => U(e, t(), i, n), o);
|
|
323
|
+
}
|
|
324
|
+
function je(e) {
|
|
325
|
+
let t = e.target;
|
|
326
|
+
const n = `$$${e.type}`, o = e.target, i = e.currentTarget, r = (f) => Object.defineProperty(e, "target", {
|
|
327
|
+
configurable: !0,
|
|
328
|
+
value: f
|
|
329
|
+
}), l = () => {
|
|
330
|
+
const f = t[n];
|
|
331
|
+
if (f && !t.disabled) {
|
|
332
|
+
const d = t[`${n}Data`];
|
|
333
|
+
if (d !== void 0 ? f.call(t, d, e) : f.call(t, e), e.cancelBubble) return;
|
|
334
|
+
}
|
|
335
|
+
return t.host && typeof t.host != "string" && !t.host._$host && t.contains(e.target) && r(t.host), !0;
|
|
336
|
+
}, s = () => {
|
|
337
|
+
for (; l() && (t = t._$host || t.parentNode || t.host); ) ;
|
|
338
|
+
};
|
|
339
|
+
if (Object.defineProperty(e, "currentTarget", {
|
|
340
|
+
configurable: !0,
|
|
341
|
+
get() {
|
|
342
|
+
return t || document;
|
|
343
|
+
}
|
|
344
|
+
}), e.composedPath) {
|
|
345
|
+
const f = e.composedPath();
|
|
346
|
+
r(f[0]);
|
|
347
|
+
for (let d = 0; d < f.length - 2 && (t = f[d], !!l()); d++) {
|
|
348
|
+
if (t._$host) {
|
|
349
|
+
t = t._$host, s();
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
if (t.parentNode === i)
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
} else s();
|
|
356
|
+
r(o);
|
|
357
|
+
}
|
|
358
|
+
function U(e, t, n, o, i) {
|
|
359
|
+
for (; typeof n == "function"; ) n = n();
|
|
360
|
+
if (t === n) return n;
|
|
361
|
+
const r = typeof t, l = o !== void 0;
|
|
362
|
+
if (e = l && n[0] && n[0].parentNode || e, r === "string" || r === "number") {
|
|
363
|
+
if (r === "number" && (t = t.toString(), t === n))
|
|
364
|
+
return n;
|
|
365
|
+
if (l) {
|
|
366
|
+
let s = n[0];
|
|
367
|
+
s && s.nodeType === 3 ? s.data !== t && (s.data = t) : s = document.createTextNode(t), n = C(e, n, o, s);
|
|
368
|
+
} else
|
|
369
|
+
n !== "" && typeof n == "string" ? n = e.firstChild.data = t : n = e.textContent = t;
|
|
370
|
+
} else if (t == null || r === "boolean")
|
|
371
|
+
n = C(e, n, o);
|
|
372
|
+
else {
|
|
373
|
+
if (r === "function")
|
|
374
|
+
return _(() => {
|
|
375
|
+
let s = t();
|
|
376
|
+
for (; typeof s == "function"; ) s = s();
|
|
377
|
+
n = U(e, s, n, o);
|
|
378
|
+
}), () => n;
|
|
379
|
+
if (Array.isArray(t)) {
|
|
380
|
+
const s = [], f = n && Array.isArray(n);
|
|
381
|
+
if (F(s, t, n, i))
|
|
382
|
+
return _(() => n = U(e, s, n, o, !0)), () => n;
|
|
383
|
+
if (s.length === 0) {
|
|
384
|
+
if (n = C(e, n, o), l) return n;
|
|
385
|
+
} else f ? n.length === 0 ? le(e, s, o) : De(e, n, s) : (n && C(e), le(e, s));
|
|
386
|
+
n = s;
|
|
387
|
+
} else if (t.nodeType) {
|
|
388
|
+
if (Array.isArray(n)) {
|
|
389
|
+
if (l) return n = C(e, n, o, t);
|
|
390
|
+
C(e, n, null, t);
|
|
391
|
+
} else n == null || n === "" || !e.firstChild ? e.appendChild(t) : e.replaceChild(t, e.firstChild);
|
|
392
|
+
n = t;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return n;
|
|
396
|
+
}
|
|
397
|
+
function F(e, t, n, o) {
|
|
398
|
+
let i = !1;
|
|
399
|
+
for (let r = 0, l = t.length; r < l; r++) {
|
|
400
|
+
let s = t[r], f = n && n[e.length], d;
|
|
401
|
+
if (!(s == null || s === !0 || s === !1)) if ((d = typeof s) == "object" && s.nodeType)
|
|
402
|
+
e.push(s);
|
|
403
|
+
else if (Array.isArray(s))
|
|
404
|
+
i = F(e, s, f) || i;
|
|
405
|
+
else if (d === "function")
|
|
406
|
+
if (o) {
|
|
407
|
+
for (; typeof s == "function"; ) s = s();
|
|
408
|
+
i = F(e, Array.isArray(s) ? s : [s], Array.isArray(f) ? f : [f]) || i;
|
|
409
|
+
} else
|
|
410
|
+
e.push(s), i = !0;
|
|
411
|
+
else {
|
|
412
|
+
const h = String(s);
|
|
413
|
+
f && f.nodeType === 3 && f.data === h ? e.push(f) : e.push(document.createTextNode(h));
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return i;
|
|
417
|
+
}
|
|
418
|
+
function le(e, t, n = null) {
|
|
419
|
+
for (let o = 0, i = t.length; o < i; o++) e.insertBefore(t[o], n);
|
|
420
|
+
}
|
|
421
|
+
function C(e, t, n, o) {
|
|
422
|
+
if (n === void 0) return e.textContent = "";
|
|
423
|
+
const i = o || document.createTextNode("");
|
|
424
|
+
if (t.length) {
|
|
425
|
+
let r = !1;
|
|
426
|
+
for (let l = t.length - 1; l >= 0; l--) {
|
|
427
|
+
const s = t[l];
|
|
428
|
+
if (i !== s) {
|
|
429
|
+
const f = s.parentNode === e;
|
|
430
|
+
!r && !l ? f ? e.replaceChild(i, s) : e.insertBefore(i, n) : f && s.remove();
|
|
431
|
+
} else r = !0;
|
|
432
|
+
}
|
|
433
|
+
} else e.insertBefore(i, n);
|
|
434
|
+
return [i];
|
|
435
|
+
}
|
|
436
|
+
const Ge = "http://www.w3.org/2000/svg";
|
|
437
|
+
function He(e, t = !1, n = void 0) {
|
|
438
|
+
return t ? document.createElementNS(Ge, e) : document.createElement(e, {
|
|
439
|
+
is: n
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
function Re(e) {
|
|
443
|
+
const {
|
|
444
|
+
useShadow: t
|
|
445
|
+
} = e, n = document.createTextNode(""), o = () => e.mount || document.body, i = $e();
|
|
446
|
+
let r;
|
|
447
|
+
return Te(() => {
|
|
448
|
+
r || (r = Pe(i, () => N(() => e.children)));
|
|
449
|
+
const l = o();
|
|
450
|
+
if (l instanceof HTMLHeadElement) {
|
|
451
|
+
const [s, f] = k(!1), d = () => f(!0);
|
|
452
|
+
ue((h) => D(l, () => s() ? h() : r(), null)), se(d);
|
|
453
|
+
} else {
|
|
454
|
+
const s = He(e.isSVG ? "g" : "div", e.isSVG), f = t && s.attachShadow ? s.attachShadow({
|
|
455
|
+
mode: "open"
|
|
456
|
+
}) : s;
|
|
457
|
+
Object.defineProperty(s, "_$host", {
|
|
458
|
+
get() {
|
|
459
|
+
return n.parentNode;
|
|
460
|
+
},
|
|
461
|
+
configurable: !0
|
|
462
|
+
}), D(f, r), l.appendChild(s), e.ref && e.ref(s), se(() => l.contains(s) && l.removeChild(s));
|
|
463
|
+
}
|
|
464
|
+
}, void 0, {}), n;
|
|
465
|
+
}
|
|
466
|
+
var Fe = /* @__PURE__ */ ge("<div class=llm-config-tray-popover style=transform:translateY(-100%)><div>"), Ie = /* @__PURE__ */ ge('<div class=llm-config-tray><button class=llm-config-tray-button title="LLM model & config"><span>🤖</span><span>model');
|
|
467
|
+
function We(e) {
|
|
468
|
+
const t = document.createElement("style");
|
|
469
|
+
t.textContent = `
|
|
470
|
+
.llm-config-tray { position: relative; display: inline-flex; align-items: center; }
|
|
471
|
+
.llm-config-tray-button {
|
|
472
|
+
display: inline-flex; align-items: center; gap: var(--studio-space-2xs, 0.25rem);
|
|
473
|
+
height: 1.75rem; padding: 0 var(--studio-space-xs, 0.375rem);
|
|
474
|
+
border: 1px solid var(--studio-chrome-offset-20, var(--studio-fill-offset-20, #d4d4d4));
|
|
475
|
+
border-radius: var(--studio-radius-sm, 4px);
|
|
476
|
+
background: var(--studio-chrome, var(--studio-fill, white));
|
|
477
|
+
color: var(--studio-chrome-line, var(--studio-line, black));
|
|
478
|
+
font: 500 0.75rem/1 var(--studio-family-sans, system-ui, sans-serif); cursor: pointer;
|
|
479
|
+
}
|
|
480
|
+
.llm-config-tray-button:hover {
|
|
481
|
+
background: var(--studio-chrome-offset-10, var(--studio-fill-offset-10, #f2f2f2));
|
|
482
|
+
}
|
|
483
|
+
.llm-config-tray-popover {
|
|
484
|
+
position: fixed; z-index: 2147483000;
|
|
485
|
+
max-width: min(92vw, 520px); max-height: 80vh; overflow: auto;
|
|
486
|
+
background: var(--studio-fill, white); color: var(--studio-line, black);
|
|
487
|
+
border: 1px solid var(--studio-fill-offset-20, #d4d4d4);
|
|
488
|
+
border-radius: var(--studio-radius-md, 8px);
|
|
489
|
+
box-shadow: var(--studio-shadow-lg, 0 8px 32px rgba(0,0,0,0.24));
|
|
490
|
+
padding: var(--studio-space-sm, 0.5rem);
|
|
491
|
+
}
|
|
492
|
+
`, e.append(t);
|
|
493
|
+
const [n, o] = k(!1), [i, r] = k(), [l, s] = k({}), [f, d] = k(null);
|
|
494
|
+
let h, m, y, S = null;
|
|
495
|
+
function j(c) {
|
|
496
|
+
return c ? {
|
|
497
|
+
read: () => {
|
|
498
|
+
try {
|
|
499
|
+
return Se(c);
|
|
500
|
+
} catch {
|
|
501
|
+
return oe();
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
write: (p) => Ee(c, p)
|
|
505
|
+
} : {
|
|
506
|
+
read: () => oe(),
|
|
507
|
+
write: (p) => xe(p)
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
async function me() {
|
|
511
|
+
const c = i(), p = l() || {};
|
|
512
|
+
await ve(c, e), y && (y.replaceChildren(), S = be({
|
|
513
|
+
source: j(c),
|
|
514
|
+
scope: c,
|
|
515
|
+
toolName: c?.toolName || p.toolName,
|
|
516
|
+
toolPrompt: p.toolPrompt,
|
|
517
|
+
toolTools: p.toolTools
|
|
518
|
+
}), y.append(S));
|
|
519
|
+
}
|
|
520
|
+
function we() {
|
|
521
|
+
const c = h.getBoundingClientRect();
|
|
522
|
+
d({
|
|
523
|
+
left: Math.max(8, c.right - 520),
|
|
524
|
+
top: Math.max(8, c.top - 8)
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function W(c, p) {
|
|
528
|
+
r(c?.toolId ? c : void 0), s(p || {}), we(), o(!0), queueMicrotask(me);
|
|
529
|
+
}
|
|
530
|
+
function P() {
|
|
531
|
+
try {
|
|
532
|
+
S?.destroy?.();
|
|
533
|
+
} catch {
|
|
534
|
+
}
|
|
535
|
+
S = null, o(!1);
|
|
536
|
+
}
|
|
537
|
+
const K = (c) => {
|
|
538
|
+
const p = c.detail;
|
|
539
|
+
!p || p.component !== "llm-config-tray" || W(p.scope, p);
|
|
540
|
+
};
|
|
541
|
+
document.addEventListener("patchwork:open-tool", K);
|
|
542
|
+
const Q = (c) => {
|
|
543
|
+
if (!n()) return;
|
|
544
|
+
const p = c.composedPath();
|
|
545
|
+
m && p.includes(m) || h && p.includes(h) || P();
|
|
546
|
+
}, X = (c) => {
|
|
547
|
+
c.key === "Escape" && n() && P();
|
|
548
|
+
};
|
|
549
|
+
document.addEventListener("click", Q), document.addEventListener("keydown", X);
|
|
550
|
+
const ye = Ue(() => (() => {
|
|
551
|
+
var c = Ie(), p = c.firstChild;
|
|
552
|
+
p.$$click = (w) => {
|
|
553
|
+
w.stopPropagation(), n() ? P() : W(void 0, {});
|
|
554
|
+
};
|
|
555
|
+
var Y = h;
|
|
556
|
+
return typeof Y == "function" ? R(Y, p) : h = p, D(c, ie(Be, {
|
|
557
|
+
get when() {
|
|
558
|
+
return n();
|
|
559
|
+
},
|
|
560
|
+
get children() {
|
|
561
|
+
return ie(Re, {
|
|
562
|
+
get mount() {
|
|
563
|
+
return document.body;
|
|
564
|
+
},
|
|
565
|
+
get children() {
|
|
566
|
+
var w = Fe(), J = w.firstChild;
|
|
567
|
+
w.$$click = (v) => v.stopPropagation();
|
|
568
|
+
var Z = m;
|
|
569
|
+
typeof Z == "function" ? R(Z, w) : m = w;
|
|
570
|
+
var z = y;
|
|
571
|
+
return typeof z == "function" ? R(z, J) : y = J, _((v) => {
|
|
572
|
+
var ee = `${f()?.left ?? 0}px`, te = `${f()?.top ?? 0}px`, ne = f() ? "visible" : "hidden";
|
|
573
|
+
return ee !== v.e && H(w, "left", v.e = ee), te !== v.t && H(w, "top", v.t = te), ne !== v.a && H(w, "visibility", v.a = ne), v;
|
|
574
|
+
}, {
|
|
575
|
+
e: void 0,
|
|
576
|
+
t: void 0,
|
|
577
|
+
a: void 0
|
|
578
|
+
}), w;
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}), null), c;
|
|
583
|
+
})(), e);
|
|
584
|
+
return () => {
|
|
585
|
+
P(), ye(), t.remove(), document.removeEventListener("patchwork:open-tool", K), document.removeEventListener("click", Q), document.removeEventListener("keydown", X);
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
Ve(["click"]);
|
|
589
|
+
export {
|
|
590
|
+
We as LlmConfigTray
|
|
591
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
function k(i) {
|
|
2
|
+
function u(n, e = {}) {
|
|
3
|
+
const { promise: m } = i.request(
|
|
4
|
+
{
|
|
5
|
+
op: "generate",
|
|
6
|
+
sessionKey: e.sessionKey,
|
|
7
|
+
scope: e.scope,
|
|
8
|
+
system: e.system,
|
|
9
|
+
// Handlers can't be structured-cloned across the isolation boundary.
|
|
10
|
+
tools: e.tools?.map(({ name: t, description: f, parameters: y, defaultOff: p }) => ({
|
|
11
|
+
name: t,
|
|
12
|
+
description: f,
|
|
13
|
+
parameters: y,
|
|
14
|
+
defaultOff: p
|
|
15
|
+
})),
|
|
16
|
+
userTools: e.userTools,
|
|
17
|
+
...typeof n == "string" ? { text: n } : { messages: n }
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
element: e.element,
|
|
21
|
+
signal: e.signal,
|
|
22
|
+
terminal: {
|
|
23
|
+
result: (t) => ({ text: t.text, toolCalls: t.toolCalls || null, toolMode: t.toolMode }),
|
|
24
|
+
error: (t) => {
|
|
25
|
+
throw new Error(t.message);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
onFrame: (t) => {
|
|
29
|
+
t.type === "token" ? e.onToken?.(t.delta, t.text) : t.type === "status" ? e.onStatus?.(t.message) : t.type === "model" && e.onModel?.(t.label);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
return m;
|
|
34
|
+
}
|
|
35
|
+
function c(n, e = {}) {
|
|
36
|
+
return i.request(
|
|
37
|
+
{ op: "run-tool", scope: e.scope, name: n.name, args: n.args },
|
|
38
|
+
{
|
|
39
|
+
element: e.element,
|
|
40
|
+
signal: e.signal,
|
|
41
|
+
terminal: {
|
|
42
|
+
"tool-result": (m) => m.result,
|
|
43
|
+
error: (m) => {
|
|
44
|
+
throw new Error(m.message);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
).promise;
|
|
49
|
+
}
|
|
50
|
+
async function o(n, e = {}) {
|
|
51
|
+
const { maxRounds: m = 6, onToolCall: t, onToken: f, ...y } = e, p = e.tools || [], h = typeof n == "string" ? [{ role: "user", content: n }] : [...n];
|
|
52
|
+
async function w(a) {
|
|
53
|
+
const { name: s, args: g } = a;
|
|
54
|
+
try {
|
|
55
|
+
let r;
|
|
56
|
+
if (a.host) r = await c(a, e);
|
|
57
|
+
else {
|
|
58
|
+
const l = p.find((d) => d.name === s)?.handler;
|
|
59
|
+
if (!l) throw new Error(`no tool named "${s}"`);
|
|
60
|
+
r = await l(g || {});
|
|
61
|
+
}
|
|
62
|
+
return t?.({ name: s, args: g, result: r }), typeof r == "string" ? r : JSON.stringify(r) ?? "";
|
|
63
|
+
} catch (r) {
|
|
64
|
+
const l = (
|
|
65
|
+
/** @type {any} */
|
|
66
|
+
r?.message || String(r)
|
|
67
|
+
);
|
|
68
|
+
return t?.({ name: s, args: g, error: l }), "Error: " + l;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
let T = "";
|
|
72
|
+
for (let a = 0; a < m; a++) {
|
|
73
|
+
const s = await u(h, {
|
|
74
|
+
...y,
|
|
75
|
+
userTools: y.userTools ?? !0,
|
|
76
|
+
onToken: f && ((l, d) => f(l, d, a))
|
|
77
|
+
});
|
|
78
|
+
if (T = s.text, !s.toolCalls) break;
|
|
79
|
+
const g = s.toolCalls.map((l, d) => ({ ...l, id: l.id || `call_${a}_${d}` })), r = [];
|
|
80
|
+
for (const l of g) r.push(await w(l));
|
|
81
|
+
h.push(...x(s, g, r));
|
|
82
|
+
}
|
|
83
|
+
return { text: T, messages: h };
|
|
84
|
+
}
|
|
85
|
+
return { generate: u, generateWithTools: o, runTool: c };
|
|
86
|
+
}
|
|
87
|
+
function x(i, u, c) {
|
|
88
|
+
return i.toolMode === "native" ? [
|
|
89
|
+
{
|
|
90
|
+
role: "assistant",
|
|
91
|
+
content: i.text || null,
|
|
92
|
+
tool_calls: u.map((o) => ({
|
|
93
|
+
id: o.id,
|
|
94
|
+
type: "function",
|
|
95
|
+
function: { name: o.name, arguments: JSON.stringify(o.args || {}) }
|
|
96
|
+
}))
|
|
97
|
+
},
|
|
98
|
+
...u.map((o, n) => ({ role: "tool", tool_call_id: o.id, content: c[n] }))
|
|
99
|
+
] : i.toolMode === "template" ? [
|
|
100
|
+
{
|
|
101
|
+
role: "assistant",
|
|
102
|
+
content: "",
|
|
103
|
+
tool_calls: u.map((o) => ({ type: "function", function: { name: o.name, arguments: o.args || {} } }))
|
|
104
|
+
},
|
|
105
|
+
...c.map((o) => ({ role: "tool", content: o }))
|
|
106
|
+
] : [
|
|
107
|
+
{ role: "assistant", content: i.text },
|
|
108
|
+
...u.map((o, n) => ({ role: "user", content: `Tool "${o.name}" returned:
|
|
109
|
+
${c[n]}` }))
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
k as makeLLMClient
|
|
114
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const a = [
|
|
2
|
+
{
|
|
3
|
+
// System-tray icon that opens the model/config picker. Tools open it with a
|
|
4
|
+
// `patchwork:open-tool` event, which isolation relays to the host.
|
|
5
|
+
type: "patchwork:component",
|
|
6
|
+
id: "llm-config-tray",
|
|
7
|
+
name: "LLM Model & Config",
|
|
8
|
+
icon: "Bot",
|
|
9
|
+
tags: ["system-tray"],
|
|
10
|
+
async load() {
|
|
11
|
+
const { LlmConfigTray: t } = await import("./LlmConfigTray-BPL_cmra.js");
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
// The serve half, run by the host's worker provider when a tool connects.
|
|
17
|
+
type: "patchwork:worker",
|
|
18
|
+
id: "llm",
|
|
19
|
+
name: "LLM",
|
|
20
|
+
async load() {
|
|
21
|
+
const t = await import("./patchwork-llm-h1ZevlV6.js"), { makeLLMWorkerSpec: o } = await import("./worker-spec-ceN4G8JW.js");
|
|
22
|
+
return o(t);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
// The consume half, resolved by `connectWorkerClient("llm", …)`. Imports
|
|
27
|
+
// nothing, so it's safe to load into a sandbox.
|
|
28
|
+
type: "patchwork:worker-client",
|
|
29
|
+
id: "llm",
|
|
30
|
+
name: "LLM client",
|
|
31
|
+
async load() {
|
|
32
|
+
const { makeLLMClient: t } = await import("./client-VAkC0nI7.js");
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
export {
|
|
38
|
+
a as plugins
|
|
39
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { getImportableUrlFromAutomergeUrl as e } from "@inkandswitch/patchwork-filesystem";
|
|
2
|
+
const t = e("automerge:m6dt2f4hYdhyvmFDvXYbYDdNQey", "./index.js"), o = await import(
|
|
3
|
+
/* @vite-ignore */
|
|
4
|
+
t
|
|
5
|
+
), r = o.readConfig, s = o.writeConfig, c = o.callConfig, a = o.normalizeConfig, i = o.subscribeConfig, l = o.resolveConfig, d = o.ensureSettingsDoc, p = o.ensureConfig, m = o.scopedRaw, L = o.hasScopeOverride, T = o.readScopedConfig, u = o.writeScopeOverride, P = o.clearScopeOverride, S = o.settingsDocHandle, g = o.applyPrompts, O = o.effectiveSystem, f = o.DEFAULTS, C = o.PARAM_KEYS, M = o.PROVIDER_CAPS, E = o.TOOL_STORAGE_ID, D = o.CONFIG_SELECTOR, v = o.LOCAL_MODELS, _ = o.WEBLLM_MODELS, b = o.fetchOpenRouterModels, A = o.fetchOllamaModels, R = o.describeConfig, y = o.generate, F = o.generateWithTools, h = o.stream, I = o.predict, w = o.scoreTokens, k = o.preload, x = o.abort, G = o.resume, V = o.onStatus, W = o.registerLocalModel, N = o.computeImportance, U = o.computeAttentionWeights, H = o.extractFeatures, Y = o.extractCutFeatures, z = o.decodeTokens, B = o.probeAttention, K = o.dom, j = o.popup, Q = o.builtinSupported, X = o.builtinAvailability, q = o.builtinGenerate, J = o.createWorker, Z = o.prepareGenerate, $ = o.buildGeneratePayload, oo = o.NATIVE_TOOL_PROVIDERS, eo = o.TEMPLATE_TOOL_PROVIDERS, to = o.createLLMTool, no = o.createToolFile, ro = o.LLMToolDatatype, so = o.sanitizeToolName, co = o.resolveTools, ao = o.toToolSchemas, io = o.buildToolsSystem, lo = o.parseToolCalls, po = o.loadHandler, mo = o.runTool, Lo = o.runHandlerSandboxed, To = o.createPromptDoc, uo = o.resolvePromptDocs, Po = o.resolvePromptText, So = o.resolveCfgPrompts, go = o.LLMSystemPromptDatatype, Oo = o.LLMPrePromptDatatype, fo = o.ensureFolderUrl, Co = o.addToFolder, Mo = o.removeFromFolder, Eo = o.migrateConfig, Do = o.PatchworkLLMConfigProvider, vo = o.definePatchworkLLMConfigProvider, _o = o.PROMPT_TEMPLATES;
|
|
6
|
+
export {
|
|
7
|
+
D as CONFIG_SELECTOR,
|
|
8
|
+
f as DEFAULTS,
|
|
9
|
+
Oo as LLMPrePromptDatatype,
|
|
10
|
+
go as LLMSystemPromptDatatype,
|
|
11
|
+
ro as LLMToolDatatype,
|
|
12
|
+
v as LOCAL_MODELS,
|
|
13
|
+
oo as NATIVE_TOOL_PROVIDERS,
|
|
14
|
+
C as PARAM_KEYS,
|
|
15
|
+
_o as PROMPT_TEMPLATES,
|
|
16
|
+
M as PROVIDER_CAPS,
|
|
17
|
+
Do as PatchworkLLMConfigProvider,
|
|
18
|
+
eo as TEMPLATE_TOOL_PROVIDERS,
|
|
19
|
+
E as TOOL_STORAGE_ID,
|
|
20
|
+
_ as WEBLLM_MODELS,
|
|
21
|
+
x as abort,
|
|
22
|
+
Co as addToFolder,
|
|
23
|
+
g as applyPrompts,
|
|
24
|
+
$ as buildGeneratePayload,
|
|
25
|
+
io as buildToolsSystem,
|
|
26
|
+
X as builtinAvailability,
|
|
27
|
+
q as builtinGenerate,
|
|
28
|
+
Q as builtinSupported,
|
|
29
|
+
c as callConfig,
|
|
30
|
+
P as clearScopeOverride,
|
|
31
|
+
U as computeAttentionWeights,
|
|
32
|
+
N as computeImportance,
|
|
33
|
+
to as createLLMTool,
|
|
34
|
+
To as createPromptDoc,
|
|
35
|
+
no as createToolFile,
|
|
36
|
+
J as createWorker,
|
|
37
|
+
z as decodeTokens,
|
|
38
|
+
vo as definePatchworkLLMConfigProvider,
|
|
39
|
+
R as describeConfig,
|
|
40
|
+
K as dom,
|
|
41
|
+
O as effectiveSystem,
|
|
42
|
+
p as ensureConfig,
|
|
43
|
+
fo as ensureFolderUrl,
|
|
44
|
+
d as ensureSettingsDoc,
|
|
45
|
+
Y as extractCutFeatures,
|
|
46
|
+
H as extractFeatures,
|
|
47
|
+
A as fetchOllamaModels,
|
|
48
|
+
b as fetchOpenRouterModels,
|
|
49
|
+
y as generate,
|
|
50
|
+
F as generateWithTools,
|
|
51
|
+
L as hasScopeOverride,
|
|
52
|
+
po as loadHandler,
|
|
53
|
+
Eo as migrateConfig,
|
|
54
|
+
a as normalizeConfig,
|
|
55
|
+
V as onStatus,
|
|
56
|
+
lo as parseToolCalls,
|
|
57
|
+
j as popup,
|
|
58
|
+
I as predict,
|
|
59
|
+
k as preload,
|
|
60
|
+
Z as prepareGenerate,
|
|
61
|
+
B as probeAttention,
|
|
62
|
+
r as readConfig,
|
|
63
|
+
T as readScopedConfig,
|
|
64
|
+
W as registerLocalModel,
|
|
65
|
+
Mo as removeFromFolder,
|
|
66
|
+
So as resolveCfgPrompts,
|
|
67
|
+
l as resolveConfig,
|
|
68
|
+
uo as resolvePromptDocs,
|
|
69
|
+
Po as resolvePromptText,
|
|
70
|
+
co as resolveTools,
|
|
71
|
+
G as resume,
|
|
72
|
+
Lo as runHandlerSandboxed,
|
|
73
|
+
mo as runTool,
|
|
74
|
+
so as sanitizeToolName,
|
|
75
|
+
m as scopedRaw,
|
|
76
|
+
w as scoreTokens,
|
|
77
|
+
S as settingsDocHandle,
|
|
78
|
+
h as stream,
|
|
79
|
+
i as subscribeConfig,
|
|
80
|
+
ao as toToolSchemas,
|
|
81
|
+
s as writeConfig,
|
|
82
|
+
u as writeScopeOverride
|
|
83
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
function L(t, c) {
|
|
2
|
+
return t == null || typeof t == "string" ? t ?? void 0 : t[c] ?? t.default ?? void 0;
|
|
3
|
+
}
|
|
4
|
+
function B(t, c = {}) {
|
|
5
|
+
return Array.isArray(t) ? t.filter((h) => h.defaultOff ? c[h.name] === !0 : c[h.name] !== !1) : [];
|
|
6
|
+
}
|
|
7
|
+
function V(t) {
|
|
8
|
+
const { sanitizeToolName: c } = t, h = /* @__PURE__ */ new Set();
|
|
9
|
+
let S = null;
|
|
10
|
+
async function E(e) {
|
|
11
|
+
try {
|
|
12
|
+
return e.provider === "openrouter" && (S ??= t.fetchOpenRouterModels().catch(() => [])), t.describeConfig(e, { openrouterModels: await S || [] });
|
|
13
|
+
} catch {
|
|
14
|
+
return "the configured model";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function m(e, n) {
|
|
18
|
+
return n && await n, t.settingsDocHandle() || await t.ensureSettingsDoc(), t.ensureConfig(e.scope);
|
|
19
|
+
}
|
|
20
|
+
function A(e) {
|
|
21
|
+
return {
|
|
22
|
+
temperature: e.temperature,
|
|
23
|
+
topP: e.topP,
|
|
24
|
+
topk: e.topk,
|
|
25
|
+
maxNewTokens: e.maxNewTokens
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function x(e, n) {
|
|
29
|
+
const o = await t.resolveCfgPrompts(await m(e, n));
|
|
30
|
+
return { cfg: o, config: t.callConfig(o, A(e)) };
|
|
31
|
+
}
|
|
32
|
+
async function R(e, n) {
|
|
33
|
+
const o = B(e.tools, n.toolToggles).map((s) => ({
|
|
34
|
+
name: s.name,
|
|
35
|
+
description: s.description,
|
|
36
|
+
parameters: s.parameters
|
|
37
|
+
}));
|
|
38
|
+
if (!e.userTools) return o;
|
|
39
|
+
const r = new Set(o.map((s) => c(s.name)));
|
|
40
|
+
for (const s of await t.resolveTools(n))
|
|
41
|
+
r.has(c(s.name)) || (r.add(c(s.name)), o.push({ name: s.name, description: s.description, parameters: s.parameters, host: !0 }));
|
|
42
|
+
return o;
|
|
43
|
+
}
|
|
44
|
+
function M(e, n) {
|
|
45
|
+
return e.find((o) => o.name === n) ?? e.find((o) => c(o.name) === n);
|
|
46
|
+
}
|
|
47
|
+
function W(e) {
|
|
48
|
+
return Array.isArray(e) ? e.map(
|
|
49
|
+
(n) => Array.isArray(n?.tool_calls) ? {
|
|
50
|
+
...n,
|
|
51
|
+
tool_calls: n.tool_calls.map(
|
|
52
|
+
(o) => o?.function ? { ...o, function: { ...o.function, name: c(o.function.name) } } : o
|
|
53
|
+
)
|
|
54
|
+
} : n
|
|
55
|
+
) : e;
|
|
56
|
+
}
|
|
57
|
+
function P(e, n) {
|
|
58
|
+
if (!n.length) return { toolCalls: null, toolMode: e.toolMode };
|
|
59
|
+
const o = Array.isArray(e.toolCalls) && e.toolCalls.length > 0, r = o ? e.toolCalls : t.parseToolCalls(e.text || ""), s = [];
|
|
60
|
+
for (const f of r) {
|
|
61
|
+
const d = M(n, f.name);
|
|
62
|
+
!d && !o || s.push({ ...f, name: d?.name ?? f.name, ...d?.host ? { host: !0 } : {} });
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
toolCalls: s.length ? s : null,
|
|
66
|
+
toolMode: o ? "native" : e.toolMode === "template" ? "template" : "text"
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
createWorker: t.createWorker,
|
|
71
|
+
/**
|
|
72
|
+
* Warm the settings doc. `ctx.element` reaches the tool-storage provider;
|
|
73
|
+
* the transport bounds this with a timeout.
|
|
74
|
+
* @param {{element?: HTMLElement}} ctx
|
|
75
|
+
*/
|
|
76
|
+
open(e) {
|
|
77
|
+
return e.element ? Promise.resolve(t.ensureSettingsDoc(e.element)).catch(() => null) : null;
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* @param {any} frame
|
|
81
|
+
* @param {any} io @grjte/patchwork-worker's IO: {post, emit, on, workerId, state}
|
|
82
|
+
*/
|
|
83
|
+
async handle(e, n) {
|
|
84
|
+
const { post: o, emit: r, on: s, workerId: f, state: d } = n, y = e.op, u = e.sessionKey || f;
|
|
85
|
+
if (y === "generate") {
|
|
86
|
+
const l = await m(e, d), i = await R(e, l), p = L(e.system, l.provider), v = {
|
|
87
|
+
messages: e.text != null ? e.text : W(e.messages),
|
|
88
|
+
// A continuation is a raw string prompt with no chat messages.
|
|
89
|
+
continuation: !!e.continuation && e.messages === void 0,
|
|
90
|
+
overrides: A(e)
|
|
91
|
+
}, w = () => t.prepareGenerate(l, { ...v, system: p, tools: i }), N = () => t.prepareGenerate(l, {
|
|
92
|
+
...v,
|
|
93
|
+
system: [t.buildToolsSystem(i), p].filter(Boolean).join(`
|
|
94
|
+
|
|
95
|
+
`)
|
|
96
|
+
});
|
|
97
|
+
let k = await w();
|
|
98
|
+
const { cfg: O, config: g } = k, _ = `${g.provider}:${g.model}`;
|
|
99
|
+
let T = i.length > 0 && t.NATIVE_TOOL_PROVIDERS.has(g.provider);
|
|
100
|
+
T && h.has(_) && (k = await N(), T = !1);
|
|
101
|
+
const F = T ? await N() : null;
|
|
102
|
+
if (E(O).then((a) => r({ type: "model", label: a })), k.builtin) {
|
|
103
|
+
try {
|
|
104
|
+
const a = await t.builtinGenerate(k.input, {
|
|
105
|
+
temperature: g.temperature,
|
|
106
|
+
topK: g.topK,
|
|
107
|
+
system: t.effectiveSystem(O, k.extraSystem),
|
|
108
|
+
onToken: (I, $) => r({ type: "token", delta: "", text: $ }),
|
|
109
|
+
onStatus: (I) => r({ type: "status", message: I })
|
|
110
|
+
});
|
|
111
|
+
r({ type: "result", text: a, ...P({ text: a }, i) });
|
|
112
|
+
} catch (a) {
|
|
113
|
+
r({ type: "error", message: (
|
|
114
|
+
/** @type {any} */
|
|
115
|
+
a?.message || String(a)
|
|
116
|
+
) });
|
|
117
|
+
}
|
|
118
|
+
return { sessionKey: u };
|
|
119
|
+
}
|
|
120
|
+
const D = (a) => o(t.buildGeneratePayload(a.config, a.input, { id: f, sessionKey: u }));
|
|
121
|
+
let G = !1, C = !1;
|
|
122
|
+
return s((a) => {
|
|
123
|
+
switch (a.type) {
|
|
124
|
+
case "token":
|
|
125
|
+
return G = !0, r(a), !1;
|
|
126
|
+
case "prediction":
|
|
127
|
+
case "stats":
|
|
128
|
+
return r(a), !1;
|
|
129
|
+
case "result":
|
|
130
|
+
return C && h.add(_), r({ ...a, ...P(a, i) }), !0;
|
|
131
|
+
case "error":
|
|
132
|
+
return F && !G && !C ? (C = !0, D(F), !1) : (r(a), !0);
|
|
133
|
+
}
|
|
134
|
+
return !1;
|
|
135
|
+
}), D(k), { sessionKey: u };
|
|
136
|
+
}
|
|
137
|
+
if (y === "run-tool") {
|
|
138
|
+
const l = await m(e, d), i = M(await t.resolveTools(l), e.name);
|
|
139
|
+
if (!i) throw new Error(`no tool named "${e.name}"`);
|
|
140
|
+
const p = await t.runTool(i, e.args, { sandbox: !0 });
|
|
141
|
+
return r({ type: "tool-result", result: p }), { sessionKey: u };
|
|
142
|
+
}
|
|
143
|
+
if (y === "predict") {
|
|
144
|
+
const { cfg: l, config: i } = await x(e, d);
|
|
145
|
+
return i.continuation = !!e.continuation, i.provider === "builtin" ? (r({ type: "predictions", candidates: [] }), { sessionKey: u }) : (s((p) => p.type !== "predictions" && p.type !== "error" ? !1 : (r(p), !0)), o({
|
|
146
|
+
type: "predict",
|
|
147
|
+
id: f,
|
|
148
|
+
sessionKey: u,
|
|
149
|
+
provider: i.provider,
|
|
150
|
+
text: t.applyPrompts(e.text, l, L(e.system, i.provider)),
|
|
151
|
+
config: i
|
|
152
|
+
}), { sessionKey: u });
|
|
153
|
+
}
|
|
154
|
+
const K = {
|
|
155
|
+
"score-tokens": ["token-scores", "score-progress"],
|
|
156
|
+
"compute-importance": ["importance-scores"],
|
|
157
|
+
"compute-attention-weights": ["attention-weights"],
|
|
158
|
+
"extract-features": ["features"],
|
|
159
|
+
"extract-cut-features": ["cut-features"],
|
|
160
|
+
"decode-tokens": ["decoded-tokens"],
|
|
161
|
+
"probe-attention": ["probe-attention-result"]
|
|
162
|
+
};
|
|
163
|
+
if (K[y]) {
|
|
164
|
+
const { config: l } = await x(e, d), [i, p] = K[y];
|
|
165
|
+
s((w) => (w.type === p && r(w), w.type !== i && w.type !== "error" ? !1 : (r(w), !0)));
|
|
166
|
+
const v = { type: y, id: f, sessionKey: u, provider: l.provider, config: l };
|
|
167
|
+
return e.text != null && (v.text = e.text), e.ids != null && (v.ids = e.ids), o(v), { sessionKey: u };
|
|
168
|
+
}
|
|
169
|
+
if (y === "preload") {
|
|
170
|
+
const { config: l } = await x(e, d);
|
|
171
|
+
o({ type: "preload", provider: l.provider, config: l });
|
|
172
|
+
}
|
|
173
|
+
return { sessionKey: u };
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* The worker keys in-flight generations by sessionKey.
|
|
177
|
+
* @param {{sessionKey: string}} token
|
|
178
|
+
* @param {(m: any) => void} post
|
|
179
|
+
*/
|
|
180
|
+
abort(e, n) {
|
|
181
|
+
n({ type: "abort", sessionKey: e.sessionKey });
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
V as makeLLMWorkerSpec
|
|
187
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@grjte/llm-host",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The host-realm LLM package: owns the settings doc + config picker (llm-config-tray) and registers the LLM worker as a patchwork:worker plugin. The library itself is @chee/patchwork-llm.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "vite build",
|
|
12
|
+
"dev": "vite build --watch",
|
|
13
|
+
"push": "pnpm build && pushwork sync",
|
|
14
|
+
"register": "pw-modules add \"$MODULE_SETTINGS_DOC_URL\" \"$(pushwork url)\"",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:watch": "vitest"
|
|
17
|
+
},
|
|
18
|
+
"author": "grjte",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@chee/patchwork-llm": "automerge:m6dt2f4hYdhyvmFDvXYbYDdNQey",
|
|
22
|
+
"solid-js": "^1.9.11"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@chee/patchwork-bundles": "^0.2.0",
|
|
26
|
+
"@inkandswitch/patchwork-bootloader": "^0.0.3",
|
|
27
|
+
"@inkandswitch/patchwork-plugins": "^0.0.5",
|
|
28
|
+
"happy-dom": "^15.11.7",
|
|
29
|
+
"typescript": "^5.8.3",
|
|
30
|
+
"vite": "^5.4.19",
|
|
31
|
+
"vite-plugin-solid": "^2.10.0",
|
|
32
|
+
"vitest": "^3.2.4"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-FW4363Y4.js";function a(){return new Promise(t=>setTimeout(t))}async function e(t){let{renderPatchworkFrame:o}=await import("./PatchworkFrame-3XYJCU3F.js");return await a(),o(t)}var n=[{type:"patchwork:datatype",id:"account",name:"Patchwork Account",icon:"UserCircle",unlisted:!0,async load(){let{AccountDatatype:t}=await import("./datatypes-WPL4KARJ.js");return t}},{type:"patchwork:datatype",id:"threepane:config",name:"Threepane Config",icon:"Settings",unlisted:!0,async load(){let{ThreepaneConfigDatatype:t}=await import("./datatypes-WPL4KARJ.js");return t}},{type:"patchwork:tool",id:"threepane",tags:["frame-tool"],name:"Threepane
|
|
1
|
+
import"./chunk-FW4363Y4.js";function a(){return new Promise(t=>setTimeout(t))}async function e(t){let{renderPatchworkFrame:o}=await import("./PatchworkFrame-3XYJCU3F.js");return await a(),o(t)}var n=[{type:"patchwork:datatype",id:"account",name:"Patchwork Account",icon:"UserCircle",unlisted:!0,async load(){let{AccountDatatype:t}=await import("./datatypes-WPL4KARJ.js");return t}},{type:"patchwork:datatype",id:"threepane:config",name:"Threepane Config",icon:"Settings",unlisted:!0,async load(){let{ThreepaneConfigDatatype:t}=await import("./datatypes-WPL4KARJ.js");return t}},{type:"patchwork:tool",id:"threepane",tags:["frame-tool"],name:"Threepane",icon:"Window",supportedDatatypes:["account"],load:e},{type:"patchwork:tool",id:"threepane-isolation",tags:["frame-tool"],name:"Threepane (isolate)",icon:"Window",supportedDatatypes:["account"],load:()=>e(!0),unlisted:!0},{type:"patchwork:component",id:"threepane-isolation-root",name:"Threepane Isolation Root",async load(){let{mountIsolationRoot:t}=await import("./IsolatedDocumentArea-MSJE4GCW.js");return await a(),t}},{type:"patchwork:tool",id:"patchwork-frame",name:"Patchwork Frame",icon:"Window",supportedDatatypes:["account"],unlisted:!0,load:e}];export{n as plugins};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["function yieldToMacrotask() {\n return new Promise(resolve => setTimeout(resolve));\n}\nasync function loadFrame(isolation) {\n const {\n renderPatchworkFrame\n } = await import(\"./PatchworkFrame\");\n await yieldToMacrotask();\n return renderPatchworkFrame(isolation);\n}\nexport const plugins = [{\n type: \"patchwork:datatype\",\n id: \"account\",\n name: \"Patchwork Account\",\n icon: \"UserCircle\",\n unlisted: true,\n async load() {\n const {\n AccountDatatype\n } = await import(\"./datatypes\");\n return AccountDatatype;\n }\n}, {\n type: \"patchwork:datatype\",\n id: \"threepane:config\",\n name: \"Threepane Config\",\n icon: \"Settings\",\n unlisted: true,\n async load() {\n const {\n ThreepaneConfigDatatype\n } = await import(\"./datatypes\");\n return ThreepaneConfigDatatype;\n }\n}, {\n type: \"patchwork:tool\",\n id: \"threepane\",\n tags: [\"frame-tool\"],\n name: \"Threepane
|
|
5
|
-
"mappings": "4BAAA,SAASA,GAAmB,CAC1B,OAAO,IAAI,QAAQC,GAAW,WAAWA,CAAO,CAAC,CACnD,CACA,eAAeC,EAAUC,EAAW,CAClC,GAAM,CACJ,qBAAAC,CACF,EAAI,KAAM,QAAO,8BAAkB,EACnC,aAAMJ,EAAiB,EAChBI,EAAqBD,CAAS,CACvC,CACO,IAAME,EAAU,CAAC,CACtB,KAAM,qBACN,GAAI,UACJ,KAAM,oBACN,KAAM,aACN,SAAU,GACV,MAAM,MAAO,CACX,GAAM,CACJ,gBAAAC,CACF,EAAI,KAAM,QAAO,yBAAa,EAC9B,OAAOA,CACT,CACF,EAAG,CACD,KAAM,qBACN,GAAI,mBACJ,KAAM,mBACN,KAAM,WACN,SAAU,GACV,MAAM,MAAO,CACX,GAAM,CACJ,wBAAAC,CACF,EAAI,KAAM,QAAO,yBAAa,EAC9B,OAAOA,CACT,CACF,EAAG,CACD,KAAM,iBACN,GAAI,YACJ,KAAM,CAAC,YAAY,EACnB,KAAM,
|
|
4
|
+
"sourcesContent": ["function yieldToMacrotask() {\n return new Promise(resolve => setTimeout(resolve));\n}\nasync function loadFrame(isolation) {\n const {\n renderPatchworkFrame\n } = await import(\"./PatchworkFrame\");\n await yieldToMacrotask();\n return renderPatchworkFrame(isolation);\n}\nexport const plugins = [{\n type: \"patchwork:datatype\",\n id: \"account\",\n name: \"Patchwork Account\",\n icon: \"UserCircle\",\n unlisted: true,\n async load() {\n const {\n AccountDatatype\n } = await import(\"./datatypes\");\n return AccountDatatype;\n }\n}, {\n type: \"patchwork:datatype\",\n id: \"threepane:config\",\n name: \"Threepane Config\",\n icon: \"Settings\",\n unlisted: true,\n async load() {\n const {\n ThreepaneConfigDatatype\n } = await import(\"./datatypes\");\n return ThreepaneConfigDatatype;\n }\n}, {\n type: \"patchwork:tool\",\n id: \"threepane\",\n tags: [\"frame-tool\"],\n name: \"Threepane\",\n icon: \"Window\",\n supportedDatatypes: [\"account\"],\n load: loadFrame\n}, {\n type: \"patchwork:tool\",\n id: \"threepane-isolation\",\n tags: [\"frame-tool\"],\n name: \"Threepane (isolate)\",\n icon: \"Window\",\n supportedDatatypes: [\"account\"],\n load: () => loadFrame(true),\n unlisted: true\n}, {\n // The isolated document-area root mounted inside the iframe by `threepane-isolation`.\n type: \"patchwork:component\",\n id: \"threepane-isolation-root\",\n name: \"Threepane Isolation Root\",\n async load() {\n const {\n mountIsolationRoot\n } = await import(\"./components/IsolatedDocumentArea\");\n await yieldToMacrotask();\n return mountIsolationRoot;\n }\n}, {\n // Back-compat alias: accounts whose frameToolId still points at the old id\n // keep resolving. Unlisted + untagged so it isn't offered as a new option.\n type: \"patchwork:tool\",\n id: \"patchwork-frame\",\n name: \"Patchwork Frame\",\n icon: \"Window\",\n supportedDatatypes: [\"account\"],\n unlisted: true,\n load: loadFrame\n}];"],
|
|
5
|
+
"mappings": "4BAAA,SAASA,GAAmB,CAC1B,OAAO,IAAI,QAAQC,GAAW,WAAWA,CAAO,CAAC,CACnD,CACA,eAAeC,EAAUC,EAAW,CAClC,GAAM,CACJ,qBAAAC,CACF,EAAI,KAAM,QAAO,8BAAkB,EACnC,aAAMJ,EAAiB,EAChBI,EAAqBD,CAAS,CACvC,CACO,IAAME,EAAU,CAAC,CACtB,KAAM,qBACN,GAAI,UACJ,KAAM,oBACN,KAAM,aACN,SAAU,GACV,MAAM,MAAO,CACX,GAAM,CACJ,gBAAAC,CACF,EAAI,KAAM,QAAO,yBAAa,EAC9B,OAAOA,CACT,CACF,EAAG,CACD,KAAM,qBACN,GAAI,mBACJ,KAAM,mBACN,KAAM,WACN,SAAU,GACV,MAAM,MAAO,CACX,GAAM,CACJ,wBAAAC,CACF,EAAI,KAAM,QAAO,yBAAa,EAC9B,OAAOA,CACT,CACF,EAAG,CACD,KAAM,iBACN,GAAI,YACJ,KAAM,CAAC,YAAY,EACnB,KAAM,YACN,KAAM,SACN,mBAAoB,CAAC,SAAS,EAC9B,KAAML,CACR,EAAG,CACD,KAAM,iBACN,GAAI,sBACJ,KAAM,CAAC,YAAY,EACnB,KAAM,sBACN,KAAM,SACN,mBAAoB,CAAC,SAAS,EAC9B,KAAM,IAAMA,EAAU,EAAI,EAC1B,SAAU,EACZ,EAAG,CAED,KAAM,sBACN,GAAI,2BACJ,KAAM,2BACN,MAAM,MAAO,CACX,GAAM,CACJ,mBAAAM,CACF,EAAI,KAAM,QAAO,oCAAmC,EACpD,aAAMR,EAAiB,EAChBQ,CACT,CACF,EAAG,CAGD,KAAM,iBACN,GAAI,kBACJ,KAAM,kBACN,KAAM,SACN,mBAAoB,CAAC,SAAS,EAC9B,SAAU,GACV,KAAMN,CACR,CAAC",
|
|
6
6
|
"names": ["yieldToMacrotask", "resolve", "loadFrame", "isolation", "renderPatchworkFrame", "plugins", "AccountDatatype", "ThreepaneConfigDatatype", "mountIsolationRoot"]
|
|
7
7
|
}
|
package/plugin-registry-url
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
automerge:
|
|
1
|
+
automerge:FFpDfe1Lp2itsHkWf29rFoWXDcy
|