create-principles-disciple 1.150.6 → 1.152.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 +5 -5
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/ingestion/codex-version.d.ts +14 -12
- package/codex-adapter/dist/ingestion/codex-version.js +19 -20
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/bind-guard.d.ts +6 -13
- package/console/dist/server/bind-guard.js +8 -17
- package/console/dist/server/index.d.ts +9 -3
- package/console/dist/server/index.js +55 -53
- package/console/dist/server/models/ActivationsConsoleModel.js +2 -1
- package/console/dist/server/models/OwnerDecisionConsoleModel.js +58 -19
- package/console/dist/server/routes/activations.js +2 -2
- package/console/dist/server/routes/diagnostician.js +1 -1
- package/console/dist/server/routes/evidence-outcomes.d.ts +3 -2
- package/console/dist/server/routes/evidence-outcomes.js +1 -1
- package/console/dist/server/routes/failed-tasks.js +85 -2
- package/console/dist/server/routes/governance.d.ts +9 -6
- package/console/dist/server/routes/governance.js +10 -6
- package/console/dist/server/routes/owner-decisions.d.ts +3 -3
- package/console/dist/server/routes/owner-decisions.js +1 -1
- package/console/dist/server/routes/owner-identity.d.ts +4 -5
- package/console/dist/server/routes/owner-identity.js +4 -4
- package/console/dist/server/routes/rule-candidate-bindings.js +1 -1
- package/console/dist/server/routes/update.js +24 -6
- package/console/dist/server/utils/request-guard.d.ts +35 -0
- package/console/dist/server/utils/request-guard.js +81 -0
- package/console/dist/server/utils/response.d.ts +0 -1
- package/console/dist/server/utils/response.js +0 -3
- package/console/dist/web/assets/app.css +95 -167
- package/console/dist/web/assets/app.js +32 -37
- package/core/dist/runtime/activation/activation-control-types.d.ts +3 -0
- package/core/dist/runtime/activation/activation-control-types.d.ts.map +1 -1
- package/core/dist/runtime/activation/ledger-identity.d.ts.map +1 -1
- package/core/dist/runtime/activation/ledger-identity.js +5 -0
- package/core/dist/runtime/activation/ledger-identity.js.map +1 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts +6 -0
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts.map +1 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.js +105 -7
- package/core/dist/runtime/activation/prompt-activation-reader-contract.js.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.d.ts.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js +3 -2
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js.map +1 -1
- package/core/dist/runtime/activation/sqlite-activation-safety-store.d.ts.map +1 -1
- package/core/dist/runtime/activation/sqlite-activation-safety-store.js +26 -13
- package/core/dist/runtime/activation/sqlite-activation-safety-store.js.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +22 -8
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js +10 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.d.ts +17 -2
- package/core/dist/runtime/adapter/structured-output-repair.d.ts.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.js +26 -5
- package/core/dist/runtime/adapter/structured-output-repair.js.map +1 -1
- package/core/dist/runtime/governance-experience-contract.d.ts +12 -12
- package/core/dist/runtime/governance-experience-contract.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience-contract.js +0 -2
- package/core/dist/runtime/governance-experience-contract.js.map +1 -1
- package/core/dist/runtime/governance-experience.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience.js +8 -16
- package/core/dist/runtime/governance-experience.js.map +1 -1
- package/core/dist/runtime/internalization/approved-rule-revision.d.ts.map +1 -1
- package/core/dist/runtime/internalization/approved-rule-revision.js +2 -1
- package/core/dist/runtime/internalization/approved-rule-revision.js.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +13 -0
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js +28 -4
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.js +25 -3
- package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime/recovery-sweep-service.d.ts +7 -0
- package/core/dist/runtime/recovery-sweep-service.d.ts.map +1 -1
- package/core/dist/runtime/recovery-sweep-service.js +1 -0
- package/core/dist/runtime/recovery-sweep-service.js.map +1 -1
- package/core/dist/runtime/signal-collector/types.d.ts +6 -0
- package/core/dist/runtime/signal-collector/types.d.ts.map +1 -1
- package/core/dist/runtime/signal-collector/types.js.map +1 -1
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +59 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.js +201 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -0
- package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.js +43 -2
- package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.js +96 -37
- package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts +1 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
- package/core/package.json +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +49 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +118 -78
- package/dist/installer.js.map +1 -1
- package/dist/installers/index.d.ts +31 -0
- package/dist/installers/index.d.ts.map +1 -1
- package/dist/installers/index.js +76 -3
- package/dist/installers/index.js.map +1 -1
- package/dist/mvp-config.js +1 -1
- package/dist/mvp-config.js.map +1 -1
- package/dist/update/data-compatibility.d.ts.map +1 -1
- package/dist/update/data-compatibility.js +3 -1
- package/dist/update/data-compatibility.js.map +1 -1
- package/dist/update/release-manager.d.ts +6 -1
- package/dist/update/release-manager.d.ts.map +1 -1
- package/dist/update/release-manager.js +56 -3
- package/dist/update/release-manager.js.map +1 -1
- package/host-runtime/dist/active-principle-prompt.js +1 -0
- package/host-runtime/dist/adaptive-decision-protocol.d.ts +36 -8
- package/host-runtime/dist/adaptive-decision-protocol.js +79 -20
- package/host-runtime/dist/adaptive-selection.js +6 -1
- package/host-runtime/dist/cli-recovery-probe.d.ts +42 -1
- package/host-runtime/dist/cli-recovery-probe.js +16 -3
- package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +0 -29
- package/host-runtime/dist/conversation-ingestion/pipeline.js +39 -2
- package/host-runtime/dist/governance-signal-admission.js +12 -0
- package/host-runtime/dist/prompt-activation-deliverability.d.ts +2 -0
- package/host-runtime/dist/prompt-activation-deliverability.js +2 -0
- package/host-runtime/dist/prompt-injection-status.js +1 -0
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/mcp-binding-contract.js +5 -0
- package/install-layout/package.json +1 -1
- package/package.json +3 -3
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +117 -3
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/console.d.ts +0 -4
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +8 -63
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +4 -8
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js +114 -63
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +0 -8
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +13 -15
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +3 -85
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/pd-mcp-server/dist/version.d.ts +1 -1
- package/pd-mcp-server/dist/version.js +1 -1
- package/pd-mcp-server/package.json +1 -1
- package/plugin/dist/bundle.js +469 -452
- package/plugin/dist/core/mcp-binding.d.ts +3 -1
- package/plugin/dist/core/signal-collector-host.d.ts +19 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/mcp/launcher.cjs +85 -0
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +118 -78
- package/release-manager/dist/installers/index.js +76 -3
- package/release-manager/dist/mvp-config.js +1 -1
- package/release-manager/dist/update/release-manager.js +56 -3
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/mcp/launcher.cjs +85 -0
- package/console/dist/server/config/AuthConfig.d.ts +0 -14
- package/console/dist/server/config/AuthConfig.js +0 -42
|
@@ -38,4 +38,6 @@ export declare function invalidateMcpBinding(extensionRoot: string): {
|
|
|
38
38
|
removed: boolean;
|
|
39
39
|
reason?: string;
|
|
40
40
|
};
|
|
41
|
-
export declare function ensureMcpBinding(workspaceDir: string | undefined, extensionRoot: string, homeDir: string
|
|
41
|
+
export declare function ensureMcpBinding(workspaceDir: string | undefined, extensionRoot: string, homeDir: string, options?: {
|
|
42
|
+
experimentRoot?: string | null;
|
|
43
|
+
}): McpBindingOutcome;
|
|
@@ -91,6 +91,12 @@ export declare class SignalCollectorHost {
|
|
|
91
91
|
private readonly processedRuns;
|
|
92
92
|
/** Zero-hit discovery budget for this workspace's host process. */
|
|
93
93
|
private discoveryBucket;
|
|
94
|
+
/**
|
|
95
|
+
* Per-session discovery buckets. The global bucket alone lets one chatty
|
|
96
|
+
* session starve every other session's explicit corrections; the per-session
|
|
97
|
+
* dimension keeps ordinary conversation from exhausting the shared budget.
|
|
98
|
+
*/
|
|
99
|
+
private readonly discoverySessionBuckets;
|
|
94
100
|
constructor(wctx: WorkspaceContext, options?: SignalCollectorHostOptions);
|
|
95
101
|
/**
|
|
96
102
|
* ★ 同步路径 (prompt.ts before_prompt_build 钩子里调用,绝不能阻塞)。
|
|
@@ -150,9 +156,21 @@ export declare class SignalCollectorHost {
|
|
|
150
156
|
private countStage2Invocation;
|
|
151
157
|
/**
|
|
152
158
|
* 零命中发现调用的配额判定(纯内存,同步安全)。
|
|
153
|
-
*
|
|
159
|
+
* 全局每小时最多 discoveryRateLimitPerHour 次,且每个 session 最多
|
|
160
|
+
* discoveryRateLimitPerSessionPerHour 次;0/未设置 = 该维度不限制。
|
|
161
|
+
*
|
|
162
|
+
* 先判 session 再判全局:一个 session 达到自己的上限时不能继续消耗共享
|
|
163
|
+
* 预算,否则"某个会话聊得多"仍会间接饿死其它会话的明确纠正。
|
|
154
164
|
*/
|
|
155
165
|
private takeDiscoveryBudget;
|
|
166
|
+
/**
|
|
167
|
+
* 预算耗尽的结构化诊断:每小时窗口内每个 scope 只记一次 SYSTEM log,
|
|
168
|
+
* 健康计数仍然逐次累加(stage2DiscoverySkipped)。既有"挡下了多少次",
|
|
169
|
+
* 也有"为什么被挡、是哪个 scope、上限多少"。
|
|
170
|
+
*/
|
|
171
|
+
private reportDiscoveryExhaustion;
|
|
172
|
+
/** Expired session buckets carry no information; keep the map bounded. */
|
|
173
|
+
private pruneDiscoverySessionBuckets;
|
|
156
174
|
/** 被配额挡下的零命中发现计数(旁路,同 countStage2* 推迟到微任务)。 */
|
|
157
175
|
private countStage2DiscoverySkipped;
|
|
158
176
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.1.1",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
package/plugin/mcp/launcher.cjs
CHANGED
|
@@ -94,6 +94,76 @@ const logState = {
|
|
|
94
94
|
exhausted: false,
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
// ── Experiment isolation (P0, 2026-11-13 real-host E2E) ────────────────────
|
|
98
|
+
// The experiment gateway inherits this launcher's environment. When
|
|
99
|
+
// PD_EXPERIMENT_ROOT is present every PD-owned path used here must stay inside
|
|
100
|
+
// it: the log directory (default would be the PRODUCTION `~/.pd/logs/mcp`) and
|
|
101
|
+
// the binding workspace (a stale/inherited binding must never point the
|
|
102
|
+
// experiment at the production workspace). Refuse BEFORE any MCP traffic.
|
|
103
|
+
const EXPERIMENT_ROOT = typeof process.env.PD_EXPERIMENT_ROOT === 'string'
|
|
104
|
+
? process.env.PD_EXPERIMENT_ROOT.trim()
|
|
105
|
+
: '';
|
|
106
|
+
|
|
107
|
+
function canonicalExisting(target) {
|
|
108
|
+
const resolved = path.resolve(target);
|
|
109
|
+
const missing = [];
|
|
110
|
+
let current = resolved;
|
|
111
|
+
for (;;) {
|
|
112
|
+
try {
|
|
113
|
+
const real = fs.realpathSync.native(current);
|
|
114
|
+
return missing.length === 0 ? real : path.join(real, ...missing.reverse());
|
|
115
|
+
} catch {
|
|
116
|
+
// Missing path (the log dir is created later): canonicalize the deepest
|
|
117
|
+
// existing ancestor so an 8.3-form ancestor cannot make two views of the
|
|
118
|
+
// same directory look different.
|
|
119
|
+
}
|
|
120
|
+
const parent = path.dirname(current);
|
|
121
|
+
if (parent === current) return resolved;
|
|
122
|
+
missing.push(path.basename(current));
|
|
123
|
+
current = parent;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function isInsideOrSame(parent, child) {
|
|
128
|
+
const relative = path.relative(path.resolve(parent), path.resolve(child));
|
|
129
|
+
return relative === '' || (!path.isAbsolute(relative) && relative !== '..' && !relative.startsWith('..' + path.sep));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function experimentRootRealPath() {
|
|
133
|
+
if (EXPERIMENT_ROOT === '') return null;
|
|
134
|
+
if (!path.isAbsolute(EXPERIMENT_ROOT)) {
|
|
135
|
+
fail('experiment_root_not_absolute', 'PD_EXPERIMENT_ROOT must be an absolute path; refusing to start the MCP server from an ambiguous root.');
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
return fs.realpathSync.native(EXPERIMENT_ROOT);
|
|
139
|
+
} catch {
|
|
140
|
+
fail('experiment_root_missing', 'PD_EXPERIMENT_ROOT does not resolve to an existing directory; refusing to start the MCP server.');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isLogDirAllowed(dir) {
|
|
145
|
+
if (EXPERIMENT_ROOT === '') return true;
|
|
146
|
+
const rootReal = experimentRootRealPath();
|
|
147
|
+
return rootReal !== null && isInsideOrSame(rootReal, canonicalExisting(dir));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (EXPERIMENT_ROOT !== '') {
|
|
151
|
+
const logOverride = typeof process.env.PD_MCP_LOG_DIR === 'string' ? process.env.PD_MCP_LOG_DIR.trim() : '';
|
|
152
|
+
if (logOverride === '') {
|
|
153
|
+
fail(
|
|
154
|
+
'experiment_mcp_log_dir_missing',
|
|
155
|
+
'PD_MCP_LOG_DIR must be set for an experiment instance; the default log directory is the production ~/.pd/logs/mcp.',
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
const rootReal = experimentRootRealPath();
|
|
159
|
+
if (rootReal !== null && !isInsideOrSame(rootReal, canonicalExisting(logOverride))) {
|
|
160
|
+
fail(
|
|
161
|
+
'experiment_mcp_log_dir_outside_root',
|
|
162
|
+
'PD_MCP_LOG_DIR resolves outside PD_EXPERIMENT_ROOT; refusing to write MCP logs into production state.',
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
97
167
|
function pad(value, width) {
|
|
98
168
|
return String(value).padStart(width || 2, '0');
|
|
99
169
|
}
|
|
@@ -176,6 +246,7 @@ function ensureLogFile() {
|
|
|
176
246
|
if (logState.currentPath !== null) return logState.currentPath;
|
|
177
247
|
try {
|
|
178
248
|
const dir = logDir();
|
|
249
|
+
if (!isLogDirAllowed(dir)) return null;
|
|
179
250
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
180
251
|
if (!fs.statSync(dir).isDirectory()) return null;
|
|
181
252
|
maintainLogDir(dir, Date.now(), null);
|
|
@@ -497,6 +568,20 @@ if (!workspaceStat.isDirectory()) {
|
|
|
497
568
|
}
|
|
498
569
|
logState.workspaceResolution = 'ok';
|
|
499
570
|
|
|
571
|
+
// P0 (2026-11-13): an experiment must never bind a workspace outside its own
|
|
572
|
+
// root. The binding is untrusted input written by another process generation;
|
|
573
|
+
// a stale one (or one produced from an inherited production pointer) keeps the
|
|
574
|
+
// production path while every environment variable says "experiment".
|
|
575
|
+
if (EXPERIMENT_ROOT !== '') {
|
|
576
|
+
const rootReal = experimentRootRealPath();
|
|
577
|
+
if (rootReal !== null && !isInsideOrSame(rootReal, canonicalExisting(binding.workspaceDir))) {
|
|
578
|
+
fail(
|
|
579
|
+
'experiment_binding_workspace_outside_root',
|
|
580
|
+
'mcp-binding.json binds a workspace outside PD_EXPERIMENT_ROOT. Restart the experiment gateway so the PD plugin rewrites the binding for the experiment workspace.',
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
500
585
|
// ── OpenClaw workspace-declaration gate (SPEC §3.5, final safety closure) ──
|
|
501
586
|
// The OpenClaw binding is HOST-WIDE while agents have per-agent workspaces, so
|
|
502
587
|
// a binding may only be trusted while it still matches the workspace the Owner
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.1.1",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
package/plugin/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "principles-disciple",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,7 +12,7 @@ import { logger } from './utils/logger.js';
|
|
|
12
12
|
import { checkOpenClawGateway, stopOpenClawGateway, restartOpenClawGateway } from './utils/env.js';
|
|
13
13
|
import { t } from './i18n.js';
|
|
14
14
|
import { generateConfigYamlContent, ExistingConfigVerifyInfraError, validateExistingConfigYamlForPreserve, getConfigYamlPath, readEnabledChannelsFromConfigYaml, getOpenClawDir, getPdDir, getPdRuntimeDir, getInstallManifestPath, getPdRuntimeBackupsDir, getPluginExtDir, getInstalledPluginDir, getInstalledLayoutPackageDir, getPdBackupsDir, getInstalledPdCliDir, getInstalledBinDir, getInstalledConsoleDir, getHomeDir, isWindows, } from './mvp-config.js';
|
|
15
|
-
import { detectInstalledHosts, getHostInstallers } from './installers/index.js';
|
|
15
|
+
import { detectInstalledHosts, evaluateRecordedHostPresence, getHostInstallers, isRecordedHost } from './installers/index.js';
|
|
16
16
|
import { readCanonicalRuntimeCohort, readInstalledRuntimeCohort, resolvePluginDataRoot } from './installers/codex-host-installer.js';
|
|
17
17
|
import { runWorkbuddyEarlyPreflight } from './installers/workbuddy-host-installer.js';
|
|
18
18
|
import { INSTALL_LAYOUT_VERSION, getInstallLayoutPaths, getWorkbuddyWorkspaceDir, installManifestHostsForPersist, mergeInstallManifestWorkspaces, parseInstallManifest } from '@principles/install-layout';
|
|
@@ -610,6 +610,87 @@ export async function repairUpdateChain(input) {
|
|
|
610
610
|
notes,
|
|
611
611
|
};
|
|
612
612
|
}
|
|
613
|
+
export function repairInstallManifestHosts(options = {}) {
|
|
614
|
+
const manifestPath = getInstallManifestPath();
|
|
615
|
+
const refuse = (reason, nextAction) => ({
|
|
616
|
+
success: false,
|
|
617
|
+
applied: false,
|
|
618
|
+
manifestPath,
|
|
619
|
+
before: [],
|
|
620
|
+
after: [],
|
|
621
|
+
removed: [],
|
|
622
|
+
entries: [],
|
|
623
|
+
reason,
|
|
624
|
+
nextAction,
|
|
625
|
+
});
|
|
626
|
+
let raw;
|
|
627
|
+
try {
|
|
628
|
+
raw = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
629
|
+
}
|
|
630
|
+
catch (error) {
|
|
631
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
632
|
+
return refuse(`install_manifest_unreadable: ${detail}`, `Inspect ${manifestPath} and re-run the official installer once it is valid JSON.`);
|
|
633
|
+
}
|
|
634
|
+
const parsed = parseInstallManifest(raw);
|
|
635
|
+
if (parsed.manifest === undefined) {
|
|
636
|
+
return refuse(parsed.error ?? 'install_manifest_malformed', `Inspect ${manifestPath}; the host record cannot be judged safely.`);
|
|
637
|
+
}
|
|
638
|
+
const before = installManifestHostsForPersist(parsed.manifest);
|
|
639
|
+
const entries = before.map((host) => {
|
|
640
|
+
if (!isRecordedHost(host)) {
|
|
641
|
+
return { host, verdict: 'not-judged', detail: 'unknown host id — never removed by this repair' };
|
|
642
|
+
}
|
|
643
|
+
const presence = evaluateRecordedHostPresence(host, getHomeDir());
|
|
644
|
+
return presence.status === 'undecidable'
|
|
645
|
+
? { host, verdict: 'undecidable', detail: presence.reason }
|
|
646
|
+
: { host, verdict: presence.status, detail: presence.evidence };
|
|
647
|
+
});
|
|
648
|
+
const removed = entries.filter((entry) => entry.verdict === 'absent').map((entry) => entry.host);
|
|
649
|
+
const after = before.filter((host) => !removed.includes(host));
|
|
650
|
+
if (removed.length === 0) {
|
|
651
|
+
return {
|
|
652
|
+
success: true,
|
|
653
|
+
applied: false,
|
|
654
|
+
manifestPath,
|
|
655
|
+
before,
|
|
656
|
+
after,
|
|
657
|
+
removed,
|
|
658
|
+
entries,
|
|
659
|
+
nextAction: 'Nothing to repair: every recorded host is installed or cannot be judged safely.',
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
if (after.length === 0) {
|
|
663
|
+
return refuse('manifest_would_be_empty: every recorded host is provably absent, so no host installer would serve this installation', `Re-run the official installer to register a host before repairing ${manifestPath}.`);
|
|
664
|
+
}
|
|
665
|
+
if (options.apply !== true) {
|
|
666
|
+
return {
|
|
667
|
+
success: true,
|
|
668
|
+
applied: false,
|
|
669
|
+
manifestPath,
|
|
670
|
+
before,
|
|
671
|
+
after,
|
|
672
|
+
removed,
|
|
673
|
+
entries,
|
|
674
|
+
nextAction: 'Dry run — re-run with --apply to write the repair (the current file is backed up first).',
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const backupPath = path.join(getPdRuntimeBackupsDir(), `install-manifest.backup.${Date.now()}.json`);
|
|
678
|
+
mkdirSync(getPdRuntimeBackupsDir(), { recursive: true });
|
|
679
|
+
writeFileSync(backupPath, readFileSync(manifestPath));
|
|
680
|
+
writeInstallManifest([...after], [...(parsed.manifest.workspaces ?? [])]);
|
|
681
|
+
return {
|
|
682
|
+
success: true,
|
|
683
|
+
applied: true,
|
|
684
|
+
manifestPath,
|
|
685
|
+
before,
|
|
686
|
+
after,
|
|
687
|
+
removed,
|
|
688
|
+
entries,
|
|
689
|
+
backupPath,
|
|
690
|
+
restoreCommand: `cp "${backupPath}" "${manifestPath}"`,
|
|
691
|
+
nextAction: `Removed ${removed.join(', ')} from the host record. Restore the previous value with: cp "${backupPath}" "${manifestPath}"`,
|
|
692
|
+
};
|
|
693
|
+
}
|
|
613
694
|
function installBundledLayoutPackage(pluginDir) {
|
|
614
695
|
const source = path.join(pluginDir, 'install-layout');
|
|
615
696
|
const destination = getInstalledLayoutPackageDir();
|
|
@@ -2728,6 +2809,22 @@ export function ensureConsoleResolution() {
|
|
|
2728
2809
|
export function ensureCodexAdapterResolution() {
|
|
2729
2810
|
ensureComponentFileDependencyLinks(getInstalledCodexAdapterDir(), '@principles/codex-adapter');
|
|
2730
2811
|
}
|
|
2812
|
+
/**
|
|
2813
|
+
* PRI-1145: the INSTALLED host-runtime declares the same `file:../<component>`
|
|
2814
|
+
* siblings as the other runtime components (core / install-layout), but it was
|
|
2815
|
+
* the only one with no `ensure*Resolution()` caller. `installBundledHostRuntime`
|
|
2816
|
+
* therefore left the npm-materialized `node_modules/@principles/core` physical
|
|
2817
|
+
* copy in place, so a second core byte lived on the machine outside the
|
|
2818
|
+
* "every component resolves the canonical runtime core" invariant. Reuses the
|
|
2819
|
+
* shared helper (Connection Before Creation) instead of a new mechanism.
|
|
2820
|
+
*
|
|
2821
|
+
* Ordering contract: MUST run after installBundledHostRuntime() AND after every
|
|
2822
|
+
* `file:../` sibling it declares is deployed (core, install-layout). A missing
|
|
2823
|
+
* sibling fails the install loud (the helper).
|
|
2824
|
+
*/
|
|
2825
|
+
export function ensureHostRuntimeResolution() {
|
|
2826
|
+
ensureComponentFileDependencyLinks(getInstalledHostRuntimeDir(), '@principles/host-runtime');
|
|
2827
|
+
}
|
|
2731
2828
|
/**
|
|
2732
2829
|
* SPEC workbuddy-host-adapter §4.1/§5: the bundled @principles/workbuddy-adapter
|
|
2733
2830
|
* payload installs as a runtime sibling exactly like codex-adapter, and its
|
|
@@ -3065,22 +3162,16 @@ export class ConsoleVerifyError extends Error {
|
|
|
3065
3162
|
}
|
|
3066
3163
|
}
|
|
3067
3164
|
/**
|
|
3068
|
-
* PD Console health shape
|
|
3069
|
-
* for untrusted keys).
|
|
3165
|
+
* PD Console health shape (rc-5: Object.hasOwn for untrusted keys).
|
|
3070
3166
|
*
|
|
3071
3167
|
* P1-B: `data.overall` is the PD-specific discriminative field — the generic
|
|
3072
|
-
* { success: true } envelope alone matches any service.
|
|
3073
|
-
* `data.authenticationMode` must equal the launched posture, because that is the
|
|
3074
|
-
* same fact `pd console open` refuses on (`console_authentication_mode_mismatch`).
|
|
3075
|
-
* Without it the installer certified ANY healthy PD console on 3100..3119 as
|
|
3076
|
-
* "the console I just launched", including a pre-existing no-auth one that
|
|
3077
|
-
* `pd console open` had already refused to adopt.
|
|
3168
|
+
* { success: true } envelope alone matches any service.
|
|
3078
3169
|
*
|
|
3079
3170
|
* (Hoisted above the G1 P0-1 identity verifier — its first caller in file
|
|
3080
3171
|
* order — for no-use-before-define discipline; the autolaunch probe below
|
|
3081
3172
|
* shares this same shape contract.)
|
|
3082
3173
|
*/
|
|
3083
|
-
function isLaunchedConsoleHealth(payload
|
|
3174
|
+
function isLaunchedConsoleHealth(payload) {
|
|
3084
3175
|
if (typeof payload !== 'object' || payload === null)
|
|
3085
3176
|
return false;
|
|
3086
3177
|
if (!Object.hasOwn(payload, 'success') || Reflect.get(payload, 'success') !== true)
|
|
@@ -3093,18 +3184,7 @@ function isLaunchedConsoleHealth(payload, expectedMode) {
|
|
|
3093
3184
|
if (!Object.hasOwn(data, 'overall'))
|
|
3094
3185
|
return false;
|
|
3095
3186
|
const overall = Reflect.get(data, 'overall');
|
|
3096
|
-
|
|
3097
|
-
return false;
|
|
3098
|
-
if (!Object.hasOwn(data, 'authenticationMode'))
|
|
3099
|
-
return false;
|
|
3100
|
-
return Reflect.get(data, 'authenticationMode') === expectedMode;
|
|
3101
|
-
}
|
|
3102
|
-
/** sendUnauthorized's envelope — the only responder worth offering the token to. */
|
|
3103
|
-
function isConsoleUnauthorizedEnvelope(payload) {
|
|
3104
|
-
if (typeof payload !== 'object' || payload === null)
|
|
3105
|
-
return false;
|
|
3106
|
-
return Object.hasOwn(payload, 'success') && Reflect.get(payload, 'success') === false
|
|
3107
|
-
&& Object.hasOwn(payload, 'error') && Reflect.get(payload, 'error') === 'unauthorized';
|
|
3187
|
+
return overall === 'healthy' || overall === 'degraded' || overall === 'error';
|
|
3108
3188
|
}
|
|
3109
3189
|
/** P0-1 (SPEC v1.2 §7 / invariant I-3): the response must prove it came from
|
|
3110
3190
|
* THIS child — a one-shot nonce injected through the child env and echoed by
|
|
@@ -3112,7 +3192,7 @@ function isConsoleUnauthorizedEnvelope(payload) {
|
|
|
3112
3192
|
* 200+JSON cannot know the value, so they all fail closed here. The nonce
|
|
3113
3193
|
* value never enters logs or diagnostics. */
|
|
3114
3194
|
function isVerifiedConsoleIdentity(payload, expectedNonce) {
|
|
3115
|
-
if (!isLaunchedConsoleHealth(payload
|
|
3195
|
+
if (!isLaunchedConsoleHealth(payload))
|
|
3116
3196
|
return false;
|
|
3117
3197
|
const data = Reflect.get(payload, 'data');
|
|
3118
3198
|
if (typeof data !== 'object' || data === null || Array.isArray(data))
|
|
@@ -3163,7 +3243,7 @@ export async function verifyConsole(workspaceDir) {
|
|
|
3163
3243
|
// Cleared at every attempt exit below; attempts are strictly serial.
|
|
3164
3244
|
const nonce = randomUUID();
|
|
3165
3245
|
process.env.PD_CONSOLE_VERIFY_NONCE = nonce;
|
|
3166
|
-
const child = spawn(process.execPath, [serverEntry, '--workspace', workspaceDir, '--port', String(port), '--
|
|
3246
|
+
const child = spawn(process.execPath, [serverEntry, '--workspace', workspaceDir, '--port', String(port), '--host', '127.0.0.1'], {
|
|
3167
3247
|
stdio: 'pipe',
|
|
3168
3248
|
env: { ...process.env },
|
|
3169
3249
|
detached: false,
|
|
@@ -3315,9 +3395,9 @@ function openBrowserForOnboarding(url) {
|
|
|
3315
3395
|
return { opened: false, reason: err instanceof Error ? err.message : String(err) };
|
|
3316
3396
|
}
|
|
3317
3397
|
}
|
|
3318
|
-
function requestConsoleHealth(port,
|
|
3398
|
+
function requestConsoleHealth(port, timeoutMs) {
|
|
3319
3399
|
return new Promise((resolve) => {
|
|
3320
|
-
const req = http.get(`http://127.0.0.1:${port}/api/health`,
|
|
3400
|
+
const req = http.get(`http://127.0.0.1:${port}/api/health`, (res) => {
|
|
3321
3401
|
const chunks = [];
|
|
3322
3402
|
res.on('data', (c) => chunks.push(c));
|
|
3323
3403
|
res.on('end', () => {
|
|
@@ -3336,31 +3416,13 @@ function requestConsoleHealth(port, token, timeoutMs) {
|
|
|
3336
3416
|
});
|
|
3337
3417
|
}
|
|
3338
3418
|
/**
|
|
3339
|
-
* Is the console READY on this port
|
|
3340
|
-
*
|
|
3341
|
-
*
|
|
3342
|
-
* 1. bare GET first: a bearer credential must never be sprayed at up to
|
|
3343
|
-
* CONSOLE_AUTOLAUNCH_PORT_SCAN_LIMIT unidentified local ports;
|
|
3344
|
-
* 2. the token is attached only to a responder that answered 401 with the
|
|
3345
|
-
* console's own error envelope, and 200 is accepted only when
|
|
3346
|
-
* `authenticationMode` matches the launched posture.
|
|
3347
|
-
* An authenticated console answers 401 to a bare probe, so phase 1 alone cannot
|
|
3348
|
-
* distinguish it — phase 2 is the proof that the responder accepts THIS token.
|
|
3419
|
+
* Is the console READY on this port? A single bare GET is enough now: the
|
|
3420
|
+
* Console has no credential, so a 200 with a healthy envelope (and the
|
|
3421
|
+
* launcher's one-shot nonce where required) is the whole proof.
|
|
3349
3422
|
*/
|
|
3350
|
-
async function probeAutolaunchHealth(port,
|
|
3351
|
-
const
|
|
3352
|
-
|
|
3353
|
-
if (bare === null)
|
|
3354
|
-
return false;
|
|
3355
|
-
if (bare.status === 200)
|
|
3356
|
-
return isLaunchedConsoleHealth(bare.payload, expectedMode);
|
|
3357
|
-
if (bare.status !== 401 || !posture.authenticated)
|
|
3358
|
-
return false;
|
|
3359
|
-
if (!isConsoleUnauthorizedEnvelope(bare.payload))
|
|
3360
|
-
return false;
|
|
3361
|
-
const authorized = await requestConsoleHealth(port, posture.token, timeoutMs);
|
|
3362
|
-
return authorized !== null && authorized.status === 200
|
|
3363
|
-
&& isLaunchedConsoleHealth(authorized.payload, expectedMode);
|
|
3423
|
+
async function probeAutolaunchHealth(port, timeoutMs = 1500) {
|
|
3424
|
+
const response = await requestConsoleHealth(port, timeoutMs);
|
|
3425
|
+
return response !== null && response.status === 200 && isLaunchedConsoleHealth(response.payload);
|
|
3364
3426
|
}
|
|
3365
3427
|
/**
|
|
3366
3428
|
* Task 8: Auto-launch the PD Console at the end of a successful install by
|
|
@@ -3382,32 +3444,8 @@ async function probeAutolaunchHealth(port, posture, timeoutMs = 1500) {
|
|
|
3382
3444
|
export function resolveConsoleWorkspaceDir(host, projectWorkspaceDir, homeDir) {
|
|
3383
3445
|
return host === 'workbuddy' ? getWorkbuddyWorkspaceDir(homeDir) : projectWorkspaceDir;
|
|
3384
3446
|
}
|
|
3385
|
-
/**
|
|
3386
|
-
* PRI-1054: the authentication posture to auto-launch the console in.
|
|
3387
|
-
*
|
|
3388
|
-
* The update chain must NOT invent a posture: PD Companion asks for an
|
|
3389
|
-
* authenticated console whenever PD_CONSOLE_TOKEN is in its environment, and it
|
|
3390
|
-
* restores that token from its own encrypted state on every launch. Hardcoding
|
|
3391
|
-
* `--no-auth` here therefore swapped a healthy authenticated console for a
|
|
3392
|
-
* no-auth one on every release, and the next Companion start aborted with
|
|
3393
|
-
* `console_authentication_mode_mismatch` — i.e. configuring a token made every
|
|
3394
|
-
* later release brick the desktop app.
|
|
3395
|
-
*
|
|
3396
|
-
* Inheriting this process's own PD_CONSOLE_TOKEN keeps the machine's posture
|
|
3397
|
-
* unchanged, because `pd console open` reads the same variable (console.ts
|
|
3398
|
-
* resolves `opts.token ?? process.env.PD_CONSOLE_TOKEN` and only skips auth for
|
|
3399
|
-
* `--no-auth`). No new authority: the variable stays the single declaration.
|
|
3400
|
-
*/
|
|
3401
|
-
function readConsoleAuthPosture(env = process.env) {
|
|
3402
|
-
const token = env.PD_CONSOLE_TOKEN?.trim();
|
|
3403
|
-
return token ? { authenticated: true, token } : { authenticated: false };
|
|
3404
|
-
}
|
|
3405
3447
|
async function autoLaunchConsole(workspaceDir) {
|
|
3406
|
-
const
|
|
3407
|
-
const noAuthFlag = posture.authenticated ? '' : ' --no-auth';
|
|
3408
|
-
// The instruction the Owner may follow by hand — it must carry the same
|
|
3409
|
-
// posture as the launch, or following it re-creates the collision.
|
|
3410
|
-
const manualOpenCommand = `pd console open --workspace "${workspaceDir}"${noAuthFlag}`;
|
|
3448
|
+
const manualOpenCommand = `pd console open --workspace "${workspaceDir}"`;
|
|
3411
3449
|
// Test/smoke seam (mirrors PD_SKIP_GLOBAL_SHIM): isolated installs (release
|
|
3412
3450
|
// smoke, upgrade gate) must not spawn a detached console that holds the
|
|
3413
3451
|
// installed files open or pops a browser.
|
|
@@ -3422,8 +3460,6 @@ async function autoLaunchConsole(workspaceDir) {
|
|
|
3422
3460
|
// Spawn `pd console open` detached — reuses handleConsoleOpen (port detection,
|
|
3423
3461
|
// reuse, health). --no-browser because we open /welcome ourselves.
|
|
3424
3462
|
const launchArgs = [pdCliEntry, 'console', 'open', '--workspace', workspaceDir, '--no-browser'];
|
|
3425
|
-
if (!posture.authenticated)
|
|
3426
|
-
launchArgs.push('--no-auth');
|
|
3427
3463
|
const child = spawn(process.execPath, launchArgs, { detached: true, stdio: 'ignore', shell: false });
|
|
3428
3464
|
child.unref();
|
|
3429
3465
|
// Wait for the console to become ready (bounded poll on
|
|
@@ -3432,7 +3468,7 @@ async function autoLaunchConsole(workspaceDir) {
|
|
|
3432
3468
|
while (Date.now() < deadline) {
|
|
3433
3469
|
for (let i = 0; i < CONSOLE_AUTOLAUNCH_PORT_SCAN_LIMIT; i++) {
|
|
3434
3470
|
const port = CONSOLE_AUTOLAUNCH_BASE_PORT + i;
|
|
3435
|
-
if (await probeAutolaunchHealth(port
|
|
3471
|
+
if (await probeAutolaunchHealth(port)) {
|
|
3436
3472
|
// HashRouter: client-side routes live under /#/ — server only serves /,
|
|
3437
3473
|
// anything else (incl. /welcome) is treated as an API path and returns
|
|
3438
3474
|
// 404 not_found. Must open /#/welcome so the browser loads index.html
|
|
@@ -4299,6 +4335,10 @@ transaction) {
|
|
|
4299
4335
|
installBundledCodexAdapter(pluginDir);
|
|
4300
4336
|
stepIndex++;
|
|
4301
4337
|
installBundledLayoutPackage(pluginDir);
|
|
4338
|
+
// PRI-1145: host-runtime declares file:../core + file:../install-layout.
|
|
4339
|
+
// Both siblings are deployed above, so its physical nested copies are
|
|
4340
|
+
// corrected here — same contract as the adapters below.
|
|
4341
|
+
ensureHostRuntimeResolution();
|
|
4302
4342
|
// PRI-711: the adapter's own file: deps must resolve or pd-cli's eager
|
|
4303
4343
|
// import graph crashes on every command. Runs only once ALL adapter
|
|
4304
4344
|
// siblings exist — the manifest declares file:../core, file:../host-runtime
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as os from 'os';
|
|
4
4
|
import { OpenClawHostInstaller } from './openclaw-host-installer.js';
|
|
5
|
-
import { CodexHostInstaller } from './codex-host-installer.js';
|
|
6
|
-
import { WorkBuddyHostInstaller, readWorkbuddyHostState } from './workbuddy-host-installer.js';
|
|
5
|
+
import { CodexHostInstaller, detectCodexMarketplaceState } from './codex-host-installer.js';
|
|
6
|
+
import { WorkBuddyHostInstaller, readWorkbuddyHostState, resolveWorkbuddyPaths } from './workbuddy-host-installer.js';
|
|
7
7
|
export { OpenClawHostInstaller } from './openclaw-host-installer.js';
|
|
8
8
|
export { CodexHostInstaller } from './codex-host-installer.js';
|
|
9
9
|
export { WorkBuddyHostInstaller } from './workbuddy-host-installer.js';
|
|
@@ -78,4 +78,77 @@ export function detectInstalledHosts(homeDir = os.homedir(), codexHome) {
|
|
|
78
78
|
}
|
|
79
79
|
return detected;
|
|
80
80
|
}
|
|
81
|
+
export const RECORDED_HOSTS = ['openclaw', 'codex', 'workbuddy'];
|
|
82
|
+
export function isRecordedHost(value) {
|
|
83
|
+
return RECORDED_HOSTS.includes(value);
|
|
84
|
+
}
|
|
85
|
+
function errorCode(error) {
|
|
86
|
+
if (error instanceof Error && Object.hasOwn(error, 'code')) {
|
|
87
|
+
const code = Reflect.get(error, 'code');
|
|
88
|
+
return typeof code === 'string' ? code : undefined;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
function describeError(error) {
|
|
93
|
+
return error instanceof Error ? error.message : String(error);
|
|
94
|
+
}
|
|
95
|
+
export function evaluateRecordedHostPresence(host, homeDir = os.homedir()) {
|
|
96
|
+
const detected = detectInstalledHosts(homeDir).find((entry) => entry.hostId === host);
|
|
97
|
+
if (detected !== undefined) {
|
|
98
|
+
return { status: 'installed', evidence: detected.evidence };
|
|
99
|
+
}
|
|
100
|
+
if (host === 'openclaw') {
|
|
101
|
+
const openclawDir = path.join(homeDir, '.openclaw');
|
|
102
|
+
const configPath = path.join(openclawDir, 'openclaw.json');
|
|
103
|
+
let raw;
|
|
104
|
+
try {
|
|
105
|
+
raw = readFileSync(configPath, 'utf8');
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (errorCode(error) === 'ENOENT') {
|
|
109
|
+
return { status: 'absent', evidence: `no PD extension and no ${configPath}` };
|
|
110
|
+
}
|
|
111
|
+
return { status: 'undecidable', reason: `cannot read ${configPath}: ${describeError(error)}` };
|
|
112
|
+
}
|
|
113
|
+
// Conservative: a config that still names PD counts as installed even when
|
|
114
|
+
// the extension directory is gone — dropping the record would strand those
|
|
115
|
+
// entries, and a false "installed" only keeps the manifest as it is.
|
|
116
|
+
if (raw.includes('principles-disciple')) {
|
|
117
|
+
return { status: 'installed', evidence: `${configPath} still references principles-disciple` };
|
|
118
|
+
}
|
|
119
|
+
return { status: 'absent', evidence: `no PD extension and ${configPath} does not reference principles-disciple` };
|
|
120
|
+
}
|
|
121
|
+
if (host === 'codex') {
|
|
122
|
+
const detection = new CodexHostInstaller().detect();
|
|
123
|
+
if (detection.installed) {
|
|
124
|
+
const evidence = detection.paths.find((entry) => entry.exists);
|
|
125
|
+
return { status: 'installed', evidence: evidence?.path ?? 'codex install detected' };
|
|
126
|
+
}
|
|
127
|
+
// The Marketplace cache is the supported install path: its three-state
|
|
128
|
+
// detector distinguishes "absent" from "cannot judge".
|
|
129
|
+
const marketplace = detectCodexMarketplaceState();
|
|
130
|
+
if (marketplace.state === 'unknown') {
|
|
131
|
+
return { status: 'undecidable', reason: marketplace.reason };
|
|
132
|
+
}
|
|
133
|
+
const hooks = detection.paths.find((entry) => entry.name === 'Codex hooks.json' && entry.exists);
|
|
134
|
+
if (hooks !== undefined) {
|
|
135
|
+
try {
|
|
136
|
+
JSON.parse(readFileSync(hooks.path, 'utf8'));
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
return { status: 'undecidable', reason: `${hooks.path} exists but cannot be read as JSON: ${describeError(error)}` };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { status: 'absent', evidence: 'no PD marker, PD hook entries, or Marketplace plugin in the Codex home' };
|
|
143
|
+
}
|
|
144
|
+
const workbuddyPaths = resolveWorkbuddyPaths(homeDir);
|
|
145
|
+
const workbuddy = readWorkbuddyHostState(homeDir);
|
|
146
|
+
if (workbuddy.pluginState === undefined) {
|
|
147
|
+
return { status: 'undecidable', reason: 'workbuddy plugin state could not be read' };
|
|
148
|
+
}
|
|
149
|
+
if (!workbuddy.pluginState.registryReadable) {
|
|
150
|
+
return { status: 'undecidable', reason: `${workbuddyPaths.registryPath} exists but is not a readable plugin registry` };
|
|
151
|
+
}
|
|
152
|
+
return { status: 'absent', evidence: `PD is not registered in ${workbuddyPaths.registryPath}` };
|
|
153
|
+
}
|
|
81
154
|
//# sourceMappingURL=index.js.map
|
|
@@ -128,7 +128,7 @@ export function buildSuccessOutput(opts) {
|
|
|
128
128
|
nextActions.push(`Console ready at ${consoleUrl} (browser opened automatically)`);
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
nextActions.push('Start console: pd console --workspace <path>
|
|
131
|
+
nextActions.push('Start console: pd console --workspace <path> (listens on 127.0.0.1 only)');
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
if (isComplete) {
|