@principles/core 1.146.3 → 1.147.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.
Files changed (118) hide show
  1. package/dist/index.d.ts +0 -9
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/io.d.ts +0 -1
  6. package/dist/io.d.ts.map +1 -1
  7. package/dist/io.js +0 -2
  8. package/dist/io.js.map +1 -1
  9. package/dist/principle-injector.d.ts +1 -1
  10. package/dist/principle-injector.d.ts.map +1 -1
  11. package/dist/runtime-v2/__tests__/architecture-regression.test.js +76 -1
  12. package/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  13. package/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +5 -0
  14. package/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
  15. package/dist/runtime-v2/context-payload.d.ts +4 -4
  16. package/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.d.ts +5 -0
  17. package/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.d.ts.map +1 -0
  18. package/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.js +91 -0
  19. package/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.js.map +1 -0
  20. package/dist/runtime-v2/core-principles/core-axiom-block.d.ts +67 -0
  21. package/dist/runtime-v2/core-principles/core-axiom-block.d.ts.map +1 -0
  22. package/dist/runtime-v2/core-principles/core-axiom-block.js +76 -0
  23. package/dist/runtime-v2/core-principles/core-axiom-block.js.map +1 -0
  24. package/dist/runtime-v2/core-principles/index.d.ts +2 -0
  25. package/dist/runtime-v2/core-principles/index.d.ts.map +1 -1
  26. package/dist/runtime-v2/core-principles/index.js +1 -0
  27. package/dist/runtime-v2/core-principles/index.js.map +1 -1
  28. package/dist/runtime-v2/diagnostician/distiller-prompt-builder.d.ts.map +1 -1
  29. package/dist/runtime-v2/diagnostician/distiller-prompt-builder.js +5 -12
  30. package/dist/runtime-v2/diagnostician/distiller-prompt-builder.js.map +1 -1
  31. package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
  32. package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js +9 -13
  33. package/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js.map +1 -1
  34. package/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +2 -0
  35. package/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
  36. package/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  37. package/dist/runtime-v2/feature-flags/feature-flag-contract.js +1 -0
  38. package/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  39. package/dist/runtime-v2/full-trace-contract.d.ts +3 -3
  40. package/dist/runtime-v2/internalization/__tests__/scribe-prompt-builder.test.js +13 -8
  41. package/dist/runtime-v2/internalization/__tests__/scribe-prompt-builder.test.js.map +1 -1
  42. package/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.js +4 -3
  43. package/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.js.map +1 -1
  44. package/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +1 -1
  45. package/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
  46. package/dist/runtime-v2/internalization/artificer-prompt-builder.js +1 -1
  47. package/dist/runtime-v2/internalization/artificer-runner.d.ts +3 -0
  48. package/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  49. package/dist/runtime-v2/internalization/artificer-runner.js +8 -0
  50. package/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  51. package/dist/runtime-v2/internalization/dreamer-prompt-builder.d.ts +19 -1
  52. package/dist/runtime-v2/internalization/dreamer-prompt-builder.d.ts.map +1 -1
  53. package/dist/runtime-v2/internalization/dreamer-prompt-builder.js +48 -8
  54. package/dist/runtime-v2/internalization/dreamer-prompt-builder.js.map +1 -1
  55. package/dist/runtime-v2/internalization/dreamer-runner.d.ts +6 -0
  56. package/dist/runtime-v2/internalization/dreamer-runner.d.ts.map +1 -1
  57. package/dist/runtime-v2/internalization/dreamer-runner.js +24 -1
  58. package/dist/runtime-v2/internalization/dreamer-runner.js.map +1 -1
  59. package/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +1 -1
  60. package/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  61. package/dist/runtime-v2/internalization/evaluator-prompt-builder.js +2 -2
  62. package/dist/runtime-v2/internalization/evaluator-runner.d.ts +3 -0
  63. package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  64. package/dist/runtime-v2/internalization/evaluator-runner.js +8 -0
  65. package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  66. package/dist/runtime-v2/internalization/philosopher-prompt-builder.d.ts +20 -1
  67. package/dist/runtime-v2/internalization/philosopher-prompt-builder.d.ts.map +1 -1
  68. package/dist/runtime-v2/internalization/philosopher-prompt-builder.js +47 -6
  69. package/dist/runtime-v2/internalization/philosopher-prompt-builder.js.map +1 -1
  70. package/dist/runtime-v2/internalization/philosopher-runner.d.ts +5 -0
  71. package/dist/runtime-v2/internalization/philosopher-runner.d.ts.map +1 -1
  72. package/dist/runtime-v2/internalization/philosopher-runner.js +14 -1
  73. package/dist/runtime-v2/internalization/philosopher-runner.js.map +1 -1
  74. package/dist/runtime-v2/internalization/rollout-reviewer-prompt-builder.d.ts +1 -1
  75. package/dist/runtime-v2/internalization/rollout-reviewer-prompt-builder.d.ts.map +1 -1
  76. package/dist/runtime-v2/internalization/rollout-reviewer-prompt-builder.js +2 -2
  77. package/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts +20 -6
  78. package/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
  79. package/dist/runtime-v2/internalization/scribe-prompt-builder.js +31 -15
  80. package/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
  81. package/dist/runtime-v2/internalization/scribe-runner.d.ts +5 -0
  82. package/dist/runtime-v2/internalization/scribe-runner.d.ts.map +1 -1
  83. package/dist/runtime-v2/internalization/scribe-runner.js +14 -1
  84. package/dist/runtime-v2/internalization/scribe-runner.js.map +1 -1
  85. package/dist/runtime-v2/internalization/trainer-prompt-builder.d.ts +1 -1
  86. package/dist/runtime-v2/internalization/trainer-prompt-builder.d.ts.map +1 -1
  87. package/dist/runtime-v2/internalization/trainer-prompt-builder.js +2 -2
  88. package/dist/runtime-v2/runner/base-peer-runner.d.ts +4 -1
  89. package/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
  90. package/dist/runtime-v2/runner/base-peer-runner.js +12 -2
  91. package/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
  92. package/dist/runtime-v2/runner/peer-runner-types.d.ts +7 -0
  93. package/dist/runtime-v2/runner/peer-runner-types.d.ts.map +1 -1
  94. package/package.json +1 -1
  95. package/dist/evolution-hook.d.ts +0 -70
  96. package/dist/evolution-hook.d.ts.map +0 -1
  97. package/dist/evolution-hook.js +0 -10
  98. package/dist/evolution-hook.js.map +0 -1
  99. package/dist/pain-flag-resolver.d.ts +0 -18
  100. package/dist/pain-flag-resolver.d.ts.map +0 -1
  101. package/dist/pain-flag-resolver.js +0 -21
  102. package/dist/pain-flag-resolver.js.map +0 -1
  103. package/dist/pain-recorder.d.ts +0 -38
  104. package/dist/pain-recorder.d.ts.map +0 -1
  105. package/dist/pain-recorder.js +0 -62
  106. package/dist/pain-recorder.js.map +0 -1
  107. package/dist/storage-adapter.d.ts +0 -59
  108. package/dist/storage-adapter.d.ts.map +0 -1
  109. package/dist/storage-adapter.js +0 -2
  110. package/dist/storage-adapter.js.map +0 -1
  111. package/dist/types/workspace-resolver.d.ts +0 -25
  112. package/dist/types/workspace-resolver.d.ts.map +0 -1
  113. package/dist/types/workspace-resolver.js +0 -10
  114. package/dist/types/workspace-resolver.js.map +0 -1
  115. package/dist/types.d.ts +0 -56
  116. package/dist/types.d.ts.map +0 -1
  117. package/dist/types.js +0 -16
  118. package/dist/types.js.map +0 -1
@@ -1,70 +0,0 @@
1
- /**
2
- * EvolutionHook interface for the Evolution SDK.
3
- *
4
- * Provides a callback-based interface for observing evolution lifecycle
5
- * events: pain detection, principle creation, and principle promotion.
6
- *
7
- * Per D-03, this interface contains only the 3 core event methods.
8
- * Per D-04, consumers implement the interface directly (no EventEmitter).
9
- * Hooks not needed can use the provided noOpEvolutionHook and override
10
- * individual methods.
11
- */
12
- import type { PainSignal } from './pain-signal.js';
13
- /** Event payload for principle creation lifecycle events. */
14
- export interface PrincipleCreatedEvent {
15
- /** Unique principle identifier */
16
- id: string;
17
- /** Principle text ("When X, then Y.") */
18
- text: string;
19
- /** What triggered this principle's creation */
20
- trigger: string;
21
- }
22
- /** Event payload for principle promotion lifecycle events. */
23
- export interface PrinciplePromotedEvent {
24
- /** Unique principle identifier */
25
- id: string;
26
- /** Previous status tier */
27
- from: string;
28
- /** New status tier */
29
- to: string;
30
- }
31
- /**
32
- * Callback interface for observing evolution lifecycle events.
33
- *
34
- * Implement all 3 methods, or spread noOpEvolutionHook and override
35
- * only the methods you need:
36
- *
37
- * @example
38
- * ```ts
39
- * const myHook: EvolutionHook = {
40
- * ...noOpEvolutionHook,
41
- * onPainDetected(signal) { console.log(signal); },
42
- * };
43
- * ```
44
- *
45
- * Error handling: implementations MUST NOT throw. Throwing will propagate
46
- * exceptions to the caller of the hook. If a hook needs to perform fallible
47
- * operations (e.g., network calls, file I/O), it should catch internally
48
- * and return gracefully. This constraint ensures the core evolution pipeline
49
- * is not disrupted by hook failures.
50
- */
51
- export interface EvolutionHook {
52
- /**
53
- * Called when a pain signal is detected and recorded.
54
- * Implementations MUST NOT throw.
55
- */
56
- onPainDetected(signal: PainSignal): void;
57
- /**
58
- * Called when a new principle candidate is created.
59
- * Implementations MUST NOT throw.
60
- */
61
- onPrincipleCreated(event: PrincipleCreatedEvent): void;
62
- /**
63
- * Called when a principle is promoted to a higher tier.
64
- * Implementations MUST NOT throw.
65
- */
66
- onPrinciplePromoted(event: PrinciplePromotedEvent): void;
67
- }
68
- /** No-op implementation -- consumers can spread and override individual methods. */
69
- export declare const noOpEvolutionHook: EvolutionHook;
70
- //# sourceMappingURL=evolution-hook.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evolution-hook.d.ts","sourceRoot":"","sources":["../src/evolution-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMnD,6DAA6D;AAC7D,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8DAA8D;AAC9D,MAAM,WAAW,sBAAsB;IACrC,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,EAAE,EAAE,MAAM,CAAC;CACZ;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACzC;;;OAGG;IACH,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACvD;;;OAGG;IACH,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC1D;AAMD,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,EAAE,aAI/B,CAAC"}
@@ -1,10 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // No-op Helper
3
- // ---------------------------------------------------------------------------
4
- /** No-op implementation -- consumers can spread and override individual methods. */
5
- export const noOpEvolutionHook = {
6
- onPainDetected(_signal) { },
7
- onPrincipleCreated(_event) { },
8
- onPrinciplePromoted(_event) { },
9
- };
10
- //# sourceMappingURL=evolution-hook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evolution-hook.js","sourceRoot":"","sources":["../src/evolution-hook.ts"],"names":[],"mappings":"AA+EA,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,oFAAoF;AACpF,MAAM,CAAC,MAAM,iBAAiB,GAAkB;IAC9C,cAAc,CAAC,OAAmB,IAAqB,CAAC;IACxD,kBAAkB,CAAC,MAA6B,IAAqB,CAAC;IACtE,mBAAmB,CAAC,MAA8B,IAAqB,CAAC;CACzE,CAAC"}
@@ -1,18 +0,0 @@
1
- /**
2
- * PainFlagPathResolver — Pure function for resolving pain flag file paths.
3
- *
4
- * D-04: resolvePainFlagPath(workspaceDir: string): string
5
- *
6
- * Usage:
7
- * import { resolvePainFlagPath } from '@principles/core';
8
- * const flagPath = resolvePainFlagPath('/path/to/workspace');
9
- * // => '/path/to/workspace/.state/.pain_flag'
10
- */
11
- /**
12
- * Resolve the absolute path to the .pain_flag file for a given workspace.
13
- *
14
- * @param workspaceDir - Absolute path to the workspace directory
15
- * @returns The absolute path to the .pain_flag file
16
- */
17
- export declare function resolvePainFlagPath(workspaceDir: string): string;
18
- //# sourceMappingURL=pain-flag-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pain-flag-resolver.d.ts","sourceRoot":"","sources":["../src/pain-flag-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEhE"}
@@ -1,21 +0,0 @@
1
- /**
2
- * PainFlagPathResolver — Pure function for resolving pain flag file paths.
3
- *
4
- * D-04: resolvePainFlagPath(workspaceDir: string): string
5
- *
6
- * Usage:
7
- * import { resolvePainFlagPath } from '@principles/core';
8
- * const flagPath = resolvePainFlagPath('/path/to/workspace');
9
- * // => '/path/to/workspace/.state/.pain_flag'
10
- */
11
- import * as path from 'path';
12
- /**
13
- * Resolve the absolute path to the .pain_flag file for a given workspace.
14
- *
15
- * @param workspaceDir - Absolute path to the workspace directory
16
- * @returns The absolute path to the .pain_flag file
17
- */
18
- export function resolvePainFlagPath(workspaceDir) {
19
- return path.join(workspaceDir, '.state', '.pain_flag');
20
- }
21
- //# sourceMappingURL=pain-flag-resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pain-flag-resolver.js","sourceRoot":"","sources":["../src/pain-flag-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAoB;IACtD,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AACzD,CAAC"}
@@ -1,38 +0,0 @@
1
- /**
2
- * PainRecorder — Pure function for recording pain signals.
3
- *
4
- * D-02: PainRecorder as pure function, decoupled from OpenClawPluginApi.
5
- *
6
- * Usage:
7
- * import { recordPainSignal } from '@principles/core';
8
- * const signal = await recordPainSignal(
9
- * { reason: 'edited file without reading first', source: 'manual', score: 75 },
10
- * '/path/to/workspace'
11
- * );
12
- *
13
- * Runtime V2 note:
14
- * This helper no longer writes .state/.pain_flag. Manual diagnosis requests
15
- * must use `pd pain record`, and OpenClaw runtime events must use
16
- * PainSignalBridge/emitPainDetectedEvent.
17
- */
18
- import type { PainSignal } from './pain-signal.js';
19
- /** Input shape for recordPainSignal. */
20
- export interface PainSignalInput {
21
- reason: string;
22
- source?: string;
23
- score?: number;
24
- sessionId?: string;
25
- is_risky?: boolean;
26
- }
27
- /**
28
- * Validate and normalize a pain signal.
29
- *
30
- * This does not write .state/.pain_flag. It remains as an SDK validation
31
- * helper for callers that need a framework-agnostic PainSignal object.
32
- *
33
- * @param input - PainSignalInput (reason required, source/score optional)
34
- * @param workspaceDir - Kept for API compatibility; not used for file writes.
35
- * @returns Promise resolving to a validated PainSignal
36
- */
37
- export declare function recordPainSignal(input: PainSignalInput, workspaceDir: string): Promise<PainSignal>;
38
- //# sourceMappingURL=pain-recorder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pain-recorder.d.ts","sourceRoot":"","sources":["../src/pain-recorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,CAoCrB"}
@@ -1,62 +0,0 @@
1
- /**
2
- * PainRecorder — Pure function for recording pain signals.
3
- *
4
- * D-02: PainRecorder as pure function, decoupled from OpenClawPluginApi.
5
- *
6
- * Usage:
7
- * import { recordPainSignal } from '@principles/core';
8
- * const signal = await recordPainSignal(
9
- * { reason: 'edited file without reading first', source: 'manual', score: 75 },
10
- * '/path/to/workspace'
11
- * );
12
- *
13
- * Runtime V2 note:
14
- * This helper no longer writes .state/.pain_flag. Manual diagnosis requests
15
- * must use `pd pain record`, and OpenClaw runtime events must use
16
- * PainSignalBridge/emitPainDetectedEvent.
17
- */
18
- import { validatePainSignal, deriveSeverity } from './pain-signal.js';
19
- /**
20
- * Validate and normalize a pain signal.
21
- *
22
- * This does not write .state/.pain_flag. It remains as an SDK validation
23
- * helper for callers that need a framework-agnostic PainSignal object.
24
- *
25
- * @param input - PainSignalInput (reason required, source/score optional)
26
- * @param workspaceDir - Kept for API compatibility; not used for file writes.
27
- * @returns Promise resolving to a validated PainSignal
28
- */
29
- export async function recordPainSignal(input, workspaceDir) {
30
- void workspaceDir;
31
- // Validate required fields
32
- if (!input.reason || !input.reason.trim()) {
33
- throw new Error('PainSignalInput.reason is required and must be non-empty');
34
- }
35
- const timestamp = new Date().toISOString();
36
- const severity = deriveSeverity(input.score ?? 80);
37
- // Build PainSignal-compatible object for schema validation
38
- const rawSignal = {
39
- source: input.source ?? 'manual',
40
- score: input.score ?? 80,
41
- timestamp,
42
- reason: input.reason.trim(),
43
- sessionId: input.sessionId ?? 'unknown',
44
- agentId: 'principles-core', // SDK does not have agent identity
45
- traceId: 'sdk', // SDK does not have trace context
46
- triggerTextPreview: input.reason.slice(0, 100),
47
- version: '0.1.0',
48
- domain: 'coding',
49
- severity,
50
- context: {},
51
- };
52
- // Validate against schema (fills defaults for optional fields)
53
- const result = validatePainSignal(rawSignal);
54
- if (!result.valid) {
55
- throw new Error(`Invalid PainSignal: ${result.errors.join(', ')}`);
56
- }
57
- const { signal } = result;
58
- if (!signal)
59
- throw new Error('Unexpected: validated PainSignal is undefined');
60
- return signal;
61
- }
62
- //# sourceMappingURL=pain-recorder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pain-recorder.js","sourceRoot":"","sources":["../src/pain-recorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAYtE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAsB,EACtB,YAAoB;IAEpB,KAAK,YAAY,CAAC;IAClB,2BAA2B;IAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAEnD,2DAA2D;IAC3D,MAAM,SAAS,GAAG;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,QAAQ;QAChC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE;QACxB,SAAS;QACT,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;QAC3B,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS;QACvC,OAAO,EAAE,iBAAiB,EAAE,mCAAmC;QAC/D,OAAO,EAAE,KAAK,EAAc,kCAAkC;QAC9D,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;QAC9C,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,QAAQ;QAChB,QAAQ;QACR,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,+DAA+D;IAC/D,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAE9E,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,59 +0,0 @@
1
- /**
2
- * StorageAdapter interface for the Evolution SDK.
3
- *
4
- * This interface decouples the evolution engine from specific persistence
5
- * implementations (file system, SQLite, remote API). All higher-level
6
- * modules that need to read or mutate the principle ledger should depend
7
- * on this interface rather than importing principle-tree-ledger directly.
8
- *
9
- * The interface uses HybridLedgerStore from types.ts as the
10
- * canonical store shape, but future adapters can map alternative backends
11
- * to this shape.
12
- */
13
- import type { HybridLedgerStore } from './types.js';
14
- /**
15
- * Abstract storage adapter for the principle ledger.
16
- *
17
- * Implementations must guarantee:
18
- * - Atomic writes (no partial/corrupted state on crash)
19
- * - Thread-safe concurrent access (locking or equivalent)
20
- * - Consistent read-after-write visibility
21
- *
22
- * The `mutateLedger` method is the preferred way to perform read-modify-write
23
- * cycles. It encapsulates locking so callers never need to manage it.
24
- */
25
- export interface StorageAdapter {
26
- /**
27
- * Load the current ledger state from persistence.
28
- *
29
- * If no persisted state exists (first run), returns an empty store.
30
- */
31
- loadLedger(): Promise<HybridLedgerStore>;
32
- /**
33
- * Persist the full ledger state.
34
- *
35
- * Must be atomic -- partial writes must never be visible to readers.
36
- */
37
- saveLedger(store: HybridLedgerStore): Promise<void>;
38
- /**
39
- * Perform a read-modify-write cycle with automatic locking.
40
- *
41
- * The `mutate` function receives the current store and may return a
42
- * value synchronously or via Promise. The store is persisted after
43
- * the mutate function resolves, regardless of its return value.
44
- *
45
- * If two concurrent `mutateLedger` calls overlap, one must wait for
46
- * the other to complete (pessimistic locking) or retry on conflict
47
- * (optimistic locking). The choice is left to the implementation.
48
- *
49
- * @example
50
- * ```ts
51
- * const count = await adapter.mutateLedger((store) => {
52
- * store.tree.principles['p-1'] = newPrinciple;
53
- * return Object.keys(store.tree.principles).length;
54
- * });
55
- * ```
56
- */
57
- mutateLedger<T>(mutate: (store: HybridLedgerStore) => T | Promise<T>): Promise<T>;
58
- }
59
- //# sourceMappingURL=storage-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage-adapter.d.ts","sourceRoot":"","sources":["../src/storage-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAMpD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEzC;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACnF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=storage-adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage-adapter.js","sourceRoot":"","sources":["../src/storage-adapter.ts"],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
1
- /**
2
- * WorkspaceResolver Interface
3
- *
4
- * Framework-agnostic contract for resolving the active workspace directory.
5
- * Concrete implementation is provided by the openclaw-plugin extension mechanism.
6
- *
7
- * D-01: Interface in @principles/core, implementation in openclaw-plugin
8
- */
9
- /**
10
- * Interface for resolving the active workspace directory.
11
- *
12
- * Concrete implementation lives in openclaw-plugin via extension/override pattern.
13
- * CLI commands depend on the interface only — no plugin internals.
14
- */
15
- export interface WorkspaceResolver {
16
- /**
17
- * Resolve the active workspace directory.
18
- *
19
- * @param workspaceDir - Optional override. If not provided, resolves using
20
- * platform-specific defaults (env vars, config file, cwd).
21
- * @returns The resolved workspace directory path.
22
- */
23
- resolve(workspaceDir?: string): string;
24
- }
25
- //# sourceMappingURL=workspace-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace-resolver.d.ts","sourceRoot":"","sources":["../../src/types/workspace-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * WorkspaceResolver Interface
3
- *
4
- * Framework-agnostic contract for resolving the active workspace directory.
5
- * Concrete implementation is provided by the openclaw-plugin extension mechanism.
6
- *
7
- * D-01: Interface in @principles/core, implementation in openclaw-plugin
8
- */
9
- export {};
10
- //# sourceMappingURL=workspace-resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace-resolver.js","sourceRoot":"","sources":["../../src/types/workspace-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
package/dist/types.d.ts DELETED
@@ -1,56 +0,0 @@
1
- /**
2
- * Duplicated type shapes for principles-core.
3
- *
4
- * These types are minimal shapes duplicated from openclaw-plugin to avoid
5
- * cross-package imports. principles-core must NOT depend on openclaw-plugin.
6
- *
7
- * MAINTENANCE CONTRACT: When updating these types, also update the corresponding
8
- * source types in openclaw-plugin and vice-versa. These are the same shapes --
9
- * drift between them will cause subtle storage/pipeline bugs.
10
- *
11
- * Source locations:
12
- * - InjectablePrinciple -> openclaw-plugin/src/core/principle-injection.ts
13
- * - HybridLedgerStore -> openclaw-plugin/src/core/principle-tree-ledger.ts
14
- */
15
- /**
16
- * Minimal InjectablePrinciple shape for principle injection.
17
- * Must stay in sync with openclaw-plugin/src/core/principle-injection.ts.
18
- */
19
- export interface InjectablePrinciple {
20
- id: string;
21
- text: string;
22
- /** Priority level. Defaults to 'P1' if not set by the source. */
23
- priority?: 'P0' | 'P1' | 'P2';
24
- createdAt: string;
25
- }
26
- /**
27
- * Minimal HybridLedgerStore shape for storage adapter interface.
28
- * Must stay in sync with openclaw-plugin/src/core/principle-tree-ledger.ts.
29
- *
30
- * Note: tree.* fields use `unknown` to avoid importing the actual node types.
31
- * This is an intentional trade-off -- StorageAdapter implementations must
32
- * be careful to validate the shape of objects they store/retrieve.
33
- */
34
- export interface HybridLedgerStore {
35
- trainingStore: Record<string, {
36
- principleId: string;
37
- evaluability: 'deterministic' | 'weak_heuristic' | 'manual_only';
38
- applicableOpportunityCount: number;
39
- observedViolationCount: number;
40
- complianceRate: number;
41
- violationTrend: number;
42
- generatedSampleCount: number;
43
- approvedSampleCount: number;
44
- includedTrainRunIds: string[];
45
- deployedCheckpointIds: string[];
46
- internalizationStatus: 'prompt_only' | 'needs_training' | 'in_training' | 'deployed_pending_eval' | 'internalized' | 'regressed';
47
- }>;
48
- tree: {
49
- principles: Record<string, unknown>;
50
- rules: Record<string, unknown>;
51
- implementations: Record<string, unknown>;
52
- metrics: Record<string, unknown>;
53
- lastUpdated: string;
54
- };
55
- }
56
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE;QAC5B,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,eAAe,GAAG,gBAAgB,GAAG,aAAa,CAAC;QACjE,0BAA0B,EAAE,MAAM,CAAC;QACnC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,mBAAmB,EAAE,MAAM,EAAE,CAAC;QAC9B,qBAAqB,EAAE,MAAM,EAAE,CAAC;QAChC,qBAAqB,EAAE,aAAa,GAAG,gBAAgB,GAAG,aAAa,GAAG,uBAAuB,GAAG,cAAc,GAAG,WAAW,CAAC;KAClI,CAAC,CAAC;IACH,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH"}
package/dist/types.js DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * Duplicated type shapes for principles-core.
3
- *
4
- * These types are minimal shapes duplicated from openclaw-plugin to avoid
5
- * cross-package imports. principles-core must NOT depend on openclaw-plugin.
6
- *
7
- * MAINTENANCE CONTRACT: When updating these types, also update the corresponding
8
- * source types in openclaw-plugin and vice-versa. These are the same shapes --
9
- * drift between them will cause subtle storage/pipeline bugs.
10
- *
11
- * Source locations:
12
- * - InjectablePrinciple -> openclaw-plugin/src/core/principle-injection.ts
13
- * - HybridLedgerStore -> openclaw-plugin/src/core/principle-tree-ledger.ts
14
- */
15
- export {};
16
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}