@agent-link/server 0.1.42 → 0.1.43
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/package.json +1 -1
- package/web/app.js +5 -0
- package/web/modules/connection.js +8 -5
package/package.json
CHANGED
package/web/app.js
CHANGED
|
@@ -35,7 +35,12 @@ const App = {
|
|
|
35
35
|
return messages.value.slice(messages.value.length - visibleLimit.value);
|
|
36
36
|
});
|
|
37
37
|
function loadMoreMessages() {
|
|
38
|
+
const el = document.querySelector('.message-list');
|
|
39
|
+
const prevHeight = el ? el.scrollHeight : 0;
|
|
38
40
|
visibleLimit.value += 50;
|
|
41
|
+
nextTick(() => {
|
|
42
|
+
if (el) el.scrollTop += el.scrollHeight - prevHeight;
|
|
43
|
+
});
|
|
39
44
|
}
|
|
40
45
|
const inputText = ref('');
|
|
41
46
|
const isProcessing = ref(false);
|
|
@@ -24,6 +24,7 @@ export function createConnection(deps) {
|
|
|
24
24
|
let sessionKey = null;
|
|
25
25
|
let reconnectAttempts = 0;
|
|
26
26
|
let reconnectTimer = null;
|
|
27
|
+
const toolMsgMap = new Map(); // toolId -> message (for fast tool_result lookup)
|
|
27
28
|
|
|
28
29
|
function wsSend(msg) {
|
|
29
30
|
if (!ws || ws.readyState !== WebSocket.OPEN) return;
|
|
@@ -70,12 +71,14 @@ export function createConnection(deps) {
|
|
|
70
71
|
finalizeStreamingMsg(scheduleHighlight);
|
|
71
72
|
|
|
72
73
|
for (const tool of data.tools) {
|
|
73
|
-
|
|
74
|
+
const toolMsg = {
|
|
74
75
|
id: streaming.nextId(), role: 'tool',
|
|
75
76
|
toolId: tool.id, toolName: tool.name || 'unknown',
|
|
76
77
|
toolInput: tool.input ? JSON.stringify(tool.input, null, 2) : '',
|
|
77
78
|
hasResult: false, expanded: (tool.name === 'Edit' || tool.name === 'TodoWrite'), timestamp: new Date(),
|
|
78
|
-
}
|
|
79
|
+
};
|
|
80
|
+
messages.value.push(toolMsg);
|
|
81
|
+
if (tool.id) toolMsgMap.set(tool.id, toolMsg);
|
|
79
82
|
}
|
|
80
83
|
scrollToBottom();
|
|
81
84
|
return;
|
|
@@ -85,9 +88,7 @@ export function createConnection(deps) {
|
|
|
85
88
|
const result = data.tool_use_result;
|
|
86
89
|
const results = Array.isArray(result) ? result : [result];
|
|
87
90
|
for (const r of results) {
|
|
88
|
-
const toolMsg =
|
|
89
|
-
m => m.role === 'tool' && m.toolId === r.tool_use_id
|
|
90
|
-
);
|
|
91
|
+
const toolMsg = toolMsgMap.get(r.tool_use_id);
|
|
91
92
|
if (toolMsg) {
|
|
92
93
|
toolMsg.toolOutput = typeof r.content === 'string'
|
|
93
94
|
? r.content : JSON.stringify(r.content, null, 2);
|
|
@@ -272,6 +273,7 @@ export function createConnection(deps) {
|
|
|
272
273
|
}
|
|
273
274
|
}
|
|
274
275
|
messages.value = batch;
|
|
276
|
+
toolMsgMap.clear();
|
|
275
277
|
}
|
|
276
278
|
loadingHistory.value = false;
|
|
277
279
|
messages.value.push({
|
|
@@ -290,6 +292,7 @@ export function createConnection(deps) {
|
|
|
290
292
|
workDir.value = msg.workDir;
|
|
291
293
|
localStorage.setItem('agentlink-workdir', msg.workDir);
|
|
292
294
|
messages.value = [];
|
|
295
|
+
toolMsgMap.clear();
|
|
293
296
|
visibleLimit.value = 50;
|
|
294
297
|
streaming.setMessageIdCounter(0);
|
|
295
298
|
streaming.setStreamingMessageId(null);
|