@agent-link/server 0.1.32 → 0.1.34
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/context.d.ts +2 -1
- package/dist/context.js.map +1 -1
- package/dist/ws-agent.js +21 -7
- package/dist/ws-agent.js.map +1 -1
- package/dist/ws-client.js +9 -8
- package/dist/ws-client.js.map +1 -1
- package/package.json +36 -36
- package/web/app.js +1 -1
- package/web/modules/connection.js +350 -369
- package/web/modules/sidebar.js +186 -188
package/web/modules/sidebar.js
CHANGED
|
@@ -1,188 +1,186 @@
|
|
|
1
|
-
// ── Sidebar: session management, folder picker, grouped sessions ─────────────
|
|
2
|
-
const { computed } = Vue;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Creates sidebar functionality bound to reactive state.
|
|
6
|
-
* @param {object} deps
|
|
7
|
-
* @param {Function} deps.wsSend
|
|
8
|
-
* @param {import('vue').Ref} deps.messages
|
|
9
|
-
* @param {import('vue').Ref} deps.isProcessing
|
|
10
|
-
* @param {import('vue').Ref} deps.sidebarOpen
|
|
11
|
-
* @param {import('vue').Ref} deps.historySessions
|
|
12
|
-
* @param {import('vue').Ref} deps.currentClaudeSessionId
|
|
13
|
-
* @param {import('vue').Ref} deps.needsResume
|
|
14
|
-
* @param {import('vue').Ref} deps.loadingSessions
|
|
15
|
-
* @param {import('vue').Ref} deps.loadingHistory
|
|
16
|
-
* @param {import('vue').Ref} deps.workDir
|
|
17
|
-
* @param {import('vue').Ref} deps.visibleLimit
|
|
18
|
-
* @param {import('vue').Ref} deps.folderPickerOpen
|
|
19
|
-
* @param {import('vue').Ref} deps.folderPickerPath
|
|
20
|
-
* @param {import('vue').Ref} deps.folderPickerEntries
|
|
21
|
-
* @param {import('vue').Ref} deps.folderPickerLoading
|
|
22
|
-
* @param {import('vue').Ref} deps.folderPickerSelected
|
|
23
|
-
* @param {object} deps.streaming - streaming controller
|
|
24
|
-
*/
|
|
25
|
-
export function createSidebar(deps) {
|
|
26
|
-
const {
|
|
27
|
-
wsSend, messages, isProcessing, sidebarOpen,
|
|
28
|
-
historySessions, currentClaudeSessionId, needsResume,
|
|
29
|
-
loadingSessions, loadingHistory, workDir, visibleLimit,
|
|
30
|
-
folderPickerOpen, folderPickerPath, folderPickerEntries,
|
|
31
|
-
folderPickerLoading, folderPickerSelected, streaming,
|
|
32
|
-
} = deps;
|
|
33
|
-
|
|
34
|
-
// ── Session management ──
|
|
35
|
-
|
|
36
|
-
function requestSessionList() {
|
|
37
|
-
loadingSessions.value = true;
|
|
38
|
-
wsSend({ type: 'list_sessions' });
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function resumeSession(session) {
|
|
42
|
-
if (isProcessing.value) return;
|
|
43
|
-
if (window.innerWidth <= 768) sidebarOpen.value = false;
|
|
44
|
-
messages.value = [];
|
|
45
|
-
visibleLimit.value = 50;
|
|
46
|
-
streaming.setMessageIdCounter(0);
|
|
47
|
-
streaming.setStreamingMessageId(null);
|
|
48
|
-
streaming.reset();
|
|
49
|
-
|
|
50
|
-
currentClaudeSessionId.value = session.sessionId;
|
|
51
|
-
needsResume.value = true;
|
|
52
|
-
loadingHistory.value = true;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
streaming.
|
|
67
|
-
streaming.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
newPath =
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (s.lastModified >=
|
|
172
|
-
else
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
};
|
|
188
|
-
}
|
|
1
|
+
// ── Sidebar: session management, folder picker, grouped sessions ─────────────
|
|
2
|
+
const { computed } = Vue;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates sidebar functionality bound to reactive state.
|
|
6
|
+
* @param {object} deps
|
|
7
|
+
* @param {Function} deps.wsSend
|
|
8
|
+
* @param {import('vue').Ref} deps.messages
|
|
9
|
+
* @param {import('vue').Ref} deps.isProcessing
|
|
10
|
+
* @param {import('vue').Ref} deps.sidebarOpen
|
|
11
|
+
* @param {import('vue').Ref} deps.historySessions
|
|
12
|
+
* @param {import('vue').Ref} deps.currentClaudeSessionId
|
|
13
|
+
* @param {import('vue').Ref} deps.needsResume
|
|
14
|
+
* @param {import('vue').Ref} deps.loadingSessions
|
|
15
|
+
* @param {import('vue').Ref} deps.loadingHistory
|
|
16
|
+
* @param {import('vue').Ref} deps.workDir
|
|
17
|
+
* @param {import('vue').Ref} deps.visibleLimit
|
|
18
|
+
* @param {import('vue').Ref} deps.folderPickerOpen
|
|
19
|
+
* @param {import('vue').Ref} deps.folderPickerPath
|
|
20
|
+
* @param {import('vue').Ref} deps.folderPickerEntries
|
|
21
|
+
* @param {import('vue').Ref} deps.folderPickerLoading
|
|
22
|
+
* @param {import('vue').Ref} deps.folderPickerSelected
|
|
23
|
+
* @param {object} deps.streaming - streaming controller
|
|
24
|
+
*/
|
|
25
|
+
export function createSidebar(deps) {
|
|
26
|
+
const {
|
|
27
|
+
wsSend, messages, isProcessing, sidebarOpen,
|
|
28
|
+
historySessions, currentClaudeSessionId, needsResume,
|
|
29
|
+
loadingSessions, loadingHistory, workDir, visibleLimit,
|
|
30
|
+
folderPickerOpen, folderPickerPath, folderPickerEntries,
|
|
31
|
+
folderPickerLoading, folderPickerSelected, streaming,
|
|
32
|
+
} = deps;
|
|
33
|
+
|
|
34
|
+
// ── Session management ──
|
|
35
|
+
|
|
36
|
+
function requestSessionList() {
|
|
37
|
+
loadingSessions.value = true;
|
|
38
|
+
wsSend({ type: 'list_sessions' });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function resumeSession(session) {
|
|
42
|
+
if (isProcessing.value) return;
|
|
43
|
+
if (window.innerWidth <= 768) sidebarOpen.value = false;
|
|
44
|
+
messages.value = [];
|
|
45
|
+
visibleLimit.value = 50;
|
|
46
|
+
streaming.setMessageIdCounter(0);
|
|
47
|
+
streaming.setStreamingMessageId(null);
|
|
48
|
+
streaming.reset();
|
|
49
|
+
|
|
50
|
+
currentClaudeSessionId.value = session.sessionId;
|
|
51
|
+
needsResume.value = true;
|
|
52
|
+
loadingHistory.value = true;
|
|
53
|
+
|
|
54
|
+
wsSend({
|
|
55
|
+
type: 'resume_conversation',
|
|
56
|
+
claudeSessionId: session.sessionId,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function newConversation() {
|
|
61
|
+
if (isProcessing.value) return;
|
|
62
|
+
if (window.innerWidth <= 768) sidebarOpen.value = false;
|
|
63
|
+
messages.value = [];
|
|
64
|
+
visibleLimit.value = 50;
|
|
65
|
+
streaming.setMessageIdCounter(0);
|
|
66
|
+
streaming.setStreamingMessageId(null);
|
|
67
|
+
streaming.reset();
|
|
68
|
+
currentClaudeSessionId.value = null;
|
|
69
|
+
needsResume.value = false;
|
|
70
|
+
|
|
71
|
+
messages.value.push({
|
|
72
|
+
id: streaming.nextId(), role: 'system',
|
|
73
|
+
content: 'New conversation started.',
|
|
74
|
+
timestamp: new Date(),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function toggleSidebar() {
|
|
79
|
+
sidebarOpen.value = !sidebarOpen.value;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ── Folder picker ──
|
|
83
|
+
|
|
84
|
+
function openFolderPicker() {
|
|
85
|
+
folderPickerOpen.value = true;
|
|
86
|
+
folderPickerSelected.value = '';
|
|
87
|
+
folderPickerLoading.value = true;
|
|
88
|
+
folderPickerPath.value = workDir.value || '';
|
|
89
|
+
folderPickerEntries.value = [];
|
|
90
|
+
wsSend({ type: 'list_directory', dirPath: workDir.value || '' });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function loadFolderPickerDir(dirPath) {
|
|
94
|
+
folderPickerLoading.value = true;
|
|
95
|
+
folderPickerSelected.value = '';
|
|
96
|
+
folderPickerEntries.value = [];
|
|
97
|
+
wsSend({ type: 'list_directory', dirPath });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function folderPickerNavigateUp() {
|
|
101
|
+
if (!folderPickerPath.value) return;
|
|
102
|
+
const isWin = folderPickerPath.value.includes('\\');
|
|
103
|
+
const parts = folderPickerPath.value.replace(/[/\\]$/, '').split(/[/\\]/);
|
|
104
|
+
parts.pop();
|
|
105
|
+
if (parts.length === 0) {
|
|
106
|
+
folderPickerPath.value = '';
|
|
107
|
+
loadFolderPickerDir('');
|
|
108
|
+
} else if (isWin && parts.length === 1 && /^[A-Za-z]:$/.test(parts[0])) {
|
|
109
|
+
folderPickerPath.value = parts[0] + '\\';
|
|
110
|
+
loadFolderPickerDir(parts[0] + '\\');
|
|
111
|
+
} else {
|
|
112
|
+
const sep = isWin ? '\\' : '/';
|
|
113
|
+
const parent = parts.join(sep);
|
|
114
|
+
folderPickerPath.value = parent;
|
|
115
|
+
loadFolderPickerDir(parent);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function folderPickerSelectItem(entry) {
|
|
120
|
+
folderPickerSelected.value = entry.name;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function folderPickerEnter(entry) {
|
|
124
|
+
const sep = folderPickerPath.value.includes('\\') || /^[A-Z]:/.test(entry.name) ? '\\' : '/';
|
|
125
|
+
let newPath;
|
|
126
|
+
if (!folderPickerPath.value) {
|
|
127
|
+
newPath = entry.name + (entry.name.endsWith('\\') ? '' : '\\');
|
|
128
|
+
} else {
|
|
129
|
+
newPath = folderPickerPath.value.replace(/[/\\]$/, '') + sep + entry.name;
|
|
130
|
+
}
|
|
131
|
+
folderPickerPath.value = newPath;
|
|
132
|
+
folderPickerSelected.value = '';
|
|
133
|
+
loadFolderPickerDir(newPath);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function folderPickerGoToPath() {
|
|
137
|
+
const path = folderPickerPath.value.trim();
|
|
138
|
+
if (!path) {
|
|
139
|
+
loadFolderPickerDir('');
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
folderPickerSelected.value = '';
|
|
143
|
+
loadFolderPickerDir(path);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function confirmFolderPicker() {
|
|
147
|
+
let path = folderPickerPath.value;
|
|
148
|
+
if (!path) return;
|
|
149
|
+
if (folderPickerSelected.value) {
|
|
150
|
+
const sep = path.includes('\\') ? '\\' : '/';
|
|
151
|
+
path = path.replace(/[/\\]$/, '') + sep + folderPickerSelected.value;
|
|
152
|
+
}
|
|
153
|
+
folderPickerOpen.value = false;
|
|
154
|
+
wsSend({ type: 'change_workdir', workDir: path });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ── Grouped sessions ──
|
|
158
|
+
|
|
159
|
+
const groupedSessions = computed(() => {
|
|
160
|
+
if (!historySessions.value.length) return [];
|
|
161
|
+
const now = new Date();
|
|
162
|
+
const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
|
|
163
|
+
const yesterdayStart = todayStart - 86400000;
|
|
164
|
+
const weekStart = todayStart - 6 * 86400000;
|
|
165
|
+
|
|
166
|
+
const groups = {};
|
|
167
|
+
for (const s of historySessions.value) {
|
|
168
|
+
let label;
|
|
169
|
+
if (s.lastModified >= todayStart) label = 'Today';
|
|
170
|
+
else if (s.lastModified >= yesterdayStart) label = 'Yesterday';
|
|
171
|
+
else if (s.lastModified >= weekStart) label = 'This week';
|
|
172
|
+
else label = 'Earlier';
|
|
173
|
+
if (!groups[label]) groups[label] = [];
|
|
174
|
+
groups[label].push(s);
|
|
175
|
+
}
|
|
176
|
+
const order = ['Today', 'Yesterday', 'This week', 'Earlier'];
|
|
177
|
+
return order.filter(k => groups[k]).map(k => ({ label: k, sessions: groups[k] }));
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
requestSessionList, resumeSession, newConversation, toggleSidebar,
|
|
182
|
+
openFolderPicker, folderPickerNavigateUp, folderPickerSelectItem,
|
|
183
|
+
folderPickerEnter, folderPickerGoToPath, confirmFolderPicker,
|
|
184
|
+
groupedSessions,
|
|
185
|
+
};
|
|
186
|
+
}
|