@goodandready/dsh-agent-loop-guard 0.3.0 → 0.3.2
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 +24 -0
- package/README.md +6 -5
- package/README.ru.md +6 -5
- package/README.zh.md +6 -5
- package/lib/assistant-output-state.js +17 -2
- package/lib/client.js +470 -424
- package/lib/guard-helpers.js +67 -0
- package/lib/guard-state.js +96 -96
- package/lib/index.js +5 -0
- package/lib/target-quota-guard.js +244 -0
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -57,430 +57,476 @@ window.__ModuleLoader__.load({
|
|
|
57
57
|
document.head.appendChild(style);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
const en = {
|
|
61
|
-
title: 'Agent Loop Guard', sub: 'Fail-closed tool-call and assistant-output loop limits',
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
updateFailed: '
|
|
91
|
-
telemetryTitle: '
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
React.createElement(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
)
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
60
|
+
const en = {
|
|
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',
|
|
84
|
+
};
|
|
85
|
+
|
|
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: 'Сохранено',
|
|
110
|
+
};
|
|
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
|
+
};
|
|
137
|
+
const DEFAULTS = {
|
|
138
|
+
maxToolAttemptsPerTurn: 64, maxProgressToolCallsPerTurn: 16, progressToolNames: ['todo_write'],
|
|
139
|
+
maxCallsPerRepeatGroup: 5, strictTools: [], strictToolLimit: 3, blockExactDuplicates: true,
|
|
140
|
+
dryRunMode: false, assistantOutputGuard: true, maxRepeatedAssistantLines: 5,
|
|
141
|
+
maxRepeatedAssistantBlocks: 5, maxAssistantBlockChars: 16384, pseudoToolCallThreshold: 3,
|
|
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,
|
|
146
|
+
};
|
|
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
|
+
}
|
|
206
|
+
function PluginCard({ ctx: _ctx, t, bare, ...props }) {
|
|
207
|
+
const isBare = Boolean(bare || props?.view === 'page');
|
|
208
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
209
|
+
const isExpanded = Boolean(isBare || expanded);
|
|
210
|
+
const [draft, setDraft] = React.useState({ ...DEFAULTS, progressToolNamesText: 'todo_write', strictToolsText: '' });
|
|
211
|
+
const [status, setStatus] = React.useState('loading');
|
|
212
|
+
const [saving, setSaving] = React.useState(false);
|
|
213
|
+
const [msg, setMsg] = React.useState('');
|
|
214
|
+
|
|
215
|
+
const [updateState, setUpdateState] = React.useState({
|
|
216
|
+
checking: false, updateAvailable: false, currentVersion: '', latestVersion: '',
|
|
217
|
+
updating: false, notice: '', error: '', canAutoUpdate: true, isDesktop: false,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const [telemetry, setTelemetry] = React.useState({ totalViolations: 0, steeredCount: 0, byCode: {}, lastViolation: null, incidents: [] });
|
|
221
|
+
|
|
222
|
+
const scopeRef = React.useRef(null);
|
|
223
|
+
if (!scopeRef.current && _ctx && _ctx.configForms) {
|
|
224
|
+
try { scopeRef.current = _ctx.configForms.get(NS); } catch (e) { scopeRef.current = null; }
|
|
225
|
+
}
|
|
226
|
+
const scope = scopeRef.current;
|
|
227
|
+
|
|
228
|
+
const [, setLocaleTick] = React.useState(0);
|
|
229
|
+
React.useEffect(() => {
|
|
230
|
+
if (typeof _ctx?.locale?.subscribe === 'function') return _ctx.locale.subscribe(() => setLocaleTick((c) => c + 1));
|
|
231
|
+
}, []);
|
|
232
|
+
|
|
233
|
+
const getActiveLocale = () => {
|
|
234
|
+
const snap = typeof _ctx?.locale?.getLocale === 'function' ? _ctx.locale.getLocale()
|
|
235
|
+
: (typeof _ctx?.locale?.getSnapshot === 'function' ? _ctx.locale.getSnapshot() : null);
|
|
236
|
+
const loc = typeof snap === 'string' ? snap : (snap?.active || snap?.locale || snap?.id);
|
|
237
|
+
return loc || (typeof navigator !== 'undefined' && navigator.language ? navigator.language : 'en');
|
|
238
|
+
};
|
|
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);
|
|
242
|
+
const tt = (k, params) => {
|
|
243
|
+
let str = (typeof t === 'function' ? t(k) : null) || dict[k] || en[k] || k;
|
|
244
|
+
if (params && typeof params === 'object') {
|
|
245
|
+
for (const [pk, pv] of Object.entries(params)) {
|
|
246
|
+
str = str.replace(new RegExp('\\{' + pk + '\\}', 'g'), String(pv));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return str;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
React.useEffect(() => {
|
|
253
|
+
if (!scope) { setStatus('unavailable'); return; }
|
|
254
|
+
let cancelled = false;
|
|
255
|
+
const syncFromSnapshot = (snap) => {
|
|
256
|
+
if (!snap || typeof snap !== 'object') return;
|
|
257
|
+
if ('status' in snap) {
|
|
258
|
+
if (snap.status === 'loading') { setStatus('loading'); return; }
|
|
259
|
+
if (snap.status === 'unavailable') { setStatus('unavailable'); return; }
|
|
260
|
+
}
|
|
261
|
+
const vals = snap.value !== undefined ? snap.value : (snap.values !== undefined ? snap.values : snap);
|
|
262
|
+
if (vals && typeof vals === 'object') {
|
|
263
|
+
const names = Array.isArray(vals.progressToolNames) ? vals.progressToolNames : DEFAULTS.progressToolNames;
|
|
264
|
+
const strict = Array.isArray(vals.strictTools) ? vals.strictTools : DEFAULTS.strictTools;
|
|
265
|
+
setDraft((d) => ({
|
|
266
|
+
...d, ...DEFAULTS, ...vals,
|
|
267
|
+
progressToolNamesText: names.join(', '),
|
|
268
|
+
strictToolsText: strict.join(', '),
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
setStatus('ready');
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
try {
|
|
275
|
+
if (typeof scope.getSnapshot === 'function') syncFromSnapshot(scope.getSnapshot());
|
|
276
|
+
else if (typeof scope.get === 'function') Promise.resolve(scope.get()).then((s) => { if (!cancelled) syncFromSnapshot(s); }).catch(() => { if (!cancelled) setStatus('unavailable'); });
|
|
277
|
+
else setStatus('unavailable');
|
|
278
|
+
} catch (_) { if (!cancelled) setStatus('unavailable'); }
|
|
279
|
+
|
|
280
|
+
const unsub = typeof scope.subscribe === 'function' ? scope.subscribe(() => {
|
|
281
|
+
if (!cancelled && typeof scope.getSnapshot === 'function') { try { syncFromSnapshot(scope.getSnapshot()); } catch (err) { void err; } }
|
|
282
|
+
}) : null;
|
|
283
|
+
|
|
284
|
+
return () => { cancelled = true; if (typeof unsub === 'function') unsub(); };
|
|
285
|
+
}, [scope]);
|
|
286
|
+
|
|
287
|
+
React.useEffect(() => {
|
|
288
|
+
if (!isExpanded) return;
|
|
289
|
+
let cancelled = false;
|
|
290
|
+
|
|
291
|
+
(async () => {
|
|
292
|
+
try {
|
|
293
|
+
const res = await fetch('/api/@goodandready/dsh-agent-loop-guard/update');
|
|
294
|
+
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
295
|
+
const data = await res.json();
|
|
296
|
+
if (cancelled) return;
|
|
297
|
+
setUpdateState((s) => ({
|
|
298
|
+
...s, checking: false, updateAvailable: Boolean(data.updateAvailable),
|
|
299
|
+
currentVersion: data.currentVersion || '', latestVersion: data.latestVersion || '',
|
|
300
|
+
updating: false, notice: '', error: '',
|
|
301
|
+
canAutoUpdate: data.canAutoUpdate !== false, isDesktop: !!data.isDesktop,
|
|
302
|
+
}));
|
|
303
|
+
} catch (err) {
|
|
304
|
+
if (cancelled) return;
|
|
305
|
+
setUpdateState((s) => ({ ...s, checking: false, error: tt('checkUpdateFailed') }));
|
|
306
|
+
}
|
|
307
|
+
})();
|
|
308
|
+
|
|
309
|
+
(async () => {
|
|
310
|
+
try {
|
|
311
|
+
const res = await fetch('/api/@goodandready/dsh-agent-loop-guard/telemetry');
|
|
312
|
+
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
313
|
+
const data = await res.json();
|
|
314
|
+
if (cancelled) return;
|
|
315
|
+
setTelemetry({
|
|
316
|
+
totalViolations: Number(data.totalViolations) || 0,
|
|
317
|
+
steeredCount: Number(data.steeredCount) || 0,
|
|
318
|
+
byCode: data.byCode || {},
|
|
319
|
+
lastViolation: data.lastViolation || null,
|
|
320
|
+
incidents: Array.isArray(data.incidents) ? data.incidents : [],
|
|
321
|
+
error: null,
|
|
322
|
+
});
|
|
323
|
+
} catch (err) {
|
|
324
|
+
if (cancelled) return;
|
|
325
|
+
setTelemetry((t) => ({ ...t, error: tt('telemetryLoadFailed') }));
|
|
326
|
+
}
|
|
327
|
+
})();
|
|
328
|
+
|
|
329
|
+
return () => { cancelled = true; };
|
|
330
|
+
}, [isExpanded]);
|
|
331
|
+
|
|
332
|
+
async function onSave() {
|
|
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);
|
|
338
|
+
const payload = {
|
|
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,
|
|
345
|
+
oscillationDetection: draft.oscillationDetection !== false, maxOscillationRepeats: Number(draft.maxOscillationRepeats) || 3,
|
|
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,
|
|
354
|
+
};
|
|
355
|
+
const errs = [];
|
|
356
|
+
for (const [k, v] of Object.entries(payload)) {
|
|
357
|
+
try { await scope.set(k, v); } catch (e) { errs.push(k + ': ' + (e && e.message || String(e))); }
|
|
358
|
+
}
|
|
359
|
+
setSaving(false);
|
|
360
|
+
setMsg(errs.length ? errs.join('; ') : tt('saved'));
|
|
361
|
+
}
|
|
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
|
+
|
|
376
|
+
async function onTriggerUpdate() {
|
|
377
|
+
if (updateState.updating) return;
|
|
378
|
+
setUpdateState((s) => ({ ...s, updating: true, error: '', notice: '' }));
|
|
379
|
+
try {
|
|
380
|
+
const res = await fetch('/api/@goodandready/dsh-agent-loop-guard/update', {
|
|
381
|
+
method: 'POST', headers: { 'x-dsh-plugin-update': '1' },
|
|
382
|
+
});
|
|
383
|
+
const data = await res.json();
|
|
384
|
+
if (!res.ok || data.error) throw new Error(data.error || 'HTTP ' + res.status);
|
|
385
|
+
setUpdateState((s) => ({
|
|
386
|
+
...s, updating: false, updateAvailable: false,
|
|
387
|
+
currentVersion: data.updatedVersion || s.latestVersion,
|
|
388
|
+
notice: tt('updateSuccess', { v: data.updatedVersion || s.latestVersion }),
|
|
389
|
+
}));
|
|
390
|
+
} catch (err) { setUpdateState((s) => ({ ...s, updating: false, error: tt('updateFailed', { msg: err.message || String(err) }) })); }
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
async function onResetTelemetry() {
|
|
394
|
+
try {
|
|
395
|
+
const res = await fetch('/api/@goodandready/dsh-agent-loop-guard/telemetry', {
|
|
396
|
+
method: 'POST', headers: { 'x-dsh-loop-guard': '1' },
|
|
397
|
+
});
|
|
398
|
+
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
399
|
+
setTelemetry({ totalViolations: 0, steeredCount: 0, byCode: {}, lastViolation: null, incidents: [], error: null });
|
|
400
|
+
setMsg(tt('statsResetDone'));
|
|
401
|
+
} catch (err) { setMsg(tt('statsResetFailed')); }
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const renderChevron = () => {
|
|
405
|
+
if (PrimitivesChevron) {
|
|
406
|
+
return React.createElement(PrimitivesChevron, {
|
|
407
|
+
className: 'alg-chevron' + (expanded ? ' expanded' : ''),
|
|
408
|
+
style: { width: 14, height: 14, color: 'inherit' }
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return React.createElement('svg', {
|
|
412
|
+
className: 'alg-chevron' + (expanded ? ' expanded' : ''),
|
|
413
|
+
width: 14, height: 14, viewBox: '0 0 24 24', fill: 'none',
|
|
414
|
+
stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round',
|
|
415
|
+
style: { flexShrink: 0 }
|
|
416
|
+
}, React.createElement('polyline', { points: '6 9 12 15 18 9' }));
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
const field = (key, input) => {
|
|
420
|
+
const id = 'alg-' + key;
|
|
421
|
+
const linkedInput = React.isValidElement && React.isValidElement(input)
|
|
422
|
+
? React.cloneElement(input, { id }) : input;
|
|
423
|
+
return React.createElement('div', { key, className: 'alg-field' },
|
|
424
|
+
React.createElement('label', { htmlFor: id }, tt(key)),
|
|
425
|
+
linkedInput
|
|
426
|
+
);
|
|
427
|
+
};
|
|
428
|
+
|
|
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));
|
|
432
|
+
|
|
433
|
+
const header = React.createElement('button', {
|
|
434
|
+
className: 'alg-header-btn', onClick: () => setExpanded(!expanded), 'aria-expanded': expanded,
|
|
435
|
+
},
|
|
436
|
+
React.createElement('span', { style: { display: 'flex', flexDirection: 'column' } },
|
|
437
|
+
React.createElement('span', { style: { color: 'var(--dsw-alias-label-primary)', fontSize: 15, fontWeight: 600, display: 'flex', alignItems: 'center', gap: 8 } },
|
|
438
|
+
tt('title'),
|
|
439
|
+
React.createElement('span', { style: { fontSize: 11, fontWeight: 500, padding: '2px 6px', borderRadius: 6, background: 'color-mix(in srgb, var(--dsw-alias-brand-primary) 15%, transparent)', color: 'var(--dsw-alias-brand-primary)' } }, updateState.currentVersion ? 'v' + updateState.currentVersion : (updateState.checking ? '…' : '—'))
|
|
440
|
+
),
|
|
441
|
+
React.createElement('span', { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 13 } }, tt('sub'))
|
|
442
|
+
),
|
|
443
|
+
renderChevron()
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
const body = React.createElement('div', { className: 'alg-body' },
|
|
447
|
+
React.createElement('div', {
|
|
448
|
+
style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 0', borderBottom: '1px solid var(--dsw-alias-border-l2)' }
|
|
449
|
+
},
|
|
450
|
+
React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 2 } },
|
|
451
|
+
React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
452
|
+
React.createElement('span', { style: { fontSize: 13, fontWeight: 500, color: 'var(--dsw-alias-label-primary)' } },
|
|
453
|
+
tt('version') + ': ' + (updateState.currentVersion ? 'v' + updateState.currentVersion : '—')
|
|
454
|
+
),
|
|
455
|
+
React.createElement('span', {
|
|
456
|
+
style: {
|
|
457
|
+
fontSize: 11, padding: '1px 6px', borderRadius: 4,
|
|
458
|
+
background: updateState.updateAvailable ? 'color-mix(in srgb, var(--dsw-alias-brand-primary) 15%, transparent)' : 'color-mix(in srgb, var(--dsw-alias-state-success-primary) 15%, transparent)',
|
|
459
|
+
color: updateState.updateAvailable ? 'var(--dsw-alias-brand-primary)' : 'var(--dsw-alias-state-success-primary)',
|
|
460
|
+
}
|
|
461
|
+
}, updateState.checking ? tt('updateChecking') : (updateState.updateAvailable ? tt('updateAvailable', { v: updateState.latestVersion }) : (updateState.currentVersion ? tt('upToDate') : '—')))
|
|
462
|
+
),
|
|
463
|
+
updateState.error && React.createElement('span', { style: { color: 'var(--dsw-alias-state-error-primary)', fontSize: 12 } }, updateState.error)
|
|
464
|
+
),
|
|
465
|
+
updateState.updateAvailable && (
|
|
466
|
+
(updateState.isDesktop || !updateState.canAutoUpdate)
|
|
467
|
+
? React.createElement('span', { className: 'alg-updater-hint', style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary)' } }, tt('updateViaPluginsPage'))
|
|
468
|
+
: React.createElement('button', { className: 'alg-btn-updater', onClick: onTriggerUpdate, disabled: updateState.updating }, updateState.updating ? tt('updating') : tt('updateNow'))
|
|
469
|
+
)
|
|
470
|
+
),
|
|
471
|
+
updateState.notice && React.createElement('div', {
|
|
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)' }
|
|
473
|
+
}, updateState.notice),
|
|
474
|
+
|
|
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'))
|
|
480
|
+
),
|
|
481
|
+
|
|
482
|
+
React.createElement(IncidentTelemetryPanel, { telemetry, tt, onCopyDump, onResetTelemetry }),
|
|
483
|
+
|
|
484
|
+
field('maxToolAttemptsPerTurn', num('maxToolAttemptsPerTurn')),
|
|
485
|
+
field('maxProgressToolCallsPerTurn', num('maxProgressToolCallsPerTurn')),
|
|
486
|
+
field('maxCallsPerRepeatGroup', num('maxCallsPerRepeatGroup')),
|
|
487
|
+
field('strictTools', str('strictToolsText')),
|
|
488
|
+
field('strictToolLimit', num('strictToolLimit')),
|
|
489
|
+
check('blockExactDuplicates'),
|
|
490
|
+
check('dryRunMode'),
|
|
491
|
+
check('assistantOutputGuard'),
|
|
492
|
+
field('maxRepeatedAssistantLines', num('maxRepeatedAssistantLines')),
|
|
493
|
+
field('maxRepeatedAssistantBlocks', num('maxRepeatedAssistantBlocks')),
|
|
494
|
+
field('maxAssistantBlockChars', num('maxAssistantBlockChars')),
|
|
495
|
+
field('progressToolNames', str('progressToolNamesText')),
|
|
496
|
+
field('pseudoToolCallThreshold', num('pseudoToolCallThreshold')),
|
|
497
|
+
check('oscillationDetection'),
|
|
498
|
+
field('maxOscillationRepeats', num('maxOscillationRepeats')),
|
|
499
|
+
check('payloadBloatGuard'),
|
|
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')),
|
|
509
|
+
|
|
510
|
+
React.createElement('div', {
|
|
511
|
+
style: { display: 'flex', alignItems: 'center', gap: 12, paddingTop: 14, borderTop: '1px solid var(--dsw-alias-border-l2)', marginTop: 10 }
|
|
512
|
+
},
|
|
513
|
+
React.createElement('button', {
|
|
514
|
+
className: 'alg-btn-primary', onClick: onSave, disabled: saving || status !== 'ready',
|
|
515
|
+
}, saving ? tt('saving') : tt('ready')),
|
|
516
|
+
msg && React.createElement('span', { style: { fontSize: 13, color: msg.includes(';') ? 'var(--dsw-alias-state-error-primary)' : 'var(--dsw-alias-state-success-primary)' } }, msg)
|
|
517
|
+
)
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
if (isBare) return React.createElement('div', { className: 'alg-page' }, body);
|
|
521
|
+
return React.createElement('li', { className: 'alg-card' }, header, expanded && body);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function PluginItem(props) {
|
|
525
|
+
if (props && props.view === 'summary') {
|
|
526
|
+
return React.createElement('div', { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 13 } }, en.sub);
|
|
527
|
+
}
|
|
528
|
+
return React.createElement(PluginCard, { ...props, bare: Boolean(props && (props.bare || props.view === 'page')) });
|
|
529
|
+
}
|
|
484
530
|
exports.inject = ['slots', 'configForms', 'locale'];
|
|
485
531
|
exports.apply = function apply(ctx) {
|
|
486
532
|
if (typeof ctx.locale?.register === 'function') {
|