@modelprofile.com/flexharness 6.1.0 → 7.0.0
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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts_chat/classes.chatsession.d.ts +37 -0
- package/dist_ts_chat/classes.chatsession.js +102 -0
- package/dist_ts_chat/index.d.ts +2 -0
- package/dist_ts_chat/index.js +2 -0
- package/dist_ts_chat/interfaces.d.ts +72 -0
- package/dist_ts_chat/interfaces.js +2 -0
- package/dist_ts_chat/plugins.d.ts +4 -0
- package/dist_ts_chat/plugins.js +4 -0
- package/dist_ts_chat_cli/components.chatapp.d.ts +10 -0
- package/dist_ts_chat_cli/components.chatapp.js +75 -0
- package/dist_ts_chat_cli/components.inputarea.d.ts +7 -0
- package/dist_ts_chat_cli/components.inputarea.js +18 -0
- package/dist_ts_chat_cli/components.message.d.ts +12 -0
- package/dist_ts_chat_cli/components.message.js +21 -0
- package/dist_ts_chat_cli/components.messagelist.d.ts +9 -0
- package/dist_ts_chat_cli/components.messagelist.js +19 -0
- package/dist_ts_chat_cli/components.statusbar.d.ts +9 -0
- package/dist_ts_chat_cli/components.statusbar.js +15 -0
- package/dist_ts_chat_cli/index.d.ts +2 -0
- package/dist_ts_chat_cli/index.js +2 -0
- package/dist_ts_chat_cli/plugins.d.ts +12 -0
- package/dist_ts_chat_cli/plugins.js +14 -0
- package/dist_ts_chat_cli/startchat.d.ts +18 -0
- package/dist_ts_chat_cli/startchat.js +17 -0
- package/dist_ts_chat_web/flexchat-input.d.ts +21 -0
- package/dist_ts_chat_web/flexchat-input.js +172 -0
- package/dist_ts_chat_web/flexchat-message.d.ts +26 -0
- package/dist_ts_chat_web/flexchat-message.js +174 -0
- package/dist_ts_chat_web/flexchat-window.d.ts +34 -0
- package/dist_ts_chat_web/flexchat-window.js +394 -0
- package/dist_ts_chat_web/index.d.ts +3 -0
- package/dist_ts_chat_web/index.js +4 -0
- package/dist_ts_chat_web/plugins.d.ts +6 -0
- package/dist_ts_chat_web/plugins.js +4 -0
- package/dist_ts_compaction/index.d.ts +2 -0
- package/dist_ts_compaction/index.js +2 -0
- package/dist_ts_compaction/plugins.d.ts +4 -0
- package/dist_ts_compaction/plugins.js +3 -0
- package/dist_ts_compaction/smartagent.compaction.d.ts +14 -0
- package/dist_ts_compaction/smartagent.compaction.js +49 -0
- package/dist_ts_document/index.d.ts +19 -0
- package/dist_ts_document/index.js +55 -0
- package/dist_ts_document/plugins.d.ts +3 -0
- package/dist_ts_document/plugins.js +4 -0
- package/dist_ts_kvm/classes.browserkvm.d.ts +22 -0
- package/dist_ts_kvm/classes.browserkvm.js +271 -0
- package/dist_ts_kvm/classes.kvmterminal.d.ts +8 -0
- package/dist_ts_kvm/classes.kvmterminal.js +88 -0
- package/dist_ts_kvm/commandwrappers.d.ts +14 -0
- package/dist_ts_kvm/commandwrappers.js +58 -0
- package/dist_ts_kvm/index.d.ts +6 -0
- package/dist_ts_kvm/index.js +7 -0
- package/dist_ts_kvm/interfaces.d.ts +106 -0
- package/dist_ts_kvm/interfaces.js +2 -0
- package/dist_ts_kvm/ocr.d.ts +14 -0
- package/dist_ts_kvm/ocr.js +23 -0
- package/dist_ts_kvm/plugins.d.ts +6 -0
- package/dist_ts_kvm/plugins.js +10 -0
- package/dist_ts_kvm/tools.d.ts +15 -0
- package/dist_ts_kvm/tools.js +40 -0
- package/dist_ts_mcp/index.d.ts +86 -0
- package/dist_ts_mcp/index.js +284 -0
- package/dist_ts_mcp/requestcontext.d.ts +11 -0
- package/dist_ts_mcp/requestcontext.js +42 -0
- package/dist_ts_media/index.d.ts +8 -0
- package/dist_ts_media/index.js +21 -0
- package/dist_ts_media/plugins.d.ts +2 -0
- package/dist_ts_media/plugins.js +3 -0
- package/dist_ts_ocr/classes.imageocr.d.ts +19 -0
- package/dist_ts_ocr/classes.imageocr.js +27 -0
- package/dist_ts_ocr/index.d.ts +2 -0
- package/dist_ts_ocr/index.js +3 -0
- package/dist_ts_ocr/ocr.mistral.d.ts +75 -0
- package/dist_ts_ocr/ocr.mistral.js +77 -0
- package/dist_ts_tools/index.d.ts +17 -0
- package/dist_ts_tools/index.js +10 -0
- package/dist_ts_tools/plugins.d.ts +7 -0
- package/dist_ts_tools/plugins.js +6 -0
- package/dist_ts_tools/tool.browser.d.ts +11 -0
- package/dist_ts_tools/tool.browser.js +128 -0
- package/dist_ts_tools/tool.context.d.ts +4 -0
- package/dist_ts_tools/tool.context.js +23 -0
- package/dist_ts_tools/tool.filesystem.d.ts +11 -0
- package/dist_ts_tools/tool.filesystem.js +106 -0
- package/dist_ts_tools/tool.http.d.ts +2 -0
- package/dist_ts_tools/tool.http.js +65 -0
- package/dist_ts_tools/tool.json.d.ts +2 -0
- package/dist_ts_tools/tool.json.js +47 -0
- package/dist_ts_tools/tool.shell.d.ts +15 -0
- package/dist_ts_tools/tool.shell.js +329 -0
- package/dist_ts_tools/utils.truncation.d.ts +10 -0
- package/dist_ts_tools/utils.truncation.js +26 -0
- package/dist_ts_tools_node/index.d.ts +5 -0
- package/dist_ts_tools_node/index.js +4 -0
- package/dist_ts_tools_node/plugins.d.ts +13 -0
- package/dist_ts_tools_node/plugins.js +13 -0
- package/dist_ts_tools_node/tool.context.d.ts +31 -0
- package/dist_ts_tools_node/tool.context.js +837 -0
- package/dist_ts_tools_node/tool.persistence.d.ts +15 -0
- package/dist_ts_tools_node/tool.persistence.js +129 -0
- package/dist_ts_tools_node/tools.local.d.ts +11 -0
- package/dist_ts_tools_node/tools.local.js +15 -0
- package/package.json +112 -4
- package/readme.md +122 -66
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/readme.md +122 -66
- package/ts_chat/classes.chatsession.ts +116 -0
- package/ts_chat/index.ts +8 -0
- package/ts_chat/interfaces.ts +64 -0
- package/ts_chat/plugins.ts +7 -0
- package/ts_chat/readme.md +49 -0
- package/ts_chat_cli/components.chatapp.ts +103 -0
- package/ts_chat_cli/components.inputarea.ts +29 -0
- package/ts_chat_cli/components.message.ts +48 -0
- package/ts_chat_cli/components.messagelist.ts +45 -0
- package/ts_chat_cli/components.statusbar.ts +31 -0
- package/ts_chat_cli/index.ts +2 -0
- package/ts_chat_cli/plugins.ts +21 -0
- package/ts_chat_cli/readme.md +40 -0
- package/ts_chat_cli/startchat.ts +34 -0
- package/ts_chat_web/flexchat-input.ts +184 -0
- package/ts_chat_web/flexchat-message.ts +185 -0
- package/ts_chat_web/flexchat-window.ts +416 -0
- package/ts_chat_web/index.ts +3 -0
- package/ts_chat_web/plugins.ts +9 -0
- package/ts_chat_web/readme.md +46 -0
- package/ts_compaction/index.ts +2 -0
- package/ts_compaction/plugins.ts +6 -0
- package/ts_compaction/readme.md +37 -0
- package/ts_compaction/smartagent.compaction.ts +59 -0
- package/ts_document/index.ts +82 -0
- package/ts_document/plugins.ts +3 -0
- package/ts_document/readme.md +49 -0
- package/ts_kvm/classes.browserkvm.ts +335 -0
- package/ts_kvm/classes.kvmterminal.ts +103 -0
- package/ts_kvm/commandwrappers.ts +83 -0
- package/ts_kvm/index.ts +6 -0
- package/ts_kvm/interfaces.ts +152 -0
- package/ts_kvm/ocr.ts +41 -0
- package/ts_kvm/plugins.ts +13 -0
- package/ts_kvm/readme.md +482 -0
- package/ts_kvm/tools.ts +58 -0
- package/ts_mcp/index.ts +470 -0
- package/ts_mcp/readme.md +37 -0
- package/ts_mcp/requestcontext.ts +66 -0
- package/ts_media/index.ts +29 -0
- package/ts_media/plugins.ts +2 -0
- package/ts_media/readme.md +37 -0
- package/ts_ocr/classes.imageocr.ts +53 -0
- package/ts_ocr/index.ts +2 -0
- package/ts_ocr/ocr.mistral.ts +192 -0
- package/ts_ocr/readme.md +48 -0
- package/ts_tools/index.ts +49 -0
- package/ts_tools/plugins.ts +7 -0
- package/ts_tools/readme.md +37 -0
- package/ts_tools/tool.browser.ts +159 -0
- package/ts_tools/tool.context.ts +23 -0
- package/ts_tools/tool.filesystem.ts +144 -0
- package/ts_tools/tool.http.ts +78 -0
- package/ts_tools/tool.json.ts +53 -0
- package/ts_tools/tool.shell.ts +418 -0
- package/ts_tools/utils.truncation.ts +39 -0
- package/ts_tools_node/index.ts +5 -0
- package/ts_tools_node/plugins.ts +16 -0
- package/ts_tools_node/readme.md +37 -0
- package/ts_tools_node/tool.context.ts +991 -0
- package/ts_tools_node/tool.persistence.ts +146 -0
- package/ts_tools_node/tools.local.ts +26 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import { LitElement, html, css } from './plugins.js';
|
|
2
|
+
import type { CSSResult, TemplateResult, IChatSession, IAgentRunResult, PropertyValues } from './plugins.js';
|
|
3
|
+
import './flexchat-message.js';
|
|
4
|
+
import './flexchat-input.js';
|
|
5
|
+
|
|
6
|
+
interface IDisplayMessage {
|
|
7
|
+
role: 'user' | 'assistant' | 'tool';
|
|
8
|
+
content: string;
|
|
9
|
+
toolName?: string;
|
|
10
|
+
timestamp?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class FlexChatWindow extends LitElement {
|
|
14
|
+
declare chatSession: IChatSession;
|
|
15
|
+
declare placeholder: string;
|
|
16
|
+
declare headerTitle: string;
|
|
17
|
+
private messages: IDisplayMessage[] = [];
|
|
18
|
+
private busy = false;
|
|
19
|
+
private streamingText = '';
|
|
20
|
+
private unsubscribe: (() => void) | undefined;
|
|
21
|
+
|
|
22
|
+
static properties = {
|
|
23
|
+
chatSession: { attribute: false },
|
|
24
|
+
placeholder: { type: String },
|
|
25
|
+
headerTitle: { type: String, attribute: 'header-title' },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
static styles: CSSResult = css`
|
|
29
|
+
:host {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
height: 100%;
|
|
33
|
+
background: var(--flexchat-bg, #0c0c14);
|
|
34
|
+
color: var(--flexchat-text, #e4e4e7);
|
|
35
|
+
font-family: var(--flexchat-font, 'Inter', system-ui, -apple-system, sans-serif);
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
line-height: 1.6;
|
|
38
|
+
border-radius: var(--flexchat-radius, 16px);
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* ── Header ── */
|
|
43
|
+
.header {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: 12px;
|
|
47
|
+
padding: 14px 20px;
|
|
48
|
+
background: var(--flexchat-header-bg, rgba(255, 255, 255, 0.025));
|
|
49
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
|
50
|
+
flex-shrink: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.header-icon {
|
|
54
|
+
width: 34px;
|
|
55
|
+
height: 34px;
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
background: linear-gradient(135deg, #6366f1, #7c3aed);
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
font-size: 15px;
|
|
62
|
+
color: #fff;
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.header-info {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: 1px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.header-title {
|
|
74
|
+
font-weight: 600;
|
|
75
|
+
font-size: 14px;
|
|
76
|
+
color: #f0f0f3;
|
|
77
|
+
letter-spacing: -0.01em;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.header-status {
|
|
81
|
+
font-size: 11px;
|
|
82
|
+
color: #71717a;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
gap: 5px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.status-dot {
|
|
89
|
+
width: 7px;
|
|
90
|
+
height: 7px;
|
|
91
|
+
border-radius: 50%;
|
|
92
|
+
background: #22c55e;
|
|
93
|
+
box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.status-dot.busy {
|
|
97
|
+
background: #f59e0b;
|
|
98
|
+
box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
|
|
99
|
+
animation: pulse-dot 1.4s ease-in-out infinite;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@keyframes pulse-dot {
|
|
103
|
+
0%, 100% { opacity: 1; }
|
|
104
|
+
50% { opacity: 0.35; }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* ── Message List ── */
|
|
108
|
+
.message-list {
|
|
109
|
+
flex: 1;
|
|
110
|
+
overflow-y: auto;
|
|
111
|
+
padding: 16px 20px;
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
gap: 0;
|
|
115
|
+
scroll-behavior: smooth;
|
|
116
|
+
overscroll-behavior: contain;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.message-list::-webkit-scrollbar {
|
|
120
|
+
width: 5px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.message-list::-webkit-scrollbar-track {
|
|
124
|
+
background: transparent;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.message-list::-webkit-scrollbar-thumb {
|
|
128
|
+
background: rgba(255, 255, 255, 0.07);
|
|
129
|
+
border-radius: 3px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.message-list::-webkit-scrollbar-thumb:hover {
|
|
133
|
+
background: rgba(255, 255, 255, 0.14);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ── Empty State ── */
|
|
137
|
+
.empty-state {
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-direction: column;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
flex: 1;
|
|
143
|
+
gap: 14px;
|
|
144
|
+
padding: 40px 20px;
|
|
145
|
+
text-align: center;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.empty-icon {
|
|
149
|
+
width: 56px;
|
|
150
|
+
height: 56px;
|
|
151
|
+
border-radius: 50%;
|
|
152
|
+
background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(124, 58, 237, 0.06));
|
|
153
|
+
border: 1px solid rgba(99, 102, 241, 0.12);
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: center;
|
|
157
|
+
font-size: 22px;
|
|
158
|
+
color: #818cf8;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.empty-title {
|
|
162
|
+
font-size: 15px;
|
|
163
|
+
font-weight: 600;
|
|
164
|
+
color: #e4e4e7;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.empty-subtitle {
|
|
168
|
+
font-size: 13px;
|
|
169
|
+
color: #52525b;
|
|
170
|
+
max-width: 260px;
|
|
171
|
+
line-height: 1.5;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* ── Streaming ── */
|
|
175
|
+
.streaming-row {
|
|
176
|
+
display: flex;
|
|
177
|
+
gap: 10px;
|
|
178
|
+
align-items: flex-end;
|
|
179
|
+
margin-bottom: 4px;
|
|
180
|
+
padding-top: 4px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.stream-avatar {
|
|
184
|
+
width: 28px;
|
|
185
|
+
height: 28px;
|
|
186
|
+
border-radius: 50%;
|
|
187
|
+
background: linear-gradient(135deg, #6366f1, #7c3aed);
|
|
188
|
+
display: flex;
|
|
189
|
+
align-items: center;
|
|
190
|
+
justify-content: center;
|
|
191
|
+
font-size: 12px;
|
|
192
|
+
color: #fff;
|
|
193
|
+
flex-shrink: 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.stream-bubble {
|
|
197
|
+
background: #1e1e2e;
|
|
198
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
199
|
+
color: #d1d5db;
|
|
200
|
+
padding: 10px 14px;
|
|
201
|
+
border-radius: 18px;
|
|
202
|
+
border-bottom-left-radius: 6px;
|
|
203
|
+
max-width: min(75%, 480px);
|
|
204
|
+
white-space: pre-wrap;
|
|
205
|
+
word-break: break-word;
|
|
206
|
+
font-size: 14px;
|
|
207
|
+
line-height: 1.55;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.cursor {
|
|
211
|
+
display: inline-block;
|
|
212
|
+
width: 2px;
|
|
213
|
+
height: 1.1em;
|
|
214
|
+
background: #818cf8;
|
|
215
|
+
vertical-align: text-bottom;
|
|
216
|
+
margin-left: 1px;
|
|
217
|
+
animation: cursor-blink 0.8s step-end infinite;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@keyframes cursor-blink {
|
|
221
|
+
50% { opacity: 0; }
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* ── Thinking Indicator ── */
|
|
225
|
+
.thinking-bubble {
|
|
226
|
+
display: inline-flex;
|
|
227
|
+
align-items: center;
|
|
228
|
+
gap: 5px;
|
|
229
|
+
padding: 12px 18px;
|
|
230
|
+
background: #1e1e2e;
|
|
231
|
+
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
232
|
+
border-radius: 18px;
|
|
233
|
+
border-bottom-left-radius: 6px;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.thinking-dot {
|
|
237
|
+
width: 7px;
|
|
238
|
+
height: 7px;
|
|
239
|
+
border-radius: 50%;
|
|
240
|
+
background: #6366f1;
|
|
241
|
+
animation: thinking-bounce 1.4s ease-in-out infinite;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.thinking-dot:nth-child(2) { animation-delay: 0.16s; }
|
|
245
|
+
.thinking-dot:nth-child(3) { animation-delay: 0.32s; }
|
|
246
|
+
|
|
247
|
+
@keyframes thinking-bounce {
|
|
248
|
+
0%, 60%, 100% {
|
|
249
|
+
transform: translateY(0);
|
|
250
|
+
opacity: 0.3;
|
|
251
|
+
}
|
|
252
|
+
30% {
|
|
253
|
+
transform: translateY(-5px);
|
|
254
|
+
opacity: 1;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* ── Input Area ── */
|
|
259
|
+
.input-area {
|
|
260
|
+
padding: 12px 20px 16px;
|
|
261
|
+
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
|
262
|
+
background: var(--flexchat-input-area-bg, rgba(255, 255, 255, 0.015));
|
|
263
|
+
flex-shrink: 0;
|
|
264
|
+
}
|
|
265
|
+
`;
|
|
266
|
+
|
|
267
|
+
constructor() {
|
|
268
|
+
super();
|
|
269
|
+
this.placeholder = 'Type a message...';
|
|
270
|
+
this.headerTitle = 'FlexChat';
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
connectedCallback() {
|
|
274
|
+
super.connectedCallback();
|
|
275
|
+
this.bindSession();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
disconnectedCallback() {
|
|
279
|
+
this.unsubscribe?.();
|
|
280
|
+
this.unsubscribe = undefined;
|
|
281
|
+
super.disconnectedCallback();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
protected updated(changed: PropertyValues<this>) {
|
|
285
|
+
if (changed.has('chatSession')) this.bindSession();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
private bindSession() {
|
|
289
|
+
this.unsubscribe?.();
|
|
290
|
+
this.unsubscribe = undefined;
|
|
291
|
+
if (this.isConnected && this.chatSession) {
|
|
292
|
+
this.unsubscribe = this.chatSession.subscribe({
|
|
293
|
+
onToken: (delta: string) => {
|
|
294
|
+
this.streamingText += delta;
|
|
295
|
+
this.requestUpdate();
|
|
296
|
+
this.scrollToBottom();
|
|
297
|
+
},
|
|
298
|
+
onToolCall: (name: string) => {
|
|
299
|
+
this.messages = [
|
|
300
|
+
...this.messages,
|
|
301
|
+
{ role: 'tool', content: '', toolName: name, timestamp: Date.now() },
|
|
302
|
+
];
|
|
303
|
+
this.requestUpdate();
|
|
304
|
+
this.scrollToBottom();
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
private scrollToBottom() {
|
|
311
|
+
requestAnimationFrame(() => {
|
|
312
|
+
const list = this.shadowRoot?.querySelector('.message-list');
|
|
313
|
+
if (list) {
|
|
314
|
+
list.scrollTop = list.scrollHeight;
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private async handleSend(e: CustomEvent<{ text: string }>) {
|
|
320
|
+
if (this.busy) return;
|
|
321
|
+
|
|
322
|
+
const text = e.detail.text;
|
|
323
|
+
this.messages = [...this.messages, { role: 'user', content: text, timestamp: Date.now() }];
|
|
324
|
+
this.busy = true;
|
|
325
|
+
this.streamingText = '';
|
|
326
|
+
this.requestUpdate();
|
|
327
|
+
this.scrollToBottom();
|
|
328
|
+
|
|
329
|
+
try {
|
|
330
|
+
const result = await this.chatSession.send(text);
|
|
331
|
+
this.streamingText = '';
|
|
332
|
+
this.messages = [...this.messages, { role: 'assistant', content: result.text, timestamp: Date.now() }];
|
|
333
|
+
} catch (error) {
|
|
334
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
335
|
+
this.messages = [
|
|
336
|
+
...this.messages,
|
|
337
|
+
{ role: 'assistant', content: `Error: ${errMsg}`, timestamp: Date.now() },
|
|
338
|
+
];
|
|
339
|
+
} finally {
|
|
340
|
+
this.busy = false;
|
|
341
|
+
this.requestUpdate();
|
|
342
|
+
this.scrollToBottom();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
render(): TemplateResult {
|
|
347
|
+
return html`
|
|
348
|
+
<div class="header">
|
|
349
|
+
<div class="header-icon">✦</div>
|
|
350
|
+
<div class="header-info">
|
|
351
|
+
<div class="header-title">${this.headerTitle}</div>
|
|
352
|
+
<div class="header-status">
|
|
353
|
+
<span class="status-dot ${this.busy ? 'busy' : ''}"></span>
|
|
354
|
+
${this.busy ? 'Thinking...' : 'Online'}
|
|
355
|
+
</div>
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
358
|
+
|
|
359
|
+
<div class="message-list">
|
|
360
|
+
${this.messages.length === 0 && !this.busy
|
|
361
|
+
? html`
|
|
362
|
+
<div class="empty-state">
|
|
363
|
+
<div class="empty-icon">✦</div>
|
|
364
|
+
<div class="empty-title">Start a conversation</div>
|
|
365
|
+
<div class="empty-subtitle">
|
|
366
|
+
Send a message below to begin chatting.
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
`
|
|
370
|
+
: ''}
|
|
371
|
+
${this.messages.map(
|
|
372
|
+
(msg) => html`
|
|
373
|
+
<flexchat-message
|
|
374
|
+
role=${msg.role}
|
|
375
|
+
content=${msg.content}
|
|
376
|
+
.toolName=${msg.toolName ?? ''}
|
|
377
|
+
.timestamp=${msg.timestamp ?? 0}
|
|
378
|
+
></flexchat-message>
|
|
379
|
+
`,
|
|
380
|
+
)}
|
|
381
|
+
${this.busy && this.streamingText
|
|
382
|
+
? html`
|
|
383
|
+
<div class="streaming-row">
|
|
384
|
+
<div class="stream-avatar">✦</div>
|
|
385
|
+
<div class="stream-bubble">
|
|
386
|
+
${this.streamingText}<span class="cursor"></span>
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
`
|
|
390
|
+
: ''}
|
|
391
|
+
${this.busy && !this.streamingText
|
|
392
|
+
? html`
|
|
393
|
+
<div class="streaming-row">
|
|
394
|
+
<div class="stream-avatar">✦</div>
|
|
395
|
+
<div class="thinking-bubble">
|
|
396
|
+
<span class="thinking-dot"></span>
|
|
397
|
+
<span class="thinking-dot"></span>
|
|
398
|
+
<span class="thinking-dot"></span>
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
`
|
|
402
|
+
: ''}
|
|
403
|
+
</div>
|
|
404
|
+
|
|
405
|
+
<div class="input-area">
|
|
406
|
+
<flexchat-input
|
|
407
|
+
?disabled=${this.busy}
|
|
408
|
+
placeholder=${this.placeholder}
|
|
409
|
+
@send=${this.handleSend}
|
|
410
|
+
></flexchat-input>
|
|
411
|
+
</div>
|
|
412
|
+
`;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
customElements.define('flexchat-window', FlexChatWindow);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Lit
|
|
2
|
+
import { LitElement, html, css } from 'lit';
|
|
3
|
+
export { LitElement, html, css };
|
|
4
|
+
export type { TemplateResult, CSSResult, PropertyValues } from 'lit';
|
|
5
|
+
|
|
6
|
+
// Core (cross-folder import)
|
|
7
|
+
export type { IChatSession } from '@modelprofile.com/flexharness/chat';
|
|
8
|
+
export type { IChatSessionOptions, IChatCallbacks, IChatUsage } from '@modelprofile.com/flexharness/chat';
|
|
9
|
+
export type { IAgentRunResult } from '@modelprofile.com/flexharness-agent';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Lit chat elements for a caller-owned FlexHarness chat session.
|
|
2
|
+
|
|
3
|
+
```sh
|
|
4
|
+
pnpm add @modelprofile.com/flexharness lit
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { ChatSession } from '@modelprofile.com/flexharness/chat';
|
|
9
|
+
import { FlexChatWindow } from '@modelprofile.com/flexharness/chat/web';
|
|
10
|
+
|
|
11
|
+
const element = new FlexChatWindow();
|
|
12
|
+
element.chatSession = new ChatSession({ model });
|
|
13
|
+
element.headerTitle = 'Project assistant';
|
|
14
|
+
document.body.append(element);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The model can use your application's authenticated server transport. Do not embed a private provider key in a browser bundle. Alternatively, implement `IChatSession` for a remote session. The element accepts its session before or after connection and detaches its callback subscription on disconnect.
|
|
18
|
+
|
|
19
|
+
Exports: `FlexChatWindow`, `FlexChatMessage`, `FlexChatInput`. Importing this component registers `flexchat-window`, `flexchat-message`, and `flexchat-input`. This subpath preserves element-registration side effects and contains no terminal UI imports.
|
|
20
|
+
|
|
21
|
+
This replaces `@push.rocks/smartchat/web`. Rename `SmartchatWindow`, `SmartchatMessage` and `SmartchatInput` to `FlexChatWindow`, `FlexChatMessage` and `FlexChatInput`, custom elements from `smartchat-*` to `flexchat-*`, and CSS custom properties from `--smartchat-*` to `--flexchat-*`. The window exposes `chatSession`, `headerTitle` and `placeholder` properties. Give the window an explicit height or place it in a sized flex container.
|
|
22
|
+
|
|
23
|
+
## Issue Reporting and Security
|
|
24
|
+
|
|
25
|
+
Report issues and security concerns through [community.foss.global](https://community.foss.global).
|
|
26
|
+
|
|
27
|
+
## License and Legal Information
|
|
28
|
+
|
|
29
|
+
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the repository license file.
|
|
30
|
+
|
|
31
|
+
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
32
|
+
|
|
33
|
+
### Trademarks
|
|
34
|
+
|
|
35
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
|
|
36
|
+
|
|
37
|
+
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
|
38
|
+
|
|
39
|
+
### Company Information
|
|
40
|
+
|
|
41
|
+
Task Venture Capital GmbH<br>
|
|
42
|
+
Registered at District Court Bremen HRB 35230 HB, Germany
|
|
43
|
+
|
|
44
|
+
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
|
45
|
+
|
|
46
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Opt-in model-driven conversation compaction.
|
|
2
|
+
|
|
3
|
+
Part of the [FlexHarness toolbox](https://code.foss.global/modelprofile.com/flexharness).
|
|
4
|
+
Install the components your project uses. Provider adapters are registered explicitly;
|
|
5
|
+
the agent and harness do not install or register vendor SDKs.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @modelprofile.com/flexharness
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
See the [toolbox usage and migration guide](https://code.foss.global/modelprofile.com/flexharness#readme)
|
|
12
|
+
for composition examples and the SmartAI/SmartAgent migration map.
|
|
13
|
+
|
|
14
|
+
## Issue Reporting and Security
|
|
15
|
+
|
|
16
|
+
Report issues and security concerns through [community.foss.global](https://community.foss.global).
|
|
17
|
+
|
|
18
|
+
## License and Legal Information
|
|
19
|
+
|
|
20
|
+
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the repository license file.
|
|
21
|
+
|
|
22
|
+
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
23
|
+
|
|
24
|
+
### Trademarks
|
|
25
|
+
|
|
26
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
|
|
27
|
+
|
|
28
|
+
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
|
29
|
+
|
|
30
|
+
### Company Information
|
|
31
|
+
|
|
32
|
+
Task Venture Capital GmbH<br>
|
|
33
|
+
Registered at District Court Bremen HRB 35230 HB, Germany
|
|
34
|
+
|
|
35
|
+
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
|
36
|
+
|
|
37
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
|
|
3
|
+
const COMPACTION_PROMPT = `Provide a detailed prompt for continuing our conversation above.
|
|
4
|
+
Focus on information that would be helpful for continuing the conversation, including what we did, what we're doing, which files we're working on, and what we're going to do next.
|
|
5
|
+
The summary that you construct will be used so that another agent can read it and continue the work.
|
|
6
|
+
|
|
7
|
+
When constructing the summary, try to stick to this template:
|
|
8
|
+
---
|
|
9
|
+
## Goal
|
|
10
|
+
[What goal(s) is the user trying to accomplish?]
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
- [What important instructions did the user give you that are relevant]
|
|
14
|
+
|
|
15
|
+
## Discoveries
|
|
16
|
+
[What notable things were learned during this conversation that would be useful for the next agent to know]
|
|
17
|
+
|
|
18
|
+
## Accomplished
|
|
19
|
+
[What work has been completed, what work is still in progress, and what work is left?]
|
|
20
|
+
|
|
21
|
+
## Relevant files / directories
|
|
22
|
+
[A structured list of relevant files that have been read, edited, or created]
|
|
23
|
+
---`;
|
|
24
|
+
|
|
25
|
+
export interface ICompactMessagesOptions {
|
|
26
|
+
abortSignal?: AbortSignal;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Compacts a message history into a summary.
|
|
31
|
+
* Pass this as the onContextOverflow handler in IAgentRunOptions.
|
|
32
|
+
*
|
|
33
|
+
* @param model The same model used by runAgent, or a cheaper small model
|
|
34
|
+
* @param messages The full message history that overflowed
|
|
35
|
+
* @param options Invocation options, including cancellation
|
|
36
|
+
* @returns A minimal ModelMessage[] containing the summary as context
|
|
37
|
+
*/
|
|
38
|
+
export async function compactMessages(
|
|
39
|
+
model: plugins.TSmartAiLanguageModel,
|
|
40
|
+
messages: plugins.ModelMessage[],
|
|
41
|
+
options: ICompactMessagesOptions = {},
|
|
42
|
+
): Promise<plugins.ModelMessage[]> {
|
|
43
|
+
const result = await plugins.generateText({
|
|
44
|
+
model,
|
|
45
|
+
abortSignal: options.abortSignal,
|
|
46
|
+
allowSystemInMessages: true,
|
|
47
|
+
messages: [
|
|
48
|
+
...messages,
|
|
49
|
+
{ role: 'user', content: COMPACTION_PROMPT },
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
role: 'user',
|
|
56
|
+
content: `[Previous conversation summary]\n\n${result.text}\n\n[End of summary. Continue from here.]`,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import type { ModelMessage } from 'ai';
|
|
3
|
+
import type { TSmartAiLanguageModel } from '@modelprofile.com/flexharness-models';
|
|
4
|
+
|
|
5
|
+
let smartpdfInstance: InstanceType<typeof plugins.smartpdf.SmartPdf> | null = null;
|
|
6
|
+
|
|
7
|
+
async function ensureSmartpdf(): Promise<InstanceType<typeof plugins.smartpdf.SmartPdf>> {
|
|
8
|
+
if (!smartpdfInstance) {
|
|
9
|
+
smartpdfInstance = new plugins.smartpdf.SmartPdf();
|
|
10
|
+
await smartpdfInstance.start();
|
|
11
|
+
}
|
|
12
|
+
return smartpdfInstance;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IDocumentOptions {
|
|
16
|
+
model: TSmartAiLanguageModel;
|
|
17
|
+
systemMessage?: string;
|
|
18
|
+
userMessage: string;
|
|
19
|
+
pdfDocuments: Uint8Array[];
|
|
20
|
+
messageHistory?: ModelMessage[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IPdfTextExtractionOptions {
|
|
24
|
+
model: TSmartAiLanguageModel;
|
|
25
|
+
systemMessage?: string;
|
|
26
|
+
userMessage?: string;
|
|
27
|
+
messageHistory?: ModelMessage[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The model-based PDF OCR recipe formerly provided by SmartOCR. */
|
|
31
|
+
export async function extractTextFromPdf(
|
|
32
|
+
pdfDocument: Uint8Array,
|
|
33
|
+
options: IPdfTextExtractionOptions,
|
|
34
|
+
): Promise<string> {
|
|
35
|
+
return analyzeDocuments({
|
|
36
|
+
model: options.model,
|
|
37
|
+
systemMessage: options.systemMessage ?? 'You are a precise OCR engine. Extract text faithfully and do not summarize.',
|
|
38
|
+
userMessage: options.userMessage ?? 'Extract all readable text from this PDF. Preserve page order, line breaks, table structure, and obvious headings. Return only the extracted text.',
|
|
39
|
+
pdfDocuments: [pdfDocument],
|
|
40
|
+
messageHistory: options.messageHistory,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function analyzeDocuments(options: IDocumentOptions): Promise<string> {
|
|
45
|
+
const pdf = await ensureSmartpdf();
|
|
46
|
+
|
|
47
|
+
const imagePages: Uint8Array[] = [];
|
|
48
|
+
for (const doc of options.pdfDocuments) {
|
|
49
|
+
const pages = await pdf.convertPDFToPngBytes(doc);
|
|
50
|
+
imagePages.push(...pages);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Filter out empty buffers
|
|
54
|
+
const validPages = imagePages.filter(page => page && page.length > 0);
|
|
55
|
+
|
|
56
|
+
const result = await plugins.generateText({
|
|
57
|
+
model: options.model,
|
|
58
|
+
instructions: options.systemMessage,
|
|
59
|
+
messages: [
|
|
60
|
+
...(options.messageHistory ?? []),
|
|
61
|
+
{
|
|
62
|
+
role: 'user',
|
|
63
|
+
content: [
|
|
64
|
+
{ type: 'text', text: options.userMessage },
|
|
65
|
+
...validPages.map(page => ({
|
|
66
|
+
type: 'file' as const,
|
|
67
|
+
data: page,
|
|
68
|
+
mediaType: 'image/png' as const,
|
|
69
|
+
})),
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
return result.text;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function stopSmartpdf(): Promise<void> {
|
|
78
|
+
if (smartpdfInstance) {
|
|
79
|
+
await smartpdfInstance.stop();
|
|
80
|
+
smartpdfInstance = null;
|
|
81
|
+
}
|
|
82
|
+
}
|