@myrialabs/clopen 0.2.14 → 0.2.16
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/backend/engine/adapters/opencode/server.ts +72 -33
- package/backend/snapshot/helpers.ts +8 -0
- package/backend/tunnel/cloudflared/binary.ts +153 -0
- package/backend/tunnel/cloudflared/index.ts +21 -0
- package/backend/tunnel/cloudflared/tunnel.ts +389 -0
- package/backend/tunnel/global-tunnel-manager.ts +538 -152
- package/backend/tunnel/project-tunnel-manager.ts +6 -14
- package/backend/tunnel/tunnel-config.ts +234 -0
- package/backend/ws/tunnel/config.ts +108 -0
- package/backend/ws/tunnel/index.ts +3 -1
- package/backend/ws/tunnel/operations.ts +290 -43
- package/bin/clopen.ts +1 -1
- package/bun.lock +0 -4
- package/frontend/App.svelte +2 -1
- package/frontend/components/chat/ChatInterface.svelte +6 -1
- package/frontend/components/chat/formatters/Tools.svelte +3 -1
- package/frontend/components/chat/input/components/EngineModelPicker.svelte +12 -1
- package/frontend/components/chat/message/ChatMessage.svelte +0 -29
- package/frontend/components/chat/message/ChatMessages.svelte +2 -2
- package/frontend/components/chat/message/MessageBubble.svelte +0 -6
- package/frontend/components/chat/message/MessageHeader.svelte +0 -16
- package/frontend/components/chat/tools/SkillTool.svelte +21 -0
- package/frontend/components/chat/tools/index.ts +1 -0
- package/frontend/components/chat/widgets/ContextIndicator.svelte +186 -0
- package/frontend/components/history/HistoryModal.svelte +3 -3
- package/frontend/components/settings/SettingsModal.svelte +5 -0
- package/frontend/components/settings/SettingsView.svelte +4 -0
- package/frontend/components/settings/model/EngineModelPicker.svelte +9 -0
- package/frontend/components/settings/tunnel/TunnelSettings.svelte +1060 -0
- package/frontend/components/tunnel/TunnelActive.svelte +132 -71
- package/frontend/components/tunnel/TunnelButton.svelte +4 -4
- package/frontend/components/tunnel/TunnelInactive.svelte +38 -65
- package/frontend/components/tunnel/TunnelModal.svelte +55 -2
- package/frontend/components/workspace/PanelHeader.svelte +4 -0
- package/frontend/components/workspace/WorkspaceLayout.svelte +31 -1
- package/frontend/components/workspace/panels/ChatPanel.svelte +6 -0
- package/frontend/services/favicon.service.ts +103 -0
- package/frontend/services/terminal/project.service.ts +52 -0
- package/frontend/stores/features/tunnel-config.svelte.ts +205 -0
- package/frontend/stores/features/tunnel.svelte.ts +194 -80
- package/frontend/stores/ui/settings-modal.svelte.ts +7 -0
- package/frontend/utils/chat/message-grouper.ts +33 -5
- package/frontend/utils/chat/message-processor.ts +2 -1
- package/frontend/utils/chat/tool-handler.ts +38 -3
- package/frontend/utils/context-manager.ts +35 -237
- package/package.json +1 -2
- package/shared/types/messaging/index.ts +1 -0
- package/shared/types/messaging/tool.ts +24 -1
- package/shared/utils/ws-client.ts +23 -1
- package/frontend/components/chat/modal/TokenUsageModal.svelte +0 -124
- package/frontend/components/chat/widgets/TokenUsage.svelte +0 -78
|
@@ -2,90 +2,337 @@
|
|
|
2
2
|
* Tunnel Operations
|
|
3
3
|
*
|
|
4
4
|
* HTTP endpoints for tunnel management:
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
5
|
+
* - Quick tunnel: start/stop with random URL
|
|
6
|
+
* - Remote tunnel: start/stop dashboard-managed tunnels
|
|
7
|
+
* - Local tunnel: auth, create, delete, ingress, route-dns, start/stop
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { t } from 'elysia';
|
|
11
11
|
import { createRouter } from '$shared/utils/ws-server';
|
|
12
12
|
import { globalTunnelManager } from '../../tunnel/global-tunnel-manager';
|
|
13
|
+
import {
|
|
14
|
+
getRemoteTunnelConfigById,
|
|
15
|
+
getLocalTunnelConfigById,
|
|
16
|
+
addLocalTunnelConfig,
|
|
17
|
+
removeLocalTunnelConfig,
|
|
18
|
+
addLocalTunnelIngress,
|
|
19
|
+
removeLocalTunnelIngress,
|
|
20
|
+
getAuthorizedZone,
|
|
21
|
+
setAuthorizedZone,
|
|
22
|
+
clearAuthorizedZone
|
|
23
|
+
} from '../../tunnel/tunnel-config';
|
|
13
24
|
import { debug } from '$shared/utils/logger';
|
|
25
|
+
import { ws } from '$backend/utils/ws';
|
|
26
|
+
|
|
27
|
+
// Wire up ingress update callback to push via WS
|
|
28
|
+
globalTunnelManager.setRemoteIngressUpdateCallback((configId, ingress) => {
|
|
29
|
+
ws.emit.global('tunnel:remote:ingress-update', { configId, ingress });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Wire up status changed callback to push tunnel list via WS
|
|
33
|
+
globalTunnelManager.setStatusChangedCallback(() => {
|
|
34
|
+
const tunnels = globalTunnelManager.getActiveTunnels();
|
|
35
|
+
ws.emit.global('tunnel:status-changed', { tunnels });
|
|
36
|
+
});
|
|
14
37
|
|
|
15
38
|
export const operationsHandler = createRouter()
|
|
16
|
-
|
|
17
|
-
|
|
39
|
+
|
|
40
|
+
// ═══════════════════════════════════════
|
|
41
|
+
// Quick Tunnel
|
|
42
|
+
// ═══════════════════════════════════════
|
|
43
|
+
|
|
44
|
+
.http('tunnel:quick:start', {
|
|
18
45
|
data: t.Object({
|
|
19
46
|
port: t.Number({ minimum: 1, maximum: 65535 }),
|
|
20
|
-
autoStopMinutes: t.Optional(t.Number())
|
|
47
|
+
autoStopMinutes: t.Optional(t.Number({ minimum: 0 }))
|
|
21
48
|
}),
|
|
22
49
|
response: t.Any()
|
|
23
50
|
}, async ({ data }) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
51
|
+
const { port, autoStopMinutes = 60 } = data;
|
|
52
|
+
debug.log('tunnel', `[WS] Quick tunnel start: port=${port}, autoStop=${autoStopMinutes}`);
|
|
26
53
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
54
|
+
const result = await globalTunnelManager.startQuickTunnel(port, autoStopMinutes);
|
|
55
|
+
return result;
|
|
56
|
+
})
|
|
30
57
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
58
|
+
.http('tunnel:quick:stop', {
|
|
59
|
+
data: t.Object({
|
|
60
|
+
port: t.Number()
|
|
61
|
+
}),
|
|
62
|
+
response: t.Object({ stopped: t.Boolean() })
|
|
63
|
+
}, async ({ data }) => {
|
|
64
|
+
await globalTunnelManager.stopQuickTunnel(data.port);
|
|
65
|
+
return { stopped: true };
|
|
66
|
+
})
|
|
36
67
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
autoStopMinutes || 60,
|
|
41
|
-
undefined // No progress callback for HTTP pattern
|
|
42
|
-
);
|
|
68
|
+
// ═══════════════════════════════════════
|
|
69
|
+
// Remote Tunnel (Dashboard-managed)
|
|
70
|
+
// ═══════════════════════════════════════
|
|
43
71
|
|
|
44
|
-
|
|
72
|
+
.http('tunnel:remote:start', {
|
|
73
|
+
data: t.Object({
|
|
74
|
+
configId: t.String({ minLength: 1 })
|
|
75
|
+
}),
|
|
76
|
+
response: t.Any()
|
|
77
|
+
}, async ({ data }) => {
|
|
78
|
+
const config = getRemoteTunnelConfigById(data.configId);
|
|
79
|
+
if (!config) throw new Error('Remote tunnel config not found');
|
|
45
80
|
|
|
81
|
+
debug.log('tunnel', `[WS] Remote tunnel start: ${config.label}`);
|
|
82
|
+
const result = await globalTunnelManager.startRemoteTunnel(config);
|
|
46
83
|
return result;
|
|
47
84
|
})
|
|
48
85
|
|
|
49
|
-
|
|
50
|
-
|
|
86
|
+
.http('tunnel:remote:stop', {
|
|
87
|
+
data: t.Object({
|
|
88
|
+
configId: t.String({ minLength: 1 })
|
|
89
|
+
}),
|
|
90
|
+
response: t.Object({ stopped: t.Boolean() })
|
|
91
|
+
}, async ({ data }) => {
|
|
92
|
+
await globalTunnelManager.stopRemoteTunnel(data.configId);
|
|
93
|
+
return { stopped: true };
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
.http('tunnel:remote:ingress', {
|
|
51
97
|
data: t.Object({
|
|
52
|
-
|
|
98
|
+
configId: t.String({ minLength: 1 })
|
|
53
99
|
}),
|
|
54
100
|
response: t.Object({
|
|
55
|
-
|
|
101
|
+
ingress: t.Array(t.Object({
|
|
102
|
+
hostname: t.Optional(t.String()),
|
|
103
|
+
service: t.String()
|
|
104
|
+
}))
|
|
56
105
|
})
|
|
57
106
|
}, async ({ data }) => {
|
|
58
|
-
const
|
|
107
|
+
const ingress = globalTunnelManager.getRemoteTunnelIngress(data.configId);
|
|
108
|
+
return { ingress };
|
|
109
|
+
})
|
|
59
110
|
|
|
60
|
-
|
|
111
|
+
// ═══════════════════════════════════════
|
|
112
|
+
// Local Tunnel (Locally-managed)
|
|
113
|
+
// ═══════════════════════════════════════
|
|
61
114
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
115
|
+
.http('tunnel:local:auth-status', {
|
|
116
|
+
data: t.Object({}),
|
|
117
|
+
response: t.Object({
|
|
118
|
+
authenticated: t.Boolean(),
|
|
119
|
+
certPath: t.String(),
|
|
120
|
+
zone: t.Nullable(t.String())
|
|
121
|
+
})
|
|
122
|
+
}, async () => {
|
|
123
|
+
const auth = globalTunnelManager.checkCloudflaredAuth();
|
|
124
|
+
const zone = getAuthorizedZone();
|
|
125
|
+
return { ...auth, zone };
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
.http('tunnel:local:logout', {
|
|
129
|
+
data: t.Object({}),
|
|
130
|
+
response: t.Object({ success: t.Boolean() })
|
|
131
|
+
}, async () => {
|
|
132
|
+
globalTunnelManager.logoutCloudflared();
|
|
133
|
+
clearAuthorizedZone();
|
|
134
|
+
return { success: true };
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
.http('tunnel:local:set-zone', {
|
|
138
|
+
data: t.Object({
|
|
139
|
+
zone: t.String({ minLength: 1 })
|
|
140
|
+
}),
|
|
141
|
+
response: t.Object({ success: t.Boolean(), zone: t.String() })
|
|
142
|
+
}, async ({ data }) => {
|
|
143
|
+
setAuthorizedZone(data.zone);
|
|
144
|
+
return { success: true, zone: data.zone };
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// Login is event-driven (push URL back via WS event)
|
|
148
|
+
.on('tunnel:local:login-start', {
|
|
149
|
+
data: t.Object({})
|
|
150
|
+
}, async ({ conn }) => {
|
|
151
|
+
const userId = ws.getUserId(conn);
|
|
152
|
+
|
|
153
|
+
await globalTunnelManager.loginCloudflared(
|
|
154
|
+
(url) => {
|
|
155
|
+
ws.emit.user(userId, 'tunnel:local:login-url', { url });
|
|
156
|
+
},
|
|
157
|
+
() => {
|
|
158
|
+
ws.emit.user(userId, 'tunnel:local:login-complete', {});
|
|
159
|
+
},
|
|
160
|
+
(error) => {
|
|
161
|
+
ws.emit.user(userId, 'tunnel:local:login-error', { message: error });
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
.on('tunnel:local:login-cancel', {
|
|
167
|
+
data: t.Object({})
|
|
168
|
+
}, async () => {
|
|
169
|
+
globalTunnelManager.cancelLogin();
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
.http('tunnel:local:create', {
|
|
173
|
+
data: t.Object({
|
|
174
|
+
name: t.String({ minLength: 1, maxLength: 100 })
|
|
175
|
+
}),
|
|
176
|
+
response: t.Object({
|
|
177
|
+
id: t.String(),
|
|
178
|
+
name: t.String(),
|
|
179
|
+
tunnelId: t.String()
|
|
180
|
+
})
|
|
181
|
+
}, async ({ data }) => {
|
|
182
|
+
debug.log('tunnel', `[WS] Creating local tunnel: ${data.name}`);
|
|
183
|
+
|
|
184
|
+
const result = await globalTunnelManager.createLocalTunnel(data.name);
|
|
185
|
+
const config = addLocalTunnelConfig(data.name, result.tunnelId, result.credentialsFile);
|
|
186
|
+
|
|
187
|
+
return { id: config.id, name: config.name, tunnelId: config.tunnelId };
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
.http('tunnel:local:delete', {
|
|
191
|
+
data: t.Object({
|
|
192
|
+
id: t.String({ minLength: 1 })
|
|
193
|
+
}),
|
|
194
|
+
response: t.Object({ success: t.Boolean() })
|
|
195
|
+
}, async ({ data }) => {
|
|
196
|
+
const config = getLocalTunnelConfigById(data.id);
|
|
197
|
+
if (!config) throw new Error('Local tunnel config not found');
|
|
198
|
+
|
|
199
|
+
// Stop if running
|
|
200
|
+
if (globalTunnelManager.isLocalTunnelActive(data.id)) {
|
|
201
|
+
await globalTunnelManager.stopLocalTunnel(data.id);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Delete from Cloudflare
|
|
205
|
+
try {
|
|
206
|
+
await globalTunnelManager.deleteLocalTunnel(config.tunnelId, config.credentialsFile);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
debug.warn('tunnel', `Could not delete tunnel from Cloudflare (may already be deleted):`, error);
|
|
66
209
|
}
|
|
67
210
|
|
|
68
|
-
//
|
|
69
|
-
|
|
211
|
+
// Remove from config and cleanup files
|
|
212
|
+
removeLocalTunnelConfig(data.id);
|
|
213
|
+
globalTunnelManager.cleanupLocalTunnelFiles(config.tunnelId);
|
|
214
|
+
return { success: true };
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
.http('tunnel:local:ingress:add', {
|
|
218
|
+
data: t.Object({
|
|
219
|
+
id: t.String({ minLength: 1 }),
|
|
220
|
+
hostname: t.String({ minLength: 1 }),
|
|
221
|
+
service: t.String({ minLength: 1 })
|
|
222
|
+
}),
|
|
223
|
+
response: t.Object({
|
|
224
|
+
success: t.Boolean(),
|
|
225
|
+
ingress: t.Array(t.Object({
|
|
226
|
+
hostname: t.String(),
|
|
227
|
+
service: t.String()
|
|
228
|
+
})),
|
|
229
|
+
dnsRouted: t.Boolean(),
|
|
230
|
+
dnsError: t.Nullable(t.String())
|
|
231
|
+
})
|
|
232
|
+
}, async ({ data }) => {
|
|
233
|
+
const tunnelConfig = getLocalTunnelConfigById(data.id);
|
|
234
|
+
if (!tunnelConfig) throw new Error('Local tunnel config not found');
|
|
235
|
+
|
|
236
|
+
// Add ingress rule
|
|
237
|
+
const config = addLocalTunnelIngress(data.id, data.hostname, data.service);
|
|
238
|
+
if (!config) throw new Error('Failed to add ingress rule');
|
|
239
|
+
|
|
240
|
+
// Auto route DNS using tunnel UUID (more reliable than name)
|
|
241
|
+
let dnsRouted = false;
|
|
242
|
+
let dnsError: string | null = null;
|
|
243
|
+
try {
|
|
244
|
+
await globalTunnelManager.routeDns(tunnelConfig.tunnelId, data.hostname);
|
|
245
|
+
dnsRouted = true;
|
|
246
|
+
debug.log('tunnel', `DNS routed for ${data.hostname} -> tunnel ${tunnelConfig.tunnelId}`);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
dnsError = error instanceof Error ? error.message : String(error);
|
|
249
|
+
debug.warn('tunnel', `Auto route-dns for ${data.hostname} failed:`, dnsError);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return { success: true, ingress: config.ingress, dnsRouted, dnsError };
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
.http('tunnel:local:ingress:remove', {
|
|
256
|
+
data: t.Object({
|
|
257
|
+
id: t.String({ minLength: 1 }),
|
|
258
|
+
hostname: t.String({ minLength: 1 })
|
|
259
|
+
}),
|
|
260
|
+
response: t.Object({
|
|
261
|
+
success: t.Boolean(),
|
|
262
|
+
ingress: t.Array(t.Object({
|
|
263
|
+
hostname: t.String(),
|
|
264
|
+
service: t.String()
|
|
265
|
+
}))
|
|
266
|
+
})
|
|
267
|
+
}, async ({ data }) => {
|
|
268
|
+
const config = removeLocalTunnelIngress(data.id, data.hostname);
|
|
269
|
+
if (!config) throw new Error('Local tunnel config not found');
|
|
270
|
+
|
|
271
|
+
// Regenerate config.yml to stay in sync
|
|
272
|
+
globalTunnelManager.writeLocalTunnelConfig(config);
|
|
273
|
+
|
|
274
|
+
return { success: true, ingress: config.ingress };
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
.http('tunnel:local:start', {
|
|
278
|
+
data: t.Object({
|
|
279
|
+
id: t.String({ minLength: 1 })
|
|
280
|
+
}),
|
|
281
|
+
response: t.Any()
|
|
282
|
+
}, async ({ data }) => {
|
|
283
|
+
const config = getLocalTunnelConfigById(data.id);
|
|
284
|
+
if (!config) throw new Error('Local tunnel config not found');
|
|
70
285
|
|
|
71
|
-
debug.log('tunnel', `[WS]
|
|
286
|
+
debug.log('tunnel', `[WS] Starting local tunnel: ${config.name}`);
|
|
287
|
+
const result = await globalTunnelManager.startLocalTunnel(config);
|
|
288
|
+
return result;
|
|
289
|
+
})
|
|
72
290
|
|
|
291
|
+
.http('tunnel:local:stop', {
|
|
292
|
+
data: t.Object({
|
|
293
|
+
id: t.String({ minLength: 1 })
|
|
294
|
+
}),
|
|
295
|
+
response: t.Object({ stopped: t.Boolean() })
|
|
296
|
+
}, async ({ data }) => {
|
|
297
|
+
await globalTunnelManager.stopLocalTunnel(data.id);
|
|
73
298
|
return { stopped: true };
|
|
74
299
|
})
|
|
75
300
|
|
|
76
|
-
//
|
|
301
|
+
// ═══════════════════════════════════════
|
|
302
|
+
// Global Status
|
|
303
|
+
// ═══════════════════════════════════════
|
|
304
|
+
|
|
77
305
|
.http('tunnel:status', {
|
|
78
306
|
data: t.Object({}),
|
|
79
307
|
response: t.Object({
|
|
80
308
|
tunnels: t.Array(t.Any())
|
|
81
309
|
})
|
|
82
310
|
}, async () => {
|
|
83
|
-
|
|
311
|
+
return { tunnels: globalTunnelManager.getActiveTunnels() };
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
// ═══════════════════════════════════════
|
|
315
|
+
// Event declarations (Server → Client)
|
|
316
|
+
// ═══════════════════════════════════════
|
|
317
|
+
|
|
318
|
+
.emit('tunnel:status-changed', t.Object({
|
|
319
|
+
tunnels: t.Array(t.Any())
|
|
320
|
+
}))
|
|
321
|
+
|
|
322
|
+
.emit('tunnel:remote:ingress-update', t.Object({
|
|
323
|
+
configId: t.String(),
|
|
324
|
+
ingress: t.Array(t.Object({
|
|
325
|
+
hostname: t.Optional(t.String()),
|
|
326
|
+
service: t.String()
|
|
327
|
+
}))
|
|
328
|
+
}))
|
|
84
329
|
|
|
85
|
-
|
|
86
|
-
|
|
330
|
+
.emit('tunnel:local:login-url', t.Object({
|
|
331
|
+
url: t.String()
|
|
332
|
+
}))
|
|
87
333
|
|
|
88
|
-
|
|
334
|
+
.emit('tunnel:local:login-complete', t.Object({}))
|
|
89
335
|
|
|
90
|
-
|
|
91
|
-
|
|
336
|
+
.emit('tunnel:local:login-error', t.Object({
|
|
337
|
+
message: t.String()
|
|
338
|
+
}));
|
package/bin/clopen.ts
CHANGED
package/bun.lock
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"@xterm/headless": "^6.0.0",
|
|
23
23
|
"@xterm/xterm": "^6.0.0",
|
|
24
24
|
"bun-pty": "^0.4.2",
|
|
25
|
-
"cloudflared": "^0.7.1",
|
|
26
25
|
"elysia": "^1.4.19",
|
|
27
26
|
"file-type": "^21.0.0",
|
|
28
27
|
"is-text-path": "^3.0.0",
|
|
@@ -56,7 +55,6 @@
|
|
|
56
55
|
},
|
|
57
56
|
},
|
|
58
57
|
"trustedDependencies": [
|
|
59
|
-
"cloudflared",
|
|
60
58
|
"puppeteer",
|
|
61
59
|
],
|
|
62
60
|
"packages": {
|
|
@@ -434,8 +432,6 @@
|
|
|
434
432
|
|
|
435
433
|
"clone-deep": ["clone-deep@0.2.4", "", { "dependencies": { "for-own": "^0.1.3", "is-plain-object": "^2.0.1", "kind-of": "^3.0.2", "lazy-cache": "^1.0.3", "shallow-clone": "^0.1.2" } }, "sha512-we+NuQo2DHhSl+DP6jlUiAhyAjBQrYnpOk15rN6c6JSPScjiCLh8IbSU+VTcph6YS3o7mASE8a0+gbZ7ChLpgg=="],
|
|
436
434
|
|
|
437
|
-
"cloudflared": ["cloudflared@0.7.1", "", { "bin": { "cloudflared": "lib/cloudflared.js" } }, "sha512-jJn1Gu9Tf4qnIu8tfiHZ25Hs8rNcRYSVf8zAd97wvYdOCzftm1CTs1S/RPhijjGi8gUT1p9yzfDi9zYlU/0RwA=="],
|
|
438
|
-
|
|
439
435
|
"clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
|
|
440
436
|
|
|
441
437
|
"color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="],
|
package/frontend/App.svelte
CHANGED
|
@@ -36,8 +36,9 @@
|
|
|
36
36
|
// Initialize MCP Preview Integration
|
|
37
37
|
initializeMCPPreview();
|
|
38
38
|
|
|
39
|
-
// Restore tunnel status
|
|
39
|
+
// Restore tunnel status and listen for realtime updates
|
|
40
40
|
tunnelStore.checkStatus();
|
|
41
|
+
tunnelStore.initRealtimeListener();
|
|
41
42
|
|
|
42
43
|
// Start periodic update checker
|
|
43
44
|
startUpdateChecker();
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
import ChatInput from './input/ChatInput.svelte';
|
|
24
24
|
import FloatingTodoList from './widgets/FloatingTodoList.svelte';
|
|
25
25
|
import TimelineModal from '$frontend/components/checkpoint/TimelineModal.svelte';
|
|
26
|
-
// import TokenUsage from './widgets/TokenUsage.svelte'; // DISABLED
|
|
27
26
|
import Icon from '$frontend/components/common/display/Icon.svelte';
|
|
28
27
|
import AvatarBubble from '$frontend/components/common/display/AvatarBubble.svelte';
|
|
29
28
|
import Button from '$frontend/components/common/display/Button.svelte';
|
|
@@ -33,6 +32,7 @@
|
|
|
33
32
|
import type { ChatSession } from '$shared/types/database/schema';
|
|
34
33
|
import { debug } from '$shared/utils/logger';
|
|
35
34
|
import ws from '$frontend/utils/ws';
|
|
35
|
+
import { cancelEdit, editModeState } from '$frontend/stores/ui/edit-mode.svelte';
|
|
36
36
|
|
|
37
37
|
// Welcome state - don't show during restoration
|
|
38
38
|
const isWelcomeState = $derived(
|
|
@@ -215,6 +215,11 @@
|
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
// Clear edit mode if active
|
|
219
|
+
if (editModeState.isEditing) {
|
|
220
|
+
cancelEdit();
|
|
221
|
+
}
|
|
222
|
+
|
|
218
223
|
// Reset frontend state without killing the backend stream
|
|
219
224
|
// The old session's stream continues running in the background
|
|
220
225
|
if (appState.isLoading) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
NotebookEditTool,
|
|
8
8
|
ReadTool, ReadMcpResourceTool, AgentTool, TaskTool, TodoWriteTool,
|
|
9
9
|
WebFetchTool, WebSearchTool, WriteTool, CustomMcpTool,
|
|
10
|
-
AskUserQuestionTool
|
|
10
|
+
AskUserQuestionTool, SkillTool
|
|
11
11
|
} from '../tools';
|
|
12
12
|
|
|
13
13
|
const { toolInput }: { toolInput: ToolInput } = $props();
|
|
@@ -63,6 +63,8 @@
|
|
|
63
63
|
<WriteTool {toolInput} />
|
|
64
64
|
{:else if toolInput.name === 'AskUserQuestion'}
|
|
65
65
|
<AskUserQuestionTool {toolInput} />
|
|
66
|
+
{:else if toolInput.name === 'Skill'}
|
|
67
|
+
<SkillTool {toolInput} />
|
|
66
68
|
{:else}
|
|
67
69
|
<!-- Generic fallback for unknown tools (Config, EnterWorktree, etc.) -->
|
|
68
70
|
<div class="bg-slate-50 dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-lg p-4 mb-4">
|
|
@@ -330,6 +330,12 @@
|
|
|
330
330
|
.join(' ');
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
+
function formatContextWindow(tokens: number): string {
|
|
334
|
+
if (tokens >= 1_000_000) return `${(tokens / 1_000_000).toFixed(tokens % 1_000_000 === 0 ? 0 : 1)}M`;
|
|
335
|
+
if (tokens >= 1_000) return `${(tokens / 1_000).toFixed(tokens % 1_000 === 0 ? 0 : 1)}K`;
|
|
336
|
+
return `${tokens}`;
|
|
337
|
+
}
|
|
338
|
+
|
|
333
339
|
// Dropdown state
|
|
334
340
|
let showDropdown = $state(false);
|
|
335
341
|
let triggerButton: HTMLButtonElement;
|
|
@@ -610,7 +616,12 @@
|
|
|
610
616
|
|
|
611
617
|
<!-- Model info -->
|
|
612
618
|
<div class="flex-1 min-w-0">
|
|
613
|
-
<div class="
|
|
619
|
+
<div class="flex items-center gap-2">
|
|
620
|
+
<span class="font-medium text-xs">{model.name}</span>
|
|
621
|
+
{#if model.contextWindow}
|
|
622
|
+
<span class="text-3xs text-slate-400 dark:text-slate-500">{formatContextWindow(model.contextWindow)}</span>
|
|
623
|
+
{/if}
|
|
624
|
+
</div>
|
|
614
625
|
{#if model.capabilities.length > 0}
|
|
615
626
|
<div class="flex flex-wrap gap-1 mt-1">
|
|
616
627
|
{#each model.capabilities as cap}
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
import { startEdit, shouldDimMessage } from '$frontend/stores/ui/edit-mode.svelte';
|
|
22
22
|
import { debug } from '$shared/utils/logger';
|
|
23
23
|
import MessageBubble from './MessageBubble.svelte';
|
|
24
|
-
import TokenUsageModal from '../modal/TokenUsageModal.svelte';
|
|
25
24
|
import DebugModal from '../modal/DebugModal.svelte';
|
|
26
25
|
import Dialog from '$frontend/components/common/overlay/Dialog.svelte';
|
|
27
26
|
import ConflictResolutionModal from '$frontend/components/checkpoint/ConflictResolutionModal.svelte';
|
|
@@ -38,7 +37,6 @@
|
|
|
38
37
|
|
|
39
38
|
// Modal states
|
|
40
39
|
let showDebugPopup = $state(false);
|
|
41
|
-
let showTokenUsagePopup = $state(false);
|
|
42
40
|
let showRestoreConfirm = $state(false);
|
|
43
41
|
|
|
44
42
|
// Conflict resolution state
|
|
@@ -92,15 +90,6 @@
|
|
|
92
90
|
return message.type;
|
|
93
91
|
});
|
|
94
92
|
|
|
95
|
-
// Get token usage data from assistant messages
|
|
96
|
-
const hasTokenUsageData = $derived.by(() => {
|
|
97
|
-
if ((roleCategory === 'assistant' || roleCategory === 'agent') && 'message' in message) {
|
|
98
|
-
const msg = message.message as any;
|
|
99
|
-
return msg.usage || null;
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
});
|
|
103
|
-
|
|
104
93
|
// Get sender info from metadata
|
|
105
94
|
const senderName = $derived(message.metadata?.sender_name ?? null);
|
|
106
95
|
|
|
@@ -259,14 +248,6 @@
|
|
|
259
248
|
}
|
|
260
249
|
|
|
261
250
|
// Modal handlers
|
|
262
|
-
function openTokenUsageModal() {
|
|
263
|
-
showTokenUsagePopup = true;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function closeTokenUsageModal() {
|
|
267
|
-
showTokenUsagePopup = false;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
251
|
function openDebugInfoModal() {
|
|
271
252
|
showDebugPopup = true;
|
|
272
253
|
}
|
|
@@ -460,12 +441,10 @@
|
|
|
460
441
|
{roleCategory}
|
|
461
442
|
{agentStatus}
|
|
462
443
|
{senderName}
|
|
463
|
-
{hasTokenUsageData}
|
|
464
444
|
{formatTime}
|
|
465
445
|
onCopy={copyToClipboard}
|
|
466
446
|
onRestore={handleRestore}
|
|
467
447
|
onEdit={handleEdit}
|
|
468
|
-
onShowTokenUsage={openTokenUsageModal}
|
|
469
448
|
onShowDebug={openDebugInfoModal}
|
|
470
449
|
/>
|
|
471
450
|
</div>
|
|
@@ -479,14 +458,6 @@
|
|
|
479
458
|
</div>
|
|
480
459
|
</div>
|
|
481
460
|
|
|
482
|
-
<!-- Token Usage Popup -->
|
|
483
|
-
<TokenUsageModal
|
|
484
|
-
bind:isOpen={showTokenUsagePopup}
|
|
485
|
-
tokenUsage={hasTokenUsageData}
|
|
486
|
-
timestamp={messageTimestamp}
|
|
487
|
-
onClose={closeTokenUsageModal}
|
|
488
|
-
/>
|
|
489
|
-
|
|
490
461
|
<!-- Debug Info Popup -->
|
|
491
462
|
<DebugModal
|
|
492
463
|
bind:isOpen={showDebugPopup}
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
|
|
50
50
|
// Process messages through grouping and embedding
|
|
51
51
|
const processedMessages = $derived.by(() => {
|
|
52
|
-
const { groups, toolUseMap, subAgentMap } = groupMessages(sessionState.messages);
|
|
53
|
-
return embedToolResults(groups, toolUseMap, subAgentMap);
|
|
52
|
+
const { groups, toolUseMap, subAgentMap, skillPromptMap } = groupMessages(sessionState.messages);
|
|
53
|
+
return embedToolResults(groups, toolUseMap, subAgentMap, skillPromptMap);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
// Filter out messages with empty content arrays
|
|
@@ -24,12 +24,10 @@
|
|
|
24
24
|
roleCategory,
|
|
25
25
|
agentStatus,
|
|
26
26
|
senderName,
|
|
27
|
-
hasTokenUsageData,
|
|
28
27
|
formatTime,
|
|
29
28
|
onCopy,
|
|
30
29
|
onRestore,
|
|
31
30
|
onEdit,
|
|
32
|
-
onShowTokenUsage,
|
|
33
31
|
onShowDebug
|
|
34
32
|
}: {
|
|
35
33
|
message: SDKMessageFormatter;
|
|
@@ -39,12 +37,10 @@
|
|
|
39
37
|
roleCategory: 'user' | 'assistant' | 'agent' | string;
|
|
40
38
|
agentStatus: 'processing' | 'waiting' | 'success' | 'error' | null;
|
|
41
39
|
senderName: string | null;
|
|
42
|
-
hasTokenUsageData: any;
|
|
43
40
|
formatTime: (timestamp?: string) => string;
|
|
44
41
|
onCopy: () => void;
|
|
45
42
|
onRestore: () => void;
|
|
46
43
|
onEdit: () => void;
|
|
47
|
-
onShowTokenUsage: () => void;
|
|
48
44
|
onShowDebug: () => void;
|
|
49
45
|
} = $props();
|
|
50
46
|
|
|
@@ -94,12 +90,10 @@
|
|
|
94
90
|
{roleCategory}
|
|
95
91
|
{agentStatus}
|
|
96
92
|
{senderName}
|
|
97
|
-
{hasTokenUsageData}
|
|
98
93
|
{formatTime}
|
|
99
94
|
{onCopy}
|
|
100
95
|
{onRestore}
|
|
101
96
|
{onEdit}
|
|
102
|
-
{onShowTokenUsage}
|
|
103
97
|
{onShowDebug}
|
|
104
98
|
/>
|
|
105
99
|
|
|
@@ -22,12 +22,10 @@
|
|
|
22
22
|
roleCategory,
|
|
23
23
|
agentStatus,
|
|
24
24
|
senderName,
|
|
25
|
-
hasTokenUsageData,
|
|
26
25
|
formatTime,
|
|
27
26
|
onCopy,
|
|
28
27
|
onRestore,
|
|
29
28
|
onEdit,
|
|
30
|
-
onShowTokenUsage,
|
|
31
29
|
onShowDebug
|
|
32
30
|
}: {
|
|
33
31
|
message: SDKMessageFormatter;
|
|
@@ -37,12 +35,10 @@
|
|
|
37
35
|
roleCategory: 'user' | 'assistant' | 'agent' | string;
|
|
38
36
|
agentStatus: 'processing' | 'waiting' | 'success' | 'error' | null;
|
|
39
37
|
senderName: string | null;
|
|
40
|
-
hasTokenUsageData: any;
|
|
41
38
|
formatTime: (timestamp?: string) => string;
|
|
42
39
|
onCopy: () => void;
|
|
43
40
|
onRestore: () => void;
|
|
44
41
|
onEdit: () => void;
|
|
45
|
-
onShowTokenUsage: () => void;
|
|
46
42
|
onShowDebug: () => void;
|
|
47
43
|
} = $props();
|
|
48
44
|
|
|
@@ -134,18 +130,6 @@
|
|
|
134
130
|
</button>
|
|
135
131
|
{/if}
|
|
136
132
|
|
|
137
|
-
<!-- Token Usage button -->
|
|
138
|
-
{#if hasTokenUsageData}
|
|
139
|
-
<button
|
|
140
|
-
onclick={onShowTokenUsage}
|
|
141
|
-
class="inline-flex p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-600 transition-colors opacity-60 hover:opacity-100"
|
|
142
|
-
aria-label="Show token usage info"
|
|
143
|
-
title="Token usage"
|
|
144
|
-
>
|
|
145
|
-
<Icon name="lucide:zap" class="w-3.5 h-3.5" />
|
|
146
|
-
</button>
|
|
147
|
-
{/if}
|
|
148
|
-
|
|
149
133
|
<!-- Debug toggle button -->
|
|
150
134
|
<button
|
|
151
135
|
onclick={onShowDebug}
|