agentgui 1.0.992 → 1.0.993

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.992",
3
+ "version": "1.0.993",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "electron/main.js",
@@ -1,114 +0,0 @@
1
- // Files plugin - file browser, upload handler, drag-drop support
2
-
3
- import path from 'path';
4
- import fs from 'fs';
5
- import { confineToRoots, fsAllowRoots } from '../http-handler.js';
6
-
7
- export default {
8
- name: 'files',
9
- version: '1.0.0',
10
- dependencies: ['database'],
11
-
12
- async init(config, plugins) {
13
- const db = plugins.get('database');
14
- const uploadedFiles = new Map();
15
-
16
- const browseDirectory = (dir) => {
17
- const conf = confineToRoots(dir, fsAllowRoots());
18
- if (!conf.ok) return [];
19
- try {
20
- const entries = fs.readdirSync(conf.realPath);
21
- return entries.map(entry => {
22
- const fullPath = path.join(conf.realPath, entry);
23
- try {
24
- const stat = fs.statSync(fullPath);
25
- return {
26
- name: entry,
27
- path: fullPath,
28
- isDirectory: stat.isDirectory(),
29
- size: stat.size,
30
- };
31
- } catch (_) {
32
- return null;
33
- }
34
- }).filter(Boolean);
35
- } catch (e) {
36
- return [];
37
- }
38
- };
39
-
40
- return {
41
- routes: [
42
- {
43
- method: 'GET',
44
- path: '/files/:conversationId',
45
- handler: (req, res) => {
46
- const { conversationId } = req.params;
47
- const { dir } = req.query;
48
- const requestedDir = dir || process.cwd();
49
- const conf = confineToRoots(requestedDir, fsAllowRoots());
50
- if (!conf.ok) {
51
- return res.status(403).json({ error: 'Path not allowed' });
52
- }
53
- const entries = browseDirectory(conf.realPath);
54
- res.json({ entries, currentDir: conf.realPath });
55
- },
56
- },
57
- {
58
- method: 'POST',
59
- path: '/api/upload/:conversationId',
60
- handler: async (req, res) => {
61
- const { conversationId } = req.params;
62
- uploadedFiles.set(conversationId, Date.now());
63
- res.json({ success: true, conversationId });
64
- },
65
- },
66
- {
67
- method: 'POST',
68
- path: '/api/folders',
69
- handler: async (req, res) => {
70
- const { path: folderPath } = req.body;
71
- if (!folderPath || typeof folderPath !== 'string') {
72
- return res.status(400).json({ error: 'path is required' });
73
- }
74
- // Sanitize each path component - reject traversal attempts
75
- const parts = folderPath.split(/[/\\]/);
76
- for (const part of parts) {
77
- if (part === '..' || part === '.' || /[<>:"|?*\x00-\x1f]/.test(part)) {
78
- return res.status(400).json({ error: 'Invalid path component' });
79
- }
80
- }
81
- const conf = confineToRoots(folderPath, fsAllowRoots());
82
- if (!conf.ok && conf.reason !== 'not found') {
83
- return res.status(403).json({ error: 'Path not allowed' });
84
- }
85
- // For mkdir, path may not exist yet; re-check parent is confined
86
- const parentConf = confineToRoots(path.dirname(folderPath), fsAllowRoots());
87
- if (!parentConf.ok) {
88
- return res.status(403).json({ error: 'Path not allowed' });
89
- }
90
- try {
91
- fs.mkdirSync(folderPath, { recursive: true });
92
- res.json({ success: true, path: folderPath });
93
- } catch (e) {
94
- res.status(400).json({ error: e.message });
95
- }
96
- },
97
- },
98
- ],
99
- wsHandlers: {},
100
- api: {
101
- browseDirectory,
102
- },
103
- stop: async () => {
104
- uploadedFiles.clear();
105
- },
106
- };
107
- },
108
-
109
- async reload(state) {
110
- return state;
111
- },
112
-
113
- async stop() {},
114
- };