create-principles-disciple 1.135.1 → 1.136.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/core/dist/runtime-v2/__tests__/architecture-regression.test.js +5 -3
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/dist/commands/errors-list.d.ts.map +1 -1
- package/pd-cli/dist/commands/errors-list.js +9 -10
- package/pd-cli/dist/commands/errors-list.js.map +1 -1
- package/pd-cli/dist/commands/pain-list.d.ts +14 -0
- package/pd-cli/dist/commands/pain-list.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-list.js +28 -1
- package/pd-cli/dist/commands/pain-list.js.map +1 -1
- package/pd-cli/dist/commands/pain-record.d.ts +2 -0
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +71 -4
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/runtime-init.d.ts +3 -1
- package/pd-cli/dist/commands/runtime-init.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-init.js +7 -47
- package/pd-cli/dist/commands/runtime-init.js.map +1 -1
- package/pd-cli/dist/index.js +2 -1
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +562 -682
- package/plugin/dist/config/defaults/runtime.d.ts +0 -10
- package/plugin/dist/core/config.d.ts +0 -9
- package/plugin/dist/core/detection-funnel.d.ts +1 -1
- package/plugin/dist/core/paths.d.ts +0 -2
- package/plugin/dist/core/principle-tree-ledger.d.ts +1 -1
- package/plugin/dist/core/system-logger.d.ts +1 -3
- package/plugin/dist/index.d.ts +0 -10
- package/plugin/dist/rulehost-evidence.js +28 -28
- package/plugin/dist/service/keyword-optimization-service.d.ts +2 -2
- package/plugin/dist/templates/pain_settings.json +0 -5
- package/plugin/dist/utils/trace-id.d.ts +9 -0
- package/plugin/docs/COMMAND_REFERENCE.md +2 -3
- package/plugin/docs/COMMAND_REFERENCE_EN.md +1 -2
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/templates/pain_settings.json +0 -5
- package/release-manager/package.json +2 -2
- package/plugin/dist/commands/workflow-debug.d.ts +0 -4
- package/plugin/dist/core/evolution-engine.d.ts +0 -119
- package/plugin/dist/core/evolution-logger.d.ts +0 -137
- package/plugin/dist/service/evolution-dedup.d.ts +0 -27
- package/plugin/dist/service/evolution-worker.d.ts +0 -105
- package/plugin/dist/service/queue-io.d.ts +0 -30
- package/plugin/dist/service/queue-migration.d.ts +0 -84
- package/plugin/dist/service/subagent-workflow/subagent-error-utils.d.ts +0 -8
- package/plugin/dist/service/subagent-workflow/types.d.ts +0 -264
- package/plugin/dist/service/subagent-workflow/workflow-store.d.ts +0 -44
- package/plugin/dist/service/workflow-watchdog.d.ts +0 -23
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Keyword Optimization Service
|
|
3
3
|
*
|
|
4
4
|
* Applies LLM optimization results (ADD/UPDATE/REMOVE mutations) to the
|
|
5
|
-
* correction keyword store.
|
|
6
|
-
*
|
|
5
|
+
* correction keyword store. Invoked by the correction observer service
|
|
6
|
+
* when optimization results are available.
|
|
7
7
|
*/
|
|
8
8
|
import type { CorrectionObserverOutputV1 as CorrectionObserverResult } from '@principles/core/runtime-v2';
|
|
9
9
|
import type { PluginLogger } from '../openclaw-sdk.js';
|
|
@@ -50,6 +50,5 @@
|
|
|
50
50
|
|
|
51
51
|
1. `user_empathy` / `system_infer` 是否稳定进入 `events.jsonl`
|
|
52
52
|
2. rollback 是否只影响 empathy slice
|
|
53
|
-
3. `
|
|
54
|
-
4.
|
|
55
|
-
5. EP 积累是否正常驱动等级提升
|
|
53
|
+
3. summary 是否仍然需要 `partial` 警告才能解释当前状态
|
|
54
|
+
4. EP 积累是否正常驱动等级提升
|
|
@@ -51,7 +51,6 @@ Before entering new capability phases, check daily:
|
|
|
51
51
|
1. EP tier and queue are functioning correctly
|
|
52
52
|
2. `user_empathy` and `system_infer` appear in `events.jsonl`
|
|
53
53
|
3. rollback affects only the empathy slice
|
|
54
|
-
4.
|
|
55
|
-
5. summary warnings still accurately explain partial data quality
|
|
54
|
+
4. summary warnings still accurately explain partial data quality
|
|
56
55
|
|
|
57
56
|
(End of file - total 84 lines)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.235.0",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
package/plugin/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "principles-disciple",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.235.0",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-principles-disciple",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.136.0",
|
|
4
4
|
"description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"directory": "packages/create-principles-disciple"
|
|
75
75
|
},
|
|
76
76
|
"pd": {
|
|
77
|
-
"bundledPluginVersion": "1.
|
|
77
|
+
"bundledPluginVersion": "1.235.0"
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Evolution Engine V2.0 - MVP
|
|
3
|
-
*
|
|
4
|
-
* 成长驱动的进化积分系统,替代惩罚驱动的 Trust Engine。
|
|
5
|
-
*
|
|
6
|
-
* 核心原则:
|
|
7
|
-
* 1. 起点0分,只能增加,不扣分
|
|
8
|
-
* 2. 失败记录教训,不扣分
|
|
9
|
-
* 3. 同类任务失败后首次成功 = 双倍奖励(1小时冷却)
|
|
10
|
-
* 4. 高等级做低级任务积分衰减
|
|
11
|
-
* 5. 原子写入防止并发损坏
|
|
12
|
-
*/
|
|
13
|
-
import type { EvolutionScorecard, EvolutionStats, EvolutionConfig, TaskDifficulty, TierDefinition, GateDecision, ToolCallContext } from './evolution-types.js';
|
|
14
|
-
import { EvolutionTier } from './evolution-types.js';
|
|
15
|
-
export declare class EvolutionEngine {
|
|
16
|
-
private readonly scorecard;
|
|
17
|
-
private readonly workspaceDir;
|
|
18
|
-
private readonly stateDir;
|
|
19
|
-
private readonly config;
|
|
20
|
-
private readonly storagePath;
|
|
21
|
-
constructor(workspaceDir: string, config?: Partial<EvolutionConfig>);
|
|
22
|
-
/** 获取当前积分 */
|
|
23
|
-
getPoints(): number;
|
|
24
|
-
/** 获取可用积分 */
|
|
25
|
-
getAvailablePoints(): number;
|
|
26
|
-
/** 获取当前等级 */
|
|
27
|
-
getTier(): EvolutionTier;
|
|
28
|
-
/** 获取当前等级定义 */
|
|
29
|
-
getTierDefinition(): TierDefinition;
|
|
30
|
-
/** 获取完整积分卡 */
|
|
31
|
-
getScorecard(): EvolutionScorecard;
|
|
32
|
-
/** 获取统计信息 */
|
|
33
|
-
getStats(): EvolutionStats;
|
|
34
|
-
/** 获取状态摘要 */
|
|
35
|
-
getStatusSummary(): {
|
|
36
|
-
tier: EvolutionTier;
|
|
37
|
-
tierName: string;
|
|
38
|
-
totalPoints: number;
|
|
39
|
-
availablePoints: number;
|
|
40
|
-
permissions: import("@principles/core/runtime-v2").TierPermissions;
|
|
41
|
-
stats: EvolutionStats;
|
|
42
|
-
nextTier: {
|
|
43
|
-
tier: EvolutionTier;
|
|
44
|
-
name: string;
|
|
45
|
-
pointsNeeded: number;
|
|
46
|
-
} | null;
|
|
47
|
-
};
|
|
48
|
-
recordSuccess(toolName: string, options?: {
|
|
49
|
-
filePath?: string;
|
|
50
|
-
difficulty?: TaskDifficulty;
|
|
51
|
-
reason?: string;
|
|
52
|
-
sessionId?: string;
|
|
53
|
-
}): {
|
|
54
|
-
pointsAwarded: number;
|
|
55
|
-
isDoubleReward: boolean;
|
|
56
|
-
newTier?: EvolutionTier;
|
|
57
|
-
};
|
|
58
|
-
recordFailure(toolName: string, options?: {
|
|
59
|
-
filePath?: string;
|
|
60
|
-
difficulty?: TaskDifficulty;
|
|
61
|
-
reason?: string;
|
|
62
|
-
sessionId?: string;
|
|
63
|
-
}): {
|
|
64
|
-
pointsAwarded: number;
|
|
65
|
-
lessonRecorded: boolean;
|
|
66
|
-
};
|
|
67
|
-
/** 工具调用前检查 */
|
|
68
|
-
beforeToolCall(context: ToolCallContext): GateDecision;
|
|
69
|
-
private calculatePoints;
|
|
70
|
-
private getDifficultyPenalty;
|
|
71
|
-
private canReceiveDoubleReward;
|
|
72
|
-
private checkAndApplyPromotion;
|
|
73
|
-
private static inferDifficulty;
|
|
74
|
-
private static computeTaskHash;
|
|
75
|
-
private createEvent;
|
|
76
|
-
private addEvent;
|
|
77
|
-
private loadOrCreateScorecard;
|
|
78
|
-
private createNewScorecard;
|
|
79
|
-
/** 持久化评分卡(含锁保护) */
|
|
80
|
-
private saveScorecard;
|
|
81
|
-
/** Per-instance retry queue (P0 fix: was static, causing cross-instance race) */
|
|
82
|
-
private retryQueue;
|
|
83
|
-
private retryTimer;
|
|
84
|
-
/** 调度重试保存 */
|
|
85
|
-
private scheduleRetrySave;
|
|
86
|
-
/** 处理重试队列 */
|
|
87
|
-
private processRetryQueue;
|
|
88
|
-
/** 无锁快速保存(用于重试) */
|
|
89
|
-
private saveScorecardImmediate;
|
|
90
|
-
private generateId;
|
|
91
|
-
dispose(): void;
|
|
92
|
-
}
|
|
93
|
-
/** 获取指定 workspace 的引擎实例 */
|
|
94
|
-
export declare function getEvolutionEngine(workspaceDir: string): EvolutionEngine;
|
|
95
|
-
export declare function disposeEvolutionEngine(workspaceDir: string): void;
|
|
96
|
-
export declare function disposeAllEvolutionEngines(): void;
|
|
97
|
-
/** 记录成功(便捷函数) */
|
|
98
|
-
export declare function recordEvolutionSuccess(workspaceDir: string, toolName: string, options?: {
|
|
99
|
-
filePath?: string;
|
|
100
|
-
difficulty?: TaskDifficulty;
|
|
101
|
-
reason?: string;
|
|
102
|
-
sessionId?: string;
|
|
103
|
-
}): {
|
|
104
|
-
pointsAwarded: number;
|
|
105
|
-
isDoubleReward: boolean;
|
|
106
|
-
newTier?: EvolutionTier;
|
|
107
|
-
};
|
|
108
|
-
/** 记录失败(便捷函数) */
|
|
109
|
-
export declare function recordEvolutionFailure(workspaceDir: string, toolName: string, options?: {
|
|
110
|
-
filePath?: string;
|
|
111
|
-
difficulty?: TaskDifficulty;
|
|
112
|
-
reason?: string;
|
|
113
|
-
sessionId?: string;
|
|
114
|
-
}): {
|
|
115
|
-
pointsAwarded: number;
|
|
116
|
-
lessonRecorded: boolean;
|
|
117
|
-
};
|
|
118
|
-
/** Gate 检查(便捷函数) */
|
|
119
|
-
export declare function checkEvolutionGate(workspaceDir: string, context: ToolCallContext): GateDecision;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EvolutionLogger - 进化流程日志服务
|
|
3
|
-
*
|
|
4
|
-
* 提供两层日志:
|
|
5
|
-
* - 技术层:结构化 JSON,包含 trace_id、stage、metadata
|
|
6
|
-
* - 用户层:中文摘要,便于小白用户理解
|
|
7
|
-
*
|
|
8
|
-
* 日志写入两个地方:
|
|
9
|
-
* 1. SYSTEM_LOG (system.jsonl) - 技术细节
|
|
10
|
-
* 2. evolution_events 表 (SQLite) - 结构化查询
|
|
11
|
-
*/
|
|
12
|
-
import type { TrajectoryDatabase } from './trajectory.js';
|
|
13
|
-
export type EvolutionStage = 'pain_detected' | 'queued' | 'started' | 'analyzing' | 'principle_generated' | 'completed' | 'failed';
|
|
14
|
-
export type EvolutionLogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
15
|
-
export interface EvolutionLogEntry {
|
|
16
|
-
traceId: string;
|
|
17
|
-
stage: EvolutionStage;
|
|
18
|
-
level: EvolutionLogLevel;
|
|
19
|
-
message: string;
|
|
20
|
-
summary: string;
|
|
21
|
-
timestamp: string;
|
|
22
|
-
metadata?: Record<string, unknown>;
|
|
23
|
-
taskId?: string;
|
|
24
|
-
sessionId?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface EvolutionLogInput {
|
|
27
|
-
traceId: string;
|
|
28
|
-
stage: EvolutionStage;
|
|
29
|
-
level?: EvolutionLogLevel;
|
|
30
|
-
message: string;
|
|
31
|
-
summary: string;
|
|
32
|
-
metadata?: Record<string, unknown>;
|
|
33
|
-
taskId?: string;
|
|
34
|
-
sessionId?: string;
|
|
35
|
-
}
|
|
36
|
-
export declare const STAGE_LABELS: Record<EvolutionStage, string>;
|
|
37
|
-
export declare const STAGE_COLORS: Record<EvolutionStage, string>;
|
|
38
|
-
/**
|
|
39
|
-
* 创建新的 trace_id
|
|
40
|
-
* 格式: ev_{timestamp}_{random}
|
|
41
|
-
* 使用 crypto.randomBytes 确保不可预测性
|
|
42
|
-
*/
|
|
43
|
-
export declare function createTraceId(): string;
|
|
44
|
-
/**
|
|
45
|
-
* EvolutionLogger 类
|
|
46
|
-
* 管理进化流程的日志记录
|
|
47
|
-
*/
|
|
48
|
-
export declare class EvolutionLogger {
|
|
49
|
-
private readonly workspaceDir;
|
|
50
|
-
private readonly trajectory;
|
|
51
|
-
constructor(workspaceDir: string, trajectory?: TrajectoryDatabase);
|
|
52
|
-
/**
|
|
53
|
-
* 记录进化事件
|
|
54
|
-
* 同时写入 SYSTEM_LOG 和 evolution_events 表
|
|
55
|
-
*/
|
|
56
|
-
log(input: EvolutionLogInput): void;
|
|
57
|
-
/**
|
|
58
|
-
* 记录 pain_detected 事件
|
|
59
|
-
*/
|
|
60
|
-
logPainDetected(params: {
|
|
61
|
-
traceId: string;
|
|
62
|
-
source: string;
|
|
63
|
-
reason: string;
|
|
64
|
-
score: number;
|
|
65
|
-
toolName?: string;
|
|
66
|
-
filePath?: string;
|
|
67
|
-
sessionId?: string;
|
|
68
|
-
}): void;
|
|
69
|
-
/**
|
|
70
|
-
* 记录 queued 事件
|
|
71
|
-
*/
|
|
72
|
-
logQueued(params: {
|
|
73
|
-
traceId: string;
|
|
74
|
-
taskId: string;
|
|
75
|
-
score: number;
|
|
76
|
-
source: string;
|
|
77
|
-
reason: string;
|
|
78
|
-
}): void;
|
|
79
|
-
/**
|
|
80
|
-
* 记录 started 事件
|
|
81
|
-
*/
|
|
82
|
-
logStarted(params: {
|
|
83
|
-
traceId: string;
|
|
84
|
-
taskId: string;
|
|
85
|
-
}): void;
|
|
86
|
-
/**
|
|
87
|
-
* 记录 analyzing 事件
|
|
88
|
-
*/
|
|
89
|
-
logAnalyzing(params: {
|
|
90
|
-
traceId: string;
|
|
91
|
-
taskId: string;
|
|
92
|
-
analysisType?: string;
|
|
93
|
-
}): void;
|
|
94
|
-
/**
|
|
95
|
-
* 记录 principle_generated 事件
|
|
96
|
-
*/
|
|
97
|
-
logPrincipleGenerated(params: {
|
|
98
|
-
traceId: string;
|
|
99
|
-
taskId: string;
|
|
100
|
-
principleId: string;
|
|
101
|
-
principleText: string;
|
|
102
|
-
}): void;
|
|
103
|
-
/**
|
|
104
|
-
* 记录 completed 事件
|
|
105
|
-
*/
|
|
106
|
-
logCompleted(params: {
|
|
107
|
-
traceId: string;
|
|
108
|
-
taskId: string;
|
|
109
|
-
resolution: 'marker_detected' | 'auto_completed_timeout' | 'manual' | 'late_marker_principle_created' | 'late_marker_no_principle' | 'diagnostician_timeout' | 'noise_classified' | 'duplicate' | 'serverDuplicate';
|
|
110
|
-
durationMs?: number;
|
|
111
|
-
principlesGenerated?: number;
|
|
112
|
-
}): void;
|
|
113
|
-
/**
|
|
114
|
-
* 记录 failed 事件
|
|
115
|
-
*/
|
|
116
|
-
logFailed(params: {
|
|
117
|
-
traceId: string;
|
|
118
|
-
taskId: string;
|
|
119
|
-
error: string;
|
|
120
|
-
stack?: string;
|
|
121
|
-
}): void;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* 获取 EvolutionLogger 实例(单例)
|
|
125
|
-
*
|
|
126
|
-
* 注意:带 trajectory 和不带 trajectory 的请求会返回不同的实例,
|
|
127
|
-
* 因为 trajectory 影响事件持久化行为。
|
|
128
|
-
*/
|
|
129
|
-
export declare function getEvolutionLogger(workspaceDir: string, trajectory?: TrajectoryDatabase): EvolutionLogger;
|
|
130
|
-
/**
|
|
131
|
-
* 清理指定 workspace 的 logger 缓存
|
|
132
|
-
*/
|
|
133
|
-
export declare function disposeEvolutionLogger(workspaceDir: string): boolean;
|
|
134
|
-
/**
|
|
135
|
-
* 清理所有 logger 缓存(用于测试或进程退出)
|
|
136
|
-
*/
|
|
137
|
-
export declare function disposeAllEvolutionLoggers(): void;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Evolution Queue Deduplication Utilities
|
|
3
|
-
*
|
|
4
|
-
* Dedup logic for preventing duplicate pain tasks and redundant reflections.
|
|
5
|
-
* Extracted from evolution-worker.ts.
|
|
6
|
-
*/
|
|
7
|
-
import type { EvolutionQueueItem } from '../core/evolution-types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Dedup window for pain queue tasks (30 minutes).
|
|
10
|
-
*/
|
|
11
|
-
export declare const PAIN_QUEUE_DEDUP_WINDOW_MS: number;
|
|
12
|
-
export declare function findRecentDuplicateTask(queue: EvolutionQueueItem[], source: string, preview: string, now: number, reason?: string): EvolutionQueueItem | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Check if a similar pain task was enqueued recently.
|
|
15
|
-
*/
|
|
16
|
-
export declare function hasRecentDuplicateTask(queue: EvolutionQueueItem[], source: string, preview: string, now: number, reason?: string): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Check if a phrase matches an active promoted rule.
|
|
19
|
-
*/
|
|
20
|
-
export declare function hasEquivalentPromotedRule(dictionary: {
|
|
21
|
-
getAllRules(): Record<string, {
|
|
22
|
-
type: string;
|
|
23
|
-
phrases?: string[];
|
|
24
|
-
pattern?: string;
|
|
25
|
-
status: string;
|
|
26
|
-
}>;
|
|
27
|
-
}, phrase: string): boolean;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { OpenClawPluginServiceContext, OpenClawPluginApi, PluginLogger } from '../openclaw-sdk.js';
|
|
2
|
-
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
3
|
-
export type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
|
|
4
|
-
export { loadEvolutionQueue, saveEvolutionQueue, withQueueLock, acquireQueueLock, requireQueueLock } from './queue-io.js';
|
|
5
|
-
export { EVOLUTION_QUEUE_LOCK_SUFFIX, LOCK_MAX_RETRIES, LOCK_RETRY_DELAY_MS, LOCK_STALE_MS } from './queue-io.js';
|
|
6
|
-
/**
|
|
7
|
-
* Validates a queue event payload string before JSON.parse.
|
|
8
|
-
* Checks:
|
|
9
|
-
* 1. typeof payload === 'string'
|
|
10
|
-
* 2. Parsed object has required fields: 'type' and 'workspaceId'
|
|
11
|
-
* Returns the parsed object only if validation passes.
|
|
12
|
-
* Returns empty object {} if payload is falsy.
|
|
13
|
-
* Throws Error if payload is a non-empty string that fails validation.
|
|
14
|
-
*/
|
|
15
|
-
declare function validateQueueEventPayload(payload: string | null | undefined): Record<string, unknown>;
|
|
16
|
-
export { validateQueueEventPayload };
|
|
17
|
-
import { runWorkflowWatchdog, type WatchdogResult } from './workflow-watchdog.js';
|
|
18
|
-
export { runWorkflowWatchdog };
|
|
19
|
-
export type { WatchdogResult };
|
|
20
|
-
/**
|
|
21
|
-
* Queue V2 Schema - Supports background evolution task kinds.
|
|
22
|
-
*
|
|
23
|
-
* Pain diagnosis is Runtime v2 only: after_tool_call / pd pain record ->
|
|
24
|
-
* PainSignalBridge -> SplitDiagnosticianRunner. EvolutionWorker does not read
|
|
25
|
-
* .pain_flag or process pain_diagnosis queue items.
|
|
26
|
-
*
|
|
27
|
-
* Types (QueueStatus / TaskResolution / EvolutionQueueItem) are re-exported
|
|
28
|
-
* from queue-migration.ts, which sources them from evolution-types.ts
|
|
29
|
-
* (canonical single source of truth).
|
|
30
|
-
*/
|
|
31
|
-
export type { QueueStatus, TaskResolution, EvolutionQueueItem } from './queue-migration.js';
|
|
32
|
-
import { migrateToV2, isLegacyQueueItem, migrateQueueToV2, LegacyEvolutionQueueItem, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES, validateQueueItem, VALID_TASK_KINDS, isValidQueueItem, type RawQueueItem, type EvolutionQueueItem } from './queue-migration.js';
|
|
33
|
-
export { migrateToV2, isLegacyQueueItem, migrateQueueToV2, LegacyEvolutionQueueItem, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES, validateQueueItem, VALID_TASK_KINDS, isValidQueueItem };
|
|
34
|
-
export type { RawQueueItem };
|
|
35
|
-
export declare function extractEvolutionTaskId(task: string): string | null;
|
|
36
|
-
export declare function purgeStaleFailedTasks(queue: EvolutionQueueItem[], logger: PluginLogger): {
|
|
37
|
-
purged: number;
|
|
38
|
-
remaining: number;
|
|
39
|
-
byReason: Record<string, number>;
|
|
40
|
-
};
|
|
41
|
-
export declare function hasRecentDuplicateTask(queue: EvolutionQueueItem[], source: string, preview: string, now: number, reason?: string): boolean;
|
|
42
|
-
export declare function hasEquivalentPromotedRule(dictionary: {
|
|
43
|
-
getAllRules(): Record<string, {
|
|
44
|
-
type: string;
|
|
45
|
-
phrases?: string[];
|
|
46
|
-
pattern?: string;
|
|
47
|
-
status: string;
|
|
48
|
-
}>;
|
|
49
|
-
}, phrase: string): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Process compilation backfill and retry loop.
|
|
52
|
-
* Phase 1 — Backfill: on first call, scan for old principles (compilationRetryCount === undefined)
|
|
53
|
-
* with evaluability !== 'manual_only' and no active implementation, queue them (set to 0).
|
|
54
|
-
* Phase 2 — Retry: compile all principles with compilationRetryCount >= 0.
|
|
55
|
-
* After 5 consecutive failures, downgrades to manual_only and logs COMPILE_EXHAUSTED.
|
|
56
|
-
*/
|
|
57
|
-
export declare function processCompilationBackfill(wctx: WorkspaceContext, logger: PluginLogger, workerStatus?: WorkerStatusReport): Promise<void>;
|
|
58
|
-
export declare function registerEvolutionTaskSession(workspaceResolve: (key: string) => string, taskId: string, sessionKey: string, logger?: {
|
|
59
|
-
warn?: (message: string) => void;
|
|
60
|
-
info?: (message: string) => void;
|
|
61
|
-
}): Promise<boolean>;
|
|
62
|
-
/**
|
|
63
|
-
* Evolution Worker - Background service for pain processing and evolution task management.
|
|
64
|
-
*
|
|
65
|
-
* IMPORTANT: evolution_directive.json is a COMPATIBILITY-ONLY DISPLAY ARTIFACT.
|
|
66
|
-
* This service does NOT read or use directive for Phase 3 eligibility or any decisions.
|
|
67
|
-
* Queue (EVOLUTION_QUEUE) is the only authoritative execution truth source.
|
|
68
|
-
*
|
|
69
|
-
* Directive exists solely for UI/backwards compatibility display purposes.
|
|
70
|
-
* Production evidence shows directive stopped updating on 2026-03-22 and is stale.
|
|
71
|
-
*/
|
|
72
|
-
export interface ExtendedEvolutionWorkerService {
|
|
73
|
-
id: string;
|
|
74
|
-
api: OpenClawPluginApi | null;
|
|
75
|
-
_startedWorkspaces: Set<string>;
|
|
76
|
-
start: (ctx: OpenClawPluginServiceContext) => void | Promise<void>;
|
|
77
|
-
stop?: (ctx: OpenClawPluginServiceContext) => void | Promise<void>;
|
|
78
|
-
}
|
|
79
|
-
export interface WorkerStatusErrorEntry {
|
|
80
|
-
at: string;
|
|
81
|
-
kind: 'retry_count_update_failed' | 'principle_update_failed';
|
|
82
|
-
principleId: string;
|
|
83
|
-
error: string;
|
|
84
|
-
}
|
|
85
|
-
export interface WorkerStatusReport {
|
|
86
|
-
timestamp: string;
|
|
87
|
-
cycle_start_ms: number;
|
|
88
|
-
duration_ms: number;
|
|
89
|
-
pain_flag: {
|
|
90
|
-
exists: boolean;
|
|
91
|
-
score: number | null;
|
|
92
|
-
source: string | null;
|
|
93
|
-
enqueued: boolean;
|
|
94
|
-
skipped_reason: string | null;
|
|
95
|
-
};
|
|
96
|
-
queue: {
|
|
97
|
-
total: number;
|
|
98
|
-
pending: number;
|
|
99
|
-
in_progress: number;
|
|
100
|
-
completed_this_cycle: number;
|
|
101
|
-
failed_this_cycle: number;
|
|
102
|
-
};
|
|
103
|
-
errors: (string | WorkerStatusErrorEntry)[];
|
|
104
|
-
}
|
|
105
|
-
export declare const EvolutionWorkerService: ExtendedEvolutionWorkerService;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queue I/O + Enqueue — extracted from evolution-worker.ts
|
|
3
|
-
*
|
|
4
|
-
* Full persistence layer encapsulating queue file locking, atomic writes,
|
|
5
|
-
* queue format, and enqueue orchestration. Depends on file-lock.ts, io.ts,
|
|
6
|
-
* queue-migration.ts, and pain.ts.
|
|
7
|
-
* Zero imports from evolution-worker.ts.
|
|
8
|
-
*/
|
|
9
|
-
import type { EvolutionQueueItem } from '../core/evolution-types.js';
|
|
10
|
-
import type { PluginLogger } from '../openclaw-sdk.js';
|
|
11
|
-
export declare const EVOLUTION_QUEUE_LOCK_SUFFIX = ".lock";
|
|
12
|
-
export declare const LOCK_MAX_RETRIES = 50;
|
|
13
|
-
export declare const LOCK_RETRY_DELAY_MS = 50;
|
|
14
|
-
export declare const LOCK_STALE_MS = 30000;
|
|
15
|
-
export declare function requireQueueLock(resourcePath: string, logger: PluginLogger | {
|
|
16
|
-
warn?: (message: string) => void;
|
|
17
|
-
info?: (message: string) => void;
|
|
18
|
-
} | undefined, scope: string, lockSuffix?: string): Promise<() => void>;
|
|
19
|
-
export declare function createEvolutionTaskId(source: string, score: number, preview: string, reason: string, now: number): string;
|
|
20
|
-
export declare function hasPendingTask(queue: EvolutionQueueItem[], taskKind: string): boolean;
|
|
21
|
-
export declare function acquireQueueLock(resourcePath: string, logger: PluginLogger | {
|
|
22
|
-
warn?: (message: string) => void;
|
|
23
|
-
info?: (message: string) => void;
|
|
24
|
-
} | undefined, lockSuffix?: string): Promise<() => void>;
|
|
25
|
-
export declare function withQueueLock<T>(resourcePath: string, logger: PluginLogger | {
|
|
26
|
-
warn?: (message: string) => void;
|
|
27
|
-
info?: (message: string) => void;
|
|
28
|
-
} | undefined, scope: string, fn: () => Promise<T>): Promise<T>;
|
|
29
|
-
export declare function loadEvolutionQueue(queuePath: string): EvolutionQueueItem[];
|
|
30
|
-
export declare function saveEvolutionQueue(queuePath: string, queue: EvolutionQueueItem[]): void;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Queue Migration — extracted from evolution-worker.ts (lines 297-379)
|
|
3
|
-
*
|
|
4
|
-
* Pure data transformation functions for migrating legacy queue items
|
|
5
|
-
* to the V2 schema. Zero I/O, zero imports from evolution-worker.ts.
|
|
6
|
-
*/
|
|
7
|
-
import type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
|
|
8
|
-
import type { EvolutionQueueItem } from '../core/evolution-types.js';
|
|
9
|
-
export type { QueueStatus, TaskResolution, EvolutionQueueItem } from '../core/evolution-types.js';
|
|
10
|
-
/**
|
|
11
|
-
* Legacy queue item shape (pre-V2) for migration compatibility.
|
|
12
|
-
* These items lack taskKind, priority, retryCount, maxRetries, lastError fields.
|
|
13
|
-
*/
|
|
14
|
-
export interface LegacyEvolutionQueueItem {
|
|
15
|
-
id: string;
|
|
16
|
-
task?: string;
|
|
17
|
-
score: number;
|
|
18
|
-
source: string;
|
|
19
|
-
reason: string;
|
|
20
|
-
timestamp: string;
|
|
21
|
-
enqueued_at?: string;
|
|
22
|
-
started_at?: string;
|
|
23
|
-
completed_at?: string;
|
|
24
|
-
assigned_session_key?: string;
|
|
25
|
-
trigger_text_preview?: string;
|
|
26
|
-
status?: string;
|
|
27
|
-
resolution?: string;
|
|
28
|
-
session_id?: string;
|
|
29
|
-
agent_id?: string;
|
|
30
|
-
traceId?: string;
|
|
31
|
-
taskKind?: string;
|
|
32
|
-
priority?: string;
|
|
33
|
-
retryCount?: number;
|
|
34
|
-
maxRetries?: number;
|
|
35
|
-
lastError?: string;
|
|
36
|
-
resultRef?: string;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Default values for new V2 fields when migrating legacy items.
|
|
40
|
-
*/
|
|
41
|
-
declare const DEFAULT_TASK_KIND: TaskKind;
|
|
42
|
-
declare const DEFAULT_PRIORITY: TaskPriority;
|
|
43
|
-
declare const DEFAULT_MAX_RETRIES = 3;
|
|
44
|
-
export { DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES };
|
|
45
|
-
export type RawQueueItem = Record<string, unknown>;
|
|
46
|
-
/**
|
|
47
|
-
* Migrate a legacy queue item to V2 schema.
|
|
48
|
-
* Old items without taskKind are assumed to be pain_diagnosis for backward compatibility.
|
|
49
|
-
*/
|
|
50
|
-
export declare function migrateToV2(item: LegacyEvolutionQueueItem): EvolutionQueueItem;
|
|
51
|
-
/**
|
|
52
|
-
* Check if an item is a legacy (pre-V2) queue item.
|
|
53
|
-
*/
|
|
54
|
-
export declare function isLegacyQueueItem(item: RawQueueItem): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Migrate entire queue to V2 schema if needed.
|
|
57
|
-
* Returns a new array with all items migrated to V2 format.
|
|
58
|
-
*/
|
|
59
|
-
export declare function migrateQueueToV2(queue: RawQueueItem[]): EvolutionQueueItem[];
|
|
60
|
-
/**
|
|
61
|
-
* Canonical set of valid taskKind values. Single source of truth — mirrors
|
|
62
|
-
* TaskKind in trajectory-types.ts. Previously the inline validator in
|
|
63
|
-
* evolution-worker.ts hard-coded `['model_eval']`, which silently rejected
|
|
64
|
-
* three legitimate taskKind values (pain_diagnosis / sleep_reflection /
|
|
65
|
-
* keyword_optimization). Keep this in sync with TaskKind.
|
|
66
|
-
*/
|
|
67
|
-
export declare const VALID_TASK_KINDS: readonly TaskKind[];
|
|
68
|
-
/**
|
|
69
|
-
* Validate a single queue item loaded from untrusted disk JSON.
|
|
70
|
-
*
|
|
71
|
-
* Returns an array of human-readable error reasons; an empty array means the
|
|
72
|
-
* item is valid. Use {@link isValidQueueItem} for a type-guard form.
|
|
73
|
-
*
|
|
74
|
-
* This consolidates the inline validation that lived in processEvolutionQueue
|
|
75
|
-
* (evolution-worker.ts) so every queue load path (loadEvolutionQueue,
|
|
76
|
-
* registerEvolutionTaskSession) applies the same filter. rc-4 (ERR-007):
|
|
77
|
-
* array elements from parsed JSON must be element-wise validated.
|
|
78
|
-
*/
|
|
79
|
-
export declare function validateQueueItem(item: unknown): string[];
|
|
80
|
-
/**
|
|
81
|
-
* Type-guard convenience over {@link validateQueueItem}.
|
|
82
|
-
* Drops the reason strings (callers that need them should call validateQueueItem).
|
|
83
|
-
*/
|
|
84
|
-
export declare function isValidQueueItem(item: unknown): item is EvolutionQueueItem;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utility for detecting expected subagent unavailability errors.
|
|
3
|
-
* These occur during cron jobs, boot sessions, daemon mode, or isolated sessions
|
|
4
|
-
* where the gateway request context is not available.
|
|
5
|
-
*
|
|
6
|
-
* Callers should suppress warnings for these errors — they are not real failures.
|
|
7
|
-
*/
|
|
8
|
-
export declare function isExpectedSubagentError(err: unknown): boolean;
|