principles-disciple 1.116.0 → 1.117.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.
@@ -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.116.0",
5
+ "version": "1.117.0",
6
6
  "activation": {
7
7
  "onCapabilities": [
8
8
  "hook"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "1.116.0",
3
+ "version": "1.117.0",
4
4
  "description": "Native OpenClaw plugin for Principles Disciple",
5
5
  "type": "module",
6
6
  "main": "./dist/bundle.js",
@@ -5,6 +5,8 @@ import {
5
5
  DreamerRunner,
6
6
  DefaultDreamerValidator,
7
7
  PiAiRuntimeAdapter,
8
+ L2AgentLoopAdapter,
9
+ loadLedger,
8
10
  OpenClawCliRuntimeAdapter,
9
11
  storeEmitter,
10
12
  resolveRuntimeConfigFromPdConfig,
@@ -13,6 +15,7 @@ import {
13
15
  InternalizationQueueReadModel,
14
16
  MVP_CORE_TASK_KINDS,
15
17
  type PDRuntimeAdapter,
18
+ type PdL2PrincipleReader,
16
19
  } from '@principles/core/runtime-v2';
17
20
  import { loadPdConfigForPlugin, loadFeatureFlagFromConfig } from '../core/pd-config-loader.js';
18
21
  import { SystemLogger } from '../core/system-logger.js';
@@ -169,15 +172,61 @@ export async function runConsumerCycle(
169
172
 
170
173
  let adapter: PDRuntimeAdapter;
171
174
  if (runtimeKind === 'pi-ai') {
172
- adapter = new PiAiRuntimeAdapter({
173
- provider: runtimeConfigResult.provider ?? 'openai',
174
- model: runtimeConfigResult.model ?? 'gpt-4o',
175
- apiKeyEnv: runtimeConfigResult.apiKeyEnv ?? 'OPENAI_API_KEY',
176
- maxRetries: runtimeConfigResult.maxRetries,
177
- timeoutMs: runtimeConfigResult.timeoutMs,
178
- baseUrl: runtimeConfigResult.baseUrl,
179
- workspace: workspaceDir,
180
- });
175
+ // PRI-419: when l2_dreamer flag is on, route through the L2 multi-turn agent loop.
176
+ const l2Flag = loadFeatureFlagFromConfig(workspaceDir, 'l2_dreamer');
177
+ if (l2Flag.enabled) {
178
+ const stateDir = `${workspaceDir}/.state`;
179
+ const principleReader: PdL2PrincipleReader = {
180
+ listActivePrinciples: async () => {
181
+ try {
182
+ const ledger = loadLedger(stateDir);
183
+ const principles = ledger.tree.principles ?? {};
184
+ return Object.values(principles)
185
+ .filter(p => p.status === 'active' && typeof p.id === 'string' && typeof p.text === 'string')
186
+ .map(p => ({ id: p.id, statement: p.text }));
187
+ } catch (error) {
188
+ const reason = error instanceof Error ? error.message : String(error);
189
+ logger.warn(`[PD:AutoConsumer] L2 dreamer principle reader degraded: ${reason}`);
190
+ return [];
191
+ }
192
+ },
193
+ };
194
+ adapter = new L2AgentLoopAdapter(
195
+ {
196
+ provider: runtimeConfigResult.provider ?? 'openai',
197
+ model: runtimeConfigResult.model ?? 'gpt-4o',
198
+ apiKeyEnv: runtimeConfigResult.apiKeyEnv ?? 'OPENAI_API_KEY',
199
+ baseUrl: runtimeConfigResult.baseUrl,
200
+ workspace: workspaceDir,
201
+ totalBudgetMs: runtimeConfigResult.timeoutMs,
202
+ },
203
+ {
204
+ artifactReader: {
205
+ // Explicit adapter: PIArtifactRecord → PdL2ArtifactReader. The store returns
206
+ // PIArtifactRecord (with PIArtifactKind enum); map to the ArtifactSummary shape.
207
+ getArtifactById: async (id: string) => {
208
+ const r = await stateManager.piArtifactStore.getArtifactById(id);
209
+ return r ? { artifactId: r.artifactId, artifactKind: String(r.artifactKind), sourceTaskId: r.sourceTaskId, contentJson: r.contentJson, createdAt: r.createdAt } : null;
210
+ },
211
+ listBySourceTaskId: async (taskId: string) => {
212
+ const records = await stateManager.piArtifactStore.listBySourceTaskId(taskId);
213
+ return records.map(r => ({ artifactId: r.artifactId, artifactKind: String(r.artifactKind), sourceTaskId: r.sourceTaskId, contentJson: r.contentJson, createdAt: r.createdAt }));
214
+ },
215
+ },
216
+ principleReader,
217
+ },
218
+ );
219
+ } else {
220
+ adapter = new PiAiRuntimeAdapter({
221
+ provider: runtimeConfigResult.provider ?? 'openai',
222
+ model: runtimeConfigResult.model ?? 'gpt-4o',
223
+ apiKeyEnv: runtimeConfigResult.apiKeyEnv ?? 'OPENAI_API_KEY',
224
+ maxRetries: runtimeConfigResult.maxRetries,
225
+ timeoutMs: runtimeConfigResult.timeoutMs,
226
+ baseUrl: runtimeConfigResult.baseUrl,
227
+ workspace: workspaceDir,
228
+ });
229
+ }
181
230
  } else if (runtimeKind === 'openclaw-cli') {
182
231
  adapter = new OpenClawCliRuntimeAdapter({
183
232
  runtimeMode: runtimeConfigResult.openclawMode ?? 'default',