@floegence/floe-webapp-core 0.35.7 → 0.35.9
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/components/chat/ChatProvider.js +170 -185
- package/dist/components/file-browser/FileBrowserContext.js +277 -245
- package/dist/components/ui/MobileKeyboard.d.ts +22 -0
- package/dist/components/ui/MobileKeyboard.js +287 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/mobileKeyboardModel.d.ts +24 -0
- package/dist/components/ui/mobileKeyboardModel.js +103 -0
- package/dist/floe.css +12 -0
- package/dist/full.d.ts +1 -0
- package/dist/full.js +546 -509
- package/dist/styles.css +1 -1
- package/dist/terminal/editorModel.d.ts +7 -0
- package/dist/terminal/editorModel.js +84 -0
- package/dist/terminal/mockRuntime.d.ts +2 -0
- package/dist/terminal/mockRuntime.js +287 -0
- package/dist/terminal/sessionModel.d.ts +37 -0
- package/dist/terminal/sessionModel.js +143 -0
- package/dist/terminal/suggestionEngine.d.ts +64 -0
- package/dist/terminal/suggestionEngine.js +1020 -0
- package/dist/terminal/types.d.ts +44 -0
- package/dist/terminal/workspaceProfile.d.ts +3 -0
- package/dist/terminal/workspaceProfile.js +30 -0
- package/dist/terminal.d.ts +6 -0
- package/dist/terminal.js +36 -0
- package/dist/ui.css +488 -0
- package/dist/ui.js +44 -42
- package/dist/utils/touchSurfaceGuard.d.ts +9 -0
- package/dist/utils/touchSurfaceGuard.js +16 -0
- package/dist/widgets/TerminalWidget.d.ts +17 -1
- package/dist/widgets/TerminalWidget.js +160 -65
- package/dist/widgets/index.d.ts +1 -1
- package/dist/widgets.js +5 -4
- package/package.json +5 -1
|
@@ -1,79 +1,94 @@
|
|
|
1
|
-
import { createComponent as
|
|
2
|
-
import { createMemo as
|
|
3
|
-
import { createStore as
|
|
4
|
-
import { deferNonBlocking as
|
|
1
|
+
import { createComponent as Y } from "solid-js/web";
|
|
2
|
+
import { createMemo as p, createEffect as Z, on as $, createSignal as b, useContext as ee, createContext as te, batch as F } from "solid-js";
|
|
3
|
+
import { createStore as oe, reconcile as T, produce as M } from "solid-js/store";
|
|
4
|
+
import { deferNonBlocking as k } from "../../utils/defer.js";
|
|
5
5
|
import { DEFAULT_VIRTUAL_LIST_CONFIG as se } from "./types.js";
|
|
6
|
-
const
|
|
6
|
+
const z = te();
|
|
7
7
|
function Ce() {
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
8
|
+
const n = ee(z);
|
|
9
|
+
if (!n)
|
|
10
10
|
throw new Error("useChatContext must be used within a ChatProvider");
|
|
11
|
-
return
|
|
11
|
+
return n;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const xe = (n) => {
|
|
14
|
+
const C = p(() => ({
|
|
15
15
|
placeholder: "Type a message...",
|
|
16
16
|
allowAttachments: !0,
|
|
17
17
|
maxAttachments: 10,
|
|
18
18
|
maxAttachmentSize: 10485760,
|
|
19
19
|
// 10MB
|
|
20
|
-
...
|
|
21
|
-
})),
|
|
20
|
+
...n.config
|
|
21
|
+
})), u = p(() => ({
|
|
22
22
|
...se,
|
|
23
|
-
...
|
|
24
|
-
})), [
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
...n.config?.virtualList
|
|
24
|
+
})), [a, l] = oe(n.initialMessages || []), B = /* @__PURE__ */ new Map(), R = p(() => {
|
|
25
|
+
const e = /* @__PURE__ */ new Map();
|
|
26
|
+
for (let t = 0; t < a.length; t += 1) {
|
|
27
|
+
const o = a[t]?.id;
|
|
28
|
+
o && e.set(o, t);
|
|
29
|
+
}
|
|
30
|
+
return e;
|
|
31
|
+
}), x = (e) => {
|
|
32
|
+
const t = R().get(e);
|
|
33
|
+
if (t !== void 0) return t;
|
|
34
|
+
const o = a.findIndex((s) => s.id === e);
|
|
35
|
+
return o >= 0 ? o : void 0;
|
|
36
|
+
};
|
|
37
|
+
Z($(() => n.initialMessages, (e) => {
|
|
38
|
+
e && e.length > 0 && l(T(e));
|
|
27
39
|
}, {
|
|
28
40
|
defer: !0
|
|
29
41
|
}));
|
|
30
|
-
const [A, H] =
|
|
31
|
-
let
|
|
32
|
-
const g = /* @__PURE__ */ new Set(),
|
|
42
|
+
const [A, H] = b(!1), [P, D] = b(!0), [L, S] = b(null), [O, I] = b(0);
|
|
43
|
+
let j = 0;
|
|
44
|
+
const g = /* @__PURE__ */ new Set(), f = [], h = /* @__PURE__ */ new Map(), q = (e) => {
|
|
33
45
|
if (!g.delete(e)) return;
|
|
34
|
-
const t =
|
|
35
|
-
t >= 0 &&
|
|
36
|
-
},
|
|
37
|
-
const e = ++
|
|
38
|
-
return g.add(e),
|
|
39
|
-
},
|
|
40
|
-
for (;
|
|
41
|
-
const e =
|
|
46
|
+
const t = f.indexOf(e);
|
|
47
|
+
t >= 0 && f.splice(t, 1), I(g.size);
|
|
48
|
+
}, N = () => {
|
|
49
|
+
const e = ++j;
|
|
50
|
+
return g.add(e), f.push(e), I(g.size), e;
|
|
51
|
+
}, W = () => {
|
|
52
|
+
for (; f.length > 0; ) {
|
|
53
|
+
const e = f.shift();
|
|
42
54
|
if (e === void 0) return;
|
|
43
55
|
if (g.has(e)) {
|
|
44
56
|
g.delete(e), I(g.size);
|
|
45
57
|
return;
|
|
46
58
|
}
|
|
47
59
|
}
|
|
48
|
-
}, U =
|
|
49
|
-
|
|
60
|
+
}, U = p(() => O() > 0), _ = p(() => U() || L() !== null), y = (e) => {
|
|
61
|
+
l(M((t) => {
|
|
50
62
|
t.push(e);
|
|
51
63
|
}));
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
n !== -1 && (s[n] = t(s[n]));
|
|
56
|
-
}));
|
|
57
|
-
}, W = (e) => {
|
|
58
|
-
u(M((t) => {
|
|
59
|
-
const s = t.findIndex((n) => n.id === e);
|
|
60
|
-
s !== -1 && t.splice(s, 1);
|
|
61
|
-
})), f.delete(e);
|
|
62
|
-
}, _ = () => {
|
|
63
|
-
u(v([])), f.clear();
|
|
64
|
+
}, E = (e, t) => {
|
|
65
|
+
const o = x(e);
|
|
66
|
+
o !== void 0 && l(o, (s) => t(s));
|
|
64
67
|
}, V = (e) => {
|
|
65
|
-
|
|
68
|
+
const t = x(e);
|
|
69
|
+
t !== void 0 && (l(M((o) => {
|
|
70
|
+
o.splice(t, 1);
|
|
71
|
+
})), h.delete(e));
|
|
72
|
+
}, G = () => {
|
|
73
|
+
l(T([])), h.clear();
|
|
74
|
+
}, Q = (e) => {
|
|
75
|
+
l(T(e));
|
|
76
|
+
}, i = (e, t) => {
|
|
77
|
+
const o = x(e);
|
|
78
|
+
o !== void 0 && l(o, M((s) => {
|
|
79
|
+
t(s);
|
|
80
|
+
}));
|
|
66
81
|
};
|
|
67
|
-
let
|
|
68
|
-
const
|
|
69
|
-
const e =
|
|
70
|
-
|
|
71
|
-
e.forEach(
|
|
82
|
+
let v = [], w = null;
|
|
83
|
+
const J = () => {
|
|
84
|
+
const e = v;
|
|
85
|
+
v = [], w = null, F(() => {
|
|
86
|
+
e.forEach(K);
|
|
72
87
|
});
|
|
73
|
-
},
|
|
88
|
+
}, K = (e) => {
|
|
74
89
|
switch (e.type) {
|
|
75
90
|
case "message-start": {
|
|
76
|
-
|
|
91
|
+
W();
|
|
77
92
|
const t = {
|
|
78
93
|
id: e.messageId,
|
|
79
94
|
role: "assistant",
|
|
@@ -81,105 +96,94 @@ const Me = (o) => {
|
|
|
81
96
|
status: "streaming",
|
|
82
97
|
timestamp: Date.now()
|
|
83
98
|
};
|
|
84
|
-
|
|
99
|
+
y(t), S(e.messageId);
|
|
85
100
|
break;
|
|
86
101
|
}
|
|
87
102
|
case "block-start": {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}));
|
|
103
|
+
i(e.messageId, (t) => {
|
|
104
|
+
t.blocks.push(ne(e.blockType));
|
|
105
|
+
});
|
|
92
106
|
break;
|
|
93
107
|
}
|
|
94
108
|
case "block-delta": {
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
...t,
|
|
99
|
-
blocks: s
|
|
100
|
-
};
|
|
109
|
+
i(e.messageId, (t) => {
|
|
110
|
+
const o = t.blocks[e.blockIndex];
|
|
111
|
+
o && "content" in o && typeof o.content == "string" && (o.content += e.delta);
|
|
101
112
|
});
|
|
102
113
|
break;
|
|
103
114
|
}
|
|
104
115
|
case "block-set": {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return e.blockIndex === s.length ? s.push(e.block) : e.blockIndex >= 0 && e.blockIndex < s.length && (s[e.blockIndex] = e.block), {
|
|
108
|
-
...t,
|
|
109
|
-
blocks: s
|
|
110
|
-
};
|
|
116
|
+
i(e.messageId, (t) => {
|
|
117
|
+
e.blockIndex === t.blocks.length ? t.blocks.push(e.block) : e.blockIndex >= 0 && e.blockIndex < t.blocks.length && (t.blocks[e.blockIndex] = e.block);
|
|
111
118
|
});
|
|
112
119
|
break;
|
|
113
120
|
}
|
|
114
121
|
case "block-end":
|
|
115
122
|
break;
|
|
116
123
|
case "message-end": {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
})), x(null);
|
|
124
|
+
i(e.messageId, (t) => {
|
|
125
|
+
t.status = "complete";
|
|
126
|
+
}), S(null);
|
|
121
127
|
break;
|
|
122
128
|
}
|
|
123
129
|
case "error": {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
error: e.error
|
|
128
|
-
})), x(null);
|
|
130
|
+
i(e.messageId, (t) => {
|
|
131
|
+
t.status = "error", t.error = e.error;
|
|
132
|
+
}), S(null);
|
|
129
133
|
break;
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
|
-
},
|
|
133
|
-
messages: () =>
|
|
134
|
-
coldMessages:
|
|
136
|
+
}, X = {
|
|
137
|
+
messages: () => a,
|
|
138
|
+
coldMessages: B,
|
|
135
139
|
isLoadingHistory: A,
|
|
136
140
|
hasMoreHistory: P,
|
|
137
141
|
streamingMessageId: L,
|
|
138
142
|
isPreparing: U,
|
|
139
|
-
isWorking:
|
|
140
|
-
config:
|
|
141
|
-
virtualListConfig:
|
|
143
|
+
isWorking: _,
|
|
144
|
+
config: C,
|
|
145
|
+
virtualListConfig: u,
|
|
142
146
|
sendMessage: async (e, t = []) => {
|
|
143
|
-
const
|
|
147
|
+
const o = {
|
|
144
148
|
id: crypto.randomUUID(),
|
|
145
149
|
role: "user",
|
|
146
|
-
blocks:
|
|
150
|
+
blocks: re(e, t),
|
|
147
151
|
status: "sending",
|
|
148
152
|
timestamp: Date.now()
|
|
149
153
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
...
|
|
154
|
+
F(() => {
|
|
155
|
+
y(o), E(o.id, (c) => ({
|
|
156
|
+
...c,
|
|
153
157
|
status: "complete"
|
|
154
158
|
}));
|
|
155
159
|
});
|
|
156
160
|
try {
|
|
157
|
-
|
|
158
|
-
} catch (
|
|
159
|
-
console.error("onWillSend error:",
|
|
161
|
+
n.callbacks?.onWillSend?.(e, t);
|
|
162
|
+
} catch (c) {
|
|
163
|
+
console.error("onWillSend error:", c);
|
|
160
164
|
}
|
|
161
|
-
const
|
|
162
|
-
if (!
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
Promise.resolve().then(() =>
|
|
166
|
-
console.error("Failed to send message:",
|
|
165
|
+
const s = n.callbacks?.onSendMessage;
|
|
166
|
+
if (!s) return;
|
|
167
|
+
const d = N(), r = e, m = [...t];
|
|
168
|
+
k(() => {
|
|
169
|
+
Promise.resolve().then(() => s(r, m, y)).catch((c) => {
|
|
170
|
+
console.error("Failed to send message:", c);
|
|
167
171
|
}).finally(() => {
|
|
168
|
-
|
|
172
|
+
q(d);
|
|
169
173
|
});
|
|
170
174
|
});
|
|
171
175
|
},
|
|
172
176
|
loadMoreHistory: async () => {
|
|
173
177
|
if (A() || !P()) return;
|
|
174
|
-
const e =
|
|
175
|
-
e && (H(!0),
|
|
178
|
+
const e = n.callbacks?.onLoadMore;
|
|
179
|
+
e && (H(!0), k(() => {
|
|
176
180
|
Promise.resolve(e()).then((t) => {
|
|
177
181
|
if (t.length === 0) {
|
|
178
|
-
|
|
182
|
+
D(!1);
|
|
179
183
|
return;
|
|
180
184
|
}
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
l(M((o) => {
|
|
186
|
+
o.unshift(...t);
|
|
183
187
|
}));
|
|
184
188
|
}).catch((t) => {
|
|
185
189
|
console.error("Failed to load history:", t);
|
|
@@ -189,106 +193,87 @@ const Me = (o) => {
|
|
|
189
193
|
}));
|
|
190
194
|
},
|
|
191
195
|
retryMessage: (e) => {
|
|
192
|
-
const t =
|
|
193
|
-
t &&
|
|
196
|
+
const t = n.callbacks?.onRetry;
|
|
197
|
+
t && k(() => {
|
|
194
198
|
try {
|
|
195
199
|
t(e);
|
|
196
|
-
} catch (
|
|
197
|
-
console.error("Failed to retry message:",
|
|
200
|
+
} catch (o) {
|
|
201
|
+
console.error("Failed to retry message:", o);
|
|
198
202
|
}
|
|
199
203
|
});
|
|
200
204
|
},
|
|
201
|
-
addMessage:
|
|
202
|
-
updateMessage:
|
|
203
|
-
deleteMessage:
|
|
204
|
-
clearMessages:
|
|
205
|
-
setMessages:
|
|
205
|
+
addMessage: y,
|
|
206
|
+
updateMessage: E,
|
|
207
|
+
deleteMessage: V,
|
|
208
|
+
clearMessages: G,
|
|
209
|
+
setMessages: Q,
|
|
206
210
|
handleStreamEvent: (e) => {
|
|
207
|
-
|
|
211
|
+
v.push(e), w || (w = requestAnimationFrame(J));
|
|
208
212
|
},
|
|
209
213
|
uploadAttachment: async (e) => {
|
|
210
|
-
const t =
|
|
214
|
+
const t = n.callbacks?.onUploadAttachment;
|
|
211
215
|
return t ? await t(e) : URL.createObjectURL(e);
|
|
212
216
|
},
|
|
213
217
|
toggleToolCollapse: (e, t) => {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return {
|
|
220
|
-
...n,
|
|
221
|
-
collapsed: a
|
|
222
|
-
};
|
|
218
|
+
i(e, (o) => {
|
|
219
|
+
for (const s of o.blocks)
|
|
220
|
+
if (s.type === "tool-call" && s.toolId === t) {
|
|
221
|
+
s.collapsed = s.collapsed === void 0 ? !1 : !s.collapsed;
|
|
222
|
+
break;
|
|
223
223
|
}
|
|
224
|
-
|
|
225
|
-
})
|
|
226
|
-
}));
|
|
224
|
+
});
|
|
227
225
|
},
|
|
228
|
-
approveToolCall: (e, t,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
})
|
|
241
|
-
}));
|
|
242
|
-
const n = o.callbacks?.onToolApproval;
|
|
243
|
-
n && p(() => {
|
|
244
|
-
Promise.resolve(n(e, t, s)).catch((a) => {
|
|
245
|
-
console.error("Failed to approve tool call:", a);
|
|
226
|
+
approveToolCall: (e, t, o) => {
|
|
227
|
+
i(e, (d) => {
|
|
228
|
+
for (const r of d.blocks)
|
|
229
|
+
if (!(r.type !== "tool-call" || r.toolId !== t) && !(r.requiresApproval !== !0 || r.approvalState !== "required")) {
|
|
230
|
+
o ? (r.approvalState = "approved", r.status = "running") : (r.approvalState = "rejected", r.status = "error", r.error = r.error || "Rejected by user");
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
const s = n.callbacks?.onToolApproval;
|
|
235
|
+
s && k(() => {
|
|
236
|
+
Promise.resolve(s(e, t, o)).catch((d) => {
|
|
237
|
+
console.error("Failed to approve tool call:", d);
|
|
246
238
|
});
|
|
247
239
|
});
|
|
248
240
|
},
|
|
249
|
-
heightCache:
|
|
241
|
+
heightCache: h,
|
|
250
242
|
setMessageHeight: (e, t) => {
|
|
251
|
-
|
|
243
|
+
h.set(e, t);
|
|
252
244
|
},
|
|
253
|
-
getMessageHeight: (e) =>
|
|
254
|
-
toggleChecklistItem: (e, t,
|
|
255
|
-
let
|
|
256
|
-
|
|
257
|
-
const m =
|
|
258
|
-
if (
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
...i,
|
|
265
|
-
items: K
|
|
266
|
-
};
|
|
245
|
+
getMessageHeight: (e) => h.get(e) || u().defaultItemHeight,
|
|
246
|
+
toggleChecklistItem: (e, t, o) => {
|
|
247
|
+
let s = null;
|
|
248
|
+
i(e, (r) => {
|
|
249
|
+
const m = r.blocks[t];
|
|
250
|
+
if (m && m.type === "checklist") {
|
|
251
|
+
for (const c of m.items)
|
|
252
|
+
if (c.id === o) {
|
|
253
|
+
s = !c.checked, c.checked = s;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
267
256
|
}
|
|
268
|
-
return {
|
|
269
|
-
...r,
|
|
270
|
-
blocks: m
|
|
271
|
-
};
|
|
272
257
|
});
|
|
273
|
-
const
|
|
274
|
-
!
|
|
258
|
+
const d = n.callbacks?.onChecklistChange;
|
|
259
|
+
!d || s === null || k(() => {
|
|
275
260
|
try {
|
|
276
|
-
|
|
261
|
+
d(e, t, o, s);
|
|
277
262
|
} catch (r) {
|
|
278
263
|
console.error("Failed to handle checklist change:", r);
|
|
279
264
|
}
|
|
280
265
|
});
|
|
281
266
|
}
|
|
282
267
|
};
|
|
283
|
-
return
|
|
284
|
-
value:
|
|
268
|
+
return Y(z.Provider, {
|
|
269
|
+
value: X,
|
|
285
270
|
get children() {
|
|
286
|
-
return
|
|
271
|
+
return n.children;
|
|
287
272
|
}
|
|
288
273
|
});
|
|
289
274
|
};
|
|
290
|
-
function ne(
|
|
291
|
-
switch (
|
|
275
|
+
function ne(n) {
|
|
276
|
+
switch (n) {
|
|
292
277
|
case "text":
|
|
293
278
|
return {
|
|
294
279
|
type: "text",
|
|
@@ -364,26 +349,26 @@ function ne(o) {
|
|
|
364
349
|
};
|
|
365
350
|
}
|
|
366
351
|
}
|
|
367
|
-
function
|
|
368
|
-
const
|
|
369
|
-
for (const
|
|
370
|
-
|
|
352
|
+
function re(n, C) {
|
|
353
|
+
const u = [];
|
|
354
|
+
for (const a of C)
|
|
355
|
+
a.type === "image" ? u.push({
|
|
371
356
|
type: "image",
|
|
372
|
-
src:
|
|
373
|
-
alt:
|
|
374
|
-
}) :
|
|
357
|
+
src: a.url || a.preview || "",
|
|
358
|
+
alt: a.file.name
|
|
359
|
+
}) : u.push({
|
|
375
360
|
type: "file",
|
|
376
|
-
name:
|
|
377
|
-
size:
|
|
378
|
-
mimeType:
|
|
379
|
-
url:
|
|
361
|
+
name: a.file.name,
|
|
362
|
+
size: a.file.size,
|
|
363
|
+
mimeType: a.file.type,
|
|
364
|
+
url: a.url
|
|
380
365
|
});
|
|
381
|
-
return
|
|
366
|
+
return n.trim() && u.push({
|
|
382
367
|
type: "text",
|
|
383
|
-
content:
|
|
384
|
-
}),
|
|
368
|
+
content: n.trim()
|
|
369
|
+
}), u;
|
|
385
370
|
}
|
|
386
371
|
export {
|
|
387
|
-
|
|
372
|
+
xe as ChatProvider,
|
|
388
373
|
Ce as useChatContext
|
|
389
374
|
};
|