principles-disciple 1.115.1 → 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.
package/openclaw.plugin.json
CHANGED
|
@@ -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.
|
|
5
|
+
"version": "1.117.0",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onCapabilities": [
|
|
8
8
|
"hook"
|
package/package.json
CHANGED
|
@@ -94,17 +94,6 @@ export const EVENT_LOG_FLUSH_INTERVAL_MS = 30 * MS_PER_SECOND;
|
|
|
94
94
|
/** Default busy timeout for SQLite operations (5 seconds) */
|
|
95
95
|
export const DEFAULT_BUSY_TIMEOUT_MS = 5 * MS_PER_SECOND;
|
|
96
96
|
|
|
97
|
-
// ── Nocturnal Runtime Settings ─────────────────────────────────────────────────
|
|
98
|
-
|
|
99
|
-
/** Idle threshold (30 minutes) */
|
|
100
|
-
export const DEFAULT_IDLE_THRESHOLD_MS = 30 * ONE_MINUTE_MS;
|
|
101
|
-
|
|
102
|
-
/** Quota window (24 hours) */
|
|
103
|
-
export const DEFAULT_QUOTA_WINDOW_MS = ONE_DAY_MS;
|
|
104
|
-
|
|
105
|
-
/** Cool down period (30 minutes) */
|
|
106
|
-
export const DEFAULT_COOLDOWN_MS = 30 * ONE_MINUTE_MS;
|
|
107
|
-
|
|
108
97
|
// ── String & Size Limits ────────────────────────────────────────────────────────
|
|
109
98
|
|
|
110
99
|
/** Max string length for trajectory/event logs */
|
package/src/core/paths.ts
CHANGED
|
@@ -30,9 +30,6 @@ export const PD_DIRS = {
|
|
|
30
30
|
SESSIONS: posixJoin('.state', 'sessions'),
|
|
31
31
|
PAIN_SAMPLES: posixJoin('memory', 'pain'),
|
|
32
32
|
LOCKS: posixJoin('memory', '.locks'),
|
|
33
|
-
NOCTURNAL_SAMPLES: posixJoin('.state', 'nocturnal', 'samples'),
|
|
34
|
-
NOCTURNAL_MEMORY: posixJoin('.state', 'nocturnal', 'memory'),
|
|
35
|
-
NOCTURNAL_EXPORTS: posixJoin('.state', 'exports', 'orpo'),
|
|
36
33
|
IMPL_CODE_DIR: posixJoin('.state', 'principles', 'implementations'),
|
|
37
34
|
};
|
|
38
35
|
|
|
@@ -63,9 +60,6 @@ export const PD_FILES = {
|
|
|
63
60
|
DICTIONARY: posixJoin(PD_DIRS.STATE, 'pain_dictionary.json'),
|
|
64
61
|
PRINCIPLE_BLACKLIST: posixJoin(PD_DIRS.STATE, 'principle_blacklist.json'),
|
|
65
62
|
WORKFLOWS_YAML: posixJoin(PD_DIRS.STATE, 'workflows.yaml'),
|
|
66
|
-
NOCTURNAL_SAMPLES_DIR: PD_DIRS.NOCTURNAL_SAMPLES,
|
|
67
|
-
NOCTURNAL_MEMORY_DIR: PD_DIRS.NOCTURNAL_MEMORY,
|
|
68
|
-
NOCTURNAL_EXPORTS_DIR: PD_DIRS.NOCTURNAL_EXPORTS,
|
|
69
63
|
IMPL_CODE_DIR: PD_DIRS.IMPL_CODE_DIR,
|
|
70
64
|
|
|
71
65
|
MEMORY_MD: 'MEMORY.md',
|
|
@@ -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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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',
|
package/run-nocturnal.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
|
|
4
|
-
const workspaceDir = '/home/csuzngjh/.openclaw/workspace-main';
|
|
5
|
-
const stateDir = '/home/csuzngjh/.openclaw/workspace-main/.state';
|
|
6
|
-
|
|
7
|
-
console.error('WorkspaceDir:', workspaceDir);
|
|
8
|
-
console.error('StateDir:', stateDir);
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const bundlePath = './dist/nocturnal-service.bundle.js';
|
|
12
|
-
console.error('Importing from:', bundlePath);
|
|
13
|
-
|
|
14
|
-
const mod = await import(bundlePath);
|
|
15
|
-
|
|
16
|
-
console.log('Available exports:', Object.keys(mod));
|
|
17
|
-
|
|
18
|
-
if (!mod.executeNocturnalReflection) {
|
|
19
|
-
throw new Error('executeNocturnalReflection not found in bundle. Available exports: ' + Object.keys(mod).join(', '));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
console.error('Calling executeNocturnalReflection...');
|
|
23
|
-
const result = await mod.executeNocturnalReflection(workspaceDir, stateDir);
|
|
24
|
-
|
|
25
|
-
console.log(JSON.stringify(result, null, 2));
|
|
26
|
-
} catch (err) {
|
|
27
|
-
console.error('ERROR:', err.message);
|
|
28
|
-
if (err.stack) console.error(err.stack);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|