principles-disciple 1.5.4 → 1.7.0
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/dist/commands/context.d.ts +5 -0
- package/dist/commands/context.js +312 -0
- package/dist/commands/evolution-status.d.ts +4 -0
- package/dist/commands/evolution-status.js +138 -0
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/export.js +45 -0
- package/dist/commands/focus.d.ts +14 -0
- package/dist/commands/focus.js +582 -0
- package/dist/commands/pain.js +143 -6
- package/dist/commands/principle-rollback.d.ts +4 -0
- package/dist/commands/principle-rollback.js +22 -0
- package/dist/commands/rollback.d.ts +19 -0
- package/dist/commands/rollback.js +119 -0
- package/dist/commands/samples.d.ts +2 -0
- package/dist/commands/samples.js +55 -0
- package/dist/core/config.d.ts +37 -0
- package/dist/core/config.js +47 -0
- package/dist/core/control-ui-db.d.ts +68 -0
- package/dist/core/control-ui-db.js +274 -0
- package/dist/core/detection-funnel.d.ts +1 -1
- package/dist/core/detection-funnel.js +4 -0
- package/dist/core/dictionary.d.ts +2 -0
- package/dist/core/dictionary.js +13 -0
- package/dist/core/event-log.d.ts +22 -1
- package/dist/core/event-log.js +319 -0
- package/dist/core/evolution-engine.d.ts +5 -5
- package/dist/core/evolution-engine.js +18 -18
- package/dist/core/evolution-migration.d.ts +5 -0
- package/dist/core/evolution-migration.js +65 -0
- package/dist/core/evolution-reducer.d.ts +69 -0
- package/dist/core/evolution-reducer.js +369 -0
- package/dist/core/evolution-types.d.ts +103 -0
- package/dist/core/focus-history.d.ts +65 -0
- package/dist/core/focus-history.js +266 -0
- package/dist/core/init.js +30 -7
- package/dist/core/migration.js +0 -2
- package/dist/core/path-resolver.d.ts +3 -0
- package/dist/core/path-resolver.js +90 -31
- package/dist/core/paths.d.ts +7 -8
- package/dist/core/paths.js +48 -40
- package/dist/core/profile.js +1 -1
- package/dist/core/session-tracker.d.ts +4 -0
- package/dist/core/session-tracker.js +15 -0
- package/dist/core/thinking-models.d.ts +38 -0
- package/dist/core/thinking-models.js +170 -0
- package/dist/core/trajectory.d.ts +184 -0
- package/dist/core/trajectory.js +817 -0
- package/dist/core/trust-engine.d.ts +2 -0
- package/dist/core/trust-engine.js +30 -4
- package/dist/core/workspace-context.d.ts +13 -0
- package/dist/core/workspace-context.js +50 -7
- package/dist/hooks/gate.js +301 -30
- package/dist/hooks/llm.d.ts +8 -0
- package/dist/hooks/llm.js +347 -69
- package/dist/hooks/message-sanitize.d.ts +3 -0
- package/dist/hooks/message-sanitize.js +37 -0
- package/dist/hooks/pain.js +105 -5
- package/dist/hooks/prompt.d.ts +20 -11
- package/dist/hooks/prompt.js +558 -158
- package/dist/hooks/subagent.d.ts +9 -2
- package/dist/hooks/subagent.js +40 -3
- package/dist/http/principles-console-route.d.ts +2 -0
- package/dist/http/principles-console-route.js +257 -0
- package/dist/i18n/commands.js +48 -20
- package/dist/index.js +264 -8
- package/dist/service/control-ui-query-service.d.ts +217 -0
- package/dist/service/control-ui-query-service.js +537 -0
- package/dist/service/empathy-observer-manager.d.ts +42 -0
- package/dist/service/empathy-observer-manager.js +147 -0
- package/dist/service/evolution-worker.d.ts +10 -0
- package/dist/service/evolution-worker.js +156 -24
- package/dist/service/trajectory-service.d.ts +2 -0
- package/dist/service/trajectory-service.js +15 -0
- package/dist/tools/agent-spawn.d.ts +27 -6
- package/dist/tools/agent-spawn.js +339 -87
- package/dist/tools/deep-reflect.d.ts +27 -7
- package/dist/tools/deep-reflect.js +282 -113
- package/dist/types/event-types.d.ts +84 -2
- package/dist/types/event-types.js +33 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.js +24 -1
- package/openclaw.plugin.json +43 -11
- package/package.json +16 -6
- package/templates/langs/zh/core/HEARTBEAT.md +28 -4
- package/templates/langs/zh/skills/pd-daily/SKILL.md +97 -13
- package/templates/pain_settings.json +54 -2
- package/templates/workspace/.principles/PROFILE.json +2 -0
- package/templates/workspace/okr/CURRENT_FOCUS.md +57 -0
package/dist/index.js
CHANGED
|
@@ -5,18 +5,29 @@ import { handleAfterToolCall } from './hooks/pain.js';
|
|
|
5
5
|
import { handleBeforeReset, handleBeforeCompaction, handleAfterCompaction } from './hooks/lifecycle.js';
|
|
6
6
|
import { handleLlmOutput } from './hooks/llm.js';
|
|
7
7
|
import { handleSubagentEnded } from './hooks/subagent.js';
|
|
8
|
+
import { handleBeforeMessageWrite } from './hooks/message-sanitize.js';
|
|
8
9
|
import { handleInitStrategy, handleManageOkr } from './commands/strategy.js';
|
|
9
10
|
import { handleBootstrapTools, handleResearchTools } from './commands/capabilities.js';
|
|
10
11
|
import { handleThinkingOs } from './commands/thinking-os.js';
|
|
11
12
|
import { handleEvolveTask } from './commands/evolver.js';
|
|
12
13
|
import { handleTrustCommand } from './commands/trust.js';
|
|
13
14
|
import { handlePainCommand } from './commands/pain.js';
|
|
15
|
+
import { handleContextCommand } from './commands/context.js';
|
|
16
|
+
import { handleFocusCommand } from './commands/focus.js';
|
|
17
|
+
import { handleRollbackCommand } from './commands/rollback.js';
|
|
18
|
+
import { handleEvolutionStatusCommand } from './commands/evolution-status.js';
|
|
19
|
+
import { handlePrincipleRollbackCommand } from './commands/principle-rollback.js';
|
|
20
|
+
import { handleExportCommand } from './commands/export.js';
|
|
21
|
+
import { handleSamplesCommand } from './commands/samples.js';
|
|
14
22
|
import { EvolutionWorkerService } from './service/evolution-worker.js';
|
|
23
|
+
import { TrajectoryService } from './service/trajectory-service.js';
|
|
15
24
|
import { ensureWorkspaceTemplates } from './core/init.js';
|
|
16
25
|
import { migrateDirectoryStructure } from './core/migration.js';
|
|
17
26
|
import { SystemLogger } from './core/system-logger.js';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
27
|
+
import { createDeepReflectTool } from './tools/deep-reflect.js';
|
|
28
|
+
import { createAgentSpawnTool } from './tools/agent-spawn.js';
|
|
29
|
+
import { PathResolver } from './core/path-resolver.js';
|
|
30
|
+
import { createPrinciplesConsoleRoute } from './http/principles-console-route.js';
|
|
20
31
|
// Track initialization to avoid repeated calls
|
|
21
32
|
let workspaceInitialized = false;
|
|
22
33
|
const plugin = {
|
|
@@ -24,6 +35,8 @@ const plugin = {
|
|
|
24
35
|
description: "Evolutionary programming agent framework with strategic guardrails and reflection loops.",
|
|
25
36
|
register(api) {
|
|
26
37
|
api.logger.info("Principles Disciple Plugin registered.");
|
|
38
|
+
PathResolver.setExtensionRoot(api.rootDir);
|
|
39
|
+
api.registerHttpRoute(createPrinciplesConsoleRoute(api));
|
|
27
40
|
const language = api.pluginConfig?.language || 'en';
|
|
28
41
|
// ── Hook: Prompt Building ──
|
|
29
42
|
api.on('before_prompt_build', async (event, ctx) => {
|
|
@@ -75,6 +88,15 @@ const plugin = {
|
|
|
75
88
|
api.logger.error(`[PD] Error in llm_output: ${String(err)}`);
|
|
76
89
|
}
|
|
77
90
|
});
|
|
91
|
+
// ── Hook: Message Sanitization ──
|
|
92
|
+
api.on('before_message_write', (event) => {
|
|
93
|
+
try {
|
|
94
|
+
return handleBeforeMessageWrite(event);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
api.logger.error(`[PD] Error in before_message_write: ${String(err)}`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
78
100
|
// ── Hook: Subagent Loop Closure ──
|
|
79
101
|
api.on('subagent_spawning', (_event, _ctx) => {
|
|
80
102
|
// No-op for now, just to satisfy the interface expected by tests.
|
|
@@ -83,7 +105,7 @@ const plugin = {
|
|
|
83
105
|
api.on('subagent_ended', (event, ctx) => {
|
|
84
106
|
try {
|
|
85
107
|
const workspaceDir = api.resolvePath('.');
|
|
86
|
-
handleSubagentEnded(event, { ...ctx, workspaceDir });
|
|
108
|
+
handleSubagentEnded(event, { ...ctx, workspaceDir, api });
|
|
87
109
|
}
|
|
88
110
|
catch (err) {
|
|
89
111
|
api.logger.error(`[PD] Error in subagent_ended: ${String(err)}`);
|
|
@@ -106,6 +128,7 @@ const plugin = {
|
|
|
106
128
|
try {
|
|
107
129
|
EvolutionWorkerService.api = api;
|
|
108
130
|
api.registerService(EvolutionWorkerService);
|
|
131
|
+
api.registerService(TrajectoryService);
|
|
109
132
|
}
|
|
110
133
|
catch (err) {
|
|
111
134
|
api.logger.error(`[PD] Failed to register EvolutionWorkerService: ${String(err)}`);
|
|
@@ -165,9 +188,124 @@ const plugin = {
|
|
|
165
188
|
name: "pd-help",
|
|
166
189
|
description: getCommandDescription('pd-help', language),
|
|
167
190
|
handler: (_ctx) => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
191
|
+
if (language === 'zh') {
|
|
192
|
+
return { text: `
|
|
193
|
+
📖 **Principles Disciple 命令大全**
|
|
194
|
+
|
|
195
|
+
## 🚀 快速开始
|
|
196
|
+
| 命令 | 用途 | 使用时机 |
|
|
197
|
+
|------|------|----------|
|
|
198
|
+
| \`/pd-init\` | 初始化工作区 | 新项目开始时 |
|
|
199
|
+
| \`/pd-bootstrap\` | 环境工具扫描 | 缺少开发工具时 |
|
|
200
|
+
|
|
201
|
+
## 📊 状态查询
|
|
202
|
+
| 命令 | 用途 | 使用时机 |
|
|
203
|
+
|------|------|----------|
|
|
204
|
+
| \`/pd-status\` | 查看进化状态 | 想了解当前 GFI 和 Pain 情况 |
|
|
205
|
+
| \`/pd-trust\` | 查看信任分数 | 想知道自己的权限等级 |
|
|
206
|
+
| \`/pd-focus\` | 焦点文件管理 | 查看/压缩/回滚历史版本 |
|
|
207
|
+
| \`/pd-export\` | 导出分析/样本 | 导出 analytics 或纠错样本 |
|
|
208
|
+
| \`/pd-samples\` | 审核纠错样本 | 查看待审核样本并批准/拒绝 |
|
|
209
|
+
|
|
210
|
+
## ⚙️ 配置管理
|
|
211
|
+
| 命令 | 用途 | 使用时机 |
|
|
212
|
+
|------|------|----------|
|
|
213
|
+
| \`/pd-context\` | 控制上下文注入 | 想减少/增加注入内容 |
|
|
214
|
+
| \`/pd-okr\` | OKR 目标管理 | 设置战略目标 |
|
|
215
|
+
|
|
216
|
+
## 🧠 进化相关
|
|
217
|
+
| 命令 | 用途 | 使用时机 |
|
|
218
|
+
|------|------|----------|
|
|
219
|
+
| \`/pd-evolve\` | 执行进化循环 | 有 Pain 需要处理时 |
|
|
220
|
+
| \`/pd-thinking\` | 思维模型管理 | 更新 Thinking OS |
|
|
221
|
+
| \`/pd-daily\` | 进化日报 | 每日回顾时 |
|
|
222
|
+
| \`/pd-grooming\` | 工作区大扫除 | 定期清理 |
|
|
223
|
+
|
|
224
|
+
## 💡 常用命令示例
|
|
225
|
+
|
|
226
|
+
**减少 token 消耗:**
|
|
227
|
+
\`\`\`
|
|
228
|
+
/pd-context minimal
|
|
229
|
+
\`\`\`
|
|
230
|
+
|
|
231
|
+
**恢复完整上下文:**
|
|
232
|
+
\`\`\`
|
|
233
|
+
/pd-context full
|
|
234
|
+
\`\`\`
|
|
235
|
+
|
|
236
|
+
**查看当前配置:**
|
|
237
|
+
\`\`\`
|
|
238
|
+
/pd-context status
|
|
239
|
+
\`\`\`
|
|
240
|
+
|
|
241
|
+
**查看信任分数:**
|
|
242
|
+
\`\`\`
|
|
243
|
+
/pd-trust
|
|
244
|
+
\`\`\`
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
🔍 输入任意命令后加 \`help\` 可查看详细帮助,如 \`/pd-context help\`
|
|
248
|
+
`.trim() };
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
return { text: `
|
|
252
|
+
📖 **Principles Disciple Command Reference**
|
|
253
|
+
|
|
254
|
+
## 🚀 Quick Start
|
|
255
|
+
| Command | Purpose | When to Use |
|
|
256
|
+
|---------|---------|-------------|
|
|
257
|
+
| \`/pd-init\` | Initialize workspace | Starting a new project |
|
|
258
|
+
| \`/pd-bootstrap\` | Scan environment tools | Missing dev tools |
|
|
259
|
+
|
|
260
|
+
## 📊 Status Query
|
|
261
|
+
| Command | Purpose | When to Use |
|
|
262
|
+
|---------|---------|-------------|
|
|
263
|
+
| \`/pd-status\` | View evolution status | Check GFI and Pain status |
|
|
264
|
+
| \`/pd-trust\` | View trust score | Check your permission level |
|
|
265
|
+
| \`/pd-focus\` | Focus file management | View/compress/rollback history |
|
|
266
|
+
| \`/pd-export\` | Export analytics/samples | Export analytics or correction samples |
|
|
267
|
+
| \`/pd-samples\` | Review correction samples | Review pending correction samples |
|
|
268
|
+
|
|
269
|
+
## ⚙️ Configuration
|
|
270
|
+
| Command | Purpose | When to Use |
|
|
271
|
+
|---------|---------|-------------|
|
|
272
|
+
| \`/pd-context\` | Control context injection | Reduce/increase injected content |
|
|
273
|
+
| \`/pd-okr\` | OKR goal management | Set strategic goals |
|
|
274
|
+
|
|
275
|
+
## 🧠 Evolution
|
|
276
|
+
| Command | Purpose | When to Use |
|
|
277
|
+
|---------|---------|-------------|
|
|
278
|
+
| \`/pd-evolve\` | Run evolution loop | Process Pain signals |
|
|
279
|
+
| \`/pd-thinking\` | Mental model management | Update Thinking OS |
|
|
280
|
+
| \`/pd-daily\` | Evolution report | Daily review |
|
|
281
|
+
| \`/pd-grooming\` | Workspace cleanup | Periodic cleanup |
|
|
282
|
+
|
|
283
|
+
## 💡 Common Examples
|
|
284
|
+
|
|
285
|
+
**Reduce token usage:**
|
|
286
|
+
\`\`\`
|
|
287
|
+
/pd-context minimal
|
|
288
|
+
\`\`\`
|
|
289
|
+
|
|
290
|
+
**Restore full context:**
|
|
291
|
+
\`\`\`
|
|
292
|
+
/pd-context full
|
|
293
|
+
\`\`\`
|
|
294
|
+
|
|
295
|
+
**View current config:**
|
|
296
|
+
\`\`\`
|
|
297
|
+
/pd-context status
|
|
298
|
+
\`\`\`
|
|
299
|
+
|
|
300
|
+
**Check trust score:**
|
|
301
|
+
\`\`\`
|
|
302
|
+
/pd-trust
|
|
303
|
+
\`\`\`
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
🔍 Add \`help\` after any command for details, e.g., \`/pd-context help\`
|
|
307
|
+
`.trim() };
|
|
308
|
+
}
|
|
171
309
|
}
|
|
172
310
|
});
|
|
173
311
|
api.registerCommand({
|
|
@@ -196,9 +334,127 @@ const plugin = {
|
|
|
196
334
|
}
|
|
197
335
|
}
|
|
198
336
|
});
|
|
337
|
+
api.registerCommand({
|
|
338
|
+
name: "pd-context",
|
|
339
|
+
description: getCommandDescription('pd-context', language),
|
|
340
|
+
acceptsArgs: true,
|
|
341
|
+
handler: (ctx) => {
|
|
342
|
+
try {
|
|
343
|
+
const workspaceDir = api.resolvePath('.');
|
|
344
|
+
if (ctx.config)
|
|
345
|
+
ctx.config.workspaceDir = workspaceDir;
|
|
346
|
+
return handleContextCommand(ctx);
|
|
347
|
+
}
|
|
348
|
+
catch (err) {
|
|
349
|
+
api.logger.error(`[PD] Command /pd-context failed: ${String(err)}`);
|
|
350
|
+
return { text: language === 'zh' ? "命令执行失败,请检查日志。" : "Command failed. Check logs." };
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
api.registerCommand({
|
|
355
|
+
name: "pd-focus",
|
|
356
|
+
description: getCommandDescription('pd-focus', language),
|
|
357
|
+
acceptsArgs: true,
|
|
358
|
+
handler: (ctx) => {
|
|
359
|
+
try {
|
|
360
|
+
const workspaceDir = api.resolvePath('.');
|
|
361
|
+
if (ctx.config)
|
|
362
|
+
ctx.config.workspaceDir = workspaceDir;
|
|
363
|
+
return handleFocusCommand(ctx, api);
|
|
364
|
+
}
|
|
365
|
+
catch (err) {
|
|
366
|
+
api.logger.error(`[PD] Command /pd-focus failed: ${String(err)}`);
|
|
367
|
+
return { text: language === 'zh' ? "命令执行失败,请检查日志。" : "Command failed. Check logs." };
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
api.registerCommand({
|
|
372
|
+
name: "pd-evolution-status",
|
|
373
|
+
description: getCommandDescription('pd-evolution-status', language),
|
|
374
|
+
handler: (ctx) => {
|
|
375
|
+
try {
|
|
376
|
+
const workspaceDir = api.resolvePath('.');
|
|
377
|
+
if (ctx.config)
|
|
378
|
+
ctx.config.workspaceDir = workspaceDir;
|
|
379
|
+
return handleEvolutionStatusCommand(ctx);
|
|
380
|
+
}
|
|
381
|
+
catch (err) {
|
|
382
|
+
api.logger.error(`[PD] Command /pd-evolution-status failed: ${String(err)}`);
|
|
383
|
+
return { text: language === 'zh' ? "命令执行失败,请检查日志。" : "Command failed. Check logs." };
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
api.registerCommand({
|
|
388
|
+
name: "pd-principle-rollback",
|
|
389
|
+
description: getCommandDescription('pd-principle-rollback', language),
|
|
390
|
+
acceptsArgs: true,
|
|
391
|
+
handler: (ctx) => {
|
|
392
|
+
try {
|
|
393
|
+
const workspaceDir = api.resolvePath('.');
|
|
394
|
+
if (ctx.config)
|
|
395
|
+
ctx.config.workspaceDir = workspaceDir;
|
|
396
|
+
return handlePrincipleRollbackCommand(ctx);
|
|
397
|
+
}
|
|
398
|
+
catch (err) {
|
|
399
|
+
api.logger.error(`[PD] Command /pd-principle-rollback failed: ${String(err)}`);
|
|
400
|
+
return { text: language === 'zh' ? "命令执行失败,请检查日志。" : "Command failed. Check logs." };
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
api.registerCommand({
|
|
405
|
+
name: "pd-rollback",
|
|
406
|
+
description: getCommandDescription('pd-rollback', language),
|
|
407
|
+
acceptsArgs: true,
|
|
408
|
+
handler: (ctx) => {
|
|
409
|
+
try {
|
|
410
|
+
const workspaceDir = api.resolvePath('.');
|
|
411
|
+
if (ctx.config)
|
|
412
|
+
ctx.config.workspaceDir = workspaceDir;
|
|
413
|
+
return handleRollbackCommand(ctx);
|
|
414
|
+
}
|
|
415
|
+
catch (err) {
|
|
416
|
+
api.logger.error(`[PD] Command /pd-rollback failed: ${String(err)}`);
|
|
417
|
+
return { text: language === 'zh' ? "命令执行失败,请检查日志。" : "Command failed. Check logs." };
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
});
|
|
199
421
|
// ── Tools ──
|
|
200
|
-
api.
|
|
201
|
-
|
|
422
|
+
api.registerCommand({
|
|
423
|
+
name: "pd-export",
|
|
424
|
+
description: getCommandDescription('pd-export', language),
|
|
425
|
+
acceptsArgs: true,
|
|
426
|
+
handler: (ctx) => {
|
|
427
|
+
try {
|
|
428
|
+
const workspaceDir = api.resolvePath('.');
|
|
429
|
+
if (ctx.config)
|
|
430
|
+
ctx.config.workspaceDir = workspaceDir;
|
|
431
|
+
return handleExportCommand(ctx);
|
|
432
|
+
}
|
|
433
|
+
catch (err) {
|
|
434
|
+
api.logger.error(`[PD] Command /pd-export failed: ${String(err)}`);
|
|
435
|
+
return { text: language === 'zh' ? "导出失败,请检查日志。" : "Export failed. Check logs." };
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
api.registerCommand({
|
|
440
|
+
name: "pd-samples",
|
|
441
|
+
description: getCommandDescription('pd-samples', language),
|
|
442
|
+
acceptsArgs: true,
|
|
443
|
+
handler: (ctx) => {
|
|
444
|
+
try {
|
|
445
|
+
const workspaceDir = api.resolvePath('.');
|
|
446
|
+
if (ctx.config)
|
|
447
|
+
ctx.config.workspaceDir = workspaceDir;
|
|
448
|
+
return handleSamplesCommand(ctx);
|
|
449
|
+
}
|
|
450
|
+
catch (err) {
|
|
451
|
+
api.logger.error(`[PD] Command /pd-samples failed: ${String(err)}`);
|
|
452
|
+
return { text: language === 'zh' ? "样本命令执行失败,请检查日志。" : "Samples command failed. Check logs." };
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
api.registerTool(createDeepReflectTool(api));
|
|
457
|
+
api.registerTool(createAgentSpawnTool(api));
|
|
202
458
|
}
|
|
203
459
|
};
|
|
204
460
|
export default plugin;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export interface OverviewResponse {
|
|
2
|
+
workspaceDir: string;
|
|
3
|
+
generatedAt: string;
|
|
4
|
+
dataFreshness: string | null;
|
|
5
|
+
summary: {
|
|
6
|
+
repeatErrorRate: number;
|
|
7
|
+
userCorrectionRate: number;
|
|
8
|
+
pendingSamples: number;
|
|
9
|
+
approvedSamples: number;
|
|
10
|
+
thinkingCoverageRate: number;
|
|
11
|
+
painEvents: number;
|
|
12
|
+
principleEventCount: number;
|
|
13
|
+
};
|
|
14
|
+
dailyTrend: Array<{
|
|
15
|
+
day: string;
|
|
16
|
+
toolCalls: number;
|
|
17
|
+
failures: number;
|
|
18
|
+
userCorrections: number;
|
|
19
|
+
thinkingTurns: number;
|
|
20
|
+
}>;
|
|
21
|
+
topRegressions: Array<{
|
|
22
|
+
toolName: string;
|
|
23
|
+
errorType: string;
|
|
24
|
+
occurrences: number;
|
|
25
|
+
}>;
|
|
26
|
+
sampleQueue: {
|
|
27
|
+
counters: Record<string, number>;
|
|
28
|
+
preview: Array<{
|
|
29
|
+
sampleId: string;
|
|
30
|
+
sessionId: string;
|
|
31
|
+
qualityScore: number;
|
|
32
|
+
reviewStatus: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
thinkingSummary: {
|
|
37
|
+
activeModels: number;
|
|
38
|
+
dormantModels: number;
|
|
39
|
+
effectiveModels: number;
|
|
40
|
+
coverageRate: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface SampleListFilters {
|
|
44
|
+
status?: string;
|
|
45
|
+
qualityMin?: number;
|
|
46
|
+
dateFrom?: string;
|
|
47
|
+
dateTo?: string;
|
|
48
|
+
failureMode?: string;
|
|
49
|
+
page?: number;
|
|
50
|
+
pageSize?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface SamplesResponse {
|
|
53
|
+
counters: Record<string, number>;
|
|
54
|
+
items: Array<{
|
|
55
|
+
sampleId: string;
|
|
56
|
+
sessionId: string;
|
|
57
|
+
reviewStatus: string;
|
|
58
|
+
qualityScore: number;
|
|
59
|
+
failureMode: string;
|
|
60
|
+
relatedThinkingCount: number;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
diffExcerpt: string;
|
|
64
|
+
}>;
|
|
65
|
+
pagination: {
|
|
66
|
+
page: number;
|
|
67
|
+
pageSize: number;
|
|
68
|
+
total: number;
|
|
69
|
+
totalPages: number;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export interface SampleDetailResponse {
|
|
73
|
+
sampleId: string;
|
|
74
|
+
sessionId: string;
|
|
75
|
+
reviewStatus: string;
|
|
76
|
+
qualityScore: number;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
badAttempt: {
|
|
80
|
+
assistantTurnId: number;
|
|
81
|
+
rawText: string;
|
|
82
|
+
sanitizedText: string;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
};
|
|
85
|
+
userCorrection: {
|
|
86
|
+
userTurnId: number;
|
|
87
|
+
rawText: string;
|
|
88
|
+
correctionCue: string | null;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
};
|
|
91
|
+
recoveryToolSpan: Array<{
|
|
92
|
+
id: number;
|
|
93
|
+
toolName: string;
|
|
94
|
+
}>;
|
|
95
|
+
relatedPrinciples: Array<{
|
|
96
|
+
principleId: string | null;
|
|
97
|
+
eventType: string;
|
|
98
|
+
createdAt: string;
|
|
99
|
+
}>;
|
|
100
|
+
relatedThinkingHits: Array<{
|
|
101
|
+
id: number;
|
|
102
|
+
modelId: string;
|
|
103
|
+
modelName: string;
|
|
104
|
+
matchedPattern: string;
|
|
105
|
+
scenarios: string[];
|
|
106
|
+
createdAt: string;
|
|
107
|
+
triggerExcerpt: string;
|
|
108
|
+
}>;
|
|
109
|
+
reviewHistory: Array<{
|
|
110
|
+
reviewStatus: string;
|
|
111
|
+
note: string | null;
|
|
112
|
+
createdAt: string;
|
|
113
|
+
}>;
|
|
114
|
+
}
|
|
115
|
+
export interface ThinkingModelSummary {
|
|
116
|
+
modelId: string;
|
|
117
|
+
name: string;
|
|
118
|
+
description: string;
|
|
119
|
+
hits: number;
|
|
120
|
+
coverageRate: number;
|
|
121
|
+
successRate: number;
|
|
122
|
+
failureRate: number;
|
|
123
|
+
painRate: number;
|
|
124
|
+
correctionRate: number;
|
|
125
|
+
correctionSampleRate: number;
|
|
126
|
+
commonScenarios: string[];
|
|
127
|
+
recommendation: 'reinforce' | 'rework' | 'archive';
|
|
128
|
+
}
|
|
129
|
+
export interface ThinkingOverviewResponse {
|
|
130
|
+
summary: {
|
|
131
|
+
totalModels: number;
|
|
132
|
+
activeModels: number;
|
|
133
|
+
dormantModels: number;
|
|
134
|
+
effectiveModels: number;
|
|
135
|
+
coverageRate: number;
|
|
136
|
+
};
|
|
137
|
+
topModels: ThinkingModelSummary[];
|
|
138
|
+
dormantModels: Array<{
|
|
139
|
+
modelId: string;
|
|
140
|
+
name: string;
|
|
141
|
+
description: string;
|
|
142
|
+
}>;
|
|
143
|
+
effectiveModels: ThinkingModelSummary[];
|
|
144
|
+
scenarioMatrix: Array<{
|
|
145
|
+
modelId: string;
|
|
146
|
+
modelName: string;
|
|
147
|
+
scenario: string;
|
|
148
|
+
hits: number;
|
|
149
|
+
}>;
|
|
150
|
+
coverageTrend: Array<{
|
|
151
|
+
day: string;
|
|
152
|
+
assistantTurns: number;
|
|
153
|
+
thinkingTurns: number;
|
|
154
|
+
coverageRate: number;
|
|
155
|
+
}>;
|
|
156
|
+
}
|
|
157
|
+
export interface ThinkingModelDetailResponse {
|
|
158
|
+
modelMeta: {
|
|
159
|
+
modelId: string;
|
|
160
|
+
name: string;
|
|
161
|
+
description: string;
|
|
162
|
+
hits: number;
|
|
163
|
+
coverageRate: number;
|
|
164
|
+
recommendation: 'reinforce' | 'rework' | 'archive';
|
|
165
|
+
};
|
|
166
|
+
usageTrend: Array<{
|
|
167
|
+
day: string;
|
|
168
|
+
hits: number;
|
|
169
|
+
}>;
|
|
170
|
+
scenarioDistribution: Array<{
|
|
171
|
+
scenario: string;
|
|
172
|
+
hits: number;
|
|
173
|
+
}>;
|
|
174
|
+
outcomeStats: {
|
|
175
|
+
events: number;
|
|
176
|
+
successRate: number;
|
|
177
|
+
failureRate: number;
|
|
178
|
+
painRate: number;
|
|
179
|
+
correctionRate: number;
|
|
180
|
+
correctionSampleRate: number;
|
|
181
|
+
};
|
|
182
|
+
recentEvents: Array<{
|
|
183
|
+
id: number;
|
|
184
|
+
createdAt: string;
|
|
185
|
+
matchedPattern: string;
|
|
186
|
+
scenarios: string[];
|
|
187
|
+
triggerExcerpt: string;
|
|
188
|
+
toolContext: Array<{
|
|
189
|
+
toolName: string;
|
|
190
|
+
outcome: string;
|
|
191
|
+
errorType?: string | null;
|
|
192
|
+
}>;
|
|
193
|
+
painContext: Array<{
|
|
194
|
+
source: string;
|
|
195
|
+
score: number;
|
|
196
|
+
}>;
|
|
197
|
+
principleContext: Array<{
|
|
198
|
+
principleId: string | null;
|
|
199
|
+
eventType: string;
|
|
200
|
+
}>;
|
|
201
|
+
}>;
|
|
202
|
+
}
|
|
203
|
+
export declare class ControlUiQueryService {
|
|
204
|
+
private readonly workspaceDir;
|
|
205
|
+
private readonly trajectory;
|
|
206
|
+
private readonly uiDb;
|
|
207
|
+
constructor(workspaceDir: string);
|
|
208
|
+
dispose(): void;
|
|
209
|
+
getOverview(): OverviewResponse;
|
|
210
|
+
listSamples(filters?: SampleListFilters): SamplesResponse;
|
|
211
|
+
getSampleDetail(sampleId: string): SampleDetailResponse | null;
|
|
212
|
+
reviewSample(sampleId: string, decision: 'approved' | 'rejected', note?: string): import("../core/trajectory.js").CorrectionSampleRecord;
|
|
213
|
+
exportCorrections(mode: 'raw' | 'redacted'): import("../core/trajectory.js").TrajectoryExportResult;
|
|
214
|
+
getThinkingOverview(): ThinkingOverviewResponse;
|
|
215
|
+
getThinkingModelDetail(modelId: string): ThinkingModelDetailResponse | null;
|
|
216
|
+
private loadThinkingModelSummaries;
|
|
217
|
+
}
|