@agent-link/server 0.1.187 → 0.1.188

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.
Files changed (54) hide show
  1. package/dist/index.js +13 -15
  2. package/dist/index.js.map +1 -1
  3. package/package.json +3 -3
  4. package/web/dist/assets/index-C9bIrYkZ.js +320 -0
  5. package/web/dist/assets/index-C9bIrYkZ.js.map +1 -0
  6. package/web/dist/assets/index-Y1FN_mFe.css +1 -0
  7. package/web/{index.html → dist/index.html} +2 -19
  8. package/web/app.js +0 -2881
  9. package/web/css/ask-question.css +0 -333
  10. package/web/css/base.css +0 -270
  11. package/web/css/btw.css +0 -148
  12. package/web/css/chat.css +0 -176
  13. package/web/css/file-browser.css +0 -499
  14. package/web/css/input.css +0 -671
  15. package/web/css/loop.css +0 -674
  16. package/web/css/markdown.css +0 -169
  17. package/web/css/responsive.css +0 -314
  18. package/web/css/sidebar.css +0 -593
  19. package/web/css/team.css +0 -1277
  20. package/web/css/tools.css +0 -327
  21. package/web/encryption.js +0 -56
  22. package/web/modules/appHelpers.js +0 -100
  23. package/web/modules/askQuestion.js +0 -63
  24. package/web/modules/backgroundRouting.js +0 -269
  25. package/web/modules/connection.js +0 -731
  26. package/web/modules/fileAttachments.js +0 -125
  27. package/web/modules/fileBrowser.js +0 -398
  28. package/web/modules/filePreview.js +0 -213
  29. package/web/modules/i18n.js +0 -101
  30. package/web/modules/loop.js +0 -338
  31. package/web/modules/loopTemplates.js +0 -110
  32. package/web/modules/markdown.js +0 -83
  33. package/web/modules/messageHelpers.js +0 -206
  34. package/web/modules/sidebar.js +0 -402
  35. package/web/modules/streaming.js +0 -116
  36. package/web/modules/team.js +0 -396
  37. package/web/modules/teamTemplates.js +0 -360
  38. package/web/vendor/highlight.min.js +0 -1213
  39. package/web/vendor/marked.min.js +0 -6
  40. package/web/vendor/nacl-fast.min.js +0 -1
  41. package/web/vendor/nacl-util.min.js +0 -1
  42. package/web/vendor/pako.min.js +0 -2
  43. package/web/vendor/vue.global.prod.js +0 -13
  44. /package/web/{favicon.svg → dist/favicon.svg} +0 -0
  45. /package/web/{images → dist/images}/chat-iPad.webp +0 -0
  46. /package/web/{images → dist/images}/chat-iPhone.webp +0 -0
  47. /package/web/{images → dist/images}/loop-iPad.webp +0 -0
  48. /package/web/{images → dist/images}/team-iPad.webp +0 -0
  49. /package/web/{landing.html → dist/landing.html} +0 -0
  50. /package/web/{landing.zh.html → dist/landing.zh.html} +0 -0
  51. /package/web/{locales → dist/locales}/en.json +0 -0
  52. /package/web/{locales → dist/locales}/zh.json +0 -0
  53. /package/web/{vendor → dist/vendor}/github-dark.min.css +0 -0
  54. /package/web/{vendor → dist/vendor}/github.min.css +0 -0
@@ -1,125 +0,0 @@
1
- // ── File attachment handling ──────────────────────────────────────────────────
2
-
3
- const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
4
- const MAX_FILES = 5;
5
- const ACCEPTED_EXTENSIONS = [
6
- '.pdf', '.json', '.md', '.py', '.js', '.ts', '.tsx', '.jsx', '.css',
7
- '.html', '.xml', '.yaml', '.yml', '.toml', '.sh', '.sql', '.csv',
8
- '.c', '.cpp', '.h', '.hpp', '.java', '.go', '.rs', '.rb', '.php',
9
- '.swift', '.kt', '.scala', '.r', '.m', '.vue', '.svelte', '.txt',
10
- '.log', '.cfg', '.ini', '.env', '.gitignore', '.dockerfile',
11
- ];
12
-
13
- function isAcceptedFile(file) {
14
- if (file.type.startsWith('image/')) return true;
15
- if (file.type.startsWith('text/')) return true;
16
- const ext = '.' + file.name.split('.').pop().toLowerCase();
17
- return ACCEPTED_EXTENSIONS.includes(ext);
18
- }
19
-
20
- export function formatFileSize(bytes) {
21
- if (bytes < 1024) return bytes + ' B';
22
- if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
23
- return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
24
- }
25
-
26
- function readFileAsBase64(file) {
27
- return new Promise((resolve, reject) => {
28
- const reader = new FileReader();
29
- reader.onload = () => {
30
- const base64 = reader.result.split(',')[1];
31
- resolve(base64);
32
- };
33
- reader.onerror = reject;
34
- reader.readAsDataURL(file);
35
- });
36
- }
37
-
38
- /**
39
- * Creates file attachment handlers bound to Vue reactive state.
40
- * @param {import('vue').Ref} attachments - ref([])
41
- * @param {import('vue').Ref} fileInputRef - ref(null)
42
- * @param {import('vue').Ref} dragOver - ref(false)
43
- */
44
- export function createFileAttachments(attachments, fileInputRef, dragOver) {
45
-
46
- async function addFiles(fileList) {
47
- const currentCount = attachments.value.length;
48
- const remaining = MAX_FILES - currentCount;
49
- if (remaining <= 0) return;
50
-
51
- const files = Array.from(fileList).slice(0, remaining);
52
- for (const file of files) {
53
- if (!isAcceptedFile(file)) continue;
54
- if (file.size > MAX_FILE_SIZE) continue;
55
- if (attachments.value.some(a => a.name === file.name && a.size === file.size)) continue;
56
-
57
- const data = await readFileAsBase64(file);
58
- const isImage = file.type.startsWith('image/');
59
- let thumbUrl = null;
60
- if (isImage) {
61
- thumbUrl = URL.createObjectURL(file);
62
- }
63
- attachments.value.push({
64
- name: file.name,
65
- mimeType: file.type || 'application/octet-stream',
66
- size: file.size,
67
- data,
68
- isImage,
69
- thumbUrl,
70
- });
71
- }
72
- }
73
-
74
- function removeAttachment(index) {
75
- const att = attachments.value[index];
76
- if (att.thumbUrl) URL.revokeObjectURL(att.thumbUrl);
77
- attachments.value.splice(index, 1);
78
- }
79
-
80
- function triggerFileInput() {
81
- if (fileInputRef.value) fileInputRef.value.click();
82
- }
83
-
84
- function handleFileSelect(e) {
85
- if (e.target.files) addFiles(e.target.files);
86
- e.target.value = '';
87
- }
88
-
89
- function handleDragOver(e) {
90
- e.preventDefault();
91
- dragOver.value = true;
92
- }
93
-
94
- function handleDragLeave(e) {
95
- e.preventDefault();
96
- dragOver.value = false;
97
- }
98
-
99
- function handleDrop(e) {
100
- e.preventDefault();
101
- dragOver.value = false;
102
- if (e.dataTransfer?.files) addFiles(e.dataTransfer.files);
103
- }
104
-
105
- function handlePaste(e) {
106
- const items = e.clipboardData?.items;
107
- if (!items) return;
108
- const files = [];
109
- for (const item of items) {
110
- if (item.kind === 'file') {
111
- const file = item.getAsFile();
112
- if (file) files.push(file);
113
- }
114
- }
115
- if (files.length > 0) {
116
- e.preventDefault();
117
- addFiles(files);
118
- }
119
- }
120
-
121
- return {
122
- addFiles, removeAttachment, triggerFileInput, handleFileSelect,
123
- handleDragOver, handleDragLeave, handleDrop, handlePaste,
124
- };
125
- }
@@ -1,398 +0,0 @@
1
- // ── File Browser: tree state, lazy loading, context menu, file actions ────────
2
- const { computed, nextTick } = Vue;
3
-
4
- /**
5
- * Creates the file browser controller.
6
- * @param {object} deps - Reactive state and callbacks
7
- */
8
- export function createFileBrowser(deps) {
9
- const {
10
- wsSend, workDir, inputText, inputRef,
11
- filePanelOpen, fileTreeRoot, fileTreeLoading, fileContextMenu,
12
- sidebarOpen, sidebarView, filePanelWidth,
13
- } = deps;
14
-
15
- // Map of dirPath → TreeNode awaiting directory_listing response
16
- const pendingRequests = new Map();
17
-
18
- // ── Tree helpers ──
19
-
20
- function buildPath(parentPath, name) {
21
- if (!parentPath) return name;
22
- const sep = parentPath.includes('\\') ? '\\' : '/';
23
- return parentPath.replace(/[/\\]$/, '') + sep + name;
24
- }
25
-
26
- function makeNode(entry, parentPath) {
27
- return {
28
- path: buildPath(parentPath, entry.name),
29
- name: entry.name,
30
- type: entry.type,
31
- expanded: false,
32
- children: entry.type === 'directory' ? null : undefined,
33
- loading: false,
34
- error: null,
35
- };
36
- }
37
-
38
- // ── Flattened tree for rendering ──
39
-
40
- const flattenedTree = computed(() => {
41
- const root = fileTreeRoot.value;
42
- if (!root || !root.children) return [];
43
- const result = [];
44
- function walk(children, depth) {
45
- for (const node of children) {
46
- result.push({ node, depth });
47
- if (node.type === 'directory' && node.expanded && node.children) {
48
- walk(node.children, depth + 1);
49
- }
50
- }
51
- }
52
- walk(root.children, 0);
53
- return result;
54
- });
55
-
56
- // ── Panel open/close ──
57
-
58
- function openPanel() {
59
- filePanelOpen.value = true;
60
- if (!fileTreeRoot.value || fileTreeRoot.value.path !== workDir.value) {
61
- loadRoot();
62
- }
63
- }
64
-
65
- function closePanel() {
66
- filePanelOpen.value = false;
67
- closeContextMenu();
68
- }
69
-
70
- function togglePanel() {
71
- if (filePanelOpen.value) {
72
- closePanel();
73
- } else {
74
- openPanel();
75
- }
76
- }
77
-
78
- // ── Loading ──
79
-
80
- function loadRoot() {
81
- const dir = workDir.value;
82
- if (!dir) return;
83
- fileTreeLoading.value = true;
84
- fileTreeRoot.value = {
85
- path: dir,
86
- name: dir,
87
- type: 'directory',
88
- expanded: true,
89
- children: null,
90
- loading: true,
91
- error: null,
92
- };
93
- pendingRequests.set(dir, fileTreeRoot.value);
94
- wsSend({ type: 'list_directory', dirPath: dir, source: 'file_browser' });
95
- }
96
-
97
- function loadDirectory(node) {
98
- if (node.loading) return;
99
- node.loading = true;
100
- node.error = null;
101
- pendingRequests.set(node.path, node);
102
- wsSend({ type: 'list_directory', dirPath: node.path, source: 'file_browser' });
103
- }
104
-
105
- // ── Folder expand/collapse ──
106
-
107
- function toggleFolder(node) {
108
- if (node.type !== 'directory') return;
109
- if (node.expanded) {
110
- node.expanded = false;
111
- closeContextMenu();
112
- } else {
113
- node.expanded = true;
114
- if (node.children === null) {
115
- loadDirectory(node);
116
- }
117
- }
118
- }
119
-
120
- // ── Handle directory_listing response ──
121
-
122
- function handleDirectoryListing(msg) {
123
- const dirPath = msg.dirPath;
124
- const node = pendingRequests.get(dirPath);
125
- pendingRequests.delete(dirPath);
126
-
127
- // Check if this is the root loading
128
- if (fileTreeRoot.value && fileTreeRoot.value.path === dirPath) {
129
- fileTreeLoading.value = false;
130
- }
131
-
132
- if (!node) {
133
- // No pending request for this path — could be a stale response after
134
- // workdir change. Try to find the node in the tree by path.
135
- const found = findNodeByPath(dirPath);
136
- if (found) {
137
- applyListing(found, msg);
138
- }
139
- return;
140
- }
141
-
142
- applyListing(node, msg);
143
- }
144
-
145
- function applyListing(node, msg) {
146
- node.loading = false;
147
- if (msg.error) {
148
- node.error = msg.error;
149
- node.children = [];
150
- return;
151
- }
152
- const entries = msg.entries || [];
153
- node.children = entries.map(e => makeNode(e, node.path));
154
- node.expanded = true;
155
- }
156
-
157
- function findNodeByPath(targetPath) {
158
- const root = fileTreeRoot.value;
159
- if (!root) return null;
160
- if (root.path === targetPath) return root;
161
- if (!root.children) return null;
162
- function search(children) {
163
- for (const node of children) {
164
- if (node.path === targetPath) return node;
165
- if (node.type === 'directory' && node.children) {
166
- const found = search(node.children);
167
- if (found) return found;
168
- }
169
- }
170
- return null;
171
- }
172
- return search(root.children);
173
- }
174
-
175
- // ── Refresh ──
176
-
177
- function refreshTree() {
178
- if (!fileTreeRoot.value) {
179
- loadRoot();
180
- return;
181
- }
182
- // Re-fetch all expanded directories
183
- refreshNode(fileTreeRoot.value);
184
- }
185
-
186
- function refreshNode(node) {
187
- if (node.type !== 'directory') return;
188
- if (node.expanded && node.children !== null) {
189
- // Re-fetch this directory
190
- node.children = null;
191
- loadDirectory(node);
192
- }
193
- // Note: children of this node will be re-fetched when loadDirectory
194
- // completes and rebuilds the children array. No need to recurse.
195
- }
196
-
197
- // ── Workdir changed ──
198
-
199
- function onWorkdirChanged() {
200
- pendingRequests.clear();
201
- fileTreeRoot.value = null;
202
- fileTreeLoading.value = false;
203
- closeContextMenu();
204
- if (filePanelOpen.value) {
205
- loadRoot();
206
- }
207
- }
208
-
209
- // ── Context menu ──
210
-
211
- function onFileClick(event, node) {
212
- if (node.type === 'directory') return;
213
- event.stopPropagation();
214
-
215
- // Position the menu near the click, adjusting for viewport edges
216
- let x = event.clientX;
217
- let y = event.clientY;
218
- const menuWidth = 220;
219
- const menuHeight = 120; // approx 3 items
220
- if (x + menuWidth > window.innerWidth) {
221
- x = window.innerWidth - menuWidth - 8;
222
- }
223
- if (y + menuHeight > window.innerHeight) {
224
- y = y - menuHeight;
225
- }
226
- if (x < 0) x = 8;
227
- if (y < 0) y = 8;
228
-
229
- fileContextMenu.value = {
230
- x,
231
- y,
232
- path: node.path,
233
- name: node.name,
234
- };
235
- }
236
-
237
- function closeContextMenu() {
238
- fileContextMenu.value = null;
239
- }
240
-
241
- // ── File actions ──
242
-
243
- function askClaudeRead() {
244
- const menu = fileContextMenu.value;
245
- if (!menu) return;
246
- const path = menu.path;
247
- closeContextMenu();
248
- inputText.value = `Read the file ${path}`;
249
- // Close sidebar on mobile
250
- if (window.innerWidth <= 768) {
251
- sidebarOpen.value = false;
252
- sidebarView.value = 'sessions';
253
- }
254
- nextTick(() => {
255
- if (inputRef.value) inputRef.value.focus();
256
- });
257
- }
258
-
259
- function copyToClipboard(text) {
260
- // Use ClipboardItem with explicit text/plain to prevent Chrome (especially
261
- // mobile) from URL-encoding paths that look like URL schemes (e.g. Q:\...)
262
- if (navigator.clipboard && window.ClipboardItem) {
263
- const blob = new Blob([text], { type: 'text/plain' });
264
- const item = new ClipboardItem({ 'text/plain': blob });
265
- return navigator.clipboard.write([item]);
266
- }
267
- // Fallback for older browsers
268
- const textarea = document.createElement('textarea');
269
- textarea.value = text;
270
- textarea.style.position = 'fixed';
271
- textarea.style.opacity = '0';
272
- document.body.appendChild(textarea);
273
- textarea.select();
274
- document.execCommand('copy');
275
- document.body.removeChild(textarea);
276
- return Promise.resolve();
277
- }
278
-
279
- function copyPath() {
280
- const menu = fileContextMenu.value;
281
- if (!menu) return;
282
- const path = menu.path;
283
- copyToClipboard(path).catch(() => {});
284
- // Brief "Copied!" feedback — store temporarily in menu state
285
- fileContextMenu.value = { ...menu, copied: true };
286
- setTimeout(() => {
287
- closeContextMenu();
288
- }, 1000);
289
- }
290
-
291
- function insertPath() {
292
- const menu = fileContextMenu.value;
293
- if (!menu) return;
294
- const path = menu.path;
295
- closeContextMenu();
296
- const textarea = inputRef.value;
297
- if (textarea) {
298
- const start = textarea.selectionStart || inputText.value.length;
299
- const end = textarea.selectionEnd || inputText.value.length;
300
- const text = inputText.value;
301
- inputText.value = text.slice(0, start) + path + text.slice(end);
302
- nextTick(() => {
303
- const newPos = start + path.length;
304
- textarea.setSelectionRange(newPos, newPos);
305
- textarea.focus();
306
- });
307
- } else {
308
- inputText.value += path;
309
- }
310
- // Close sidebar on mobile
311
- if (window.innerWidth <= 768) {
312
- sidebarOpen.value = false;
313
- sidebarView.value = 'sessions';
314
- }
315
- }
316
-
317
- // ── Global click handler for dismissing context menu ──
318
-
319
- function setupGlobalListeners() {
320
- document.addEventListener('click', (e) => {
321
- if (!fileContextMenu.value) return;
322
- const menuEl = document.querySelector('.file-context-menu');
323
- if (menuEl && menuEl.contains(e.target)) return;
324
- closeContextMenu();
325
- });
326
- document.addEventListener('keydown', (e) => {
327
- if (e.key === 'Escape' && fileContextMenu.value) {
328
- closeContextMenu();
329
- }
330
- });
331
- }
332
-
333
- // ── Resize handle (mouse + touch) ──
334
-
335
- let _resizing = false;
336
- let _startX = 0;
337
- let _startWidth = 0;
338
- const MIN_WIDTH = 160;
339
- const MAX_WIDTH = 600;
340
-
341
- function onResizeStart(e) {
342
- e.preventDefault();
343
- _resizing = true;
344
- _startX = e.type === 'touchstart' ? e.touches[0].clientX : e.clientX;
345
- _startWidth = filePanelWidth.value;
346
- document.body.style.cursor = 'col-resize';
347
- document.body.style.userSelect = 'none';
348
- if (e.type === 'touchstart') {
349
- document.addEventListener('touchmove', onResizeMove, { passive: false });
350
- document.addEventListener('touchend', onResizeEnd);
351
- } else {
352
- document.addEventListener('mousemove', onResizeMove);
353
- document.addEventListener('mouseup', onResizeEnd);
354
- }
355
- }
356
-
357
- function onResizeMove(e) {
358
- if (!_resizing) return;
359
- if (e.type === 'touchmove') e.preventDefault();
360
- const clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX;
361
- const delta = clientX - _startX;
362
- const newWidth = Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, _startWidth + delta));
363
- filePanelWidth.value = newWidth;
364
- }
365
-
366
- function onResizeEnd() {
367
- if (!_resizing) return;
368
- _resizing = false;
369
- document.body.style.cursor = '';
370
- document.body.style.userSelect = '';
371
- document.removeEventListener('mousemove', onResizeMove);
372
- document.removeEventListener('mouseup', onResizeEnd);
373
- document.removeEventListener('touchmove', onResizeMove);
374
- document.removeEventListener('touchend', onResizeEnd);
375
- localStorage.setItem('agentlink-file-panel-width', String(filePanelWidth.value));
376
- }
377
-
378
- // Set up listeners immediately
379
- setupGlobalListeners();
380
-
381
- return {
382
- openPanel,
383
- closePanel,
384
- togglePanel,
385
- toggleFolder,
386
- onFileClick,
387
- closeContextMenu,
388
- askClaudeRead,
389
- copyPath,
390
- copyToClipboard,
391
- insertPath,
392
- refreshTree,
393
- handleDirectoryListing,
394
- onWorkdirChanged,
395
- flattenedTree,
396
- onResizeStart,
397
- };
398
- }