@goodandready/dsh-agent-loop-guard 0.2.29 → 0.3.1
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/CHANGELOG.md +19 -0
- package/README.md +6 -1
- package/README.ru.md +6 -1
- package/README.zh.md +6 -1
- package/lib/client.js +242 -237
- package/lib/guard-helpers.js +594 -264
- package/lib/guard-state.js +135 -88
- package/lib/index.js +9 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -19,172 +19,190 @@ window.__ModuleLoader__.load({
|
|
|
19
19
|
} catch (err) {
|
|
20
20
|
console.warn?.('[dsh-agent-loop-guard] primitives unavailable, using SVG fallback:', err?.message || String(err));
|
|
21
21
|
}
|
|
22
|
-
const CSS_STYLES = `
|
|
23
|
-
.alg-page { width: 100%; min-width: 0; }
|
|
24
|
-
.alg-card {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
.alg-
|
|
30
|
-
.alg-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
.alg-
|
|
37
|
-
.alg-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
.alg-
|
|
43
|
-
.alg-
|
|
44
|
-
.alg-
|
|
45
|
-
.alg-
|
|
46
|
-
.alg-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
background: var(--dsw-alias-brand-primary); color: var(--dsw-alias-label-primary-inverted, var(--dsw-alias-bg-layer-3));
|
|
61
|
-
transition: opacity 0.15s ease;
|
|
62
|
-
}
|
|
63
|
-
.alg-btn-primary:hover:not(:disabled) { opacity: 0.9; }
|
|
64
|
-
.alg-btn-primary:disabled { opacity: 0.5; cursor: default; }
|
|
65
|
-
.alg-btn-updater {
|
|
66
|
-
appearance: none; font: inherit; cursor: pointer; border: 0; border-radius: 6px;
|
|
67
|
-
padding: 4px 10px; font-size: 12px; font-weight: 500;
|
|
68
|
-
background: var(--dsw-alias-brand-primary); color: var(--dsw-alias-label-primary-inverted, var(--dsw-alias-bg-layer-3));
|
|
69
|
-
transition: opacity 0.15s ease;
|
|
70
|
-
}
|
|
71
|
-
.alg-btn-updater:hover:not(:disabled) { opacity: 0.9; }
|
|
72
|
-
.alg-btn-updater:disabled { opacity: 0.6; cursor: default; }
|
|
73
|
-
.alg-btn-ghost {
|
|
74
|
-
background: transparent; border: 1px solid var(--dsw-alias-border-l2);
|
|
75
|
-
color: var(--dsw-alias-label-tertiary); border-radius: 4px; padding: 2px 8px;
|
|
76
|
-
font-size: 11px; cursor: pointer; transition: color 0.15s ease, border-color 0.15s ease;
|
|
77
|
-
}
|
|
78
|
-
.alg-btn-ghost:hover {
|
|
79
|
-
color: var(--dsw-alias-label-primary);
|
|
80
|
-
border-color: var(--dsw-alias-label-secondary);
|
|
81
|
-
}
|
|
82
|
-
`;
|
|
83
|
-
|
|
84
|
-
if (typeof document !== 'undefined') {
|
|
85
|
-
const styleId = 'dsh-agent-loop-guard-styles';
|
|
86
|
-
if (!document.getElementById(styleId)) {
|
|
87
|
-
const style = document.createElement('style');
|
|
88
|
-
style.id = styleId;
|
|
89
|
-
style.setAttribute('data-dsh-plugin', '@goodandready/dsh-agent-loop-guard');
|
|
90
|
-
style.textContent = CSS_STYLES;
|
|
91
|
-
document.head.appendChild(style);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
22
|
+
const CSS_STYLES = `
|
|
23
|
+
.alg-page { width: 100%; min-width: 0; }
|
|
24
|
+
.alg-card { border: 1px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-3); border-radius: 12px; list-style: none; margin-bottom: 12px; overflow: hidden; transition: border-color 0.15s ease; }
|
|
25
|
+
.alg-card:hover { border-color: var(--dsw-alias-border-l1, var(--dsw-alias-border-l2)); }
|
|
26
|
+
.alg-header-btn { appearance: none; width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer; background: transparent; border: 0; border-radius: 12px; display: flex; align-items: center; gap: 12px; padding: 14px 16px; transition: background 0.15s ease; }
|
|
27
|
+
.alg-header-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
28
|
+
.alg-chevron { margin-left: auto; color: var(--dsw-alias-label-tertiary); display: flex; align-items: center; justify-content: center; transition: transform 0.2s ease; }
|
|
29
|
+
.alg-chevron.expanded { transform: rotate(180deg); }
|
|
30
|
+
.alg-body { padding: 0 16px 16px; border-top: 1px solid var(--dsw-alias-border-l2); }
|
|
31
|
+
.alg-field { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
|
|
32
|
+
.alg-field label { font-size: 13px; color: var(--dsw-alias-label-secondary); cursor: pointer; }
|
|
33
|
+
.alg-input { height: 34px; border: 1px solid var(--dsw-alias-border-l2); background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); border-radius: 8px; padding: 0 12px; font-size: 13px; outline: none; transition: border-color 0.15s ease; }
|
|
34
|
+
.alg-input:focus { border-color: var(--dsw-alias-brand-primary); }
|
|
35
|
+
.alg-checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dsw-alias-label-primary); cursor: pointer; padding: 5px 0; }
|
|
36
|
+
.alg-btn-primary { appearance: none; font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 6px 16px; font-size: 13px; font-weight: 500; background: var(--dsw-alias-brand-primary); color: var(--dsw-alias-label-primary-inverted, var(--dsw-alias-bg-layer-3)); transition: opacity 0.15s ease; }
|
|
37
|
+
.alg-btn-primary:hover:not(:disabled) { opacity: 0.9; }
|
|
38
|
+
.alg-btn-primary:disabled { opacity: 0.5; cursor: default; }
|
|
39
|
+
.alg-btn-updater { appearance: none; font: inherit; cursor: pointer; border: 0; border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 500; background: var(--dsw-alias-brand-primary); color: var(--dsw-alias-label-primary-inverted, var(--dsw-alias-bg-layer-3)); transition: opacity 0.15s ease; }
|
|
40
|
+
.alg-btn-updater:hover:not(:disabled) { opacity: 0.9; }
|
|
41
|
+
.alg-btn-updater:disabled { opacity: 0.6; cursor: default; }
|
|
42
|
+
.alg-btn-ghost { background: transparent; border: 1px solid var(--dsw-alias-border-l2); color: var(--dsw-alias-label-tertiary); border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer; transition: color 0.15s ease, border-color 0.15s ease; }
|
|
43
|
+
.alg-btn-ghost:hover { color: var(--dsw-alias-label-primary); border-color: var(--dsw-alias-label-secondary); }
|
|
44
|
+
.alg-presets { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--dsw-alias-border-l2); margin-bottom: 8px; flex-wrap: wrap; }
|
|
45
|
+
.alg-btn-preset { appearance: none; font: inherit; cursor: pointer; border: 1px solid var(--dsw-alias-border-l2); border-radius: 6px; padding: 3px 10px; font-size: 12px; background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-secondary); transition: all 0.15s ease; }
|
|
46
|
+
.alg-btn-preset:hover { border-color: var(--dsw-alias-brand-primary); color: var(--dsw-alias-label-primary); }
|
|
47
|
+
.alg-incident-row { display: flex; align-items: center; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid color-mix(in srgb, var(--dsw-alias-border-l2) 40%, transparent); font-size: 11px; }
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
if (typeof document !== 'undefined') {
|
|
51
|
+
const styleId = 'dsh-agent-loop-guard-styles';
|
|
52
|
+
if (!document.getElementById(styleId)) {
|
|
53
|
+
const style = document.createElement('style');
|
|
54
|
+
style.id = styleId;
|
|
55
|
+
style.setAttribute('data-dsh-plugin', '@goodandready/dsh-agent-loop-guard');
|
|
56
|
+
style.textContent = CSS_STYLES;
|
|
57
|
+
document.head.appendChild(style);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
94
60
|
const en = {
|
|
95
|
-
title: 'Agent Loop Guard',
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
strictTools: 'Strict tools (comma-separated, lower limit)',
|
|
119
|
-
strictToolLimit: 'Strict tools limit',
|
|
120
|
-
blockExactDuplicates: 'Block exact duplicate tool calls',
|
|
121
|
-
dryRunMode: 'Dry-run / Audit mode (log only, do not reject)',
|
|
122
|
-
assistantOutputGuard: 'Assistant output guard',
|
|
123
|
-
maxRepeatedAssistantLines: 'Max repeated assistant lines',
|
|
124
|
-
maxRepeatedAssistantBlocks: 'Max repeated assistant blocks',
|
|
125
|
-
maxAssistantBlockChars: 'Max assistant block chars',
|
|
126
|
-
progressToolNames: 'Progress tool names (comma-separated)',
|
|
127
|
-
pseudoToolCallThreshold: 'Pseudo tool-call loop threshold (turns, 0 = disabled)',
|
|
128
|
-
oscillationDetection: 'Oscillation loop guard (ping-pong cycles)',
|
|
129
|
-
maxOscillationRepeats: 'Max oscillation repeats (2-4 step cycles)',
|
|
130
|
-
payloadBloatGuard: 'Payload bloat guard (truncate huge outputs)',
|
|
131
|
-
maxToolResultChars: 'Max tool result characters (0 = disabled)',
|
|
132
|
-
saving: 'Saving…',
|
|
133
|
-
ready: 'Save Settings',
|
|
134
|
-
saved: 'Saved',
|
|
61
|
+
title: 'Agent Loop Guard', sub: 'Fail-closed tool-call and assistant-output loop limits', version: 'Version',
|
|
62
|
+
updateChecking: 'Checking updates…', updateAvailable: 'Update available: v{v}', upToDate: 'Up to date',
|
|
63
|
+
updateNow: 'Update Now', updateViaPluginsPage: 'Update in Plugins page', updating: 'Updating…',
|
|
64
|
+
updateSuccess: 'Updated to v{v}. Restart DSH service to apply changes.', updateFailed: 'Update failed: {msg}', checkUpdateFailed: 'Check failed',
|
|
65
|
+
telemetryTitle: 'Protection Telemetry', telemetryLoadFailed: 'Failed to load telemetry', totalBlocked: 'Loops Prevented',
|
|
66
|
+
steeredCount: 'Smart Steers', lastViolation: 'Last Incident', noViolations: 'No loop violations detected in current runtime.',
|
|
67
|
+
resetStats: 'Reset Stats', statsResetDone: 'Stats reset', statsResetFailed: 'Failed to reset stats',
|
|
68
|
+
presetsTitle: 'Presets', presetStrict: 'Strict', presetBalanced: 'Balanced', presetAutonomous: 'Autonomous Coding',
|
|
69
|
+
presetApplied: 'Preset {name} applied to form', copyDump: 'Copy Diagnostic Dump', dumpCopied: 'Diagnostic dump copied to clipboard',
|
|
70
|
+
incidentsTitle: 'Recent Incidents (Post-Mortem)', maxToolAttemptsPerTurn: 'Max tool attempts per turn (0 = disabled)',
|
|
71
|
+
maxProgressToolCallsPerTurn: 'Max progress tool calls per turn', maxCallsPerRepeatGroup: 'Max calls per repeat group',
|
|
72
|
+
strictTools: 'Strict tools (comma-separated, lower limit)', strictToolLimit: 'Strict tools limit',
|
|
73
|
+
blockExactDuplicates: 'Block exact duplicate tool calls', dryRunMode: 'Dry-run / Audit mode (log only, do not reject)',
|
|
74
|
+
assistantOutputGuard: 'Assistant output guard', maxRepeatedAssistantLines: 'Max repeated assistant lines',
|
|
75
|
+
maxRepeatedAssistantBlocks: 'Max repeated assistant blocks', maxAssistantBlockChars: 'Max assistant block chars',
|
|
76
|
+
progressToolNames: 'Progress tool names (comma-separated)', pseudoToolCallThreshold: 'Pseudo tool-call loop threshold (turns, 0 = disabled)',
|
|
77
|
+
oscillationDetection: 'Oscillation loop guard (ping-pong cycles)', maxOscillationRepeats: 'Max oscillation repeats (2-4 step cycles)',
|
|
78
|
+
payloadBloatGuard: 'Payload bloat guard (truncate huge outputs)', maxToolResultChars: 'Max tool result characters (0 = disabled)',
|
|
79
|
+
errorThrashingGuard: 'Error thrashing guard (fail-loop detection)', maxConsecutiveFailures: 'Max consecutive failures before thrashing block',
|
|
80
|
+
adaptiveSteering: 'Smart steering (guide agent before hard cancel)', targetQuotaGuard: 'Target quota guard (per-file loop protection)',
|
|
81
|
+
maxUnchangedReadsPerTarget: 'Max unchanged reads per target file', maxReadsPerTarget: 'Max reads per target file per turn',
|
|
82
|
+
maxEditsPerTarget: 'Max edits/writes per target file per turn', maxTargetAttempts: 'Max total operations per target file per turn',
|
|
83
|
+
saving: 'Saving…', ready: 'Save Settings', saved: 'Saved',
|
|
135
84
|
};
|
|
136
85
|
|
|
137
|
-
const
|
|
138
|
-
title: 'Agent Loop Guard',
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
strictTools: '严格限制工具(逗号分隔,触发更低阈值)',
|
|
162
|
-
strictToolLimit: '严格工具调用上限',
|
|
163
|
-
blockExactDuplicates: '立即拦截完全相同的重复工具调用',
|
|
164
|
-
dryRunMode: '审计模拟模式(仅记录日志,不实际拦截)',
|
|
165
|
-
assistantOutputGuard: '助手文本输出防循环守卫',
|
|
166
|
-
maxRepeatedAssistantLines: '最大单行重复次数',
|
|
167
|
-
maxRepeatedAssistantBlocks: '最大段落重复次数',
|
|
168
|
-
maxAssistantBlockChars: '最大段落判定字符数',
|
|
169
|
-
progressToolNames: '进度标记工具(逗号分隔)',
|
|
170
|
-
pseudoToolCallThreshold: '伪工具调用空转拦截阈值(连续回合数,0 表示禁用)',
|
|
171
|
-
oscillationDetection: '交替循环拦截(乒乓震荡检测)',
|
|
172
|
-
maxOscillationRepeats: '最大交替循环重复次数(2-4 步序列)',
|
|
173
|
-
payloadBloatGuard: '超大结果防膨胀拦截(截断巨大输出)',
|
|
174
|
-
maxToolResultChars: '工具结果字符上限(0 表示禁用)',
|
|
175
|
-
saving: '正在保存…',
|
|
176
|
-
ready: '保存配置',
|
|
177
|
-
saved: '配置已保存',
|
|
86
|
+
const ru = {
|
|
87
|
+
title: 'Agent Loop Guard', sub: 'Защита от бесконечных циклов инструментов и вывода ассистента', version: 'Версия',
|
|
88
|
+
updateChecking: 'Проверка обновлений…', updateAvailable: 'Доступно обновление: v{v}', upToDate: 'Установлена актуальная версия',
|
|
89
|
+
updateNow: 'Обновить сейчас', updateViaPluginsPage: 'Обновите на вкладке плагинов', updating: 'Обновление…',
|
|
90
|
+
updateSuccess: 'Обновлено до v{v}. Перезапустите службу DSH для применения.', updateFailed: 'Ошибка обновления: {msg}', checkUpdateFailed: 'Не удалось проверить',
|
|
91
|
+
telemetryTitle: 'Телеметрия защиты', telemetryLoadFailed: 'Не удалось загрузить телеметрию', totalBlocked: 'Предотвращено циклов',
|
|
92
|
+
steeredCount: 'Упреждающих подсказок', lastViolation: 'Последний инцидент', noViolations: 'В текущем сеансе циклов не зафиксировано.',
|
|
93
|
+
resetStats: 'Сбросить статистику', statsResetDone: 'Статистика сброшена', statsResetFailed: 'Не удалось сбросить статистику',
|
|
94
|
+
presetsTitle: 'Профили', presetStrict: 'Строгий', presetBalanced: 'Баланс', presetAutonomous: 'Автономный код',
|
|
95
|
+
presetApplied: 'Применен профиль {name}', copyDump: 'Скопировать дамп диагностики', dumpCopied: 'Дамп скопирован в буфер',
|
|
96
|
+
incidentsTitle: 'Журнал инцидентов (Post-Mortem)', maxToolAttemptsPerTurn: 'Макс. попыток инструментов за ход (0 = выкл)',
|
|
97
|
+
maxProgressToolCallsPerTurn: 'Макс. вызовов инструментов прогресса за ход', maxCallsPerRepeatGroup: 'Макс. повторов в группе',
|
|
98
|
+
strictTools: 'Строгие инструменты (через запятую)', strictToolLimit: 'Лимит строгих инструментов',
|
|
99
|
+
blockExactDuplicates: 'Блокировать точные дубликаты вызовов', dryRunMode: 'Режим аудита (логировать, но не блокировать)',
|
|
100
|
+
assistantOutputGuard: 'Защита от циклов текста ассистента', maxRepeatedAssistantLines: 'Макс. повторов одной строки',
|
|
101
|
+
maxRepeatedAssistantBlocks: 'Макс. повторов блока текста', maxAssistantBlockChars: 'Макс. размер блока текста для проверки',
|
|
102
|
+
progressToolNames: 'Инструменты прогресса (через запятую)', pseudoToolCallThreshold: 'Порог циклов псевдовызовов (ходов, 0 = выкл)',
|
|
103
|
+
oscillationDetection: 'Защита от осцилляций (циклов туда-сюда)', maxOscillationRepeats: 'Макс. повторов цикла осцилляции',
|
|
104
|
+
payloadBloatGuard: 'Защита от раздувания результатов (обрезка)', maxToolResultChars: 'Макс. символов результата (0 = выкл)',
|
|
105
|
+
errorThrashingGuard: 'Защита от серий ошибок инструментов', maxConsecutiveFailures: 'Порог серии ошибок перед блокировкой',
|
|
106
|
+
adaptiveSteering: 'Умное наставление (предупреждать перед отменой)', targetQuotaGuard: 'Квоты обращений к файлам (защита от циклов по целям)',
|
|
107
|
+
maxUnchangedReadsPerTarget: 'Макс. повторных чтений неизмененного файла', maxReadsPerTarget: 'Макс. чтений одного файла за ход',
|
|
108
|
+
maxEditsPerTarget: 'Макс. правок одного файла за ход', maxTargetAttempts: 'Макс. всего операций над файлом за ход',
|
|
109
|
+
saving: 'Сохранение…', ready: 'Сохранить настройки', saved: 'Сохранено',
|
|
178
110
|
};
|
|
179
111
|
|
|
112
|
+
const zh = {
|
|
113
|
+
title: 'Agent Loop Guard', sub: '工具调用与助手输出防死循环熔断限制', version: '版本',
|
|
114
|
+
updateChecking: '正在检查更新…', updateAvailable: '发现新版本: v{v}', upToDate: '已是最新版本',
|
|
115
|
+
updateNow: '立即更新', updateViaPluginsPage: '请在插件页面更新', updating: '正在更新…',
|
|
116
|
+
updateSuccess: '已更新至 v{v}。请重启 DSH 服务以生效变更。', updateFailed: '更新失败: {msg}', checkUpdateFailed: '检查更新失败',
|
|
117
|
+
telemetryTitle: '防护运行遥测', telemetryLoadFailed: '获取遥测数据失败', totalBlocked: '已拦截死循环',
|
|
118
|
+
steeredCount: '自纠正引导次数', lastViolation: '最近拦截事件', noViolations: '当前运行时未检测到死循环违规。',
|
|
119
|
+
resetStats: '重置统计', statsResetDone: '统计已重置', statsResetFailed: '重置统计失败',
|
|
120
|
+
presetsTitle: '灵敏度预设', presetStrict: '严格', presetBalanced: '平衡', presetAutonomous: '自主编程',
|
|
121
|
+
presetApplied: '已应用预设: {name}', copyDump: '复制诊断数据', dumpCopied: '诊断数据已复制到剪贴板',
|
|
122
|
+
incidentsTitle: '最近拦截事件日志 (Post-Mortem)', maxToolAttemptsPerTurn: '单回合最大工具尝试次数(0 表示禁用)',
|
|
123
|
+
maxProgressToolCallsPerTurn: '单回合最大进度工具调用次数', maxCallsPerRepeatGroup: '同组工具最大重复调用次数',
|
|
124
|
+
strictTools: '严格限制工具(逗号分隔,触发更低阈值)', strictToolLimit: '严格工具调用上限',
|
|
125
|
+
blockExactDuplicates: '立即拦截完全相同的重复工具调用', dryRunMode: '审计模拟模式(仅记录日志,不实际拦截)',
|
|
126
|
+
assistantOutputGuard: '助手文本输出防循环守卫', maxRepeatedAssistantLines: '最大单行重复次数',
|
|
127
|
+
maxRepeatedAssistantBlocks: '最大段落重复次数', maxAssistantBlockChars: '最大段落判定字符数',
|
|
128
|
+
progressToolNames: '进度标记工具(逗号分隔)', pseudoToolCallThreshold: '伪工具调用空转拦截阈值(连续回合数,0 表示禁用)',
|
|
129
|
+
oscillationDetection: '交替循环拦截(乒乓震荡检测)', maxOscillationRepeats: '最大交替循环重复次数(2-4 步序列)',
|
|
130
|
+
payloadBloatGuard: '超大结果防膨胀拦截(截断巨大输出)', maxToolResultChars: '工具结果字符上限(0 表示禁用)',
|
|
131
|
+
errorThrashingGuard: '工具重复报错拦截(错误循环保护)', maxConsecutiveFailures: '连续报错熔断阈值',
|
|
132
|
+
adaptiveSteering: '智能自纠正(熔断前引导修正)', targetQuotaGuard: '目标配额守卫(单文件/目标防死循环)',
|
|
133
|
+
maxUnchangedReadsPerTarget: '单文件无变化最大重复读取次数', maxReadsPerTarget: '单文件最大读取次数',
|
|
134
|
+
maxEditsPerTarget: '单文件最大修改次数', maxTargetAttempts: '单文件总操作次数上限',
|
|
135
|
+
saving: '正在保存…', ready: '保存配置', saved: '配置已保存',
|
|
136
|
+
};
|
|
180
137
|
const DEFAULTS = {
|
|
181
138
|
maxToolAttemptsPerTurn: 64, maxProgressToolCallsPerTurn: 16, progressToolNames: ['todo_write'],
|
|
182
139
|
maxCallsPerRepeatGroup: 5, strictTools: [], strictToolLimit: 3, blockExactDuplicates: true,
|
|
183
140
|
dryRunMode: false, assistantOutputGuard: true, maxRepeatedAssistantLines: 5,
|
|
184
141
|
maxRepeatedAssistantBlocks: 5, maxAssistantBlockChars: 16384, pseudoToolCallThreshold: 3,
|
|
185
142
|
oscillationDetection: true, maxOscillationRepeats: 3, payloadBloatGuard: true, maxToolResultChars: 65536,
|
|
143
|
+
errorThrashingGuard: true, maxConsecutiveFailures: 4, adaptiveSteering: true,
|
|
144
|
+
targetQuotaGuard: true, maxUnchangedReadsPerTarget: 3, maxReadsPerTarget: 6,
|
|
145
|
+
maxEditsPerTarget: 8, maxTargetAttempts: 12,
|
|
186
146
|
};
|
|
187
147
|
|
|
148
|
+
const CLIENT_PRESETS = {
|
|
149
|
+
strict: {
|
|
150
|
+
maxToolAttemptsPerTurn: 10, maxProgressToolCallsPerTurn: 3, maxCallsPerRepeatGroup: 2,
|
|
151
|
+
strictToolLimit: 1, blockExactDuplicates: true, oscillationDetection: true, maxOscillationRepeats: 2,
|
|
152
|
+
errorThrashingGuard: true, maxConsecutiveFailures: 3, payloadBloatGuard: true, maxToolResultChars: 32768,
|
|
153
|
+
pseudoToolCallThreshold: 2, adaptiveSteering: true, targetQuotaGuard: true,
|
|
154
|
+
maxUnchangedReadsPerTarget: 2, maxReadsPerTarget: 4, maxEditsPerTarget: 5, maxTargetAttempts: 8,
|
|
155
|
+
},
|
|
156
|
+
balanced: {
|
|
157
|
+
maxToolAttemptsPerTurn: 16, maxProgressToolCallsPerTurn: 6, maxCallsPerRepeatGroup: 3,
|
|
158
|
+
strictToolLimit: 2, blockExactDuplicates: true, oscillationDetection: true, maxOscillationRepeats: 3,
|
|
159
|
+
errorThrashingGuard: true, maxConsecutiveFailures: 4, payloadBloatGuard: true, maxToolResultChars: 65536,
|
|
160
|
+
pseudoToolCallThreshold: 3, adaptiveSteering: true, targetQuotaGuard: true,
|
|
161
|
+
maxUnchangedReadsPerTarget: 3, maxReadsPerTarget: 6, maxEditsPerTarget: 8, maxTargetAttempts: 12,
|
|
162
|
+
},
|
|
163
|
+
autonomous: {
|
|
164
|
+
maxToolAttemptsPerTurn: 32, maxProgressToolCallsPerTurn: 12, maxCallsPerRepeatGroup: 5,
|
|
165
|
+
strictToolLimit: 3, blockExactDuplicates: true, oscillationDetection: true, maxOscillationRepeats: 4,
|
|
166
|
+
errorThrashingGuard: true, maxConsecutiveFailures: 6, payloadBloatGuard: true, maxToolResultChars: 131072,
|
|
167
|
+
pseudoToolCallThreshold: 4, adaptiveSteering: true, targetQuotaGuard: true,
|
|
168
|
+
maxUnchangedReadsPerTarget: 5, maxReadsPerTarget: 10, maxEditsPerTarget: 12, maxTargetAttempts: 20,
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
function IncidentTelemetryPanel({ telemetry, tt, onCopyDump, onResetTelemetry }) {
|
|
172
|
+
return React.createElement('div', {
|
|
173
|
+
style: { padding: '12px 14px', margin: '14px 0', background: 'color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent)', borderRadius: 8, border: '1px solid var(--dsw-alias-border-l2)' }
|
|
174
|
+
},
|
|
175
|
+
React.createElement('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 } },
|
|
176
|
+
React.createElement('span', { style: { fontSize: 13, fontWeight: 600, color: 'var(--dsw-alias-label-primary)' } }, tt('telemetryTitle')),
|
|
177
|
+
React.createElement('div', { style: { display: 'flex', gap: 6 } },
|
|
178
|
+
telemetry.totalViolations > 0 && React.createElement('button', { className: 'alg-btn-ghost', onClick: onCopyDump }, tt('copyDump')),
|
|
179
|
+
(telemetry.totalViolations > 0 || (telemetry.incidents && telemetry.incidents.length > 0)) && React.createElement('button', { className: 'alg-btn-ghost', onClick: onResetTelemetry }, tt('resetStats'))
|
|
180
|
+
)
|
|
181
|
+
),
|
|
182
|
+
React.createElement('div', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } },
|
|
183
|
+
telemetry.error
|
|
184
|
+
? React.createElement('span', { style: { color: 'var(--dsw-alias-state-error-primary)' } }, telemetry.error)
|
|
185
|
+
: (telemetry.totalViolations > 0 || telemetry.steeredCount > 0)
|
|
186
|
+
? React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
187
|
+
React.createElement('div', { style: { display: 'flex', gap: 16 } },
|
|
188
|
+
React.createElement('div', null, tt('totalBlocked') + ': ', React.createElement('strong', { style: { color: 'var(--dsw-alias-state-warn-primary)' } }, telemetry.totalViolations)),
|
|
189
|
+
React.createElement('div', null, tt('steeredCount') + ': ', React.createElement('strong', { style: { color: 'var(--dsw-alias-brand-primary)' } }, telemetry.steeredCount || 0))
|
|
190
|
+
),
|
|
191
|
+
telemetry.lastViolation && React.createElement('div', { style: { color: 'var(--dsw-alias-label-tertiary)' } },
|
|
192
|
+
tt('lastViolation') + ': ' + telemetry.lastViolation.code + ' (' + telemetry.lastViolation.tool + ')'
|
|
193
|
+
),
|
|
194
|
+
telemetry.incidents && telemetry.incidents.length > 0 && React.createElement('div', { style: { marginTop: 6, borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: 6 } },
|
|
195
|
+
React.createElement('div', { style: { fontWeight: 500, marginBottom: 4 } }, tt('incidentsTitle')),
|
|
196
|
+
telemetry.incidents.slice(0, 4).map((inc, i) => React.createElement('div', { key: inc.id || i, className: 'alg-incident-row' },
|
|
197
|
+
React.createElement('span', { style: { fontWeight: 500, color: inc.code === 'LOOP_GUARD_STEER' ? 'var(--dsw-alias-brand-primary)' : 'var(--dsw-alias-state-error-primary)' } }, inc.code),
|
|
198
|
+
React.createElement('span', { style: { color: 'var(--dsw-alias-label-tertiary)' } }, inc.tool)
|
|
199
|
+
))
|
|
200
|
+
)
|
|
201
|
+
)
|
|
202
|
+
: React.createElement('span', { style: { color: 'var(--dsw-alias-label-tertiary)' } }, tt('noViolations'))
|
|
203
|
+
)
|
|
204
|
+
);
|
|
205
|
+
}
|
|
188
206
|
function PluginCard({ ctx: _ctx, t, bare, ...props }) {
|
|
189
207
|
const isBare = Boolean(bare || props?.view === 'page');
|
|
190
208
|
const [expanded, setExpanded] = React.useState(false);
|
|
@@ -199,7 +217,7 @@ window.__ModuleLoader__.load({
|
|
|
199
217
|
updating: false, notice: '', error: '', canAutoUpdate: true, isDesktop: false,
|
|
200
218
|
});
|
|
201
219
|
|
|
202
|
-
const [telemetry, setTelemetry] = React.useState({ totalViolations: 0, byCode: {}, lastViolation: null });
|
|
220
|
+
const [telemetry, setTelemetry] = React.useState({ totalViolations: 0, steeredCount: 0, byCode: {}, lastViolation: null, incidents: [] });
|
|
203
221
|
|
|
204
222
|
const scopeRef = React.useRef(null);
|
|
205
223
|
if (!scopeRef.current && _ctx && _ctx.configForms) {
|
|
@@ -213,15 +231,14 @@ window.__ModuleLoader__.load({
|
|
|
213
231
|
}, []);
|
|
214
232
|
|
|
215
233
|
const getActiveLocale = () => {
|
|
216
|
-
const snap = typeof _ctx?.locale?.getLocale === 'function'
|
|
217
|
-
? _ctx.locale.getLocale()
|
|
234
|
+
const snap = typeof _ctx?.locale?.getLocale === 'function' ? _ctx.locale.getLocale()
|
|
218
235
|
: (typeof _ctx?.locale?.getSnapshot === 'function' ? _ctx.locale.getSnapshot() : null);
|
|
219
236
|
const loc = typeof snap === 'string' ? snap : (snap?.active || snap?.locale || snap?.id);
|
|
220
|
-
|
|
221
|
-
return typeof navigator !== 'undefined' && navigator.language ? navigator.language : 'en';
|
|
237
|
+
return loc || (typeof navigator !== 'undefined' && navigator.language ? navigator.language : 'en');
|
|
222
238
|
};
|
|
223
|
-
const
|
|
224
|
-
const
|
|
239
|
+
const locStr = String(getActiveLocale()).toLowerCase();
|
|
240
|
+
const currentLang = locStr.startsWith('zh') ? 'zh' : (locStr.startsWith('ru') ? 'ru' : 'en');
|
|
241
|
+
const dict = currentLang === 'zh' ? zh : (currentLang === 'ru' ? ru : en);
|
|
225
242
|
const tt = (k, params) => {
|
|
226
243
|
let str = (typeof t === 'function' ? t(k) : null) || dict[k] || en[k] || k;
|
|
227
244
|
if (params && typeof params === 'object') {
|
|
@@ -272,15 +289,15 @@ window.__ModuleLoader__.load({
|
|
|
272
289
|
let cancelled = false;
|
|
273
290
|
|
|
274
291
|
(async () => {
|
|
275
|
-
setUpdateState((s) => ({ ...s, checking: true, error: '', notice: '' }));
|
|
276
292
|
try {
|
|
277
293
|
const res = await fetch('/api/@goodandready/dsh-agent-loop-guard/update');
|
|
278
294
|
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
279
295
|
const data = await res.json();
|
|
280
296
|
if (cancelled) return;
|
|
281
297
|
setUpdateState((s) => ({
|
|
282
|
-
...s, checking: false,
|
|
283
|
-
|
|
298
|
+
...s, checking: false, updateAvailable: Boolean(data.updateAvailable),
|
|
299
|
+
currentVersion: data.currentVersion || '', latestVersion: data.latestVersion || '',
|
|
300
|
+
updating: false, notice: '', error: '',
|
|
284
301
|
canAutoUpdate: data.canAutoUpdate !== false, isDesktop: !!data.isDesktop,
|
|
285
302
|
}));
|
|
286
303
|
} catch (err) {
|
|
@@ -297,8 +314,10 @@ window.__ModuleLoader__.load({
|
|
|
297
314
|
if (cancelled) return;
|
|
298
315
|
setTelemetry({
|
|
299
316
|
totalViolations: Number(data.totalViolations) || 0,
|
|
317
|
+
steeredCount: Number(data.steeredCount) || 0,
|
|
300
318
|
byCode: data.byCode || {},
|
|
301
319
|
lastViolation: data.lastViolation || null,
|
|
320
|
+
incidents: Array.isArray(data.incidents) ? data.incidents : [],
|
|
302
321
|
error: null,
|
|
303
322
|
});
|
|
304
323
|
} catch (err) {
|
|
@@ -311,24 +330,27 @@ window.__ModuleLoader__.load({
|
|
|
311
330
|
}, [isExpanded]);
|
|
312
331
|
|
|
313
332
|
async function onSave() {
|
|
314
|
-
if (!scope
|
|
315
|
-
setSaving(true);
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
const
|
|
333
|
+
if (!scope || saving) return;
|
|
334
|
+
setSaving(true);
|
|
335
|
+
setMsg('');
|
|
336
|
+
const names = draft.progressToolNamesText.split(',').map((s) => s.trim()).filter(Boolean);
|
|
337
|
+
const strictList = draft.strictToolsText.split(',').map((s) => s.trim()).filter(Boolean);
|
|
319
338
|
const payload = {
|
|
320
|
-
maxToolAttemptsPerTurn: Number.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
maxRepeatedAssistantLines: Number(draft.maxRepeatedAssistantLines) || 5, maxRepeatedAssistantBlocks: Number(draft.maxRepeatedAssistantBlocks) || 5,
|
|
327
|
-
maxAssistantBlockChars: Number(draft.maxAssistantBlockChars) || 16384,
|
|
328
|
-
pseudoToolCallThreshold: Number.isFinite(Number(draft.pseudoToolCallThreshold)) && Number(draft.pseudoToolCallThreshold) >= 0 ? Number(draft.pseudoToolCallThreshold) : 3,
|
|
339
|
+
maxToolAttemptsPerTurn: Number(draft.maxToolAttemptsPerTurn) || 0, maxProgressToolCallsPerTurn: Number(draft.maxProgressToolCallsPerTurn) || 16,
|
|
340
|
+
maxCallsPerRepeatGroup: Number(draft.maxCallsPerRepeatGroup) || 5, strictTools: strictList, strictToolLimit: Number(draft.strictToolLimit) || 3,
|
|
341
|
+
blockExactDuplicates: draft.blockExactDuplicates !== false, dryRunMode: Boolean(draft.dryRunMode),
|
|
342
|
+
assistantOutputGuard: draft.assistantOutputGuard !== false, maxRepeatedAssistantLines: Number(draft.maxRepeatedAssistantLines) || 5,
|
|
343
|
+
maxRepeatedAssistantBlocks: Number(draft.maxRepeatedAssistantBlocks) || 5, maxAssistantBlockChars: Number(draft.maxAssistantBlockChars) || 16384,
|
|
344
|
+
pseudoToolCallThreshold: Number.isFinite(Number(draft.pseudoToolCallThreshold)) ? Number(draft.pseudoToolCallThreshold) : 3,
|
|
329
345
|
oscillationDetection: draft.oscillationDetection !== false, maxOscillationRepeats: Number(draft.maxOscillationRepeats) || 3,
|
|
330
|
-
payloadBloatGuard: draft.payloadBloatGuard !== false,
|
|
331
|
-
|
|
346
|
+
payloadBloatGuard: draft.payloadBloatGuard !== false, progressToolNames: names.length ? names : ['todo_write'],
|
|
347
|
+
maxToolResultChars: Number.isFinite(Number(draft.maxToolResultChars)) && Number(draft.maxToolResultChars) >= 0 ? Number(draft.maxToolResultChars) : 65536,
|
|
348
|
+
errorThrashingGuard: draft.errorThrashingGuard !== false, maxConsecutiveFailures: Number(draft.maxConsecutiveFailures) || 4,
|
|
349
|
+
adaptiveSteering: draft.adaptiveSteering !== false, targetQuotaGuard: draft.targetQuotaGuard !== false,
|
|
350
|
+
maxUnchangedReadsPerTarget: Number(draft.maxUnchangedReadsPerTarget) || 3,
|
|
351
|
+
maxReadsPerTarget: Number(draft.maxReadsPerTarget) || 6,
|
|
352
|
+
maxEditsPerTarget: Number(draft.maxEditsPerTarget) || 8,
|
|
353
|
+
maxTargetAttempts: Number(draft.maxTargetAttempts) || 12,
|
|
332
354
|
};
|
|
333
355
|
const errs = [];
|
|
334
356
|
for (const [k, v] of Object.entries(payload)) {
|
|
@@ -338,38 +360,45 @@ window.__ModuleLoader__.load({
|
|
|
338
360
|
setMsg(errs.length ? errs.join('; ') : tt('saved'));
|
|
339
361
|
}
|
|
340
362
|
|
|
363
|
+
function applyPreset(name) {
|
|
364
|
+
if (!CLIENT_PRESETS[name]) return;
|
|
365
|
+
setDraft((d) => ({ ...d, ...CLIENT_PRESETS[name] }));
|
|
366
|
+
setMsg(tt('presetApplied', { name: tt('preset' + name.charAt(0).toUpperCase() + name.slice(1)) }));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function onCopyDump() {
|
|
370
|
+
try {
|
|
371
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) navigator.clipboard.writeText(JSON.stringify(telemetry, null, 2));
|
|
372
|
+
setMsg(tt('dumpCopied'));
|
|
373
|
+
} catch (e) { setMsg(String(e)); }
|
|
374
|
+
}
|
|
375
|
+
|
|
341
376
|
async function onTriggerUpdate() {
|
|
342
377
|
if (updateState.updating) return;
|
|
343
378
|
setUpdateState((s) => ({ ...s, updating: true, error: '', notice: '' }));
|
|
344
379
|
try {
|
|
345
380
|
const res = await fetch('/api/@goodandready/dsh-agent-loop-guard/update', {
|
|
346
|
-
method: 'POST',
|
|
347
|
-
headers: { 'x-dsh-plugin-update': '1' },
|
|
381
|
+
method: 'POST', headers: { 'x-dsh-plugin-update': '1' },
|
|
348
382
|
});
|
|
349
383
|
const data = await res.json();
|
|
350
|
-
if (!res.ok || data.error) throw new Error(data.error || '
|
|
384
|
+
if (!res.ok || data.error) throw new Error(data.error || 'HTTP ' + res.status);
|
|
351
385
|
setUpdateState((s) => ({
|
|
352
386
|
...s, updating: false, updateAvailable: false,
|
|
353
387
|
currentVersion: data.updatedVersion || s.latestVersion,
|
|
354
388
|
notice: tt('updateSuccess', { v: data.updatedVersion || s.latestVersion }),
|
|
355
389
|
}));
|
|
356
|
-
} catch (err) {
|
|
357
|
-
setUpdateState((s) => ({ ...s, updating: false, error: tt('updateFailed', { msg: err.message || String(err) }) }));
|
|
358
|
-
}
|
|
390
|
+
} catch (err) { setUpdateState((s) => ({ ...s, updating: false, error: tt('updateFailed', { msg: err.message || String(err) }) })); }
|
|
359
391
|
}
|
|
360
392
|
|
|
361
393
|
async function onResetTelemetry() {
|
|
362
394
|
try {
|
|
363
395
|
const res = await fetch('/api/@goodandready/dsh-agent-loop-guard/telemetry', {
|
|
364
|
-
method: 'POST',
|
|
365
|
-
headers: { 'x-dsh-loop-guard': '1' },
|
|
396
|
+
method: 'POST', headers: { 'x-dsh-loop-guard': '1' },
|
|
366
397
|
});
|
|
367
398
|
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
368
|
-
setTelemetry({ totalViolations: 0, byCode: {}, lastViolation: null, error: null });
|
|
399
|
+
setTelemetry({ totalViolations: 0, steeredCount: 0, byCode: {}, lastViolation: null, incidents: [], error: null });
|
|
369
400
|
setMsg(tt('statsResetDone'));
|
|
370
|
-
} catch (err) {
|
|
371
|
-
setMsg(tt('statsResetFailed'));
|
|
372
|
-
}
|
|
401
|
+
} catch (err) { setMsg(tt('statsResetFailed')); }
|
|
373
402
|
}
|
|
374
403
|
|
|
375
404
|
const renderChevron = () => {
|
|
@@ -390,36 +419,19 @@ window.__ModuleLoader__.load({
|
|
|
390
419
|
const field = (key, input) => {
|
|
391
420
|
const id = 'alg-' + key;
|
|
392
421
|
const linkedInput = React.isValidElement && React.isValidElement(input)
|
|
393
|
-
? React.cloneElement(input, { id })
|
|
394
|
-
|
|
395
|
-
return React.createElement('div', { className: 'alg-field' },
|
|
422
|
+
? React.cloneElement(input, { id }) : input;
|
|
423
|
+
return React.createElement('div', { key, className: 'alg-field' },
|
|
396
424
|
React.createElement('label', { htmlFor: id }, tt(key)),
|
|
397
425
|
linkedInput
|
|
398
426
|
);
|
|
399
427
|
};
|
|
400
428
|
|
|
401
|
-
const num = (
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
const str = (key) => React.createElement('input', {
|
|
407
|
-
type: 'text', className: 'alg-input', value: draft[key],
|
|
408
|
-
onChange: (e) => setDraft((d) => ({ ...d, [key]: e.target.value })),
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
const check = (key) => React.createElement('label', { className: 'alg-checkbox-label' },
|
|
412
|
-
React.createElement('input', {
|
|
413
|
-
type: 'checkbox', checked: !!draft[key],
|
|
414
|
-
onChange: (e) => setDraft((d) => ({ ...d, [key]: e.target.checked }))
|
|
415
|
-
}),
|
|
416
|
-
tt(key)
|
|
417
|
-
);
|
|
429
|
+
const num = (k) => React.createElement('input', { type: 'number', className: 'alg-input', value: draft[k], onChange: (e) => setDraft((d) => ({ ...d, [k]: e.target.value })) });
|
|
430
|
+
const str = (k) => React.createElement('input', { type: 'text', className: 'alg-input', value: draft[k], onChange: (e) => setDraft((d) => ({ ...d, [k]: e.target.value })) });
|
|
431
|
+
const check = (k) => React.createElement('label', { key: k, className: 'alg-checkbox-label' }, React.createElement('input', { type: 'checkbox', checked: !!draft[k], onChange: (e) => setDraft((d) => ({ ...d, [k]: e.target.checked })) }), tt(k));
|
|
418
432
|
|
|
419
433
|
const header = React.createElement('button', {
|
|
420
|
-
className: 'alg-header-btn',
|
|
421
|
-
onClick: () => setExpanded(!expanded),
|
|
422
|
-
'aria-expanded': expanded,
|
|
434
|
+
className: 'alg-header-btn', onClick: () => setExpanded(!expanded), 'aria-expanded': expanded,
|
|
423
435
|
},
|
|
424
436
|
React.createElement('span', { style: { display: 'flex', flexDirection: 'column' } },
|
|
425
437
|
React.createElement('span', { style: { color: 'var(--dsw-alias-label-primary)', fontSize: 15, fontWeight: 600, display: 'flex', alignItems: 'center', gap: 8 } },
|
|
@@ -460,29 +472,15 @@ window.__ModuleLoader__.load({
|
|
|
460
472
|
style: { padding: '8px 12px', marginBottom: 12, background: 'color-mix(in srgb, var(--dsw-alias-state-success-primary) 10%, transparent)', color: 'var(--dsw-alias-state-success-primary)', borderRadius: 6, fontSize: 12, border: '1px solid color-mix(in srgb, var(--dsw-alias-state-success-primary) 20%, transparent)' }
|
|
461
473
|
}, updateState.notice),
|
|
462
474
|
|
|
463
|
-
React.createElement('div', {
|
|
464
|
-
style: {
|
|
465
|
-
|
|
466
|
-
React.createElement('
|
|
467
|
-
|
|
468
|
-
telemetry.totalViolations > 0 && React.createElement('button', {
|
|
469
|
-
className: 'alg-btn-ghost', onClick: onResetTelemetry,
|
|
470
|
-
}, tt('resetStats'))
|
|
471
|
-
),
|
|
472
|
-
React.createElement('div', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } },
|
|
473
|
-
telemetry.error
|
|
474
|
-
? React.createElement('span', { style: { color: 'var(--dsw-alias-state-error-primary)' } }, telemetry.error)
|
|
475
|
-
: telemetry.totalViolations > 0
|
|
476
|
-
? React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
477
|
-
React.createElement('div', null, tt('totalBlocked') + ': ', React.createElement('strong', { style: { color: 'var(--dsw-alias-state-warn-primary)' } }, telemetry.totalViolations)),
|
|
478
|
-
telemetry.lastViolation && React.createElement('div', { style: { color: 'var(--dsw-alias-label-tertiary)' } },
|
|
479
|
-
tt('lastViolation') + ': ' + telemetry.lastViolation.code + ' (' + telemetry.lastViolation.tool + ')'
|
|
480
|
-
)
|
|
481
|
-
)
|
|
482
|
-
: React.createElement('span', { style: { color: 'var(--dsw-alias-label-tertiary)' } }, tt('noViolations'))
|
|
483
|
-
)
|
|
475
|
+
React.createElement('div', { className: 'alg-presets' },
|
|
476
|
+
React.createElement('span', { style: { fontSize: 12, fontWeight: 500, color: 'var(--dsw-alias-label-secondary)', marginRight: 4 } }, tt('presetsTitle') + ':'),
|
|
477
|
+
React.createElement('button', { type: 'button', className: 'alg-btn-preset', onClick: () => applyPreset('strict') }, tt('presetStrict')),
|
|
478
|
+
React.createElement('button', { type: 'button', className: 'alg-btn-preset', onClick: () => applyPreset('balanced') }, tt('presetBalanced')),
|
|
479
|
+
React.createElement('button', { type: 'button', className: 'alg-btn-preset', onClick: () => applyPreset('autonomous') }, tt('presetAutonomous'))
|
|
484
480
|
),
|
|
485
481
|
|
|
482
|
+
React.createElement(IncidentTelemetryPanel, { telemetry, tt, onCopyDump, onResetTelemetry }),
|
|
483
|
+
|
|
486
484
|
field('maxToolAttemptsPerTurn', num('maxToolAttemptsPerTurn')),
|
|
487
485
|
field('maxProgressToolCallsPerTurn', num('maxProgressToolCallsPerTurn')),
|
|
488
486
|
field('maxCallsPerRepeatGroup', num('maxCallsPerRepeatGroup')),
|
|
@@ -500,6 +498,14 @@ window.__ModuleLoader__.load({
|
|
|
500
498
|
field('maxOscillationRepeats', num('maxOscillationRepeats')),
|
|
501
499
|
check('payloadBloatGuard'),
|
|
502
500
|
field('maxToolResultChars', num('maxToolResultChars')),
|
|
501
|
+
check('errorThrashingGuard'),
|
|
502
|
+
field('maxConsecutiveFailures', num('maxConsecutiveFailures')),
|
|
503
|
+
check('adaptiveSteering'),
|
|
504
|
+
check('targetQuotaGuard'),
|
|
505
|
+
field('maxUnchangedReadsPerTarget', num('maxUnchangedReadsPerTarget')),
|
|
506
|
+
field('maxReadsPerTarget', num('maxReadsPerTarget')),
|
|
507
|
+
field('maxEditsPerTarget', num('maxEditsPerTarget')),
|
|
508
|
+
field('maxTargetAttempts', num('maxTargetAttempts')),
|
|
503
509
|
|
|
504
510
|
React.createElement('div', {
|
|
505
511
|
style: { display: 'flex', alignItems: 'center', gap: 12, paddingTop: 14, borderTop: '1px solid var(--dsw-alias-border-l2)', marginTop: 10 }
|
|
@@ -507,7 +513,7 @@ window.__ModuleLoader__.load({
|
|
|
507
513
|
React.createElement('button', {
|
|
508
514
|
className: 'alg-btn-primary', onClick: onSave, disabled: saving || status !== 'ready',
|
|
509
515
|
}, saving ? tt('saving') : tt('ready')),
|
|
510
|
-
msg && React.createElement('span', { style: { fontSize: 13, color: msg
|
|
516
|
+
msg && React.createElement('span', { style: { fontSize: 13, color: msg.includes(';') ? 'var(--dsw-alias-state-error-primary)' : 'var(--dsw-alias-state-success-primary)' } }, msg)
|
|
511
517
|
)
|
|
512
518
|
);
|
|
513
519
|
|
|
@@ -521,7 +527,6 @@ window.__ModuleLoader__.load({
|
|
|
521
527
|
}
|
|
522
528
|
return React.createElement(PluginCard, { ...props, bare: Boolean(props && (props.bare || props.view === 'page')) });
|
|
523
529
|
}
|
|
524
|
-
|
|
525
530
|
exports.inject = ['slots', 'configForms', 'locale'];
|
|
526
531
|
exports.apply = function apply(ctx) {
|
|
527
532
|
if (typeof ctx.locale?.register === 'function') {
|