principles-disciple 1.138.0 → 1.140.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/capabilities.js +3 -2
- package/dist/commands/disable-impl.js +1 -1
- package/dist/commands/focus.js +10 -2
- package/dist/commands/rollback-impl.js +1 -1
- package/dist/commands/thinking-os.js +5 -1
- package/dist/core/correction-cue-learner.js +2 -0
- package/dist/core/event-log.js +17 -10
- package/dist/core/focus-history.js +1 -1
- package/dist/core/hygiene/tracker.js +3 -3
- package/dist/core/principle-compiler/compiler.js +2 -0
- package/dist/core/replay-engine.js +1 -1
- package/dist/core/rule-host.js +3 -1
- package/dist/core/thinking-os-parser.js +13 -4
- package/dist/hooks/prompt-helpers.d.ts +87 -0
- package/dist/hooks/prompt-helpers.js +251 -0
- package/dist/hooks/prompt-types.d.ts +66 -0
- package/dist/hooks/prompt-types.js +12 -0
- package/dist/hooks/prompt.d.ts +7 -38
- package/dist/hooks/prompt.js +130 -255
- package/dist/service/evolution-worker.js +7 -3
- package/dist/service/runtime-summary-service.js +8 -1
- package/dist/service/workflow-watchdog.js +2 -1
- package/dist/utils/retry.js +7 -2
- package/dist/utils/session-key.js +4 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/hooks/subagent.d.ts +0 -9
- package/dist/hooks/subagent.js +0 -122
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Evolutionary programming agent framework with strategic guardrails and reflection loops.",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.140.0",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onCapabilities": [
|
|
8
8
|
"hook"
|
package/package.json
CHANGED
package/dist/hooks/subagent.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PluginHookSubagentEndedEvent, PluginHookSubagentContext, OpenClawPluginApi } from '../openclaw-sdk.js';
|
|
2
|
-
type SubagentEndedHookContext = PluginHookSubagentContext & {
|
|
3
|
-
api?: OpenClawPluginApi;
|
|
4
|
-
workspaceDir?: string;
|
|
5
|
-
sessionId?: string;
|
|
6
|
-
agentId?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function handleSubagentEnded(event: PluginHookSubagentEndedEvent, ctx: SubagentEndedHookContext): Promise<void>;
|
|
9
|
-
export {};
|
package/dist/hooks/subagent.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
2
|
-
import { extractAgentIdFromSessionKey } from '../utils/session-key.js';
|
|
3
|
-
import { recordEvolutionSuccess } from '../core/evolution-engine.js';
|
|
4
|
-
import { WorkflowStore } from '../service/subagent-workflow/workflow-store.js';
|
|
5
|
-
/**
|
|
6
|
-
* Factory to create the appropriate WorkflowManager by workflow_type string.
|
|
7
|
-
* Used by the subagent_ended hook to dispatch lifecycle recovery to the right manager.
|
|
8
|
-
*/
|
|
9
|
-
function createWorkflowManagerForType(workflowType) {
|
|
10
|
-
switch (workflowType) {
|
|
11
|
-
default:
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const HELPER_WORKFLOW_SESSION_PREFIX = 'agent:main:subagent:workflow-';
|
|
16
|
-
// Cleanup expired retry entries periodically
|
|
17
|
-
function emitSubagentPainEvent(wctx, payload, logger) {
|
|
18
|
-
try {
|
|
19
|
-
wctx.evolutionReducer.emitSync({
|
|
20
|
-
ts: new Date().toISOString(),
|
|
21
|
-
type: 'pain_detected',
|
|
22
|
-
data: {
|
|
23
|
-
painId: `pain_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,
|
|
24
|
-
painType: 'subagent_error',
|
|
25
|
-
source: payload.source,
|
|
26
|
-
reason: payload.reason,
|
|
27
|
-
score: payload.score,
|
|
28
|
-
sessionId: payload.sessionId,
|
|
29
|
-
agentId: payload.agentId,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
34
|
-
logger.warn(`[PD:Subagent] failed to emit evolution event: ${String(e)}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export async function handleSubagentEnded(event, ctx) {
|
|
38
|
-
const { outcome, targetSessionKey } = event;
|
|
39
|
-
const { workspaceDir } = ctx;
|
|
40
|
-
if (!workspaceDir)
|
|
41
|
-
return;
|
|
42
|
-
const wctx = WorkspaceContext.fromHookContext(ctx);
|
|
43
|
-
const logger = ctx.api?.logger ?? console;
|
|
44
|
-
// ── Helper Workflow Lifecycle Notification ──
|
|
45
|
-
// When a helper workflow's subagent ends, notify the workflow manager
|
|
46
|
-
// so that it can trigger fallback recovery (notifyWaitResult → finalizeOnce)
|
|
47
|
-
if (targetSessionKey?.startsWith(HELPER_WORKFLOW_SESSION_PREFIX)) {
|
|
48
|
-
try {
|
|
49
|
-
const store = new WorkflowStore({ workspaceDir });
|
|
50
|
-
const workflow = store.getWorkflowByChildSession(targetSessionKey);
|
|
51
|
-
if (workflow && workflow.state !== 'completed' && workflow.state !== 'terminal_error' && workflow.state !== 'expired') {
|
|
52
|
-
logger.info(`[PD:Subagent] Helper workflow lifecycle event: workflowId=${workflow.workflow_id}, workflowType=${workflow.workflow_type}, outcome=${outcome}`);
|
|
53
|
-
const mappedOutcome = outcome === 'deleted' ? 'deleted' :
|
|
54
|
-
outcome === 'killed' ? 'killed' :
|
|
55
|
-
outcome === 'reset' ? 'reset' :
|
|
56
|
-
outcome === 'error' ? 'error' :
|
|
57
|
-
outcome === 'timeout' ? 'timeout' : 'ok';
|
|
58
|
-
// Call notifyLifecycleEvent on the appropriate manager so it
|
|
59
|
-
// triggers notifyWaitResult → finalizeOnce / terminal transition.
|
|
60
|
-
const subagentRuntime = ctx.api?.runtime?.subagent;
|
|
61
|
-
if (subagentRuntime) {
|
|
62
|
-
const mgr = createWorkflowManagerForType(workflow.workflow_type);
|
|
63
|
-
if (mgr) {
|
|
64
|
-
await mgr.notifyLifecycleEvent(workflow.workflow_id, 'subagent_ended', { outcome: mappedOutcome });
|
|
65
|
-
mgr.dispose();
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
logger.warn(`[PD:Subagent] Unknown workflow type ${workflow.workflow_type} — falling back to store-only event`);
|
|
69
|
-
store.recordEvent(workflow.workflow_id, 'subagent_ended', workflow.state, workflow.state, `subagent ended with outcome: ${outcome}`, { outcome: mappedOutcome });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
logger.warn(`[PD:Subagent] Subagent runtime not available — cannot notify manager, falling back to store event`);
|
|
74
|
-
store.recordEvent(workflow.workflow_id, 'subagent_ended', workflow.state, workflow.state, `subagent ended with outcome: ${outcome}`, { outcome: mappedOutcome });
|
|
75
|
-
}
|
|
76
|
-
store.dispose();
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
store.dispose();
|
|
80
|
-
}
|
|
81
|
-
catch (e) {
|
|
82
|
-
logger.warn(`[PD:Subagent] Failed to notify helper workflow lifecycle: ${String(e)}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const { config } = wctx;
|
|
86
|
-
// ── Outcome-based EP and Pain Signal handling ──
|
|
87
|
-
// OpenClaw v2026.3.23 fixes: timeout may be false positive (fast-finishing workers)
|
|
88
|
-
// Only penalize actual errors, not timeout/killed/reset
|
|
89
|
-
if (outcome === 'error') {
|
|
90
|
-
// Only actual errors trigger penalty
|
|
91
|
-
const scoreSettings = config.get('scores');
|
|
92
|
-
const score = scoreSettings.subagent_error_penalty;
|
|
93
|
-
const reason = `Subagent session ${targetSessionKey} ended with error`;
|
|
94
|
-
// Emit pain via Runtime v2 chain (M8: no .pain_flag file)
|
|
95
|
-
emitSubagentPainEvent(wctx, {
|
|
96
|
-
source: `subagent_error`,
|
|
97
|
-
reason,
|
|
98
|
-
score,
|
|
99
|
-
sessionId: ctx.sessionId,
|
|
100
|
-
agentId: ctx.agentId || extractAgentIdFromSessionKey(targetSessionKey),
|
|
101
|
-
}, logger);
|
|
102
|
-
}
|
|
103
|
-
if (outcome === 'timeout') {
|
|
104
|
-
// OpenClaw v2026.3.23 fix: timeout may be false positive
|
|
105
|
-
// Fast-finishing workers are no longer incorrectly reported as timed out
|
|
106
|
-
// Do not penalize - the task may have actually succeeded
|
|
107
|
-
logger.warn(`[PD:Subagent] Session ${targetSessionKey} timed out - not penalizing (OpenClaw fix applied)`);
|
|
108
|
-
}
|
|
109
|
-
if (outcome === 'killed' || outcome === 'reset') {
|
|
110
|
-
// User-initiated termination or system reset - not an agent failure
|
|
111
|
-
logger.info(`[PD:Subagent] Session ${targetSessionKey} ended with ${outcome} - no penalty (user/system action)`);
|
|
112
|
-
}
|
|
113
|
-
if (outcome === 'ok' || outcome === 'deleted') {
|
|
114
|
-
recordEvolutionSuccess(workspaceDir, 'subagent', {
|
|
115
|
-
sessionId: ctx.sessionId,
|
|
116
|
-
reason: 'subagent_success',
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
// ── End of subagent_ended handling ──
|
|
120
|
-
// Note: Diagnostician runs via HEARTBEAT (main session LLM), not as a subagent.
|
|
121
|
-
// Principle creation happens in evolution-worker.ts marker detection path.
|
|
122
|
-
}
|