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.
@@ -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 {};
@@ -1,52 +1,21 @@
1
- import type { PluginHookBeforePromptBuildEvent, PluginHookAgentContext, PluginHookBeforePromptBuildResult, PluginLogger, OpenClawPluginApi } from '../openclaw-sdk.js';
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
- * Default model configuration for OpenClaw agents
5
+ * Reset all module-level prompt state for a workspace.
6
+ * Intended for test isolation — call in beforeEach().
5
7
  */
6
- interface AgentsDefaultsConfig {
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
- * Resolves model configuration for OpenClaw agents, supporting string and object formats
26
- * @param modelConfig - Model config: string (e.g. "provider/model") or { primary, fallbacks } object
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 {};