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
package/dist/installer.js
CHANGED
|
@@ -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
|