agentgui 1.0.505 → 1.0.507
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 +1 -1
- package/server.js +70 -2
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -268,7 +268,22 @@ function pushTTSAudio(cacheKey, wav, conversationId, sessionId, voiceId) {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
|
|
271
|
-
const
|
|
271
|
+
const VOICE_INSTRUCTIONS = `Plain text. Spoken aloud. Conversational. No markdown, formatting, bullets, or lists. Short sentences. Technical facts only.`;
|
|
272
|
+
|
|
273
|
+
function buildSystemPrompt(agentId, model, subAgent) {
|
|
274
|
+
const parts = [VOICE_INSTRUCTIONS];
|
|
275
|
+
if (agentId && agentId !== 'claude-code') {
|
|
276
|
+
const displayAgentId = agentId.split('-·-')[0];
|
|
277
|
+
parts.push(`Use ${displayAgentId} subagent for all tasks.`);
|
|
278
|
+
}
|
|
279
|
+
if (model) {
|
|
280
|
+
parts.push(`Model: ${model}.`);
|
|
281
|
+
}
|
|
282
|
+
if (subAgent) {
|
|
283
|
+
parts.push(`Subagent: ${subAgent}.`);
|
|
284
|
+
}
|
|
285
|
+
return parts.join(' ');
|
|
286
|
+
}
|
|
272
287
|
|
|
273
288
|
const activeExecutions = new Map();
|
|
274
289
|
const activeScripts = new Map();
|
|
@@ -1829,11 +1844,27 @@ const server = http.createServer(async (req, res) => {
|
|
|
1829
1844
|
}
|
|
1830
1845
|
queries.updateToolStatus(toolId, { status: 'installing' });
|
|
1831
1846
|
sendJSON(req, res, 200, { success: true, installing: true, estimatedTime: 60000 });
|
|
1847
|
+
|
|
1848
|
+
let installCompleted = false;
|
|
1849
|
+
const installTimeout = setTimeout(() => {
|
|
1850
|
+
if (!installCompleted) {
|
|
1851
|
+
installCompleted = true;
|
|
1852
|
+
queries.updateToolStatus(toolId, { status: 'failed', error_message: 'Install timeout after 6 minutes' });
|
|
1853
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1854
|
+
wsOptimizer.broadcast({ type: 'tool_install_failed', toolId, data: { success: false, error: 'Install timeout after 6 minutes' } });
|
|
1855
|
+
}
|
|
1856
|
+
queries.addToolInstallHistory(toolId, 'install', 'failed', 'Install timeout after 6 minutes');
|
|
1857
|
+
}
|
|
1858
|
+
}, 360000);
|
|
1859
|
+
|
|
1832
1860
|
toolManager.install(toolId, (msg) => {
|
|
1833
1861
|
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1834
1862
|
wsOptimizer.broadcast({ type: 'tool_install_progress', toolId, data: msg });
|
|
1835
1863
|
}
|
|
1836
1864
|
}).then((result) => {
|
|
1865
|
+
clearTimeout(installTimeout);
|
|
1866
|
+
if (installCompleted) return;
|
|
1867
|
+
installCompleted = true;
|
|
1837
1868
|
if (result.success) {
|
|
1838
1869
|
queries.updateToolStatus(toolId, { status: 'installed', version: result.version, installed_at: Date.now() });
|
|
1839
1870
|
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
@@ -1847,6 +1878,16 @@ const server = http.createServer(async (req, res) => {
|
|
|
1847
1878
|
}
|
|
1848
1879
|
queries.addToolInstallHistory(toolId, 'install', 'failed', result.error);
|
|
1849
1880
|
}
|
|
1881
|
+
}).catch((err) => {
|
|
1882
|
+
clearTimeout(installTimeout);
|
|
1883
|
+
if (installCompleted) return;
|
|
1884
|
+
installCompleted = true;
|
|
1885
|
+
const error = err?.message || 'Unknown error';
|
|
1886
|
+
queries.updateToolStatus(toolId, { status: 'failed', error_message: error });
|
|
1887
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1888
|
+
wsOptimizer.broadcast({ type: 'tool_install_failed', toolId, data: { success: false, error } });
|
|
1889
|
+
}
|
|
1890
|
+
queries.addToolInstallHistory(toolId, 'install', 'failed', error);
|
|
1850
1891
|
});
|
|
1851
1892
|
return;
|
|
1852
1893
|
}
|
|
@@ -1866,11 +1907,27 @@ const server = http.createServer(async (req, res) => {
|
|
|
1866
1907
|
}
|
|
1867
1908
|
queries.updateToolStatus(toolId, { status: 'updating' });
|
|
1868
1909
|
sendJSON(req, res, 200, { success: true, updating: true });
|
|
1910
|
+
|
|
1911
|
+
let updateCompleted = false;
|
|
1912
|
+
const updateTimeout = setTimeout(() => {
|
|
1913
|
+
if (!updateCompleted) {
|
|
1914
|
+
updateCompleted = true;
|
|
1915
|
+
queries.updateToolStatus(toolId, { status: 'failed', error_message: 'Update timeout after 6 minutes' });
|
|
1916
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1917
|
+
wsOptimizer.broadcast({ type: 'tool_update_failed', toolId, data: { success: false, error: 'Update timeout after 6 minutes' } });
|
|
1918
|
+
}
|
|
1919
|
+
queries.addToolInstallHistory(toolId, 'update', 'failed', 'Update timeout after 6 minutes');
|
|
1920
|
+
}
|
|
1921
|
+
}, 360000);
|
|
1922
|
+
|
|
1869
1923
|
toolManager.update(toolId, body.targetVersion, (msg) => {
|
|
1870
1924
|
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1871
1925
|
wsOptimizer.broadcast({ type: 'tool_update_progress', toolId, data: msg });
|
|
1872
1926
|
}
|
|
1873
1927
|
}).then((result) => {
|
|
1928
|
+
clearTimeout(updateTimeout);
|
|
1929
|
+
if (updateCompleted) return;
|
|
1930
|
+
updateCompleted = true;
|
|
1874
1931
|
if (result.success) {
|
|
1875
1932
|
queries.updateToolStatus(toolId, { status: 'installed', version: result.version, installed_at: Date.now() });
|
|
1876
1933
|
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
@@ -1884,6 +1941,16 @@ const server = http.createServer(async (req, res) => {
|
|
|
1884
1941
|
}
|
|
1885
1942
|
queries.addToolInstallHistory(toolId, 'update', 'failed', result.error);
|
|
1886
1943
|
}
|
|
1944
|
+
}).catch((err) => {
|
|
1945
|
+
clearTimeout(updateTimeout);
|
|
1946
|
+
if (updateCompleted) return;
|
|
1947
|
+
updateCompleted = true;
|
|
1948
|
+
const error = err?.message || 'Unknown error';
|
|
1949
|
+
queries.updateToolStatus(toolId, { status: 'failed', error_message: error });
|
|
1950
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1951
|
+
wsOptimizer.broadcast({ type: 'tool_update_failed', toolId, data: { success: false, error } });
|
|
1952
|
+
}
|
|
1953
|
+
queries.addToolInstallHistory(toolId, 'update', 'failed', error);
|
|
1887
1954
|
});
|
|
1888
1955
|
return;
|
|
1889
1956
|
}
|
|
@@ -3728,13 +3795,14 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
|
|
|
3728
3795
|
|
|
3729
3796
|
const resolvedModel = model || conv?.model || null;
|
|
3730
3797
|
const resolvedSubAgent = subAgent || conv?.subAgent || null;
|
|
3798
|
+
const unifiedSystemPrompt = buildSystemPrompt(agentId, resolvedModel, resolvedSubAgent);
|
|
3731
3799
|
const config = {
|
|
3732
3800
|
verbose: true,
|
|
3733
3801
|
outputFormat: 'stream-json',
|
|
3734
3802
|
timeout: 1800000,
|
|
3735
3803
|
print: true,
|
|
3736
3804
|
resumeSessionId,
|
|
3737
|
-
systemPrompt:
|
|
3805
|
+
systemPrompt: unifiedSystemPrompt,
|
|
3738
3806
|
model: resolvedModel || undefined,
|
|
3739
3807
|
subAgent: resolvedSubAgent || undefined,
|
|
3740
3808
|
onEvent,
|