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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for prompt assembly.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from hooks/prompt.ts per PRI-444 to enable independent testing
|
|
5
|
+
* of pure-logic helpers without importing the full hook module.
|
|
6
|
+
*
|
|
7
|
+
* ERR checklist:
|
|
8
|
+
* EP-01: All unknown inputs use typeof/Object.hasOwn guards, never `as`
|
|
9
|
+
* EP-03: Pure functions never swallow errors silently
|
|
10
|
+
* EP-09: Pure functions are independently unit-testable without mocks
|
|
11
|
+
*/
|
|
12
|
+
import type { PluginLogger, OpenClawPluginApi } from '../openclaw-sdk.js';
|
|
13
|
+
/** Cached file entry for TTL-based file reading. */
|
|
14
|
+
export interface CachedFile {
|
|
15
|
+
content: string;
|
|
16
|
+
mtime: number;
|
|
17
|
+
loadedAt: number;
|
|
18
|
+
}
|
|
19
|
+
/** Per-workspace empathy session state. */
|
|
20
|
+
export interface EmpathySessionState {
|
|
21
|
+
turnCounter: number;
|
|
22
|
+
keywordCache: {
|
|
23
|
+
store: unknown;
|
|
24
|
+
lang: string;
|
|
25
|
+
} | null;
|
|
26
|
+
}
|
|
27
|
+
/** API surface exposed to the prompt hook by the plugin runtime. */
|
|
28
|
+
export interface PromptHookApi {
|
|
29
|
+
config?: {
|
|
30
|
+
empathy_engine?: {
|
|
31
|
+
enabled?: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
runtime: OpenClawPluginApi['runtime'];
|
|
35
|
+
logger: PluginLogger;
|
|
36
|
+
}
|
|
37
|
+
/** Result of extracting the user message from the raw prompt text. */
|
|
38
|
+
export interface ExtractedUserMessage {
|
|
39
|
+
/** Cleaned user message (empty string for boot checks). */
|
|
40
|
+
message: string;
|
|
41
|
+
/** True if the message appears to be from another agent (skip empathy). */
|
|
42
|
+
isAgentToAgent: boolean;
|
|
43
|
+
/** True if the message looks like empathy observer output (prevent recursion). */
|
|
44
|
+
isEmpathyPrompt: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Input for formatting core principles into prompt text. */
|
|
47
|
+
export interface CorePrincipleEntry {
|
|
48
|
+
id: string;
|
|
49
|
+
text: string;
|
|
50
|
+
}
|
|
51
|
+
/** Input for formatting evolution principles (active + probation). */
|
|
52
|
+
export interface EvolutionPrincipleEntry extends CorePrincipleEntry {
|
|
53
|
+
}
|
|
54
|
+
/** Parts assembled into appendSystemContext. Order = priority (low → high). */
|
|
55
|
+
export interface AppendSystemContextParts {
|
|
56
|
+
behavioralConstraints?: string;
|
|
57
|
+
projectContext?: string;
|
|
58
|
+
workingMemory?: string;
|
|
59
|
+
thinkingOs?: string;
|
|
60
|
+
evolutionPrinciples?: string;
|
|
61
|
+
corePrinciples?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Input for the heartbeat checklist wrapper. */
|
|
64
|
+
export interface HeartbeatChecklistInput {
|
|
65
|
+
content: string;
|
|
66
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for prompt assembly.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from hooks/prompt.ts per PRI-444 to enable independent testing
|
|
5
|
+
* of pure-logic helpers without importing the full hook module.
|
|
6
|
+
*
|
|
7
|
+
* ERR checklist:
|
|
8
|
+
* EP-01: All unknown inputs use typeof/Object.hasOwn guards, never `as`
|
|
9
|
+
* EP-03: Pure functions never swallow errors silently
|
|
10
|
+
* EP-09: Pure functions are independently unit-testable without mocks
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
package/dist/hooks/prompt.d.ts
CHANGED
|
@@ -1,52 +1,21 @@
|
|
|
1
|
-
import type { PluginHookBeforePromptBuildEvent, PluginHookAgentContext, PluginHookBeforePromptBuildResult
|
|
1
|
+
import type { PluginHookBeforePromptBuildEvent, PluginHookAgentContext, PluginHookBeforePromptBuildResult } from '../openclaw-sdk.js';
|
|
2
2
|
import type { ContextInjectionConfig } from '../types.js';
|
|
3
|
+
import type { PromptHookApi } from './prompt-types.js';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Reset all module-level prompt state for a workspace.
|
|
6
|
+
* Intended for test isolation — call in beforeEach().
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
model?: unknown;
|
|
8
|
-
subagents?: {
|
|
9
|
-
model?: unknown;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
interface PromptHookApi {
|
|
13
|
-
config?: {
|
|
14
|
-
agents?: {
|
|
15
|
-
defaults?: AgentsDefaultsConfig;
|
|
16
|
-
};
|
|
17
|
-
empathy_engine?: {
|
|
18
|
-
enabled?: boolean;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
runtime: OpenClawPluginApi['runtime'];
|
|
22
|
-
logger: PluginLogger;
|
|
23
|
-
}
|
|
8
|
+
export declare function resetPromptStateForTest(workspaceDir?: string): void;
|
|
24
9
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @internal Helper for model configuration resolution
|
|
10
|
+
* OpenClaw API Prompt Hook
|
|
11
|
+
* Constructs the system prompt injected into LLM context for Principles Disciple
|
|
28
12
|
*/
|
|
29
|
-
export declare function resolveModelFromConfig(modelConfig: unknown, logger?: PluginLogger): string | null;
|
|
30
13
|
/**
|
|
31
14
|
* Loads context injection config from .principles/PROFILE.json
|
|
32
15
|
* Parses contextInjection configuration from PROFILE.json for context injection
|
|
33
16
|
* @internal Used by evolution engine for context settings
|
|
34
17
|
*/
|
|
35
18
|
export declare function loadContextInjectionConfig(workspaceDir: string): ContextInjectionConfig;
|
|
36
|
-
/**
|
|
37
|
-
* Gets the diagnostician model - the model used for AI self-diagnosis and reflection
|
|
38
|
-
* Priority: subagents.model > subagents.model > env.OPENCLAW_MODEL
|
|
39
|
-
* Falls back to main model if no diagnostician model is configured
|
|
40
|
-
* @internal Helper for model configuration resolution
|
|
41
|
-
*/
|
|
42
|
-
export declare function getDiagnosticianModel(api: PromptHookApi | null, logger?: PluginLogger): string;
|
|
43
|
-
/**
|
|
44
|
-
* Extract recent user messages for keyword optimization context.
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* Build prompt for keyword optimization subagent.
|
|
48
|
-
*/
|
|
49
19
|
export declare function handleBeforePromptBuild(event: PluginHookBeforePromptBuildEvent, ctx: PluginHookAgentContext & {
|
|
50
20
|
api?: PromptHookApi;
|
|
51
21
|
}): Promise<PluginHookBeforePromptBuildResult | void>;
|
|
52
|
-
export {};
|