create-principles-disciple 1.155.3 → 1.156.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 (247) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/codex-adapter/dist/ingestion/pain-receipt-fallback.d.ts +28 -1
  3. package/codex-adapter/dist/ingestion/pain-receipt-fallback.js +53 -17
  4. package/codex-adapter/dist/worker/workspace-worker.js +86 -66
  5. package/codex-adapter/package.json +1 -1
  6. package/console/dist/server/index.d.ts +11 -1
  7. package/console/dist/server/index.js +84 -19
  8. package/console/dist/server/release-handover.d.ts +256 -0
  9. package/console/dist/server/release-handover.js +402 -0
  10. package/console/dist/server/routes/onboarding.js +1 -0
  11. package/console/dist/server/routes/update-transaction.js +37 -3
  12. package/console/dist/server/routes/update.js +21 -1
  13. package/console/dist/server/successor.d.ts +46 -0
  14. package/console/dist/server/successor.js +128 -0
  15. package/console/dist/web/assets/app.css +18 -0
  16. package/console/dist/web/assets/app.js +32 -31
  17. package/console/package.json +1 -1
  18. package/core/dist/runtime/candidate-intake-service.d.ts +1 -1
  19. package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
  20. package/core/dist/runtime/candidate-intake-service.js +89 -12
  21. package/core/dist/runtime/candidate-intake-service.js.map +1 -1
  22. package/core/dist/runtime/context-payload.d.ts +11 -0
  23. package/core/dist/runtime/context-payload.d.ts.map +1 -1
  24. package/core/dist/runtime/context-payload.js +27 -0
  25. package/core/dist/runtime/context-payload.js.map +1 -1
  26. package/core/dist/runtime/host-submission-context.d.ts +13 -6
  27. package/core/dist/runtime/host-submission-context.d.ts.map +1 -1
  28. package/core/dist/runtime/host-submission-context.js +77 -8
  29. package/core/dist/runtime/host-submission-context.js.map +1 -1
  30. package/core/dist/runtime/index.d.ts +2 -1
  31. package/core/dist/runtime/index.d.ts.map +1 -1
  32. package/core/dist/runtime/index.js +8 -0
  33. package/core/dist/runtime/index.js.map +1 -1
  34. package/core/dist/runtime/pain-ingress.d.ts +8 -0
  35. package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
  36. package/core/dist/runtime/pain-ingress.js +8 -1
  37. package/core/dist/runtime/pain-ingress.js.map +1 -1
  38. package/core/dist/runtime/pain-recall-read-model.d.ts +72 -0
  39. package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
  40. package/core/dist/runtime/pain-recall-read-model.js +46 -21
  41. package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
  42. package/core/dist/runtime/pain-receipt-recovery.d.ts +4 -1
  43. package/core/dist/runtime/pain-receipt-recovery.d.ts.map +1 -1
  44. package/core/dist/runtime/pain-receipt-recovery.js +28 -10
  45. package/core/dist/runtime/pain-receipt-recovery.js.map +1 -1
  46. package/core/dist/runtime/pain-signal-bridge.d.ts +38 -23
  47. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  48. package/core/dist/runtime/pain-signal-bridge.js +533 -182
  49. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  50. package/core/dist/runtime/pain-signal-runtime-factory.d.ts +8 -1
  51. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  52. package/core/dist/runtime/pain-signal-runtime-factory.js +196 -25
  53. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  54. package/core/dist/runtime/pain-target-evidence-reconcile.d.ts +78 -4
  55. package/core/dist/runtime/pain-target-evidence-reconcile.d.ts.map +1 -1
  56. package/core/dist/runtime/pain-target-evidence-reconcile.js +229 -18
  57. package/core/dist/runtime/pain-target-evidence-reconcile.js.map +1 -1
  58. package/core/dist/runtime/pain-to-principle-service.d.ts +26 -5
  59. package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
  60. package/core/dist/runtime/pain-to-principle-service.js +63 -52
  61. package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
  62. package/core/dist/runtime/store/candidate/admission-document.d.ts +43 -0
  63. package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
  64. package/core/dist/runtime/store/candidate/admission-document.js +130 -0
  65. package/core/dist/runtime/store/candidate/admission-document.js.map +1 -1
  66. package/core/dist/runtime/store/candidate/candidate-store.d.ts +3 -1
  67. package/core/dist/runtime/store/candidate/candidate-store.d.ts.map +1 -1
  68. package/core/dist/runtime/store/candidate/memory-candidate-store.d.ts +2 -1
  69. package/core/dist/runtime/store/candidate/memory-candidate-store.d.ts.map +1 -1
  70. package/core/dist/runtime/store/candidate/memory-candidate-store.js +27 -1
  71. package/core/dist/runtime/store/candidate/memory-candidate-store.js.map +1 -1
  72. package/core/dist/runtime/store/candidate/sqlite-candidate-store.d.ts +2 -1
  73. package/core/dist/runtime/store/candidate/sqlite-candidate-store.d.ts.map +1 -1
  74. package/core/dist/runtime/store/candidate/sqlite-candidate-store.js +59 -2
  75. package/core/dist/runtime/store/candidate/sqlite-candidate-store.js.map +1 -1
  76. package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
  77. package/core/dist/runtime/store/context/sqlite-context-assembler.js +18 -3
  78. package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
  79. package/core/dist/runtime/store/runtime-state-manager.d.ts +2 -1
  80. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  81. package/core/dist/runtime/store/runtime-state-manager.js +4 -0
  82. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  83. package/core/dist/telemetry-event.d.ts +2 -2
  84. package/core/dist/telemetry-event.d.ts.map +1 -1
  85. package/core/dist/telemetry-event.js +5 -0
  86. package/core/dist/telemetry-event.js.map +1 -1
  87. package/core/package.json +1 -1
  88. package/dist/i18n.d.ts.map +1 -1
  89. package/dist/i18n.js +72 -0
  90. package/dist/i18n.js.map +1 -1
  91. package/dist/index.d.ts +15 -0
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +145 -35
  94. package/dist/index.js.map +1 -1
  95. package/dist/installer.d.ts +149 -9
  96. package/dist/installer.d.ts.map +1 -1
  97. package/dist/installer.js +542 -31
  98. package/dist/installer.js.map +1 -1
  99. package/dist/installers/codex-host-installer.js +1 -1
  100. package/dist/installers/codex-host-installer.js.map +1 -1
  101. package/dist/installers/index.d.ts +10 -0
  102. package/dist/installers/index.d.ts.map +1 -1
  103. package/dist/installers/index.js +4 -0
  104. package/dist/installers/index.js.map +1 -1
  105. package/dist/mvp-config.js +1 -1
  106. package/dist/mvp-config.js.map +1 -1
  107. package/dist/prompts.d.ts +36 -12
  108. package/dist/prompts.d.ts.map +1 -1
  109. package/dist/prompts.js +102 -30
  110. package/dist/prompts.js.map +1 -1
  111. package/dist/service-host-bridge.d.ts +71 -12
  112. package/dist/service-host-bridge.d.ts.map +1 -1
  113. package/dist/service-host-bridge.js +228 -48
  114. package/dist/service-host-bridge.js.map +1 -1
  115. package/dist/service-host-provisioning.d.ts +102 -0
  116. package/dist/service-host-provisioning.d.ts.map +1 -0
  117. package/dist/service-host-provisioning.js +595 -0
  118. package/dist/service-host-provisioning.js.map +1 -0
  119. package/dist/uninstaller.js +1 -1
  120. package/dist/uninstaller.js.map +1 -1
  121. package/dist/update/apply-payload.d.ts +9 -0
  122. package/dist/update/apply-payload.d.ts.map +1 -1
  123. package/dist/update/apply-payload.js +44 -2
  124. package/dist/update/apply-payload.js.map +1 -1
  125. package/dist/update/console-surface.d.ts +2 -1
  126. package/dist/update/console-surface.d.ts.map +1 -1
  127. package/dist/update/console-surface.js +6 -1
  128. package/dist/update/console-surface.js.map +1 -1
  129. package/dist/update/install-layout.d.ts +12 -0
  130. package/dist/update/install-layout.d.ts.map +1 -1
  131. package/dist/update/install-layout.js +49 -7
  132. package/dist/update/install-layout.js.map +1 -1
  133. package/dist/update/release-manager-authority.d.ts +16 -0
  134. package/dist/update/release-manager-authority.d.ts.map +1 -1
  135. package/dist/update/release-manager-authority.js +45 -3
  136. package/dist/update/release-manager-authority.js.map +1 -1
  137. package/dist/update/release-manager.d.ts +8 -3
  138. package/dist/update/release-manager.d.ts.map +1 -1
  139. package/dist/update/release-manager.js +29 -1
  140. package/dist/update/release-manager.js.map +1 -1
  141. package/dist/update/transaction-progress.d.ts +63 -0
  142. package/dist/update/transaction-progress.d.ts.map +1 -0
  143. package/dist/update/transaction-progress.js +207 -0
  144. package/dist/update/transaction-progress.js.map +1 -0
  145. package/dist/utils/env.d.ts +16 -1
  146. package/dist/utils/env.d.ts.map +1 -1
  147. package/dist/utils/env.js +55 -43
  148. package/dist/utils/env.js.map +1 -1
  149. package/host-runtime/dist/diagnostician-auto-run.js +37 -31
  150. package/host-runtime/dist/governance-observation-store.d.ts +38 -0
  151. package/host-runtime/dist/governance-observation-store.js +41 -0
  152. package/host-runtime/dist/governance-trajectory-turn-reader.js +26 -33
  153. package/host-runtime/package.json +1 -1
  154. package/install-layout/dist/background-execution-transition.d.ts +11 -1
  155. package/install-layout/dist/background-execution-transition.js +45 -1
  156. package/install-layout/dist/index.d.ts +3 -3
  157. package/install-layout/dist/index.js +10 -4
  158. package/install-layout/dist/pd-home.d.ts +12 -0
  159. package/install-layout/dist/pd-home.js +6 -1
  160. package/install-layout/package.json +1 -1
  161. package/package.json +7 -7
  162. package/pd-cli/dist/commands/candidate.d.ts +15 -0
  163. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  164. package/pd-cli/dist/commands/candidate.js +449 -93
  165. package/pd-cli/dist/commands/candidate.js.map +1 -1
  166. package/pd-cli/dist/commands/console.d.ts.map +1 -1
  167. package/pd-cli/dist/commands/console.js +10 -0
  168. package/pd-cli/dist/commands/console.js.map +1 -1
  169. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  170. package/pd-cli/dist/commands/diagnose.js +254 -160
  171. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  172. package/pd-cli/dist/commands/intake-outcome-guidance.d.ts +57 -0
  173. package/pd-cli/dist/commands/intake-outcome-guidance.d.ts.map +1 -0
  174. package/pd-cli/dist/commands/intake-outcome-guidance.js +206 -0
  175. package/pd-cli/dist/commands/intake-outcome-guidance.js.map +1 -0
  176. package/pd-cli/dist/commands/mcp-probe.d.ts.map +1 -1
  177. package/pd-cli/dist/commands/mcp-probe.js +1 -0
  178. package/pd-cli/dist/commands/mcp-probe.js.map +1 -1
  179. package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
  180. package/pd-cli/dist/commands/pain-record.js +18 -4
  181. package/pd-cli/dist/commands/pain-record.js.map +1 -1
  182. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  183. package/pd-cli/dist/commands/pain-retry.js +91 -21
  184. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  185. package/pd-cli/dist/commands/runtime-uat.d.ts.map +1 -1
  186. package/pd-cli/dist/commands/runtime-uat.js +1 -0
  187. package/pd-cli/dist/commands/runtime-uat.js.map +1 -1
  188. package/pd-cli/dist/commands/service-lifecycle.js +1 -1
  189. package/pd-cli/dist/commands/service-lifecycle.js.map +1 -1
  190. package/pd-cli/dist/commands/service-run-once.d.ts +1 -1
  191. package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
  192. package/pd-cli/dist/commands/service-run-once.js +9 -5
  193. package/pd-cli/dist/commands/service-run-once.js.map +1 -1
  194. package/pd-cli/dist/program.d.ts.map +1 -1
  195. package/pd-cli/dist/program.js +14 -3
  196. package/pd-cli/dist/program.js.map +1 -1
  197. package/pd-cli/dist/services/admission-write-gate.d.ts +4 -0
  198. package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
  199. package/pd-cli/dist/services/admission-write-gate.js +50 -48
  200. package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
  201. package/pd-cli/dist/services/console-launcher.js +3 -3
  202. package/pd-cli/dist/services/console-launcher.js.map +1 -1
  203. package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -1
  204. package/pd-cli/dist/services/service-host/managed-run.js +25 -8
  205. package/pd-cli/dist/services/service-host/managed-run.js.map +1 -1
  206. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +12 -0
  207. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -1
  208. package/pd-cli/dist/services/service-host/scheduler/service-status.js +16 -7
  209. package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -1
  210. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +7 -5
  211. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
  212. package/pd-cli/dist/services/service-host/status/service-run-status.js +1 -1
  213. package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
  214. package/pd-cli/package.json +1 -1
  215. package/pd-mcp-server/dist/submit-assembly.js +61 -18
  216. package/pd-mcp-server/dist/version.d.ts +1 -1
  217. package/pd-mcp-server/dist/version.js +1 -1
  218. package/pd-mcp-server/package.json +1 -1
  219. package/plugin/dist/bundle.js +493 -493
  220. package/plugin/dist/openclaw-worker.js +263 -263
  221. package/plugin/dist/openclaw.plugin.json +1 -1
  222. package/plugin/openclaw.plugin.json +1 -1
  223. package/plugin/package.json +1 -1
  224. package/release-manager/dist/i18n.js +72 -0
  225. package/release-manager/dist/installer.js +542 -31
  226. package/release-manager/dist/installers/codex-host-installer.js +1 -1
  227. package/release-manager/dist/installers/index.js +4 -0
  228. package/release-manager/dist/mvp-config.js +1 -1
  229. package/release-manager/dist/service-host-bridge.js +228 -48
  230. package/release-manager/dist/service-host-provisioning.js +595 -0
  231. package/release-manager/dist/update/apply-payload.js +44 -2
  232. package/release-manager/dist/update/console-surface.js +6 -1
  233. package/release-manager/dist/update/install-layout.js +49 -7
  234. package/release-manager/dist/update/release-manager-authority.js +45 -3
  235. package/release-manager/dist/update/release-manager.js +29 -1
  236. package/release-manager/dist/update/transaction-progress.js +207 -0
  237. package/release-manager/dist/utils/env.js +55 -43
  238. package/release-manager/package.json +5 -5
  239. package/workbuddy-adapter/dist/codec/input-decoder.d.ts +21 -0
  240. package/workbuddy-adapter/dist/codec/input-decoder.js +50 -1
  241. package/workbuddy-adapter/dist/ingestion/pain-receipt-fallback.d.ts +68 -0
  242. package/workbuddy-adapter/dist/ingestion/pain-receipt-fallback.js +225 -0
  243. package/workbuddy-adapter/dist/pd-hook.js +60 -0
  244. package/workbuddy-adapter/dist/worker/workspace-worker.js +46 -44
  245. package/workbuddy-adapter/package.json +1 -1
  246. package/console/dist/server/utils/gateway.d.ts +0 -29
  247. package/console/dist/server/utils/gateway.js +0 -175
@@ -131,6 +131,40 @@ function resolveRedirectTarget(location, from) {
131
131
  function isRedirectStatus(status) {
132
132
  return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
133
133
  }
134
+ /**
135
+ * Reads a response body while counting it, so a download that takes minutes
136
+ * can be narrated instead of sitting on an unexplained wait. The bytes are
137
+ * still returned whole — verification below wants the complete asset — and a
138
+ * body the transport does not expose as a stream is read the plain way.
139
+ */
140
+ async function readResponseBody(response, onBytes) {
141
+ const { body } = response;
142
+ if (!body || typeof body.getReader !== 'function') {
143
+ const whole = Buffer.from(await response.arrayBuffer());
144
+ onBytes(whole.length);
145
+ return whole;
146
+ }
147
+ const reader = body.getReader();
148
+ const chunks = [];
149
+ let received = 0;
150
+ try {
151
+ for (;;) {
152
+ const { done, value } = await reader.read();
153
+ if (done)
154
+ break;
155
+ // Copy: the stream may reuse its buffer for the next chunk, and these
156
+ // bytes are hashed and written to disk afterwards.
157
+ const chunk = Buffer.from(value);
158
+ chunks.push(chunk);
159
+ received += chunk.length;
160
+ onBytes(received);
161
+ }
162
+ }
163
+ finally {
164
+ reader.releaseLock();
165
+ }
166
+ return Buffer.concat(chunks, received);
167
+ }
134
168
  export async function downloadAndVerifyAssetFile(input) {
135
169
  // PRI-927 (Owner decision): HTTPS-only, no warning mode and no insecure
136
170
  // override. The signed sha256+size below is the trust anchor, so a plaintext
@@ -191,7 +225,7 @@ export async function downloadAndVerifyAssetFile(input) {
191
225
  }
192
226
  }
193
227
  else {
194
- bytes = Buffer.from(await response.arrayBuffer());
228
+ bytes = await readResponseBody(response, (receivedBytes) => input.onProgress?.(receivedBytes));
195
229
  }
196
230
  break;
197
231
  }
@@ -263,7 +297,7 @@ export async function downloadAndVerifyAssetFile(input) {
263
297
  * Zero deployment writes happen before every identity check has passed.
264
298
  */
265
299
  export async function downloadReleaseAsset(options) {
266
- const { paths, metadataBaseUrl, fetcher, assetFetcher, releaseMetadata, channel, transactionId } = options;
300
+ const { paths, metadataBaseUrl, fetcher, assetFetcher, releaseMetadata, channel, transactionId, onProgress } = options;
267
301
  const asset = selectReleaseAsset(releaseMetadata);
268
302
  // PRI-854 (option A): the signed metadata carries the asset's delivery URL —
269
303
  // fetch it directly and enforce the signed sha256+size. The digest check is
@@ -278,6 +312,9 @@ export async function downloadReleaseAsset(options) {
278
312
  expectedSizeBytes: asset.archiveSizeBytes,
279
313
  releaseId: releaseMetadata.releaseId,
280
314
  fetcher: assetFetcher,
315
+ onProgress: onProgress === undefined
316
+ ? undefined
317
+ : (receivedBytes) => onProgress(receivedBytes, asset.archiveSizeBytes),
281
318
  });
282
319
  const syntheticTarget = {
283
320
  artifactSha256: asset.archiveSha256,
@@ -358,6 +395,9 @@ function extractReleaseAssetArchive(transactionDir, payloadDir) {
358
395
  execFileSync('tar', ['xzf', 'release-asset.tar.gz', '-C', 'payload'], {
359
396
  cwd: transactionDir,
360
397
  stdio: 'pipe',
398
+ // This runs inside the detached update executor, which has no console on
399
+ // Windows: without it tar opens a visible terminal window mid-update.
400
+ windowsHide: true,
361
401
  });
362
402
  if (!fs.existsSync(path.join(payloadDir, '_release', 'manifest.json'))) {
363
403
  throw new Error('the artifact tarball does not contain a self-contained release asset at its root (missing _release/manifest.json)');
@@ -377,11 +417,13 @@ export async function extractAndVerifyReleaseAsset(options) {
377
417
  const payloadDir = path.join(transactionDir, 'payload');
378
418
  try {
379
419
  fs.mkdirSync(payloadDir, { recursive: true });
420
+ options.onStep?.('Extracting the release asset…');
380
421
  extractReleaseAssetArchive(transactionDir, payloadDir);
381
422
  // Dynamic import: keeps installer.js (and its CLI dependency graph) out
382
423
  // of the module graph until a real acquisition needs it — the governed
383
424
  // check path never pays for it.
384
425
  const { preflightSelfContainedReleaseAsset } = await import('../installer.js');
426
+ options.onStep?.('Verifying the release asset…');
385
427
  await preflightSelfContainedReleaseAsset(payloadDir);
386
428
  }
387
429
  catch (error) {
@@ -12,8 +12,13 @@
12
12
  * tests consume are re-exported here. Adding a symbol to this surface is a
13
13
  * cross-package contract decision — check the consumers first.
14
14
  */
15
- export { createReleaseManagerAuthority, mapReleaseManagerError, } from './release-manager-authority.js';
15
+ export { createReleaseManagerAuthority, createReleaseManagerAuthorityAsync, mapReleaseManagerError, } from './release-manager-authority.js';
16
16
  export { readTransactionJournalForRecovery, recoverUnfinishedTransaction, isTerminalTransactionState, readActiveRecord, hasRecoveryResolution, RESTORE_INCONSISTENCY_MARKER, } from './transaction-journal.js';
17
17
  export { resolvePdHomePaths, } from './install-layout.js';
18
18
  export { isReleaseManagerTransactionId, ReleaseManagerError, } from './release-manager.js';
19
+ // Observational companion to the journal above: how far along the stage the
20
+ // journal last announced. Derived and best-effort — a deployed release-manager
21
+ // built before it existed simply has no such export, which the Console treats
22
+ // as "no progress known" (ERR-207: components are replaced one at a time).
23
+ export { readTransactionProgress, } from './transaction-progress.js';
19
24
  //# sourceMappingURL=console-surface.js.map
@@ -58,18 +58,30 @@ export class InstallLayoutError extends Error {
58
58
  this.field = field;
59
59
  }
60
60
  }
61
+ function missingExecutorDirectory(directory) {
62
+ return new InstallLayoutError('bootstrap_executor', `executor directory is missing: ${directory}`);
63
+ }
64
+ /** Per-directory name order is part of the persisted digest format: both walkers sort with this. */
65
+ function compareEntryNames(a, b) {
66
+ return a.name.localeCompare(b.name);
67
+ }
68
+ /** One file's record in the digest — the single definition of the per-file format. */
69
+ function foldIntoDigest(hash, relative, contents) {
70
+ hash.update(`${relative}:`);
71
+ hash.update(contents);
72
+ hash.update('\n');
73
+ }
61
74
  /**
62
75
  * PRI-850: deterministic digest over every file of a directory tree (relative
63
76
  * POSIX-style paths sorted, contents hashed). This is how a bootstrap
64
77
  * registration is re-verified against the deployed executor bytes.
65
78
  */
66
79
  export function digestDirectory(directory) {
67
- if (!fs.existsSync(directory)) {
68
- throw new InstallLayoutError('bootstrap_executor', `executor directory is missing: ${directory}`);
69
- }
80
+ if (!fs.existsSync(directory))
81
+ throw missingExecutorDirectory(directory);
70
82
  const hash = crypto.createHash('sha256');
71
83
  const walk = (current, prefix) => {
72
- for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
84
+ for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort(compareEntryNames)) {
73
85
  const relative = prefix === '' ? entry.name : `${prefix}/${entry.name}`;
74
86
  if (entry.isDirectory()) {
75
87
  walk(path.join(current, entry.name), relative);
@@ -77,14 +89,44 @@ export function digestDirectory(directory) {
77
89
  }
78
90
  if (!entry.isFile())
79
91
  continue;
80
- hash.update(`${relative}:`);
81
- hash.update(fs.readFileSync(path.join(current, entry.name)));
82
- hash.update('\n');
92
+ foldIntoDigest(hash, relative, fs.readFileSync(path.join(current, entry.name)));
83
93
  }
84
94
  };
85
95
  walk(directory, '');
86
96
  return hash.digest('hex');
87
97
  }
98
+ /**
99
+ * `digestDirectory` without holding the event loop: every directory listing
100
+ * and file read is awaited, so a request-serving thread that verifies the
101
+ * registration keeps answering while the executor tree is read. Same tree,
102
+ * same order, same per-file record — the result IS the sync digest.
103
+ *
104
+ * The sync form is for batch callers (the installer). A caller that serves
105
+ * requests must use this one: measured 2026-11-23 on a real install (~17k
106
+ * executor files), the sync form held its calling thread for ~0.6-0.7 s per
107
+ * call, and nothing else ran on that thread meanwhile.
108
+ */
109
+ export async function digestDirectoryAsync(directory) {
110
+ if (!fs.existsSync(directory))
111
+ throw missingExecutorDirectory(directory);
112
+ const hash = crypto.createHash('sha256');
113
+ const walk = async (current, prefix) => {
114
+ const entries = await fs.promises.readdir(current, { withFileTypes: true });
115
+ entries.sort(compareEntryNames);
116
+ for (const entry of entries) {
117
+ const relative = prefix === '' ? entry.name : `${prefix}/${entry.name}`;
118
+ if (entry.isDirectory()) {
119
+ await walk(path.join(current, entry.name), relative);
120
+ continue;
121
+ }
122
+ if (!entry.isFile())
123
+ continue;
124
+ foldIntoDigest(hash, relative, await fs.promises.readFile(path.join(current, entry.name)));
125
+ }
126
+ };
127
+ await walk(directory, '');
128
+ return hash.digest('hex');
129
+ }
88
130
  function readJsonFileIfExists(filePath, label) {
89
131
  if (!fs.existsSync(filePath))
90
132
  return undefined;
@@ -1,7 +1,7 @@
1
1
  /** ReleaseManager readiness and failure mapping for the Console. No alternate updater exists. */
2
2
  import * as fs from 'node:fs';
3
3
  import { ReleaseManager, ReleaseManagerError, } from './release-manager.js';
4
- import { InstallLayoutError, digestDirectory, readBootstrapManifest, readInstallConfig, resolvePdHomePaths } from './install-layout.js';
4
+ import { InstallLayoutError, digestDirectory, digestDirectoryAsync, readBootstrapManifest, readInstallConfig, resolvePdHomePaths } from './install-layout.js';
5
5
  import { resolveReleaseMetadataSource } from './release-metadata-source.js';
6
6
  /** The two Console update operations. */
7
7
  export const RELEASE_MANAGER_AUTHORITY_KINDS = ['check', 'apply-full'];
@@ -21,7 +21,13 @@ function probeTransactionJournalDir(pdHome) {
21
21
  return false;
22
22
  }
23
23
  }
24
- export function createReleaseManagerAuthority(options) {
24
+ /**
25
+ * The readiness decision, shared by both factories below. `executorDigest`
26
+ * supplies the deployed executor tree's digest where the decision needs one
27
+ * (a dual-slot install with a registered digest); whatever it throws is the
28
+ * `bootstrap_identity_mismatch` verdict.
29
+ */
30
+ function assessReadiness(options, executorDigest) {
25
31
  const reasons = new Set();
26
32
  // PRI-709 P0-1: resolve the metadata source BEFORE constructing the manager.
27
33
  // `install_config` is the durable tier — an install that was installed with
@@ -92,7 +98,7 @@ export function createReleaseManagerAuthority(options) {
92
98
  }
93
99
  else {
94
100
  try {
95
- const actual = digestDirectory(pdHomePaths.bootstrapExecutorDir);
101
+ const actual = executorDigest();
96
102
  if (actual !== manifest.executorDigest) {
97
103
  reasons.add('bootstrap_identity_mismatch');
98
104
  }
@@ -119,6 +125,42 @@ export function createReleaseManagerAuthority(options) {
119
125
  };
120
126
  return { manager, installStatus, kinds, metadataSource };
121
127
  }
128
+ /**
129
+ * Synchronous assessment, for batch callers. It re-hashes the whole deployed
130
+ * executor tree on the calling thread: a caller that serves requests must use
131
+ * `createReleaseManagerAuthorityAsync`, or every other request waits for the
132
+ * length of that read.
133
+ */
134
+ export function createReleaseManagerAuthority(options) {
135
+ return assessReadiness(options, () => digestDirectory(resolvePdHomePaths(options.pdHome).bootstrapExecutorDir));
136
+ }
137
+ /**
138
+ * The same assessment with the executor tree re-hashed without holding the
139
+ * event loop. The Console server builds the authority inside `/api/update/check`
140
+ * and `/api/update/apply-full`.
141
+ *
142
+ * The digest is read up front and handed to the decision as a value (or as the
143
+ * error it would have thrown at the same point), so both factories run ONE
144
+ * readiness rule.
145
+ */
146
+ export async function createReleaseManagerAuthorityAsync(options) {
147
+ const executorDir = resolvePdHomePaths(options.pdHome).bootstrapExecutorDir;
148
+ let digest;
149
+ let readFailure;
150
+ try {
151
+ digest = await digestDirectoryAsync(executorDir);
152
+ }
153
+ catch (error) {
154
+ readFailure = error instanceof Error ? error : new Error(String(error));
155
+ }
156
+ return assessReadiness(options, () => {
157
+ if (readFailure !== undefined)
158
+ throw readFailure;
159
+ if (digest === undefined)
160
+ throw new InstallLayoutError('bootstrap_executor', `executor directory is missing: ${executorDir}`);
161
+ return digest;
162
+ });
163
+ }
122
164
  /** Preserve explicit failure details; never dispatch another writer. */
123
165
  export function mapReleaseManagerError(error) {
124
166
  if (error instanceof ReleaseManagerError) {
@@ -18,6 +18,7 @@ import { evaluateReleaseAdvancement, } from './release-policy.js';
18
18
  import { readBootstrapManifest, readInstallConfig, resolvePdHomePaths, } from './install-layout.js';
19
19
  import { appendJournalTransition, readActiveRecord, TransactionJournalError, } from './transaction-journal.js';
20
20
  import { downloadReleaseAsset, extractAndVerifyReleaseAsset, ApplyPayloadError } from './apply-payload.js';
21
+ import { createTransactionProgressReporter } from './transaction-progress.js';
21
22
  import { compareProductVersions, parseProductVersion } from './product-identity.js';
22
23
  import { installManifestHostsForPersist, parseInstallManifest } from '@principles/install-layout';
23
24
  export class ReleaseManagerError extends Error {
@@ -165,6 +166,12 @@ function toReleaseManagerError(error) {
165
166
  *
166
167
  * A legacy install.json without the manifest fields keeps the historical
167
168
  * default — there is no record to contradict it.
169
+ *
170
+ * PRI-1278 Phase 5: a VALID manifest with `hosts: []` is a Service-Host-only
171
+ * installation, not a legacy one. Falling back to OpenClaw there deployed an
172
+ * adapter the operator never selected (and rewrote `hosts`). The empty record
173
+ * is the recorded truth: resolve `none` and let the installer deploy no host
174
+ * installer at all.
168
175
  */
169
176
  function resolveDeploymentHost(installConfigPath) {
170
177
  let value;
@@ -178,6 +185,8 @@ function resolveDeploymentHost(installConfigPath) {
178
185
  if (!parsed.manifest)
179
186
  return 'openclaw';
180
187
  const recorded = installManifestHostsForPersist(parsed.manifest);
188
+ if (recorded.length === 0)
189
+ return 'none';
181
190
  if (recorded.includes('openclaw'))
182
191
  return 'openclaw';
183
192
  if (recorded.includes('workbuddy'))
@@ -436,8 +445,12 @@ export class ReleaseManager {
436
445
  }
437
446
  throw new ReleaseManagerError('journal_unavailable', `The transaction journal could not be written — refusing to update unjournaled (ADR-0024 D-2): ${error instanceof Error ? error.message : String(error)}`, 'Resolve write access to ~/.pd/transactions (disk space / permissions), then retry. No changes were made.');
438
447
  }
448
+ // Observational only (see transaction-progress.ts): narrates the stages
449
+ // the journal cannot see inside of, and is removed once they are over.
450
+ const progress = createTransactionProgressReporter(this.paths.transactionsDir, transactionId);
439
451
  try {
440
452
  const { install } = await import('../installer.js');
453
+ progress.step('Downloading the release asset…');
441
454
  const downloaded = await downloadReleaseAsset({
442
455
  paths: this.paths,
443
456
  metadataBaseUrl: this.options.metadataBaseUrl,
@@ -445,11 +458,13 @@ export class ReleaseManager {
445
458
  releaseMetadata,
446
459
  channel: status.channel,
447
460
  transactionId,
461
+ onProgress: (receivedBytes, totalBytes) => progress.bytes(receivedBytes, totalBytes),
448
462
  });
449
463
  appendApplyTransition(journal, 'downloaded', `artifact sha256=${downloaded.trustedTarget.artifactSha256} target=${downloaded.trustedTarget.targetPath}`);
450
464
  const { payloadDir } = await extractAndVerifyReleaseAsset({
451
465
  transactionDir: downloaded.transactionDir,
452
466
  archivePath: downloaded.archivePath,
467
+ onStep: (message) => progress.step(message),
453
468
  });
454
469
  appendApplyTransition(journal, 'verified', 'release-asset preflight passed (identity + whole-payload digest)');
455
470
  // Deployment is the installer's job, byte for byte the same cycle a
@@ -466,7 +481,16 @@ export class ReleaseManager {
466
481
  overwriteConfig: false,
467
482
  host: deploymentHost,
468
483
  stopGateway: true,
469
- }, payloadDir, { quiet: true, nonInteractive: true }, journal);
484
+ }, payloadDir, {
485
+ quiet: true,
486
+ nonInteractive: true,
487
+ // An update starts no console. One is usually serving already — the
488
+ // one the update was asked from — and it becomes the new release by
489
+ // handing itself over; `pd console open` beside it only adds a second
490
+ // console, with the first still on the old version.
491
+ launchConsole: false,
492
+ onProgress: ({ message, percent }) => progress.step(message, percent),
493
+ }, journal);
470
494
  if (!installResult.success) {
471
495
  ensureTerminalFailed(journal, `installer reported failure before deploying (no runtime mutation): ${installResult.error ?? installResult.reason ?? 'unknown'}`);
472
496
  throw new ReleaseManagerError('apply_failed', `The installer refused or failed the update: ${installResult.error ?? installResult.reason ?? 'unknown'}`, installResult.nextAction ?? 'The runtime is unchanged. Resolve the reported cause and retry.');
@@ -505,6 +529,10 @@ export class ReleaseManager {
505
529
  ? mapped
506
530
  : new ReleaseManagerError(mapped.reason, mapped.message, mapped.nextAction, true);
507
531
  }
532
+ finally {
533
+ // The transaction is over either way; progress has no further meaning.
534
+ progress.close();
535
+ }
508
536
  }
509
537
  /**
510
538
  * Resolve + digest-verify + cache the signed channel document (shared by
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Transaction progress sidecar — what the journal deliberately is not.
3
+ *
4
+ * The transaction journal (`<id>.jsonl`) is the authoritative state machine:
5
+ * append-only, fsynced, one validated transition per line. It records WHEN a
6
+ * stage begins, never how far along that stage is — and it must stay that way.
7
+ * A download that takes minutes and a deploy that takes half a minute are, to
8
+ * the Owner watching the Console, the difference between "it is working" and
9
+ * "it hung". This module is the observational channel for that difference.
10
+ *
11
+ * Contract:
12
+ * - `<transactionsDir>/<id>.progress.json`, replaced atomically, throttled.
13
+ * - DERIVED and best-effort, never authoritative: nothing may branch on it.
14
+ * Absence is normal (an executor built before this file never writes one;
15
+ * the reporter removes it when the transaction ends) and a failed write is
16
+ * swallowed — reporting progress can never fail an update.
17
+ * - The reader validates every field: on the Console side this file is
18
+ * untrusted runtime input, and anything it cannot vouch for is dropped.
19
+ */
20
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
21
+ import { randomUUID } from 'node:crypto';
22
+ import { basename, dirname, join } from 'node:path';
23
+ export const TRANSACTION_PROGRESS_SCHEMA_VERSION = 1;
24
+ /** Same shape the journal enforces for a transaction id; doubles as the path guard. */
25
+ const TRANSACTION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
26
+ const DEFAULT_MIN_WRITE_INTERVAL_MS = 400;
27
+ const MAX_STEP_LENGTH = 200;
28
+ /**
29
+ * Replaces the sidecar in one step: write beside it, rename over it. A reader
30
+ * sees the whole previous observation or the whole new one.
31
+ *
32
+ * Deliberately NOT the journal's `writeRecordAtomically`: that adapter is
33
+ * built for records a recovery depends on — fsync, verified reread, and a
34
+ * blocking multi-second rename retry. None of that is worth stalling the
35
+ * update for a file that is rewritten twice a second and may simply be
36
+ * missing. If the rename is refused (antivirus holding the file, a directory
37
+ * in the way), this observation is dropped; the next one is 400ms away.
38
+ */
39
+ function replaceSidecar(progressPath, text) {
40
+ const temporaryPath = join(dirname(progressPath), `.${basename(progressPath)}.${randomUUID()}.tmp`);
41
+ try {
42
+ writeFileSync(temporaryPath, text);
43
+ renameSync(temporaryPath, progressPath);
44
+ }
45
+ catch (error) {
46
+ try {
47
+ rmSync(temporaryPath, { force: true });
48
+ }
49
+ catch {
50
+ // The write itself failed; there is nothing of ours to clean up.
51
+ }
52
+ throw error;
53
+ }
54
+ }
55
+ export function transactionProgressPath(transactionsDir, transactionId) {
56
+ return join(transactionsDir, `${transactionId}.progress.json`);
57
+ }
58
+ function isPlainObject(value) {
59
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
60
+ }
61
+ function isNonNegativeSafeInteger(value) {
62
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
63
+ }
64
+ /**
65
+ * Reads and validates one transaction's progress. Null for anything that is
66
+ * not a fully trustworthy observation: absent, unreadable, a different
67
+ * transaction, an unknown schema, or a field of the wrong shape.
68
+ */
69
+ export function readTransactionProgress(transactionsDir, transactionId) {
70
+ if (!TRANSACTION_ID_PATTERN.test(transactionId))
71
+ return null;
72
+ const progressPath = transactionProgressPath(transactionsDir, transactionId);
73
+ if (!existsSync(progressPath))
74
+ return null;
75
+ let parsed;
76
+ try {
77
+ parsed = JSON.parse(readFileSync(progressPath, 'utf8'));
78
+ }
79
+ catch {
80
+ // A torn or half-replaced read is "no observation", not an error: the
81
+ // atomic writer guarantees the next read sees a whole record.
82
+ return null;
83
+ }
84
+ if (!isPlainObject(parsed))
85
+ return null;
86
+ if (parsed.schemaVersion !== TRANSACTION_PROGRESS_SCHEMA_VERSION || parsed.transactionId !== transactionId)
87
+ return null;
88
+ if (typeof parsed.at !== 'string' || Number.isNaN(Date.parse(parsed.at)))
89
+ return null;
90
+ const step = typeof parsed.step === 'string' && parsed.step.length > 0 ? parsed.step.slice(0, MAX_STEP_LENGTH) : undefined;
91
+ const rawPercent = parsed.percent;
92
+ const percent = typeof rawPercent === 'number' && Number.isFinite(rawPercent) && rawPercent >= 0 && rawPercent <= 100
93
+ ? rawPercent
94
+ : undefined;
95
+ // Byte counts are only meaningful as a pair that adds up; one without the
96
+ // other, or a count past its total, is dropped rather than shown wrong.
97
+ const { bytesReceived, bytesTotal } = parsed;
98
+ const hasBytes = isNonNegativeSafeInteger(bytesReceived) && isNonNegativeSafeInteger(bytesTotal)
99
+ && bytesTotal > 0 && bytesReceived <= bytesTotal;
100
+ return {
101
+ schemaVersion: TRANSACTION_PROGRESS_SCHEMA_VERSION,
102
+ transactionId,
103
+ at: parsed.at,
104
+ ...(step !== undefined ? { step } : {}),
105
+ ...(percent !== undefined ? { percent } : {}),
106
+ ...(hasBytes ? { bytesReceived, bytesTotal } : {}),
107
+ };
108
+ }
109
+ /**
110
+ * Reporter handed to the code that performs the transaction. Every method is
111
+ * total: no input and no filesystem state can make it throw.
112
+ */
113
+ export function createTransactionProgressReporter(transactionsDir, transactionId, options = {}) {
114
+ const noOp = { step: () => undefined, bytes: () => undefined, close: () => undefined };
115
+ if (!TRANSACTION_ID_PATTERN.test(transactionId))
116
+ return noOp;
117
+ const minWriteIntervalMs = options.minWriteIntervalMs ?? DEFAULT_MIN_WRITE_INTERVAL_MS;
118
+ const now = options.now ?? Date.now;
119
+ const progressPath = transactionProgressPath(transactionsDir, transactionId);
120
+ let observation = {};
121
+ let lastWriteAt = Number.NEGATIVE_INFINITY;
122
+ let trailingTimer;
123
+ let closed = false;
124
+ const write = () => {
125
+ if (trailingTimer !== undefined) {
126
+ clearTimeout(trailingTimer);
127
+ trailingTimer = undefined;
128
+ }
129
+ lastWriteAt = now();
130
+ try {
131
+ mkdirSync(transactionsDir, { recursive: true });
132
+ replaceSidecar(progressPath, `${JSON.stringify({
133
+ schemaVersion: TRANSACTION_PROGRESS_SCHEMA_VERSION,
134
+ transactionId,
135
+ at: new Date(now()).toISOString(),
136
+ ...observation,
137
+ })}\n`);
138
+ }
139
+ catch {
140
+ // Progress is an observability nicety. A disk that refuses it has to be
141
+ // reported by the transaction itself, on its own authority.
142
+ }
143
+ };
144
+ /** Write now, or soon: never more often than the interval, never lose the last value. */
145
+ const schedule = () => {
146
+ if (closed)
147
+ return;
148
+ const elapsed = now() - lastWriteAt;
149
+ if (elapsed >= minWriteIntervalMs) {
150
+ write();
151
+ return;
152
+ }
153
+ if (trailingTimer === undefined) {
154
+ trailingTimer = setTimeout(() => {
155
+ trailingTimer = undefined;
156
+ if (!closed)
157
+ write();
158
+ }, minWriteIntervalMs - elapsed);
159
+ // A pending progress write must not keep a dying executor alive.
160
+ trailingTimer.unref?.();
161
+ }
162
+ };
163
+ return {
164
+ step(message, percent) {
165
+ if (closed)
166
+ return;
167
+ observation = {
168
+ ...(message.length > 0 ? { step: message.slice(0, MAX_STEP_LENGTH) } : {}),
169
+ ...(typeof percent === 'number' && Number.isFinite(percent) && percent >= 0 && percent <= 100
170
+ ? { percent: Math.round(percent) }
171
+ : {}),
172
+ };
173
+ write();
174
+ },
175
+ bytes(received, total) {
176
+ if (closed)
177
+ return;
178
+ if (!isNonNegativeSafeInteger(received))
179
+ return;
180
+ observation = {
181
+ ...observation,
182
+ bytesReceived: received,
183
+ ...(isNonNegativeSafeInteger(total) && total > 0 ? { bytesTotal: total } : {}),
184
+ };
185
+ if (observation.bytesTotal !== undefined && observation.bytesTotal < received)
186
+ delete observation.bytesTotal;
187
+ schedule();
188
+ },
189
+ close() {
190
+ if (closed)
191
+ return;
192
+ closed = true;
193
+ if (trailingTimer !== undefined) {
194
+ clearTimeout(trailingTimer);
195
+ trailingTimer = undefined;
196
+ }
197
+ try {
198
+ rmSync(progressPath, { force: true });
199
+ }
200
+ catch {
201
+ // A sidecar that cannot be removed is ignored by readers the moment it
202
+ // goes stale; it must not turn a finished transaction into a failure.
203
+ }
204
+ },
205
+ };
206
+ }
207
+ //# sourceMappingURL=transaction-progress.js.map