feat: File-Explorer für Agent-Ordner im Agent-Formular
This commit is contained in:
1 parent
8e585443e2
commit
58c5ccb79b
4 files changed
+192
-4
No files matched your search
@@ -141,6 +141,10 @@
|
||||
<input type="checkbox" id="agentUseMemory" checked>
|
||||
Auf Erinnerungen zugreifen <span class="checkbox-hint">(Memory-Tools verfügbar)</span>
|
||||
</label>
|
||||
<div id="agentFilesSection" hidden>
|
||||
<label>Agent-Dateien</label>
|
||||
<button type="button" id="agentFilesBtn" class="add-cmd-btn"><i class="fa fa-folder"></i> Dateien verwalten</button>
|
||||
</div>
|
||||
<label>Benutzerdefinierte Befehle</label>
|
||||
<div class="custom-commands" id="agentCommandsList"></div>
|
||||
<button type="button" id="agentAddCommandBtn" class="add-cmd-btn">+ Befehl hinzufügen</button>
|
||||
|
||||
@@ -4,11 +4,19 @@
|
||||
|
||||
let _feState = null;
|
||||
|
||||
function _feApiUrl(action, params = '') {
|
||||
if (_feState && _feState.agentId) {
|
||||
return `/api/workspace/agent/${action}?agentId=${_feState.agentId}${params ? '&' + params : ''}`;
|
||||
}
|
||||
return `/api/workspace/${action}?sessionId=${_feState.sessionId}${params ? '&' + params : ''}`;
|
||||
}
|
||||
|
||||
function openFileExplorer(opts = {}) {
|
||||
if (_feState) closeFileExplorer();
|
||||
|
||||
_feState = {
|
||||
sessionId: opts.sessionId || getCurrentSessionId(),
|
||||
sessionId: opts.sessionId || (!opts.agentId ? getCurrentSessionId() : null),
|
||||
agentId: opts.agentId || null,
|
||||
onSelect: opts.onSelect || null,
|
||||
currentPath: '',
|
||||
history: [],
|
||||
@@ -102,7 +110,7 @@ async function feLoadDir(path) {
|
||||
document.getElementById('feFooter').hidden = true;
|
||||
|
||||
try {
|
||||
const resp = await fetch(`/api/workspace/tree?sessionId=${_feState.sessionId}&path=${encodeURIComponent(path)}`);
|
||||
const resp = await fetch(_feApiUrl('tree', `path=${encodeURIComponent(path)}`));
|
||||
if (!resp.ok) {
|
||||
const err = await resp.json().catch(() => ({}));
|
||||
sidebar.innerHTML = `<div class="fe-error">${err.error || 'Fehler'}</div>`;
|
||||
@@ -206,7 +214,7 @@ async function feSelectFile(entry, itemEl) {
|
||||
main.innerHTML = '<div class="fe-loading">Laden...</div>';
|
||||
|
||||
try {
|
||||
const resp = await fetch(`/api/workspace/file?sessionId=${_feState.sessionId}&path=${encodeURIComponent(entry.path)}`);
|
||||
const resp = await fetch(_feApiUrl('file', `path=${encodeURIComponent(entry.path)}`));
|
||||
if (!resp.ok) {
|
||||
main.innerHTML = '<div class="fe-error">Fehler beim Laden</div>';
|
||||
return;
|
||||
@@ -431,7 +439,7 @@ async function feDoSave() {
|
||||
|
||||
try {
|
||||
const resp = await fetch(
|
||||
`/api/workspace/file?sessionId=${_feState.sessionId}&path=${encodeURIComponent(path)}`,
|
||||
_feApiUrl('file', `path=${encodeURIComponent(path)}`),
|
||||
{ method: 'PUT', body: content }
|
||||
);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ registerPage('agent', {
|
||||
const deleteBtn = document.getElementById('agentDeleteBtn');
|
||||
const commandsList = document.getElementById('agentCommandsList');
|
||||
const addCommandBtn = document.getElementById('agentAddCommandBtn');
|
||||
const filesSection = document.getElementById('agentFilesSection');
|
||||
const filesBtn = document.getElementById('agentFilesBtn');
|
||||
|
||||
_agentAvatarData = null;
|
||||
|
||||
@@ -49,6 +51,7 @@ registerPage('agent', {
|
||||
useMemoryEl.checked = agent.useMemory !== false;
|
||||
_agentAvatarData = agent.avatar || null;
|
||||
deleteBtn.hidden = false;
|
||||
filesSection.hidden = false;
|
||||
|
||||
if (agent.avatar) {
|
||||
avatarPreview.innerHTML = `<img src="${agent.avatar}" alt="Avatar">`;
|
||||
@@ -58,6 +61,11 @@ registerPage('agent', {
|
||||
loadCommandsIntoUI(commandsList, agent.customCommands);
|
||||
}
|
||||
|
||||
// Agent-Dateien öffnen
|
||||
filesBtn.addEventListener('click', () => {
|
||||
openFileExplorer({ agentId: agentId });
|
||||
});
|
||||
|
||||
// Befehl hinzufügen
|
||||
addCommandBtn.addEventListener('click', () => createCommandRow(commandsList));
|
||||
|
||||
|
||||
Reference in new issue
Block a user