create-principles-disciple 1.146.9 → 1.147.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.
Files changed (112) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/ingestion/explicit-owner-statement.d.ts +6 -0
  3. package/codex-adapter/dist/ingestion/explicit-owner-statement.js +6 -0
  4. package/codex-adapter/dist/pd-hook.js +5 -2
  5. package/codex-adapter/dist/worker/workspace-worker.d.ts +13 -1
  6. package/codex-adapter/dist/worker/workspace-worker.js +26 -3
  7. package/codex-adapter/package.json +1 -1
  8. package/core/dist/runtime-v2/index.d.ts +2 -2
  9. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  10. package/core/dist/runtime-v2/index.js +1 -1
  11. package/core/dist/runtime-v2/index.js.map +1 -1
  12. package/core/dist/runtime-v2/pain-ingress-payload.d.ts +13 -1
  13. package/core/dist/runtime-v2/pain-ingress-payload.d.ts.map +1 -1
  14. package/core/dist/runtime-v2/pain-ingress-payload.js +21 -2
  15. package/core/dist/runtime-v2/pain-ingress-payload.js.map +1 -1
  16. package/core/dist/runtime-v2/pain-ingress.d.ts.map +1 -1
  17. package/core/dist/runtime-v2/pain-ingress.js +3 -0
  18. package/core/dist/runtime-v2/pain-ingress.js.map +1 -1
  19. package/core/dist/runtime-v2/signal-collector/confidence-gate.d.ts +35 -0
  20. package/core/dist/runtime-v2/signal-collector/confidence-gate.d.ts.map +1 -0
  21. package/core/dist/runtime-v2/signal-collector/confidence-gate.js +48 -0
  22. package/core/dist/runtime-v2/signal-collector/confidence-gate.js.map +1 -0
  23. package/core/dist/runtime-v2/signal-collector/index.d.ts +1 -0
  24. package/core/dist/runtime-v2/signal-collector/index.d.ts.map +1 -1
  25. package/core/dist/runtime-v2/signal-collector/index.js +1 -0
  26. package/core/dist/runtime-v2/signal-collector/index.js.map +1 -1
  27. package/core/dist/runtime-v2/signal-collector/keyword-stage.d.ts +4 -6
  28. package/core/dist/runtime-v2/signal-collector/keyword-stage.d.ts.map +1 -1
  29. package/core/dist/runtime-v2/signal-collector/keyword-stage.js +100 -9
  30. package/core/dist/runtime-v2/signal-collector/keyword-stage.js.map +1 -1
  31. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.d.ts.map +1 -1
  32. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.js +8 -4
  33. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.js.map +1 -1
  34. package/core/package.json +1 -1
  35. package/dist/installer.d.ts.map +1 -1
  36. package/dist/installer.js +52 -1
  37. package/dist/installer.js.map +1 -1
  38. package/dist/installers/mcp-registration-conflict.d.ts +35 -0
  39. package/dist/installers/mcp-registration-conflict.d.ts.map +1 -0
  40. package/dist/installers/mcp-registration-conflict.js +559 -0
  41. package/dist/installers/mcp-registration-conflict.js.map +1 -0
  42. package/dist/installers/openclaw-host-installer.d.ts.map +1 -1
  43. package/dist/installers/openclaw-host-installer.js +20 -0
  44. package/dist/installers/openclaw-host-installer.js.map +1 -1
  45. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  46. package/dist/installers/workbuddy-host-installer.js +124 -2
  47. package/dist/installers/workbuddy-host-installer.js.map +1 -1
  48. package/dist/mcp-server-layout-compat.d.ts +18 -0
  49. package/dist/mcp-server-layout-compat.d.ts.map +1 -0
  50. package/dist/mcp-server-layout-compat.js +22 -0
  51. package/dist/mcp-server-layout-compat.js.map +1 -0
  52. package/host-runtime/dist/governance-signal-admission.d.ts +147 -4
  53. package/host-runtime/dist/governance-signal-admission.js +1065 -60
  54. package/host-runtime/dist/index.d.ts +2 -0
  55. package/host-runtime/dist/index.js +2 -0
  56. package/host-runtime/dist/signal-classifier.d.ts +46 -0
  57. package/host-runtime/dist/signal-classifier.js +167 -0
  58. package/host-runtime/dist/signal-stage2-cycle.d.ts +42 -0
  59. package/host-runtime/dist/signal-stage2-cycle.js +184 -0
  60. package/host-runtime/package.json +1 -1
  61. package/install-layout/dist/index.d.ts +15 -0
  62. package/install-layout/dist/index.js +10 -0
  63. package/install-layout/package.json +1 -1
  64. package/package.json +9 -7
  65. package/pd-cli/dist/commands/health-codex.d.ts.map +1 -1
  66. package/pd-cli/dist/commands/health-codex.js +12 -0
  67. package/pd-cli/dist/commands/health-codex.js.map +1 -1
  68. package/pd-cli/dist/commands/health-mcp.d.ts +74 -0
  69. package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -0
  70. package/pd-cli/dist/commands/health-mcp.js +723 -0
  71. package/pd-cli/dist/commands/health-mcp.js.map +1 -0
  72. package/pd-cli/dist/commands/health.d.ts +2 -0
  73. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  74. package/pd-cli/dist/commands/health.js +11 -6
  75. package/pd-cli/dist/commands/health.js.map +1 -1
  76. package/pd-mcp-server/dist/budget.d.ts +15 -0
  77. package/pd-mcp-server/dist/budget.js +19 -0
  78. package/pd-mcp-server/dist/deadline.d.ts +75 -0
  79. package/pd-mcp-server/dist/deadline.js +136 -0
  80. package/pd-mcp-server/dist/envelope.d.ts +52 -0
  81. package/pd-mcp-server/dist/envelope.js +63 -0
  82. package/pd-mcp-server/dist/index.d.ts +10 -0
  83. package/pd-mcp-server/dist/index.js +76 -0
  84. package/pd-mcp-server/dist/logging.d.ts +12 -0
  85. package/pd-mcp-server/dist/logging.js +42 -0
  86. package/pd-mcp-server/dist/server.d.ts +90 -0
  87. package/pd-mcp-server/dist/server.js +178 -0
  88. package/pd-mcp-server/dist/version.d.ts +13 -0
  89. package/pd-mcp-server/dist/version.js +13 -0
  90. package/pd-mcp-server/dist/workspace.d.ts +23 -0
  91. package/pd-mcp-server/dist/workspace.js +77 -0
  92. package/pd-mcp-server/package.json +49 -0
  93. package/plugin/dist/bundle.js +414 -412
  94. package/plugin/dist/core/mcp-binding.d.ts +41 -0
  95. package/plugin/dist/index.d.ts +33 -0
  96. package/plugin/dist/openclaw.plugin.json +10 -1
  97. package/plugin/dist/utils/workspace-resolver.d.ts +17 -0
  98. package/plugin/openclaw.plugin.json +10 -1
  99. package/plugin/package.json +2 -1
  100. package/release-manager/dist/installer.js +52 -1
  101. package/release-manager/dist/installers/mcp-registration-conflict.js +559 -0
  102. package/release-manager/dist/installers/openclaw-host-installer.js +20 -0
  103. package/release-manager/dist/installers/workbuddy-host-installer.js +124 -2
  104. package/release-manager/dist/mcp-server-layout-compat.js +22 -0
  105. package/release-manager/package.json +7 -5
  106. package/workbuddy-adapter/dist/pd-hook.js +28 -5
  107. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +6 -1
  108. package/workbuddy-adapter/dist/worker/workspace-worker.js +24 -3
  109. package/workbuddy-adapter/package.json +1 -1
  110. package/workbuddy-adapter/plugin/.codebuddy-plugin/plugin.json +2 -2
  111. package/workbuddy-adapter/plugin/.mcp.json +10 -0
  112. package/workbuddy-adapter/plugin/mcp/launcher.cjs +347 -0
@@ -0,0 +1,41 @@
1
+ export declare const MCP_BINDING_SCHEMA: 'pd.mcp-binding.v1';
2
+ export declare const MCP_BINDING_HOST: 'openclaw';
3
+ export interface McpBindingOutcome {
4
+ readonly ok: boolean;
5
+ readonly reason?: string;
6
+ readonly written?: boolean;
7
+ readonly serverEntry?: string;
8
+ }
9
+ /** Pure: the binding content for a resolved workspace (exported for tests). */
10
+ export declare function buildMcpBinding(workspaceDir: string, runtimeDir: string, serverEntry: string): Record<string, unknown>;
11
+ /**
12
+ * Canonical shared runtime root (~/.pd/runtime). Mirrors
13
+ * @principles/install-layout's runtimeDir; the lean OpenClaw bundle does not
14
+ * depend on that package, so this is the single local mirror and the binding
15
+ * records it for the launcher's canonical-path check.
16
+ */
17
+ export declare function canonicalRuntimeDir(homeDir: string): string;
18
+ /**
19
+ * Canonical installed MCP server entry (~/.pd/runtime/pd-mcp-server/dist/
20
+ * index.js). Same canonical-path convention as the plugin scripts' pd-cli
21
+ * probe; layout authority stays in @principles/install-layout.
22
+ */
23
+ export declare function canonicalMcpServerEntry(homeDir: string): string;
24
+ /**
25
+ * Ensure the launcher binding matches the CURRENT resolved workspace.
26
+ * The workspace arrives from the runtime resolver and may be unresolved
27
+ * (undefined) — that state is reported, never coerced. Returns an outcome;
28
+ * never throws (degrades to a structured warning).
29
+ */
30
+ /**
31
+ * Remove the launcher binding when the current workspace cannot be trusted.
32
+ * A stale binding would keep the launcher pointed at the LAST resolved
33
+ * workspace (SPEC §3.5 requires fail-closed when the workspace cannot be
34
+ * confirmed). Missing file is not an error; a failed removal is reported.
35
+ */
36
+ export declare function invalidateMcpBinding(extensionRoot: string): {
37
+ ok: boolean;
38
+ removed: boolean;
39
+ reason?: string;
40
+ };
41
+ export declare function ensureMcpBinding(workspaceDir: string | undefined, extensionRoot: string, homeDir: string): McpBindingOutcome;
@@ -39,6 +39,39 @@ export declare function shouldUseSharedHostRuntime(workspaceDir: string, logger:
39
39
  source: string;
40
40
  rollbackReason: string | null;
41
41
  };
42
+ /**
43
+ * Gate 4 (PRI-1071): keep the host-wide launcher binding in lockstep with an
44
+ * EXPLICITLY DECLARED PD workspace only.
45
+ *
46
+ * The MCP server is one process per host and reads ONE `mcp-binding.json` beside
47
+ * the plugin payload, while OpenClaw may run several agents with different
48
+ * `ctx.workspaceDir`s. Binding whichever agent resolved first (or `main`) would
49
+ * serve that workspace's Pain evidence to every other agent — cross-workspace
50
+ * recall leakage. So:
51
+ * - explicit PD workspace (PD_WORKSPACE_DIR / OPENCLAW_WORKSPACE /
52
+ * principles-disciple.json `workspace`) → bind it (idempotent);
53
+ * - no explicit declaration → REMOVE the binding and let the launcher
54
+ * fail closed (`binding_missing`). Never infer from `main`, `cwd`, `HOME`
55
+ * or the host default (SPEC §3.5).
56
+ *
57
+ * Hooks are unaffected: per-event hook resolution keeps its existing chain.
58
+ * Never throws (G4-07: MCP unavailability must not break PD's other functions).
59
+ */
60
+ export interface McpBindingSyncResult {
61
+ status: 'written' | 'unchanged' | 'invalidated' | 'unavailable';
62
+ reason: string;
63
+ nextAction: string;
64
+ workspaceDir?: string;
65
+ source?: string;
66
+ }
67
+ export declare function syncMcpBindingFromExplicitWorkspace(options: {
68
+ extensionRoot: string;
69
+ homeDir: string;
70
+ resolver?: () => {
71
+ workspaceDir: string;
72
+ source: string;
73
+ } | null;
74
+ }): McpBindingSyncResult;
42
75
  declare const plugin: {
43
76
  name: string;
44
77
  description: string;
@@ -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": "2.2.13",
5
+ "version": "2.4.0",
6
6
  "activation": {
7
7
  "onStartup": true,
8
8
  "onCapabilities": [
@@ -12,6 +12,15 @@
12
12
  "skills": [
13
13
  "templates/langs/zh/skills"
14
14
  ],
15
+ "mcpServers": {
16
+ "pd-recall": {
17
+ "transport": "stdio",
18
+ "command": "node",
19
+ "args": [
20
+ "./mcp/launcher.cjs"
21
+ ]
22
+ }
23
+ },
15
24
  "configSchema": {
16
25
  "type": "object",
17
26
  "additionalProperties": false,
@@ -77,6 +77,23 @@ export interface RejectedWorkspaceCandidate {
77
77
  reason: 'not_absolute' | 'rejected_by_validation';
78
78
  }
79
79
  export declare function resolveCanonicalWorkspaceDir(): CanonicalWorkspaceResult | null;
80
+ /**
81
+ * Resolve ONLY owner-declared PD workspace sources (env vars + config file),
82
+ * without any host/agent/default inference.
83
+ *
84
+ * Gate 4 (PRI-1071): the MCP launcher binding is host-wide (one binding file
85
+ * per plugin payload), so it may only record a workspace the Owner explicitly
86
+ * declared. A resolved `main` agent workspace, `ctx.workspaceDir` of whichever
87
+ * agent happened to load the plugin, `process.cwd()` or `~/.openclaw/workspace`
88
+ * all describe WHERE A SESSION RUNS — never which state tree owns governance
89
+ * for every agent of the host. In a multi-agent OpenClaw install those differ,
90
+ * and binding one agent's workspace would serve that agent's Pain evidence to
91
+ * every other agent (cross-workspace recall leakage).
92
+ *
93
+ * Returns `null` when no explicit source resolves; callers must fail closed
94
+ * (invalidate a previously written binding) instead of inferring a default.
95
+ */
96
+ export declare function resolveExplicitPdWorkspaceDir(): CanonicalWorkspaceResult | null;
80
97
  export type HookWorkspaceSource = CanonicalWorkspaceSource | 'openclaw_context' | 'openclaw_api';
81
98
  export interface HookWorkspaceResolutionSuccess {
82
99
  ok: true;
@@ -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": "2.2.13",
5
+ "version": "2.4.0",
6
6
  "activation": {
7
7
  "onStartup": true,
8
8
  "onCapabilities": [
@@ -12,6 +12,15 @@
12
12
  "skills": [
13
13
  "templates/langs/zh/skills"
14
14
  ],
15
+ "mcpServers": {
16
+ "pd-recall": {
17
+ "transport": "stdio",
18
+ "command": "node",
19
+ "args": [
20
+ "./mcp/launcher.cjs"
21
+ ]
22
+ }
23
+ },
15
24
  "configSchema": {
16
25
  "type": "object",
17
26
  "additionalProperties": false,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "2.2.13",
3
+ "version": "2.4.0",
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",
@@ -28,6 +28,7 @@
28
28
  "license": "Apache-2.0",
29
29
  "files": [
30
30
  "dist",
31
+ "mcp",
31
32
  "templates",
32
33
  "assets",
33
34
  "openclaw.plugin.json",
@@ -14,7 +14,8 @@ 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
15
  import { getHostInstallers } from './installers/index.js';
16
16
  import { runWorkbuddyEarlyPreflight } from './installers/workbuddy-host-installer.js';
17
- import { INSTALL_LAYOUT_VERSION, getWorkbuddyWorkspaceDir, installManifestHostsForPersist, mergeInstallManifestWorkspaces, parseInstallManifest } from '@principles/install-layout';
17
+ import { INSTALL_LAYOUT_VERSION, getInstallLayoutPaths, getWorkbuddyWorkspaceDir, installManifestHostsForPersist, mergeInstallManifestWorkspaces, parseInstallManifest } from '@principles/install-layout';
18
+ import { resolveMcpServerDir } from './mcp-server-layout-compat.js';
18
19
  import { detectOpenClawMainWorkspaceDivergence } from './utils/workspace-divergence.js';
19
20
  import { applySkillLanguageSelection } from './skill-language.js';
20
21
  import { parseReleaseAssetIdentity, parseReleaseAssetManifest, ReleaseAssetManifestError, verifyReleaseAssetManifestAsync, verifyReleaseAssetTarget, } from './update/release-asset-manifest.js';
@@ -659,6 +660,7 @@ const NPM_DISTRIBUTED_COMPONENTS = [
659
660
  ['PD CLI', 'pd-cli'],
660
661
  ['Console', 'console'],
661
662
  ['Install layout', 'install-layout'],
663
+ ['MCP server', 'pd-mcp-server'],
662
664
  ];
663
665
  // Components whose install step demands MORE than the generic
664
666
  // package.json+dist shape check — the per-component extra files are
@@ -812,6 +814,7 @@ const SELF_CONTAINED_COMPONENTS = [
812
814
  ['PD CLI', 'pd-cli'],
813
815
  ['Console', 'console'],
814
816
  ['Install layout', 'install-layout'],
817
+ ['MCP server', 'pd-mcp-server'],
815
818
  ];
816
819
  export async function preflightSelfContainedReleaseAsset(assetDir) {
817
820
  const identityPath = path.join(assetDir, '_release', 'asset.json');
@@ -2190,6 +2193,38 @@ function getInstalledCodexAdapterDir() {
2190
2193
  function getInstalledWorkbuddyAdapterDir() {
2191
2194
  return path.join(getPdRuntimeDir(), 'workbuddy-adapter');
2192
2195
  }
2196
+ /**
2197
+ * Gate 4 (PRI-1071): the shared MCP server installs as a runtime sibling so
2198
+ * the three host launchers can point their PD-owned bindings at one canonical
2199
+ * entry (~/.pd/runtime/pd-mcp-server/dist/index.js).
2200
+ */
2201
+ function getInstalledMcpServerDir() {
2202
+ return resolveMcpServerDir(getInstallLayoutPaths(getHomeDir()));
2203
+ }
2204
+ /**
2205
+ * Gate 4 (PRI-1071): deploy the bundled @principles/pd-mcp-server the same
2206
+ * way as the codex/workbuddy adapters. Observable skip (not a failure) for
2207
+ * installer builds older than the component — the host launchers then fail
2208
+ * closed at launch with the honest "server entry missing" state (SPEC §3.5).
2209
+ * Link materialization happens via ensureComponentFileDependencyLinks AFTER
2210
+ * all siblings exist (same ordering contract as the codex adapter).
2211
+ */
2212
+ function installBundledMcpServer(pluginDir) {
2213
+ const mcpServerSrc = path.join(pluginDir, 'pd-mcp-server');
2214
+ const mcpServerDest = getInstalledMcpServerDir();
2215
+ if (!existsSync(mcpServerSrc)) {
2216
+ logger.warn(`Bundled @principles/pd-mcp-server not found in this installer package (${mcpServerSrc}) — the pd-recall MCP tool stays unavailable in this deployment. Hook/CLI/Console installation is unaffected.`);
2217
+ return false;
2218
+ }
2219
+ const mcpServerPkgJson = path.join(mcpServerSrc, 'package.json');
2220
+ const mcpServerDistEntry = path.join(mcpServerSrc, 'dist', 'index.js');
2221
+ if (!existsSync(mcpServerPkgJson) || !existsSync(mcpServerDistEntry)) {
2222
+ throw new Error('Bundled @principles/pd-mcp-server is incomplete (missing package.json / dist/index.js). Package may be corrupted.');
2223
+ }
2224
+ rmSync(mcpServerDest, { recursive: true, force: true });
2225
+ cpSync(mcpServerSrc, mcpServerDest, { recursive: true });
2226
+ return true;
2227
+ }
2193
2228
  function installBundledCore(pluginDir) {
2194
2229
  const coreSrc = path.join(pluginDir, 'core');
2195
2230
  const coreDest = getInstalledCoreDir();
@@ -2598,6 +2633,9 @@ async function installConsoleDependencies() {
2598
2633
  const consoleDest = getInstalledConsoleDir();
2599
2634
  await prepareComponentDependencies(consoleDest, 'Console');
2600
2635
  }
2636
+ async function installMcpServerDependencies() {
2637
+ await prepareComponentDependencies(getInstalledMcpServerDir(), 'MCP server');
2638
+ }
2601
2639
  const CONSOLE_PORT_MAX_RETRIES = 3;
2602
2640
  /**
2603
2641
  * P0-2 (SPEC v1.2 §5 step 6 / invariant I-4): terminate a child and WAIT for
@@ -3727,6 +3765,19 @@ transaction) {
3727
3765
  // installer builds is an observable skip, not a failure.
3728
3766
  installBundledWorkbuddyAdapter(pluginDir);
3729
3767
  ensureWorkbuddyAdapterResolution();
3768
+ // Gate 4 (PRI-1071): the shared MCP server refreshes with the runtime so
3769
+ // the host launchers' bindings always point at the current canonical
3770
+ // entry. Older installer payloads skip observably (the launchers fail
3771
+ // closed at start with the honest missing-entry state).
3772
+ const mcpServerInstalled = installBundledMcpServer(pluginDir);
3773
+ if (mcpServerInstalled) {
3774
+ ensureComponentFileDependencyLinks(getInstalledMcpServerDir(), 'pd-mcp-server');
3775
+ // The npm-distributed payload ships only dist/ + package.json, and the
3776
+ // MCP server keeps @modelcontextprotocol/server + zod as registry deps
3777
+ // (unlike the file:-linked siblings). Without this pass the launcher
3778
+ // starts an entry whose imports cannot resolve.
3779
+ await installMcpServerDependencies();
3780
+ }
3730
3781
  if (spinner)
3731
3782
  updateProgress(spinner, stepIndex, 'Installing release-manager authority module...');
3732
3783
  installBundledReleaseManagerPackage(pluginDir);