agentgui 1.0.427 → 1.0.429
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/database.js +49 -49
- package/package.json +1 -1
- package/server.js +5 -11
- package/static/js/client.js +15 -6
package/database.js
CHANGED
|
@@ -329,7 +329,7 @@ try {
|
|
|
329
329
|
const result = db.prepare("PRAGMA table_info(conversations)").all();
|
|
330
330
|
const columnNames = result.map(r => r.name);
|
|
331
331
|
const requiredColumns = {
|
|
332
|
-
agentType: 'TEXT
|
|
332
|
+
agentType: 'TEXT',
|
|
333
333
|
source: 'TEXT DEFAULT "gui"',
|
|
334
334
|
externalId: 'TEXT',
|
|
335
335
|
firstPrompt: 'TEXT',
|
|
@@ -939,54 +939,54 @@ export const queries = {
|
|
|
939
939
|
return true;
|
|
940
940
|
},
|
|
941
941
|
|
|
942
|
-
deleteClaudeSessionFile(sessionId) {
|
|
943
|
-
try {
|
|
944
|
-
const claudeDir = path.join(os.homedir(), '.claude');
|
|
945
|
-
const projectsDir = path.join(claudeDir, 'projects');
|
|
946
|
-
|
|
947
|
-
if (!fs.existsSync(projectsDir)) {
|
|
948
|
-
return false;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
// Search for session file in all project directories
|
|
952
|
-
const projects = fs.readdirSync(projectsDir);
|
|
953
|
-
for (const project of projects) {
|
|
954
|
-
const projectPath = path.join(projectsDir, project);
|
|
955
|
-
const sessionFile = path.join(projectPath, `${sessionId}.jsonl`);
|
|
956
|
-
|
|
957
|
-
if (fs.existsSync(sessionFile)) {
|
|
958
|
-
fs.unlinkSync(sessionFile);
|
|
959
|
-
console.log(`[deleteClaudeSessionFile] Deleted Claude session file: ${sessionFile}`);
|
|
960
|
-
|
|
961
|
-
// Also remove the entry from sessions-index.json if it exists
|
|
962
|
-
const indexPath = path.join(projectPath, 'sessions-index.json');
|
|
963
|
-
if (fs.existsSync(indexPath)) {
|
|
964
|
-
try {
|
|
965
|
-
const indexContent = fs.readFileSync(indexPath, 'utf8');
|
|
966
|
-
const index = JSON.parse(indexContent);
|
|
967
|
-
if (index.entries && Array.isArray(index.entries)) {
|
|
968
|
-
const originalLength = index.entries.length;
|
|
969
|
-
index.entries = index.entries.filter(entry => entry.sessionId !== sessionId);
|
|
970
|
-
if (index.entries.length < originalLength) {
|
|
971
|
-
fs.writeFileSync(indexPath, JSON.stringify(index, null, 2), { encoding: 'utf8' });
|
|
972
|
-
console.log(`[deleteClaudeSessionFile] Removed session ${sessionId} from sessions-index.json in ${projectPath}`);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
} catch (indexErr) {
|
|
976
|
-
console.error(`[deleteClaudeSessionFile] Failed to update sessions-index.json in ${projectPath}:`, indexErr.message);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
return true;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
return false;
|
|
985
|
-
} catch (err) {
|
|
986
|
-
console.error(`[deleteClaudeSessionFile] Error deleting session ${sessionId}:`, err.message);
|
|
987
|
-
return false;
|
|
988
|
-
}
|
|
989
|
-
},
|
|
942
|
+
deleteClaudeSessionFile(sessionId) {
|
|
943
|
+
try {
|
|
944
|
+
const claudeDir = path.join(os.homedir(), '.claude');
|
|
945
|
+
const projectsDir = path.join(claudeDir, 'projects');
|
|
946
|
+
|
|
947
|
+
if (!fs.existsSync(projectsDir)) {
|
|
948
|
+
return false;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// Search for session file in all project directories
|
|
952
|
+
const projects = fs.readdirSync(projectsDir);
|
|
953
|
+
for (const project of projects) {
|
|
954
|
+
const projectPath = path.join(projectsDir, project);
|
|
955
|
+
const sessionFile = path.join(projectPath, `${sessionId}.jsonl`);
|
|
956
|
+
|
|
957
|
+
if (fs.existsSync(sessionFile)) {
|
|
958
|
+
fs.unlinkSync(sessionFile);
|
|
959
|
+
console.log(`[deleteClaudeSessionFile] Deleted Claude session file: ${sessionFile}`);
|
|
960
|
+
|
|
961
|
+
// Also remove the entry from sessions-index.json if it exists
|
|
962
|
+
const indexPath = path.join(projectPath, 'sessions-index.json');
|
|
963
|
+
if (fs.existsSync(indexPath)) {
|
|
964
|
+
try {
|
|
965
|
+
const indexContent = fs.readFileSync(indexPath, 'utf8');
|
|
966
|
+
const index = JSON.parse(indexContent);
|
|
967
|
+
if (index.entries && Array.isArray(index.entries)) {
|
|
968
|
+
const originalLength = index.entries.length;
|
|
969
|
+
index.entries = index.entries.filter(entry => entry.sessionId !== sessionId);
|
|
970
|
+
if (index.entries.length < originalLength) {
|
|
971
|
+
fs.writeFileSync(indexPath, JSON.stringify(index, null, 2), { encoding: 'utf8' });
|
|
972
|
+
console.log(`[deleteClaudeSessionFile] Removed session ${sessionId} from sessions-index.json in ${projectPath}`);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
} catch (indexErr) {
|
|
976
|
+
console.error(`[deleteClaudeSessionFile] Failed to update sessions-index.json in ${projectPath}:`, indexErr.message);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
return true;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
return false;
|
|
985
|
+
} catch (err) {
|
|
986
|
+
console.error(`[deleteClaudeSessionFile] Error deleting session ${sessionId}:`, err.message);
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
990
|
|
|
991
991
|
cleanup() {
|
|
992
992
|
const thirtyDaysAgo = Date.now() - (30 * 24 * 60 * 60 * 1000);
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -462,11 +462,7 @@ async function fetchClaudeModelsFromAPI() {
|
|
|
462
462
|
const data = JSON.parse(body);
|
|
463
463
|
const items = (data.data || []).filter(m => m.id && m.id.startsWith('claude-'));
|
|
464
464
|
if (items.length === 0) return resolve(null);
|
|
465
|
-
const models =
|
|
466
|
-
for (const m of items) {
|
|
467
|
-
const label = m.display_name || modelIdToLabel(m.id);
|
|
468
|
-
models.push({ id: m.id, label });
|
|
469
|
-
}
|
|
465
|
+
const models = items.map(m => ({ id: m.id, label: m.display_name || modelIdToLabel(m.id) }));
|
|
470
466
|
resolve(models);
|
|
471
467
|
} catch { resolve(null); }
|
|
472
468
|
});
|
|
@@ -497,12 +493,10 @@ async function fetchGeminiModelsFromAPI() {
|
|
|
497
493
|
const data = JSON.parse(body);
|
|
498
494
|
const items = (data.models || []).filter(m => m.name && m.name.includes('gemini'));
|
|
499
495
|
if (items.length === 0) return resolve(null);
|
|
500
|
-
const models =
|
|
501
|
-
for (const m of items) {
|
|
496
|
+
const models = items.map(m => {
|
|
502
497
|
const modelId = m.name.replace(/^models\//, '');
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
498
|
+
return { id: modelId, label: modelId.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase()) };
|
|
499
|
+
});
|
|
506
500
|
resolve(models);
|
|
507
501
|
} catch { resolve(null); }
|
|
508
502
|
});
|
|
@@ -3173,7 +3167,7 @@ function serveFile(filePath, res, req) {
|
|
|
3173
3167
|
if (err) { res.writeHead(500); res.end('Server error'); return; }
|
|
3174
3168
|
let content = data.toString();
|
|
3175
3169
|
const baseTag = `<script>window.__BASE_URL='${BASE_URL}';</script>`;
|
|
3176
|
-
content = content.replace('<head>',
|
|
3170
|
+
content = content.replace('<head>', `<head>\n <base href="${BASE_URL}/">\n ` + baseTag);
|
|
3177
3171
|
content = content.replace(/(href|src)="vendor\//g, `$1="${BASE_URL}/vendor/`);
|
|
3178
3172
|
if (watch) {
|
|
3179
3173
|
content += `\n<script>(function(){const ws=new WebSocket((location.protocol==='https:'?'wss://':'ws://')+location.host+'${BASE_URL}/hot-reload');ws.onmessage=e=>{if(JSON.parse(e.data).type==='reload')location.reload()};})();</script>`;
|
package/static/js/client.js
CHANGED
|
@@ -1260,7 +1260,7 @@ class AgentGUIClient {
|
|
|
1260
1260
|
const prompt = this.ui.messageInput?.value || '';
|
|
1261
1261
|
const conv = this.state.currentConversation;
|
|
1262
1262
|
const isNewConversation = conv && !conv.messageCount && !this.state.streamingConversations.has(conv.id);
|
|
1263
|
-
const agentId = (isNewConversation ? this.getCurrentAgent() : null) || conv?.agentType || this.getCurrentAgent()
|
|
1263
|
+
const agentId = (isNewConversation ? this.getCurrentAgent() : null) || conv?.agentType || this.getCurrentAgent();
|
|
1264
1264
|
const model = this.ui.modelSelector?.value || null;
|
|
1265
1265
|
|
|
1266
1266
|
if (!prompt.trim()) {
|
|
@@ -1970,7 +1970,7 @@ class AgentGUIClient {
|
|
|
1970
1970
|
* Consolidates duplicate logic for cached and fresh conversation loads
|
|
1971
1971
|
*/
|
|
1972
1972
|
applyAgentAndModelSelection(conversation, hasActivity) {
|
|
1973
|
-
const agentId = conversation.agentId || conversation.agentType ||
|
|
1973
|
+
const agentId = conversation.agentId || conversation.agentType || null;
|
|
1974
1974
|
const model = conversation.model || null;
|
|
1975
1975
|
|
|
1976
1976
|
if (hasActivity) {
|
|
@@ -1980,7 +1980,8 @@ class AgentGUIClient {
|
|
|
1980
1980
|
this.unlockAgentAndModel();
|
|
1981
1981
|
this._setCliSelectorToAgent(agentId);
|
|
1982
1982
|
|
|
1983
|
-
this.
|
|
1983
|
+
const effectiveAgentId = agentId || this.getEffectiveAgentId();
|
|
1984
|
+
this.loadModelsForAgent(effectiveAgentId).then(() => {
|
|
1984
1985
|
if (model && this.ui.modelSelector) {
|
|
1985
1986
|
this.ui.modelSelector.value = model;
|
|
1986
1987
|
}
|
|
@@ -2185,7 +2186,7 @@ class AgentGUIClient {
|
|
|
2185
2186
|
*/
|
|
2186
2187
|
async createNewConversation(workingDirectory, title) {
|
|
2187
2188
|
try {
|
|
2188
|
-
const agentId = this.
|
|
2189
|
+
const agentId = this.getEffectiveAgentId();
|
|
2189
2190
|
const model = this.ui.modelSelector?.value || null;
|
|
2190
2191
|
const convTitle = title || 'New Conversation';
|
|
2191
2192
|
const body = { agentId, title: convTitle };
|
|
@@ -2461,7 +2462,7 @@ class AgentGUIClient {
|
|
|
2461
2462
|
this.state.currentSession = {
|
|
2462
2463
|
id: latestSession.id,
|
|
2463
2464
|
conversationId: conversationId,
|
|
2464
|
-
agentId: conversation.agentType ||
|
|
2465
|
+
agentId: conversation.agentType || null,
|
|
2465
2466
|
startTime: latestSession.created_at
|
|
2466
2467
|
};
|
|
2467
2468
|
|
|
@@ -2564,13 +2565,21 @@ class AgentGUIClient {
|
|
|
2564
2565
|
if (this.ui.agentSelector?.value && this.ui.agentSelector.style.display !== 'none') {
|
|
2565
2566
|
return this.ui.agentSelector.value;
|
|
2566
2567
|
}
|
|
2567
|
-
return this.ui.cliSelector?.value ||
|
|
2568
|
+
return this.ui.cliSelector?.value || null;
|
|
2568
2569
|
}
|
|
2569
2570
|
|
|
2570
2571
|
getCurrentAgent() {
|
|
2571
2572
|
return this.getEffectiveAgentId();
|
|
2572
2573
|
}
|
|
2573
2574
|
|
|
2575
|
+
saveAgentAndModelToConversation() {
|
|
2576
|
+
const convId = this.state.currentConversation;
|
|
2577
|
+
if (!convId || this._agentLocked) return;
|
|
2578
|
+
const agentId = this.getEffectiveAgentId();
|
|
2579
|
+
const model = this.getCurrentModel();
|
|
2580
|
+
window.wsClient.rpc('conv.upd', { id: convId, agentType: agentId, model: model || undefined }).catch(() => {});
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2574
2583
|
/**
|
|
2575
2584
|
* Get current selected model
|
|
2576
2585
|
*/
|