Skip to content

Commit 6a5ba9b

Browse files
committed
Add Hermes request timeout setting
1 parent d5e2bbe commit 6a5ba9b

6 files changed

Lines changed: 282 additions & 15 deletions

File tree

Plugins/Plugin_market/hermes/main.js

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
const DEFAULT_BASE_URL = 'http://127.0.0.1:8642/v1';
1515
const DEFAULT_MODEL = 'hermes-agent';
1616
const DEFAULT_API_MODE = 'chat_completions';
17+
const DEFAULT_REQUEST_TIMEOUT_SECONDS = 600;
18+
const MIN_REQUEST_TIMEOUT_SECONDS = 30;
19+
const MAX_REQUEST_TIMEOUT_SECONDS = 3600;
1720
const REMOTE_URLS_MAX_LENGTH = 4000;
1821
const REMOTE_URL_MAX_LENGTH = 300;
1922
const REMOTE_STATUS_DEBOUNCE_MS = 300;
@@ -81,6 +84,8 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
8184
apiModeChat: 'Chat Completions',
8285
apiModeRuns: 'Runs',
8386
apiModeHint: 'Runs shows Hermes tool events and approval controls in the ChatRaw chat UI.',
87+
requestTimeout: 'Request timeout (seconds)',
88+
requestTimeoutHint: 'Applies to Hermes chat generation and run event streams. Use a larger value for long tool chains; health checks, approval, and stop stay short.',
8489
apiKey: 'API Server Key (if required)',
8590
apiKeyHint: 'Stored by ChatRaw backend. Official Hermes requires API_SERVER_KEY; leave empty only for compatible servers that do not require auth.',
8691
apiKeySaved: 'API key saved',
@@ -113,6 +118,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
113118
settingsHelpRemoteTitle: 'Remote Base URL access',
114119
settingsHelpModelTitle: 'Model name',
115120
settingsHelpModeTitle: 'Execution mode',
121+
settingsHelpTimeoutTitle: 'Request timeout',
116122
settingsHelpApiKeyTitle: 'API Server Key',
117123
settingsHelpSessionKeyTitle: 'Session Key'
118124
},
@@ -168,6 +174,8 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
168174
apiModeChat: 'Chat Completions',
169175
apiModeRuns: 'Runs',
170176
apiModeHint: 'Runs 会在 ChatRaw 聊天 UI 中显示 Hermes 工具事件和审批控件。',
177+
requestTimeout: '请求超时时间(秒)',
178+
requestTimeoutHint: '只作用于 Hermes 聊天生成和 Run 事件流等待。复杂工具链可调大;检查、审批和停止仍保持短超时。',
171179
apiKey: 'API Server Key(如服务要求)',
172180
apiKeyHint: '由 ChatRaw 后端保存。官方 Hermes 需要 API_SERVER_KEY;仅无鉴权兼容服务可留空。',
173181
apiKeySaved: 'API key 已保存',
@@ -200,6 +208,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
200208
settingsHelpRemoteTitle: '远程 Base URL 放行',
201209
settingsHelpModelTitle: '模型名称',
202210
settingsHelpModeTitle: '执行模式',
211+
settingsHelpTimeoutTitle: '请求超时时间',
203212
settingsHelpApiKeyTitle: 'API Server Key',
204213
settingsHelpSessionKeyTitle: 'Session Key'
205214
}
@@ -210,6 +219,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
210219
baseUrl: DEFAULT_BASE_URL,
211220
model: DEFAULT_MODEL,
212221
apiMode: DEFAULT_API_MODE,
222+
requestTimeoutSeconds: DEFAULT_REQUEST_TIMEOUT_SECONDS,
213223
allowedRemoteBaseUrls: '',
214224
remoteBaseUrlWarningAccepted: false,
215225
remoteBaseUrlWarningAcceptedFor: ''
@@ -308,6 +318,14 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
308318
ChatRaw.utils?.showToast?.(active ? t('enabled') : t('disabled'), active ? 'success' : '');
309319
}
310320

321+
function normalizeRequestTimeoutSeconds(value) {
322+
const parsed = Number.parseInt(String(value ?? '').trim(), 10);
323+
if (!Number.isFinite(parsed)) return DEFAULT_REQUEST_TIMEOUT_SECONDS;
324+
if (parsed < MIN_REQUEST_TIMEOUT_SECONDS) return MIN_REQUEST_TIMEOUT_SECONDS;
325+
if (parsed > MAX_REQUEST_TIMEOUT_SECONDS) return MAX_REQUEST_TIMEOUT_SECONDS;
326+
return parsed;
327+
}
328+
311329
async function loadSavedSettings() {
312330
const res = await fetch('/api/plugins');
313331
if (!res.ok) return;
@@ -318,6 +336,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
318336
baseUrl: saved.baseUrl || DEFAULT_BASE_URL,
319337
model: saved.model || DEFAULT_MODEL,
320338
apiMode: saved.apiMode || DEFAULT_API_MODE,
339+
requestTimeoutSeconds: normalizeRequestTimeoutSeconds(saved.requestTimeoutSeconds),
321340
allowedRemoteBaseUrls: saved.allowedRemoteBaseUrls || '',
322341
remoteBaseUrlWarningAccepted: saved.remoteBaseUrlWarningAccepted === true,
323342
remoteBaseUrlWarningAcceptedFor: saved.remoteBaseUrlWarningAcceptedFor || ''
@@ -338,6 +357,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
338357
const baseUrlInput = document.getElementById('hermes-base-url');
339358
const modelInput = document.getElementById('hermes-model');
340359
const apiModeInput = document.getElementById('hermes-api-mode');
360+
const timeoutInput = document.getElementById('hermes-request-timeout');
341361
const allowedRemoteInput = document.getElementById('hermes-allowed-remote-base-urls');
342362
const keyInput = document.getElementById('hermes-api-key');
343363
const sessionKeyInput = document.getElementById('hermes-session-key');
@@ -346,6 +366,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
346366
baseUrl: (baseUrlInput?.value || '').trim() || DEFAULT_BASE_URL,
347367
model: (modelInput?.value || '').trim() || DEFAULT_MODEL,
348368
apiMode,
369+
requestTimeoutSeconds: normalizeRequestTimeoutSeconds(timeoutInput?.value),
349370
allowedRemoteBaseUrls: allowedRemoteInput?.value || '',
350371
apiKey: (keyInput?.value || '').trim(),
351372
sessionKey: (sessionKeyInput?.value || '').trim()
@@ -372,6 +393,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
372393
baseUrl: normalized.baseUrl,
373394
model: next.model,
374395
apiMode: next.apiMode,
396+
requestTimeoutSeconds: next.requestTimeoutSeconds,
375397
allowedRemoteBaseUrls: canonicalAllowed,
376398
remoteBaseUrlWarningAccepted: remoteAccepted,
377399
remoteBaseUrlWarningAcceptedFor: remoteAccepted ? canonicalAllowed : ''
@@ -719,7 +741,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
719741
items: [
720742
'这是 ChatRaw 后端要连接的 Hermes API Server 根地址,应填到 /v1 层,不要填到 /chat/completions、/models 或 /runs。',
721743
'少写 /v1 时,健康检查会访问 /models,官方 Hermes 通常会返回 404。',
722-
'如果出现 timeout,通常表示 ChatRaw 后端连不上这个 IP 或端口。'
744+
'如果检查时出现 timeout,通常表示 ChatRaw 后端连不上这个 IP 或端口。'
723745
]
724746
},
725747
{
@@ -747,6 +769,14 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
747769
'批准的是 Hermes API Server 所在机器和 Hermes 配置环境中的工具/命令执行;ChatRaw 不会自动批准工具调用。'
748770
]
749771
},
772+
{
773+
title: t('settingsHelpTimeoutTitle'),
774+
items: [
775+
'这个时间只用于等待 Hermes 聊天生成和 Runs 事件流,不会拉长检查、审批或停止请求。',
776+
'复杂问题、工具链或 SSH 任务可能需要更久;建议开启流式输出,并按需调大到 600 秒以上。',
777+
'如果是保存后点击检查就 timeout,优先排查 Base URL、Docker 网络和 Hermes 是否在监听。'
778+
]
779+
},
750780
{
751781
title: t('settingsHelpApiKeyTitle'),
752782
items: [
@@ -780,7 +810,7 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
780810
items: [
781811
'This is the Hermes API Server root URL used by the ChatRaw backend. It should point to /v1, not /chat/completions, /models, or /runs.',
782812
'If /v1 is missing, the health check calls /models and official Hermes will usually return 404.',
783-
'A timeout usually means the ChatRaw backend cannot reach that IP address or port.'
813+
'A timeout during Check usually means the ChatRaw backend cannot reach that IP address or port.'
784814
]
785815
},
786816
{
@@ -808,6 +838,14 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
808838
'Approval applies to tool or command execution in the Hermes API Server machine and configuration environment; ChatRaw never auto-approves tool calls.'
809839
]
810840
},
841+
{
842+
title: t('settingsHelpTimeoutTitle'),
843+
items: [
844+
'This timeout only applies while waiting for Hermes chat generation and Runs event streams. Health checks, approval, and stop requests stay short.',
845+
'Complex prompts, tool chains, or SSH work may need longer waits. Prefer Stream Output and increase this value above 600 seconds when needed.',
846+
'If Check times out right after saving, troubleshoot the Base URL, Docker networking, and whether Hermes is listening first.'
847+
]
848+
},
811849
{
812850
title: t('settingsHelpApiKeyTitle'),
813851
items: [
@@ -915,6 +953,11 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
915953
</div>
916954
<span style="color:var(--text-secondary); font-size:0.82rem;">${escapeHtml(t('apiModeHint'))}</span>
917955
</label>
956+
<label style="display:grid; gap:8px;">
957+
<span style="font-weight:500;">${escapeHtml(t('requestTimeout'))}</span>
958+
<input id="hermes-request-timeout" type="number" min="${MIN_REQUEST_TIMEOUT_SECONDS}" max="${MAX_REQUEST_TIMEOUT_SECONDS}" step="1" class="input-minimal" style="width:100%; padding:10px 12px; border:1px solid var(--border-color); border-radius:var(--radius-sm); background:var(--bg-primary);">
959+
<span style="color:var(--text-secondary); font-size:0.82rem;">${escapeHtml(t('requestTimeoutHint'))}</span>
960+
</label>
918961
</div>
919962
<div style="padding:20px 24px; border-bottom:1px solid var(--border-color); display:grid; gap:12px;">
920963
<label style="display:grid; gap:8px;">
@@ -957,13 +1000,15 @@ After enabling, ChatRaw only allows remote Hermes Base URLs explicitly listed in
9571000
const baseUrlInput = document.getElementById('hermes-base-url');
9581001
const modelInput = document.getElementById('hermes-model');
9591002
const apiModeInput = document.getElementById('hermes-api-mode');
1003+
const timeoutInput = document.getElementById('hermes-request-timeout');
9601004
const allowedRemoteInput = document.getElementById('hermes-allowed-remote-base-urls');
9611005
const keyInput = document.getElementById('hermes-api-key');
9621006
const sessionKeyInput = document.getElementById('hermes-session-key');
9631007
if (baseUrlInput) baseUrlInput.value = settings.baseUrl || DEFAULT_BASE_URL;
9641008
if (allowedRemoteInput) allowedRemoteInput.value = settings.allowedRemoteBaseUrls || '';
9651009
if (modelInput) modelInput.value = settings.model || DEFAULT_MODEL;
9661010
if (apiModeInput) apiModeInput.value = settings.apiMode === 'runs' ? 'runs' : DEFAULT_API_MODE;
1011+
if (timeoutInput) timeoutInput.value = normalizeRequestTimeoutSeconds(settings.requestTimeoutSeconds);
9671012
if (keyInput) keyInput.placeholder = maskedApiKey ? t('apiKeyPlaceholder') : '';
9681013
if (sessionKeyInput) sessionKeyInput.placeholder = maskedSessionKey ? t('sessionKeyPlaceholder') : '';
9691014
updateApiKeyStatus();

Plugins/Plugin_market/hermes/manifest.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "hermes",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"name": {
55
"en": "Hermes Router",
66
"zh": "Hermes 路由"
@@ -59,6 +59,17 @@
5959
}
6060
}
6161
]
62+
},
63+
{
64+
"id": "requestTimeoutSeconds",
65+
"type": "number",
66+
"label": {
67+
"en": "Request timeout (seconds)",
68+
"zh": "请求超时时间(秒)"
69+
},
70+
"default": 600,
71+
"min": 30,
72+
"max": 3600
6273
}
6374
],
6475
"proxy": [

0 commit comments

Comments
 (0)