principles-disciple 1.201.1 → 1.202.1

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.
Files changed (139) hide show
  1. package/dist/commands/archive-impl.d.ts +18 -0
  2. package/dist/commands/capabilities.d.ts +3 -0
  3. package/dist/commands/context.d.ts +5 -0
  4. package/dist/commands/disable-impl.d.ts +22 -0
  5. package/dist/commands/evolution-status.d.ts +4 -0
  6. package/dist/commands/export.d.ts +2 -0
  7. package/dist/commands/focus.d.ts +14 -0
  8. package/dist/commands/pain.d.ts +6 -0
  9. package/dist/commands/principle-rollback.d.ts +4 -0
  10. package/dist/commands/promote-impl.d.ts +22 -0
  11. package/dist/commands/rollback-impl.d.ts +32 -0
  12. package/dist/commands/rollback.d.ts +19 -0
  13. package/dist/commands/samples.d.ts +2 -0
  14. package/dist/commands/strategy.d.ts +2 -0
  15. package/dist/commands/thinking-os.d.ts +2 -0
  16. package/dist/commands/workflow-debug.d.ts +4 -0
  17. package/dist/config/defaults/runtime.d.ts +58 -0
  18. package/dist/config/errors.d.ts +86 -0
  19. package/dist/config/index.d.ts +7 -0
  20. package/dist/constants/tools.d.ts +17 -0
  21. package/dist/core/__tests__/focus-history.test.d.ts +1 -0
  22. package/dist/core/behavior-example-pack-assembler.d.ts +38 -0
  23. package/dist/core/bootstrap-rules.d.ts +50 -0
  24. package/dist/core/code-implementation-storage.d.ts +71 -0
  25. package/dist/core/config-health.d.ts +17 -0
  26. package/dist/core/config-service.d.ts +15 -0
  27. package/dist/core/config.d.ts +111 -0
  28. package/dist/core/control-ui-db.d.ts +117 -0
  29. package/dist/core/correction-cue-learner.d.ts +33 -0
  30. package/dist/core/correction-types.d.ts +3 -0
  31. package/dist/core/detection-funnel.d.ts +47 -0
  32. package/dist/core/detection-service.d.ts +15 -0
  33. package/dist/core/dictionary-service.d.ts +15 -0
  34. package/dist/core/dictionary.d.ts +38 -0
  35. package/dist/core/empathy-keyword-matcher.d.ts +5 -0
  36. package/dist/core/empathy-types.d.ts +2 -0
  37. package/dist/core/event-log.d.ts +98 -0
  38. package/dist/core/evolution-engine.d.ts +119 -0
  39. package/dist/core/evolution-logger.d.ts +137 -0
  40. package/dist/core/evolution-reducer.d.ts +116 -0
  41. package/dist/core/evolution-types.d.ts +50 -0
  42. package/dist/core/file-store.d.ts +41 -0
  43. package/dist/core/focus-history.d.ts +50 -0
  44. package/dist/core/hygiene/tracker.d.ts +22 -0
  45. package/dist/core/init.d.ts +30 -0
  46. package/dist/core/intent-doc-reader-adapter.d.ts +36 -0
  47. package/dist/core/intent-doc-reader.d.ts +89 -0
  48. package/dist/core/migration.d.ts +6 -0
  49. package/dist/core/pain-diagnostic-gate.d.ts +45 -0
  50. package/dist/core/pain.d.ts +24 -0
  51. package/dist/core/path-resolver.d.ts +60 -0
  52. package/dist/core/paths.d.ts +59 -0
  53. package/dist/core/pd-config-loader.d.ts +96 -0
  54. package/dist/core/pd-task-reconciler.d.ts +89 -0
  55. package/dist/core/pd-task-service.d.ts +2 -0
  56. package/dist/core/pd-task-store.d.ts +5 -0
  57. package/dist/core/pd-task-types.d.ts +8 -0
  58. package/dist/core/principle-compiler/__tests__/compiler-replay-gate.test.d.ts +1 -0
  59. package/dist/core/principle-compiler/code-validator.d.ts +14 -0
  60. package/dist/core/principle-compiler/compiler.d.ts +45 -0
  61. package/dist/core/principle-compiler/index.d.ts +12 -0
  62. package/dist/core/principle-compiler/ledger-registrar.d.ts +28 -0
  63. package/dist/core/principle-compiler/template-generator.d.ts +7 -0
  64. package/dist/core/principle-injection.d.ts +10 -0
  65. package/dist/core/principle-internalization/filesystem-lifecycle-datasource.d.ts +15 -0
  66. package/dist/core/principle-internalization/lifecycle-read-model.d.ts +17 -0
  67. package/dist/core/principle-internalization/lifecycle-refresh.d.ts +2 -0
  68. package/dist/core/principle-internalization/principle-lifecycle-service.d.ts +28 -0
  69. package/dist/core/principle-training-state.d.ts +47 -0
  70. package/dist/core/principle-tree-ledger.d.ts +30 -0
  71. package/dist/core/profile.d.ts +62 -0
  72. package/dist/core/reflection/reflection-context.d.ts +31 -0
  73. package/dist/core/replay-engine.d.ts +12 -0
  74. package/dist/core/rule-context-assembler.d.ts +45 -0
  75. package/dist/core/rule-host.d.ts +178 -0
  76. package/dist/core/rule-implementation-runtime.d.ts +18 -0
  77. package/dist/core/runtime-v2-prompt-activation-reader.d.ts +22 -0
  78. package/dist/core/session-tracker.d.ts +119 -0
  79. package/dist/core/signal-collector-host.d.ts +113 -0
  80. package/dist/core/system-logger.d.ts +24 -0
  81. package/dist/core/thinking-models.d.ts +25 -0
  82. package/dist/core/thinking-os-parser.d.ts +35 -0
  83. package/dist/core/trajectory-types.d.ts +247 -0
  84. package/dist/core/trajectory.d.ts +279 -0
  85. package/dist/core/workflow-funnel-loader.d.ts +72 -0
  86. package/dist/core/workspace-context.d.ts +114 -0
  87. package/dist/core/workspace-dir-validation.d.ts +11 -0
  88. package/dist/core/workspace-guidance-migrator.d.ts +12 -0
  89. package/dist/hooks/after-tool-call-helpers.d.ts +97 -0
  90. package/dist/hooks/after-tool-call-types.d.ts +86 -0
  91. package/dist/hooks/gate-block-helper.d.ts +44 -0
  92. package/dist/hooks/gate.d.ts +16 -0
  93. package/dist/hooks/lifecycle.d.ts +5 -0
  94. package/dist/hooks/llm.d.ts +21 -0
  95. package/dist/hooks/message-sanitize.d.ts +24 -0
  96. package/dist/hooks/pain.d.ts +35 -0
  97. package/dist/hooks/prompt-helpers.d.ts +105 -0
  98. package/dist/hooks/prompt-types.d.ts +74 -0
  99. package/dist/hooks/prompt.d.ts +22 -0
  100. package/dist/hooks/raw-observation-adapter.d.ts +16 -0
  101. package/dist/hooks/raw-observation-types.d.ts +11 -0
  102. package/dist/hooks/trajectory-collector.d.ts +41 -0
  103. package/dist/hooks/trajectory-evidence.d.ts +11 -0
  104. package/dist/hooks/triage-adapter.d.ts +58 -0
  105. package/dist/hooks/trigger-cooldown-tracker.d.ts +42 -0
  106. package/dist/i18n/commands.d.ts +26 -0
  107. package/dist/index.d.ts +52 -0
  108. package/dist/openclaw-sdk.d.ts +338 -0
  109. package/dist/openclaw.plugin.json +1 -1
  110. package/dist/rulehost-evidence.d.ts +4 -0
  111. package/dist/service/correction-observer-service.d.ts +19 -0
  112. package/dist/service/evolution-dedup.d.ts +27 -0
  113. package/dist/service/evolution-worker.d.ts +105 -0
  114. package/dist/service/internalization-auto-consumer-service.d.ts +8 -0
  115. package/dist/service/keyword-optimization-service.d.ts +44 -0
  116. package/dist/service/phase3-input-filter.d.ts +73 -0
  117. package/dist/service/queue-io.d.ts +30 -0
  118. package/dist/service/queue-migration.d.ts +84 -0
  119. package/dist/service/runtime-summary-service.d.ts +156 -0
  120. package/dist/service/subagent-workflow/subagent-error-utils.d.ts +8 -0
  121. package/dist/service/subagent-workflow/types.d.ts +264 -0
  122. package/dist/service/subagent-workflow/workflow-store.d.ts +44 -0
  123. package/dist/service/trajectory-service.d.ts +2 -0
  124. package/dist/service/workflow-watchdog.d.ts +23 -0
  125. package/dist/types/event-types.d.ts +2 -0
  126. package/dist/types/hygiene-types.d.ts +2 -0
  127. package/dist/types/principle-tree-schema.d.ts +29 -0
  128. package/dist/types/queue.d.ts +2 -0
  129. package/dist/types/runtime-summary.d.ts +1 -0
  130. package/dist/types.d.ts +13 -0
  131. package/dist/utils/file-lock.d.ts +68 -0
  132. package/dist/utils/hashing.d.ts +9 -0
  133. package/dist/utils/io.d.ts +11 -0
  134. package/dist/utils/node-vm-polyfill.d.ts +9 -0
  135. package/dist/utils/retry.d.ts +210 -0
  136. package/dist/utils/session-key.d.ts +10 -0
  137. package/dist/utils/workspace-resolver.d.ts +82 -0
  138. package/openclaw.plugin.json +1 -1
  139. package/package.json +3 -2
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Archive Implementation Command — CLI `/pd-archive-impl`
3
+ * ========================================================
4
+ *
5
+ * PURPOSE: Permanently archive an implementation (disabled -> archived,
6
+ * active -> archived, or candidate -> archived).
7
+ *
8
+ * Used for permanent cleanup of implementations that are no longer relevant.
9
+ */
10
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
11
+ /**
12
+ * Handle the /pd-archive-impl command.
13
+ *
14
+ * Usage:
15
+ * /pd-archive-impl <implId> - Archive an implementation
16
+ * /pd-archive-impl list - List archivable implementations
17
+ */
18
+ export declare function handleArchiveImplCommand(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,3 @@
1
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
2
+ export declare function handleBootstrapTools(ctx: PluginCommandContext): PluginCommandResult;
3
+ export declare function handleResearchTools(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,5 @@
1
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
2
+ /**
3
+ * Main command handler
4
+ */
5
+ export declare function handleContextCommand(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Disable Implementation Command — CLI `/pd-disable-impl`
3
+ * ========================================================
4
+ *
5
+ * PURPOSE: Manually disable an active implementation (e.g., regression in production).
6
+ *
7
+ * FLOW:
8
+ * 1. List active implementations
9
+ * 2. Select target, ask for reason
10
+ * 3. Transition active -> disabled (or candidate -> disabled)
11
+ * 4. Record disabledAt, disabledBy, disabledReason
12
+ */
13
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
14
+ /**
15
+ * Handle the /pd-disable-impl command.
16
+ *
17
+ * Usage:
18
+ * /pd-disable-impl list - List active implementations
19
+ * /pd-disable-impl <implId> - Disable an implementation
20
+ * /pd-disable-impl <implId> --reason "<reason>" - Disable with reason
21
+ */
22
+ export declare function handleDisableImplCommand(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,4 @@
1
+ import type { PluginCommandContext } from '../openclaw-sdk.js';
2
+ export declare function handleEvolutionStatusCommand(ctx: PluginCommandContext): {
3
+ text: string;
4
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
2
+ export declare function handleExportCommand(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * /pd-focus 命令 - 管理 CURRENT_FOCUS.md
3
+ *
4
+ * 功能:
5
+ * - status: 查看当前状态和历史版本
6
+ * - compress: 手动压缩并备份
7
+ * - history: 查看历史版本列表
8
+ * - rollback: 回滚到指定历史版本
9
+ */
10
+ import type { PluginCommandContext, PluginCommandResult, OpenClawPluginApi } from '../openclaw-sdk.js';
11
+ /**
12
+ * 处理 /pd-focus 命令
13
+ */
14
+ export declare function handleFocusCommand(ctx: PluginCommandContext, api: OpenClawPluginApi): Promise<PluginCommandResult>;
@@ -0,0 +1,6 @@
1
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
2
+ /**
3
+ * Handles the /pd-status command
4
+ */
5
+ export declare function handlePainCommand(ctx: PluginCommandContext): PluginCommandResult;
6
+ export declare function handlePainReportCommand(ctx: PluginCommandContext): Promise<PluginCommandResult>;
@@ -0,0 +1,4 @@
1
+ import type { PluginCommandContext } from '../openclaw-sdk.js';
2
+ export declare function handlePrincipleRollbackCommand(ctx: PluginCommandContext): {
3
+ text: string;
4
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Promote Implementation Command — CLI `/pd-promote-impl`
3
+ * ========================================================
4
+ *
5
+ * PURPOSE: Manually promote a candidate implementation to active status
6
+ * after replay evaluation review.
7
+ *
8
+ * FLOW:
9
+ * 1. List candidates with replay reports
10
+ * 2. Show replay report summary for selected candidate
11
+ * 3. Ask for confirmation
12
+ * 4. On confirm: transition candidate->active, demote previous active->disabled
13
+ *
14
+ * VALIDATION:
15
+ * - Candidate must have at least one replay report with 'pass' decision
16
+ * - Only candidate -> active is valid for promotion
17
+ * - NOTE (PRI-230): The legacy replay generation path has been retired.
18
+ * This command is temporarily unavailable for implementations without
19
+ * pre-existing replay reports until a Runtime V2 replay entry is wired.
20
+ */
21
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
22
+ export declare function handlePromoteImplCommand(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Rollback Implementation Command — CLI `/pd-rollback-impl`
3
+ * ==========================================================
4
+ *
5
+ * PURPOSE: Revert the current active implementation and restore the previous one.
6
+ *
7
+ * FLOW:
8
+ * 1. List active implementations
9
+ * 2. On confirm: current -> disabled, previous -> active
10
+ *
11
+ * SAFETY:
12
+ * - If no previous active: current -> disabled (degrades to hard-boundary gates)
13
+ * - Rollback records persisted with full audit trail
14
+ */
15
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
16
+ /**
17
+ * Handle the /pd-rollback-impl command.
18
+ *
19
+ * Usage:
20
+ * /pd-rollback-impl list - List active implementations
21
+ * /pd-rollback-impl <implId> - Rollback current active
22
+ * /pd-rollback-impl <implId> --reason "<reason>" - Rollback with reason
23
+ */
24
+ export declare function handleRollbackImplCommand(ctx: PluginCommandContext): PluginCommandResult;
25
+ /**
26
+ * Handle natural language rollback request.
27
+ * Detects phrases like "回滚这个规则实现", "rollback this implementation".
28
+ */
29
+ export declare function handleNaturalLanguageRollbackImpl(workspaceDir: string, sessionId: string | undefined, reason: string): {
30
+ success: boolean;
31
+ message: string;
32
+ };
@@ -0,0 +1,19 @@
1
+ import { WorkspaceContext } from '../core/workspace-context.js';
2
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
3
+ /**
4
+ * Handles the /pd-rollback command
5
+ *
6
+ * Usage:
7
+ * /pd-rollback <event-id> - Rollback a specific empathy event by ID
8
+ * /pd-rollback last - Rollback the last empathy event in current session
9
+ */
10
+ export declare function handleRollbackCommand(ctx: PluginCommandContext): PluginCommandResult;
11
+ /**
12
+ * Handle natural language rollback request
13
+ * Called from prompt hook when user says things like "撤销刚才的惩罚"
14
+ */
15
+ export declare function handleNaturalLanguageRollback(wctx: WorkspaceContext, sessionId: string | undefined, reason: string): {
16
+ success: boolean;
17
+ score: number;
18
+ message: string;
19
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
2
+ export declare function handleSamplesCommand(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,2 @@
1
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
2
+ export declare function handleInitStrategy(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,2 @@
1
+ import type { PluginCommandContext, PluginCommandResult } from '../openclaw-sdk.js';
2
+ export declare function handleThinkingOs(ctx: PluginCommandContext): PluginCommandResult;
@@ -0,0 +1,4 @@
1
+ import type { PluginCommandContext } from '../openclaw-sdk.js';
2
+ export declare function handleWorkflowDebugCommand(ctx: PluginCommandContext): {
3
+ text: string;
4
+ };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Centralized Runtime Defaults
3
+ *
4
+ * All runtime-related constants that were previously scattered across modules.
5
+ * Centralizing these makes it easier to tune behavior and understand limits.
6
+ */
7
+ /** Milliseconds per second */
8
+ export declare const MS_PER_SECOND = 1000;
9
+ /** Seconds per minute */
10
+ export declare const SECONDS_PER_MINUTE = 60;
11
+ /** Minutes per hour */
12
+ export declare const MINUTES_PER_HOUR = 60;
13
+ /** Hours per day */
14
+ export declare const HOURS_PER_DAY = 24;
15
+ /** Days per week */
16
+ export declare const DAYS_PER_WEEK = 7;
17
+ /** One minute in milliseconds */
18
+ export declare const ONE_MINUTE_MS: number;
19
+ /** One hour in milliseconds */
20
+ export declare const ONE_HOUR_MS: number;
21
+ /** One day in milliseconds */
22
+ export declare const ONE_DAY_MS: number;
23
+ /** One week in milliseconds */
24
+ export declare const ONE_WEEK_MS: number;
25
+ /** Default TTL for helper workflows (5 minutes) */
26
+ export declare const WORKFLOW_TTL_MS: number;
27
+ /** Default workflow timeout (15 minutes) */
28
+ export declare const WORKFLOW_TIMEOUT_MS: number;
29
+ /** Default workflow sweep interval (30 minutes) */
30
+ export declare const WORKFLOW_SWEEP_MS: number;
31
+ /**
32
+ * Trajectory gate block retry settings
33
+ * Used when trajectory recording fails and needs to retry
34
+ */
35
+ export declare const TRAJECTORY_GATE_BLOCK_RETRY_DELAY_MS = 250;
36
+ export declare const TRAJECTORY_GATE_BLOCK_MAX_RETRIES = 3;
37
+ export declare const THINKING_CHECKPOINT_WINDOW_MS: number;
38
+ export declare const THINKING_CHECKPOINT_DEFAULT_HIGH_RISK_TOOLS: readonly ['run_shell_command', 'delete_file', 'move_file'];
39
+ /** Large change threshold for GFI gate adjustments */
40
+ export declare const GFI_LARGE_CHANGE_LINES = 50;
41
+ /** Agent spawn GFI threshold (critically high = no spawn) */
42
+ export declare const AGENT_SPAWN_GFI_THRESHOLD = 90;
43
+ /** Evolution worker polling interval (15 minutes) */
44
+ export declare const EVOLUTION_WORKER_POLL_INTERVAL_MS: number;
45
+ /** Evolution queue batch size */
46
+ export declare const EVOLUTION_QUEUE_BATCH_SIZE = 10;
47
+ export declare const SESSION_TOKEN_WARNING_THRESHOLD = 8000;
48
+ export declare const SESSION_MAX_IDLE_MS: number;
49
+ export declare const EVENT_LOG_BUFFER_SIZE = 20;
50
+ export declare const EVENT_LOG_FLUSH_INTERVAL_MS: number;
51
+ /** Default busy timeout for SQLite operations (5 seconds) */
52
+ export declare const DEFAULT_BUSY_TIMEOUT_MS: number;
53
+ /** Max string length for trajectory/event logs */
54
+ export declare const MAX_STRING_LENGTH = 1000;
55
+ /** Default max file size (10MB) */
56
+ export declare const MAX_FILE_SIZE_BYTES: number;
57
+ /** Two hours in milliseconds */
58
+ export declare const TWO_HOURS_MS: number;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Domain-Specific Errors for Principles Disciple
3
+ *
4
+ * These errors provide semantic meaning to failure modes,
5
+ * making it easier to distinguish between:
6
+ * - Lock contention (resource busy)
7
+ * - Parse/validation failures
8
+ * - Derived state mismatches
9
+ * - Configuration issues
10
+ */
11
+ import type { PDErrorCategory } from '@principles/core';
12
+ /**
13
+ * Base class for all Principles Disciple errors
14
+ */
15
+ export declare class PdError extends Error {
16
+ readonly code: string;
17
+ readonly category: PDErrorCategory;
18
+ constructor(message: string, code: string, options?: {
19
+ cause?: unknown;
20
+ });
21
+ }
22
+ /**
23
+ * Thrown when a resource lock cannot be acquired
24
+ * (e.g., queue, trajectory, evolution file)
25
+ */
26
+ export declare class LockUnavailableError extends PdError {
27
+ constructor(resource: string, scope: string, options?: {
28
+ cause?: unknown;
29
+ });
30
+ }
31
+ /**
32
+ * Thrown when a path key cannot be resolved
33
+ */
34
+ export declare class PathResolutionError extends PdError {
35
+ constructor(key: string, options?: {
36
+ cause?: unknown;
37
+ });
38
+ }
39
+ /**
40
+ * Thrown when a workspace cannot be found
41
+ */
42
+ export declare class WorkspaceNotFoundError extends PdError {
43
+ constructor(workspace: string, options?: {
44
+ cause?: unknown;
45
+ });
46
+ }
47
+ /**
48
+ * Thrown when a required sample cannot be found
49
+ */
50
+ export declare class SampleNotFoundError extends PdError {
51
+ constructor(sampleId: string, options?: {
52
+ cause?: unknown;
53
+ });
54
+ }
55
+ /**
56
+ * Thrown when configuration is invalid or missing required fields
57
+ */
58
+ export declare class ConfigurationError extends PdError {
59
+ constructor(message: string, options?: {
60
+ cause?: unknown;
61
+ });
62
+ }
63
+ /**
64
+ * Thrown when prompt/logger dependencies are unavailable
65
+ */
66
+ export declare class DependencyError extends PdError {
67
+ constructor(component: string, message: string, options?: {
68
+ cause?: unknown;
69
+ });
70
+ }
71
+ /**
72
+ * Thrown when evolution worker encounters a processing error
73
+ */
74
+ export declare class EvolutionProcessingError extends PdError {
75
+ constructor(message: string, options?: {
76
+ cause?: unknown;
77
+ });
78
+ }
79
+ /**
80
+ * Thrown when trajectory operations fail
81
+ */
82
+ export declare class TrajectoryError extends PdError {
83
+ constructor(message: string, options?: {
84
+ cause?: unknown;
85
+ });
86
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Configuration module for Principles Disciple
3
+ *
4
+ * Centralizes all configuration defaults, types, and domain errors.
5
+ */
6
+ export * from './defaults/runtime.js';
7
+ export * from './errors.js';
@@ -0,0 +1,17 @@
1
+ export declare const READ_ONLY_TOOL_NAMES: readonly ['read', 'read_file', 'read_many_files', 'image_read', 'search_file_content', 'grep', 'grep_search', 'list_directory', 'ls', 'glob', 'lsp_hover', 'lsp_goto_definition', 'lsp_find_references', 'web_fetch', 'web_search', 'ref_search_documentation', 'ref_read_url', 'resolve-library-id', 'get-library-docs', 'memory_recall', 'save_memory', 'todo_read', 'todo_write', 'ask_user', 'ask_user_question', 'pd-status', 'report'];
2
+ export declare const LOW_RISK_WRITE_TOOL_NAMES: readonly ['write', 'write_file', 'edit', 'edit_file', 'replace', 'apply_patch', 'insert', 'patch'];
3
+ export declare const BASH_TOOL_NAMES: readonly ['bash', 'run_shell_command', 'exec', 'execute', 'shell', 'cmd'];
4
+ export declare const HIGH_RISK_TOOL_NAMES: readonly ["delete_file", "move_file", "bash", "run_shell_command", "exec", "execute", "shell", "cmd"];
5
+ export declare const AGENT_TOOL_NAMES: readonly ['sessions_spawn'];
6
+ export declare const CONTENT_LIMITED_TOOL_NAMES: readonly ["write", "write_file", "edit", "edit_file", "replace", "apply_patch", "insert", "patch"];
7
+ export declare const CONSTRUCTIVE_TOOL_NAMES: readonly ["write", "write_file", "edit", "edit_file", "replace", "apply_patch", "insert", "patch", "delete_file", "move_file", "bash", "run_shell_command", "exec", "execute", "shell", "cmd", "sessions_spawn", "evolve-task", "init-strategy"];
8
+ export declare const EXPLORATORY_TOOL_NAMES: readonly ["read", "read_file", "read_many_files", "image_read", "search_file_content", "grep", "grep_search", "list_directory", "ls", "glob", "lsp_hover", "lsp_goto_definition", "lsp_find_references", "web_fetch", "web_search", "ref_search_documentation", "ref_read_url", "resolve-library-id", "get-library-docs", "memory_recall", "save_memory", "todo_read", "todo_write", "ask_user", "ask_user_question", "pd-status", "report"];
9
+ export declare const READ_ONLY_TOOLS: Set<string>;
10
+ export declare const LOW_RISK_WRITE_TOOLS: Set<string>;
11
+ export declare const HIGH_RISK_TOOLS: Set<string>;
12
+ export declare const BASH_TOOLS_SET: Set<string>;
13
+ export declare const AGENT_TOOLS: Set<string>;
14
+ export declare const CONTENT_LIMITED_TOOLS: Set<string>;
15
+ export declare const CONSTRUCTIVE_TOOLS: Set<string>;
16
+ export declare const EXPLORATORY_TOOLS: Set<string>;
17
+ export declare const WRITE_TOOLS: Set<string>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { BehaviorExamplePack } from '@principles/core/runtime-v2';
2
+ export interface BehaviorExamplePackAssemblerOptions {
3
+ /** Workspace directory — used to obtain the shared TrajectoryDatabase. */
4
+ readonly workspaceDir: string;
5
+ /**
6
+ * State directory (unused for direct DB access but required by the
7
+ * WorkspaceContext facade pattern; future-proofing for redaction config).
8
+ */
9
+ readonly stateDir: string;
10
+ }
11
+ export interface BehaviorExamplePackAssemblerInput {
12
+ /** Canonical pain ID (e.g. pain_<ts>_<hash>) — entry point into pain lineage. */
13
+ readonly sourcePainId: string;
14
+ /** Owner's natural-language desired outcome — must be non-empty. */
15
+ readonly ownerDesiredOutcome: string;
16
+ /** Owner-selected call that demonstrates behaviour to block. */
17
+ readonly sourceNegativeToolCallId: number;
18
+ /** Owner-selected calls that demonstrate behaviour to allow (1..3). */
19
+ readonly positiveToolCallIds: readonly number[];
20
+ /**
21
+ * Project directory, used to detect absolute paths that should be redacted
22
+ * to relative/basename form in the assembled pack.
23
+ */
24
+ readonly projectDir: string;
25
+ }
26
+ /**
27
+ * Plugin I/O assembler: pain lineage + trajectory → validated BehaviorExamplePack.
28
+ *
29
+ * Lifecycle: cheap to construct; obtains TrajectoryDatabase via the registry.
30
+ * Dispose is the registry's responsibility (singleton per workspace).
31
+ */
32
+ export declare class BehaviorExamplePackAssembler {
33
+ private readonly db;
34
+ constructor(opts: BehaviorExamplePackAssemblerOptions);
35
+ /** Assemble only from explicit Owner labels; execution outcome is not a label. */
36
+ assemble(input: BehaviorExamplePackAssemblerInput): BehaviorExamplePack;
37
+ private buildSelectedCase;
38
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Minimal Rule Bootstrap (Phase 17)
3
+ *
4
+ * Bootstraps 1-3 stub Rule entities for high-value deterministic principles.
5
+ * Selected by: observedViolationCount (descending) + evaluability=deterministic.
6
+ * Falls back to all deterministic principles if violation data is sparse.
7
+ *
8
+ * Rule ID format: {principleId}_stub_bootstrap
9
+ * Scope: BOOT-03 — bounded, no mass migration, no implementations.
10
+ *
11
+ * Usage:
12
+ * npx vitest run tests/core/bootstrap-rules.test.ts (tests)
13
+ * npm run bootstrap-rules (production)
14
+ */
15
+ export interface BootstrapResult {
16
+ principleId: string;
17
+ ruleId: string;
18
+ status: 'created' | 'skipped';
19
+ }
20
+ /**
21
+ * Select principles for bootstrap based on violation count and evaluability.
22
+ *
23
+ * @param stateDir - State directory path
24
+ * @param limit - Maximum number of principles to select (default: 3)
25
+ * @returns Array of principle IDs sorted by observedViolationCount (descending)
26
+ * @throws Error if no deterministic principles found
27
+ */
28
+ export declare function selectPrinciplesForBootstrap(stateDir: string, limit?: number): string[];
29
+ /**
30
+ * Bootstrap stub rules for selected principles.
31
+ *
32
+ * Creates stub Rule entities with format {principleId}_stub_bootstrap.
33
+ * Links rules to principles via suggestedRules array.
34
+ * Idempotent: skips existing rules.
35
+ *
36
+ * @param stateDir - State directory path
37
+ * @param limit - Maximum number of principles to bootstrap (default: 3)
38
+ * @returns Array of results indicating created or skipped status
39
+ * @throws Error if no deterministic principles found
40
+ */
41
+ export declare function bootstrapRules(stateDir: string, limit?: number): BootstrapResult[];
42
+ /**
43
+ * Validate that bootstrapped state is correct.
44
+ *
45
+ * @param stateDir - State directory path
46
+ * @param expectedPrincipleIds - Principle IDs that should be bootstrapped
47
+ * @returns true if validation passes
48
+ * @throws Error if validation fails
49
+ */
50
+ export declare function validateBootstrap(stateDir: string, expectedPrincipleIds: string[]): boolean;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Code Implementation Asset Storage
3
+ * ================================
4
+ *
5
+ * Manages versioned code implementation assets: manifests, entry files,
6
+ * and metadata pointers for Implementation(type=code) records.
7
+ *
8
+ * DESIGN CONSTRAINTS (per D-09 through D-12):
9
+ * - Manifest is loading metadata, NOT the source of truth for lifecycle state (D-11)
10
+ * - The Principle Tree ledger remains canonical for lifecycle and relationships (D-11)
11
+ * - Asset root follows the PD stateDir convention:
12
+ * {stateDir}/principles/implementations/{implId}/
13
+ * - All writes use withLock for atomicity (matching ledger pattern)
14
+ * - This module does NOT implement replay execution, evaluation report generation,
15
+ * or promotion logic (D-12)
16
+ */
17
+ /**
18
+ * Manifest shape for a code implementation's filesystem assets.
19
+ * Subordinate to the ledger per D-11: does NOT store lifecycleState.
20
+ */
21
+ export interface CodeImplementationManifest {
22
+ /** Asset version (distinct from Implementation.version in the ledger) */
23
+ version: string;
24
+ /** Relative filename of the entry point (e.g., 'entry.js') */
25
+ entryFile: string;
26
+ /** ISO timestamp of initial creation */
27
+ createdAt: string;
28
+ /** ISO timestamp of last manifest update */
29
+ updatedAt: string;
30
+ /** Fingerprints of samples this implementation was tested against */
31
+ replaySampleRefs: string[];
32
+ /** Relative path to most recent eval report, or null */
33
+ lastEvalReportRef: string | null;
34
+ /** Provenance carried with the generated candidate assets */
35
+ lineage?: CodeImplementationLineageMetadata;
36
+ }
37
+ export interface CodeImplementationLineageMetadata {
38
+ principleId: string;
39
+ ruleId: string;
40
+ sourceSnapshotRef: string;
41
+ sourcePainIds: string[];
42
+ sourceGateBlockIds: string[];
43
+ sourceSessionId: string;
44
+ artificerArtifactId: string;
45
+ }
46
+ /**
47
+ * Get the absolute path for an implementation's asset root.
48
+ * Convention: {stateDir}/principles/implementations/{implId}/
49
+ */
50
+ export declare function getImplementationAssetRoot(stateDir: string, implId: string): string;
51
+ /**
52
+ * Write manifest atomically using withLock.
53
+ */
54
+ export declare function writeManifest(stateDir: string, implId: string, manifest: CodeImplementationManifest): void;
55
+ export declare function writeEntrySource(stateDir: string, implId: string, sourceCode: string, entryFile?: string): void;
56
+ export declare function deleteImplementationAssetDir(stateDir: string, implId: string): void;
57
+ /**
58
+ * Create the full asset directory structure for a new implementation.
59
+ *
60
+ * Creates:
61
+ * {implId}/ - asset root
62
+ * {implId}/entry.js - placeholder entry point (only if not already present)
63
+ * {implId}/manifest.json - asset manifest with version and timestamps
64
+ * {implId}/replays/ - empty directory for future replay reports
65
+ *
66
+ * Idempotent: calling again with the same implId will NOT overwrite an existing entry.js.
67
+ */
68
+ export declare function createImplementationAssetDir(stateDir: string, implId: string, version: string, options?: {
69
+ entrySource?: string;
70
+ lineage?: CodeImplementationLineageMetadata;
71
+ }): CodeImplementationManifest;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * PRI-348: Extract the full plugin entry (including hooks) from the global OpenClaw config.
3
+ * Unlike api.pluginConfig (which is only the entry.config sub-object), this returns
4
+ * the entire entry including hooks, config, enabled, etc.
5
+ */
6
+ export declare function getPluginEntry(config: unknown, pluginId: string): unknown;
7
+ export interface ConversationAccessCheckResult {
8
+ authorized: boolean;
9
+ reason?: string;
10
+ nextAction?: string;
11
+ }
12
+ /**
13
+ * PRI-343: Pure function — checks if pluginConfig has hooks.allowConversationAccess === true.
14
+ * Returns a structured result with reason and nextAction when not authorized (ERR-002).
15
+ */
16
+ export declare function checkConversationAccessConfig(pluginConfig: unknown): ConversationAccessCheckResult;
17
+ export declare function ensureConversationAccessInConfig(): boolean;
@@ -0,0 +1,15 @@
1
+ import { PainConfig } from './config.js';
2
+ /**
3
+ * Singleton service to manage the Pain Configuration.
4
+ */
5
+ export declare const ConfigService: {
6
+ /**
7
+ * Gets or initializes the Pain Configuration instance.
8
+ * @param stateDir The directory where the settings JSON is stored.
9
+ */
10
+ get(stateDir: string): PainConfig;
11
+ /**
12
+ * Resets the singleton instance (primarily for testing).
13
+ */
14
+ reset(): void;
15
+ };