principles-disciple 1.16.0 → 1.17.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/README.md +13 -5
- package/openclaw.plugin.json +4 -4
- package/package.json +1 -1
- package/src/commands/archive-impl.ts +3 -3
- package/src/commands/capabilities.ts +1 -1
- package/src/commands/context.ts +3 -3
- package/src/commands/disable-impl.ts +1 -1
- package/src/commands/evolution-status.ts +2 -2
- package/src/commands/focus.ts +2 -2
- package/src/commands/nocturnal-train.ts +6 -6
- package/src/commands/pain.ts +4 -4
- package/src/commands/pd-reflect.ts +87 -0
- package/src/commands/rollback-impl.ts +4 -4
- package/src/commands/rollback.ts +2 -2
- package/src/commands/samples.ts +2 -2
- package/src/commands/workflow-debug.ts +1 -1
- package/src/config/errors.ts +1 -1
- package/src/core/adaptive-thresholds.ts +1 -1
- package/src/core/code-implementation-storage.ts +2 -2
- package/src/core/config.ts +1 -1
- package/src/core/diagnostician-task-store.ts +2 -2
- package/src/core/empathy-keyword-matcher.ts +3 -3
- package/src/core/event-log.ts +5 -5
- package/src/core/evolution-engine.ts +4 -4
- package/src/core/evolution-logger.ts +1 -1
- package/src/core/evolution-reducer.ts +3 -3
- package/src/core/evolution-types.ts +5 -5
- package/src/core/external-training-contract.ts +1 -1
- package/src/core/focus-history.ts +14 -14
- package/src/core/hygiene/tracker.ts +1 -1
- package/src/core/init.ts +2 -2
- package/src/core/model-deployment-registry.ts +2 -2
- package/src/core/model-training-registry.ts +2 -2
- package/src/core/nocturnal-arbiter.ts +1 -1
- package/src/core/nocturnal-artificer.ts +2 -2
- package/src/core/nocturnal-candidate-scoring.ts +2 -2
- package/src/core/nocturnal-compliance.ts +3 -3
- package/src/core/nocturnal-dataset.ts +3 -3
- package/src/core/nocturnal-export.ts +4 -4
- package/src/core/nocturnal-rule-implementation-validator.ts +1 -1
- package/src/core/nocturnal-snapshot-contract.ts +112 -0
- package/src/core/nocturnal-trajectory-extractor.ts +7 -5
- package/src/core/nocturnal-trinity.ts +27 -28
- package/src/core/pain-context-extractor.ts +3 -3
- package/src/core/pain.ts +124 -11
- package/src/core/path-resolver.ts +4 -4
- package/src/core/pd-task-reconciler.ts +10 -10
- package/src/core/pd-task-service.ts +1 -1
- package/src/core/pd-task-store.ts +1 -1
- package/src/core/principle-internalization/deprecated-readiness.ts +1 -1
- package/src/core/principle-training-state.ts +2 -2
- package/src/core/principle-tree-ledger.ts +7 -7
- package/src/core/promotion-gate.ts +9 -9
- package/src/core/replay-engine.ts +12 -12
- package/src/core/risk-calculator.ts +1 -1
- package/src/core/rule-host-types.ts +2 -2
- package/src/core/rule-host.ts +5 -5
- package/src/core/schema/db-types.ts +1 -1
- package/src/core/schema/schema-definitions.ts +1 -1
- package/src/core/session-tracker.ts +96 -4
- package/src/core/shadow-observation-registry.ts +3 -3
- package/src/core/system-logger.ts +2 -2
- package/src/core/thinking-os-parser.ts +1 -1
- package/src/core/training-program.ts +2 -2
- package/src/core/trajectory.ts +8 -8
- package/src/core/workspace-context.ts +2 -2
- package/src/core/workspace-dir-service.ts +85 -0
- package/src/core/workspace-dir-validation.ts +30 -107
- package/src/hooks/bash-risk.ts +3 -3
- package/src/hooks/edit-verification.ts +4 -4
- package/src/hooks/gate-block-helper.ts +4 -4
- package/src/hooks/gate.ts +10 -10
- package/src/hooks/gfi-gate.ts +7 -7
- package/src/hooks/lifecycle.ts +2 -2
- package/src/hooks/llm.ts +1 -1
- package/src/hooks/pain.ts +25 -5
- package/src/hooks/progressive-trust-gate.ts +7 -7
- package/src/hooks/prompt.ts +24 -5
- package/src/hooks/subagent.ts +2 -2
- package/src/hooks/thinking-checkpoint.ts +2 -2
- package/src/hooks/trajectory-collector.ts +1 -1
- package/src/http/principles-console-route.ts +14 -6
- package/src/i18n/commands.ts +4 -0
- package/src/index.ts +181 -185
- package/src/service/central-health-service.ts +1 -1
- package/src/service/central-overview-service.ts +3 -3
- package/src/service/evolution-query-service.ts +1 -1
- package/src/service/evolution-worker.ts +209 -104
- package/src/service/health-query-service.ts +27 -17
- package/src/service/monitoring-query-service.ts +3 -3
- package/src/service/nocturnal-runtime.ts +4 -4
- package/src/service/nocturnal-service.ts +40 -23
- package/src/service/nocturnal-target-selector.ts +2 -2
- package/src/service/runtime-summary-service.ts +1 -1
- package/src/service/subagent-workflow/deep-reflect-workflow-manager.ts +1 -1
- package/src/service/subagent-workflow/empathy-observer-workflow-manager.ts +3 -3
- package/src/service/subagent-workflow/nocturnal-workflow-manager.ts +16 -13
- package/src/service/subagent-workflow/runtime-direct-driver.ts +10 -6
- package/src/service/subagent-workflow/types.ts +4 -4
- package/src/service/subagent-workflow/workflow-manager-base.ts +5 -5
- package/src/service/subagent-workflow/workflow-store.ts +2 -2
- package/src/tools/critique-prompt.ts +2 -3
- package/src/tools/deep-reflect.ts +17 -16
- package/src/tools/model-index.ts +1 -1
- package/src/utils/file-lock.ts +1 -1
- package/src/utils/io.ts +7 -2
- package/src/utils/nlp.ts +1 -1
- package/src/utils/plugin-logger.ts +2 -2
- package/src/utils/retry.ts +3 -2
- package/src/utils/subagent-probe.ts +20 -33
- package/templates/langs/en/skills/pd-pain-signal/SKILL.md +8 -7
- package/templates/langs/zh/skills/pd-pain-signal/SKILL.md +8 -7
- package/templates/pain_settings.json +1 -1
- package/tests/build-artifacts.test.ts +4 -58
- package/tests/commands/pd-reflect.test.ts +49 -0
- package/tests/core/nocturnal-snapshot-contract.test.ts +70 -0
- package/tests/core/pain-auto-repair.test.ts +96 -0
- package/tests/core/pain-integration.test.ts +483 -0
- package/tests/core/pain.test.ts +5 -4
- package/tests/core/workspace-dir-service.test.ts +68 -0
- package/tests/core/workspace-dir-validation.test.ts +56 -192
- package/tests/hooks/pain.test.ts +20 -0
- package/tests/http/principles-console-route.test.ts +42 -20
- package/tests/integration/empathy-workflow-integration.test.ts +1 -2
- package/tests/integration/tool-hooks-workspace-dir.e2e.test.ts +9 -17
- package/tests/service/empathy-observer-workflow-manager.test.ts +1 -2
- package/tests/service/evolution-worker.nocturnal.test.ts +562 -6
- package/tests/service/nocturnal-runtime-hardening.test.ts +33 -0
- package/tests/utils/subagent-probe.test.ts +32 -0
|
@@ -9,6 +9,7 @@ import { TrajectoryRegistry } from '../core/trajectory.js';
|
|
|
9
9
|
import { getCentralDatabase } from '../service/central-database.js';
|
|
10
10
|
import { CentralOverviewService } from '../service/central-overview-service.js';
|
|
11
11
|
import { CentralHealthService } from '../service/central-health-service.js';
|
|
12
|
+
import { resolveRequiredWorkspaceDir } from '../core/workspace-dir-service.js';
|
|
12
13
|
|
|
13
14
|
const ROUTE_PREFIX = '/plugins/principles';
|
|
14
15
|
const API_PREFIX = `${ROUTE_PREFIX}/api`;
|
|
@@ -90,11 +91,11 @@ function serveFile(res: ServerResponse, filePath: string): boolean {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
function createService(api: OpenClawPluginApi): ControlUiQueryService {
|
|
93
|
-
const workspaceDir = api
|
|
94
|
+
const workspaceDir = resolveRequiredWorkspaceDir(api, { agentId: 'main' }, { source: 'principles_console.control_ui', fallbackAgentId: 'main' });
|
|
94
95
|
return new ControlUiQueryService(workspaceDir);
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
|
|
98
99
|
function handleApiRoute(
|
|
99
100
|
api: OpenClawPluginApi,
|
|
100
101
|
pathname: string,
|
|
@@ -102,13 +103,20 @@ function handleApiRoute(
|
|
|
102
103
|
res: ServerResponse,
|
|
103
104
|
): Promise<boolean> | boolean {
|
|
104
105
|
// Check authentication for API routes
|
|
105
|
-
|
|
106
|
+
|
|
106
107
|
if (!validateGatewayAuth(req)) {
|
|
107
108
|
json(res, 401, { error: 'unauthorized', message: 'Valid Gateway token required.' });
|
|
108
109
|
return true;
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
let service: ControlUiQueryService;
|
|
113
|
+
try {
|
|
114
|
+
service = createService(api);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
api.logger.warn(`[PD:ControlUI] Failed to resolve workspace for ${pathname}: ${String(error)}`);
|
|
117
|
+
json(res, 500, { error: 'internal_error', message: String(error) });
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
112
120
|
const url = new URL(req.url || pathname, 'http://127.0.0.1');
|
|
113
121
|
const method = (req.method || 'GET').toUpperCase();
|
|
114
122
|
|
|
@@ -338,7 +346,7 @@ function handleApiRoute(
|
|
|
338
346
|
|
|
339
347
|
// === Evolution API ===
|
|
340
348
|
const evolutionService = () => {
|
|
341
|
-
const workspaceDir = api
|
|
349
|
+
const workspaceDir = resolveRequiredWorkspaceDir(api, { agentId: 'main' }, { source: 'principles_console.evolution', fallbackAgentId: 'main' });
|
|
342
350
|
const trajectory = TrajectoryRegistry.get(workspaceDir);
|
|
343
351
|
return getEvolutionQueryService(trajectory);
|
|
344
352
|
};
|
|
@@ -398,7 +406,7 @@ function handleApiRoute(
|
|
|
398
406
|
|
|
399
407
|
// === Health Query API (v1.1 new endpoints) ===
|
|
400
408
|
const healthService = () => {
|
|
401
|
-
const workspaceDir = api
|
|
409
|
+
const workspaceDir = resolveRequiredWorkspaceDir(api, { agentId: 'main' }, { source: 'principles_console.health', fallbackAgentId: 'main' });
|
|
402
410
|
return new HealthQueryService(workspaceDir);
|
|
403
411
|
};
|
|
404
412
|
|
package/src/i18n/commands.ts
CHANGED
|
@@ -37,6 +37,10 @@ export const commandDescriptions: Record<string, Record<SupportedLanguage, strin
|
|
|
37
37
|
zh: '管理思维模型 [status|propose|audit]',
|
|
38
38
|
en: 'Manage Thinking OS [status|propose|audit]'
|
|
39
39
|
},
|
|
40
|
+
'pd-reflect': {
|
|
41
|
+
zh: '手动触发 Nocturnal 睡眠反射(跳过 idle 检测)',
|
|
42
|
+
en: 'Manually trigger Nocturnal sleep reflection (bypass idle check)'
|
|
43
|
+
},
|
|
40
44
|
'pd-daily': {
|
|
41
45
|
zh: '配置并发送进化日报',
|
|
42
46
|
en: 'Configure and send daily evolution report'
|