create-principles-disciple 1.155.2 → 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 +2 -2
  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 +562 -38
  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 +10 -10
  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 +562 -38
  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 +8 -8
  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
@@ -2,6 +2,12 @@ import * as fs from 'node:fs';
2
2
  import * as path from 'node:path';
3
3
  import { sendSuccess, sendMethodNotAllowed, sendNotFound, errorMessage } from '../utils/response.js';
4
4
  import { getPdHome } from '../utils/pd-home.js';
5
+ import { releaseHandoverOwner } from '../release-handover.js';
6
+ /**
7
+ * A progress observation older than this describes a stage nobody is in any
8
+ * more (an executor that was killed never removed its sidecar).
9
+ */
10
+ const PROGRESS_STALE_AFTER_MS = 120_000;
5
11
  /** Transaction ids are installer/console-generated (`<word>-<ts>-<hex>`); this
6
12
  * pattern doubles as the path-traversal guard for the journal file name (rc-1). */
7
13
  const TRANSACTION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
@@ -29,21 +35,47 @@ function factFromTransitions(journal, transactionId, read) {
29
35
  function readJournalFact(journal, journalPath, transactionId) {
30
36
  return factFromTransitions(journal, transactionId, journal.readTransactionJournalForRecovery(journalPath));
31
37
  }
38
+ /**
39
+ * The Console process that answered. A page tracking an update compares its
40
+ * pid across polls to tell "the same console" from "its successor" — the
41
+ * release handover replaces the process underneath the page without changing
42
+ * the URL. `handover` says who will do that replacing, so the page knows
43
+ * whether to wait for it, and for how long.
44
+ */
45
+ function serverIdentity() {
46
+ return { serverPid: process.pid, handover: releaseHandoverOwner() };
47
+ }
48
+ function readProgressFact(seam, transactionsDir, transactionId) {
49
+ // `hasOwn`, not property access: an older or mocked module may not carry
50
+ // the export at all, and reading a missing export is not "no progress".
51
+ const read = Object.hasOwn(seam, 'readTransactionProgress') ? seam.readTransactionProgress : undefined;
52
+ if (read === undefined)
53
+ return null;
54
+ const progress = read(transactionsDir, transactionId);
55
+ if (progress === null)
56
+ return null;
57
+ return Math.abs(Date.now() - Date.parse(progress.at)) <= PROGRESS_STALE_AFTER_MS ? progress : null;
58
+ }
32
59
  async function transactionStatus(res, transactionId) {
33
60
  if (!TRANSACTION_ID_PATTERN.test(transactionId)) {
34
- sendSuccess(res, { transactionId, exists: false, reason: 'invalid_transaction_id' });
61
+ sendSuccess(res, { transactionId, exists: false, reason: 'invalid_transaction_id', ...serverIdentity() });
35
62
  return;
36
63
  }
37
64
  const journal = await import('create-principles-disciple/update-console');
65
+ const seam = journal;
38
66
  const layout = journal;
39
67
  const paths = layout.resolvePdHomePaths(getPdHome().pdHome);
40
68
  const journalPath = path.join(paths.transactionsDir, `${transactionId}.jsonl`);
41
69
  if (!fs.existsSync(journalPath)) {
42
- sendSuccess(res, { transactionId, exists: false });
70
+ sendSuccess(res, { transactionId, exists: false, ...serverIdentity() });
43
71
  return;
44
72
  }
45
73
  try {
46
- sendSuccess(res, readJournalFact(journal, journalPath, transactionId));
74
+ sendSuccess(res, {
75
+ ...readJournalFact(journal, journalPath, transactionId),
76
+ ...serverIdentity(),
77
+ progress: readProgressFact(seam, paths.transactionsDir, transactionId),
78
+ });
47
79
  }
48
80
  catch (error) {
49
81
  // A broken journal is exactly the kind of fact recovery presentation needs —
@@ -58,6 +90,8 @@ async function transactionStatus(res, transactionId) {
58
90
  lastAt: null,
59
91
  productVersion: null,
60
92
  transitions: [],
93
+ ...serverIdentity(),
94
+ progress: null,
61
95
  reason: errorMessage(error),
62
96
  });
63
97
  }
@@ -127,6 +127,12 @@ async function applyFullUpdate(authority, res, workspaceDir) {
127
127
  success: true,
128
128
  state: 'update_in_progress',
129
129
  transactionId,
130
+ // The console that accepted the update. The page keeps it as the
131
+ // baseline for the release handover: by the time it can read the
132
+ // transaction, the successor may already be the one answering, and
133
+ // a baseline taken from the first readable poll would then be the
134
+ // successor's own pid — something that never "changes".
135
+ serverPid: process.pid,
130
136
  message: `Update transaction ${transactionId} accepted; the update keeps running even if this console stops.`,
131
137
  requiresRestart: false,
132
138
  nextAction: 'This page tracks the running update. Do not start another update until it finishes.',
@@ -240,10 +246,24 @@ export async function handleUpdateRoute(req, res, workspaceDir, subPath) {
240
246
  else {
241
247
  try {
242
248
  mod = await import('create-principles-disciple/update-console');
243
- authority = mod.createReleaseManagerAuthority({
249
+ // Awaited: the readiness gate re-hashes the deployed executor tree, and
250
+ // awaiting it lets this server keep serving other requests while the
251
+ // tree is read.
252
+ const seam = mod;
253
+ const createAuthority = seam.createReleaseManagerAuthorityAsync ?? seam.createReleaseManagerAuthority;
254
+ authority = await createAuthority({
244
255
  pdHome: getPdHome().pdHome,
245
256
  metadataBaseUrl: process.env.PD_RELEASE_METADATA_URL,
246
257
  });
258
+ // The transport does not cancel what it times out: `asyncHandler` answers
259
+ // 504 at its budget while this route is still awaiting the gate above.
260
+ // Carrying on from there would START an update the page was told had
261
+ // failed — detached, and tracked by nobody. A request that was already
262
+ // answered, or whose caller is gone, is over: nothing below runs for it.
263
+ if (res.writableEnded || res.destroyed) {
264
+ console.error(`[update] ${subPath} abandoned: the request was already answered while the readiness gate ran`);
265
+ return;
266
+ }
247
267
  const readiness = authority.kinds[subPath === '/check' ? 'check' : 'apply-full'];
248
268
  if (!readiness.ready || authority.installStatus === null) {
249
269
  failure = { ...failure, reason: readiness.reasons.join(',') || 'install_state_corrupt', message: 'The installation is not ready for a signed release update.' };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Console successor — the process a Console starts when the installed release
3
+ * changes under it (see release-handover.ts).
4
+ *
5
+ * It exists so a handover never launches a path it was handed: the predecessor
6
+ * forks THIS module — a fixed name inside its own installed build, which an
7
+ * update has already replaced with the new release's copy — and writes the
8
+ * launch configuration to the successor's stdin. The successor then starts the
9
+ * console exactly the way the packaged entry does, with one difference: it
10
+ * keeps trying to bind while the predecessor is still releasing the port.
11
+ *
12
+ * stdin carries one JSON object, `{ "args": ["--workspace", "...", ...],
13
+ * "cwd": "<the predecessor's working directory>" }`: the predecessor's own
14
+ * command-line arguments, and the directory to resolve them from. It is
15
+ * untrusted input and is validated field by field; anything else exits before
16
+ * a port is touched, so a malformed or absent configuration never leaves a
17
+ * stray process behind.
18
+ *
19
+ * The successor's first act is to LEAVE the build directory it was resolved
20
+ * from, for the predecessor's working directory — see
21
+ * `adoptWorkingDirectory`.
22
+ *
23
+ * cli-7 / PRI-892 precedent: importing this module (a test driving
24
+ * `parseSuccessorLaunchConfig`, for example) must NOT start a console or wait
25
+ * on stdin — reading standard input blocks until it ends. Only direct
26
+ * execution runs the successor.
27
+ */
28
+ export interface SuccessorLaunchConfig {
29
+ readonly args: readonly string[];
30
+ /** The directory the predecessor was working from; absent when the launch line does not carry a usable one. */
31
+ readonly cwd?: string;
32
+ }
33
+ export declare function parseSuccessorLaunchConfig(raw: string): SuccessorLaunchConfig | null;
34
+ /**
35
+ * Moves this process's working directory to `cwd` — where the predecessor was
36
+ * launched from — before anything else is loaded from disk.
37
+ *
38
+ * The predecessor resolves this module relative to its build directory, so
39
+ * that is where this process starts out. It must not stay there: on Windows a
40
+ * process's working directory keeps its tree from being renamed or removed,
41
+ * and the next update begins by renaming the whole runtime directory away to
42
+ * back it up. A `cwd` that is gone (or was never given) falls back to the OS
43
+ * temp directory and then home: a console can run from any of those, while the
44
+ * build directory has to be released.
45
+ */
46
+ export declare function adoptWorkingDirectory(cwd: string | undefined): void;
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Console successor — the process a Console starts when the installed release
3
+ * changes under it (see release-handover.ts).
4
+ *
5
+ * It exists so a handover never launches a path it was handed: the predecessor
6
+ * forks THIS module — a fixed name inside its own installed build, which an
7
+ * update has already replaced with the new release's copy — and writes the
8
+ * launch configuration to the successor's stdin. The successor then starts the
9
+ * console exactly the way the packaged entry does, with one difference: it
10
+ * keeps trying to bind while the predecessor is still releasing the port.
11
+ *
12
+ * stdin carries one JSON object, `{ "args": ["--workspace", "...", ...],
13
+ * "cwd": "<the predecessor's working directory>" }`: the predecessor's own
14
+ * command-line arguments, and the directory to resolve them from. It is
15
+ * untrusted input and is validated field by field; anything else exits before
16
+ * a port is touched, so a malformed or absent configuration never leaves a
17
+ * stray process behind.
18
+ *
19
+ * The successor's first act is to LEAVE the build directory it was resolved
20
+ * from, for the predecessor's working directory — see
21
+ * `adoptWorkingDirectory`.
22
+ *
23
+ * cli-7 / PRI-892 precedent: importing this module (a test driving
24
+ * `parseSuccessorLaunchConfig`, for example) must NOT start a console or wait
25
+ * on stdin — reading standard input blocks until it ends. Only direct
26
+ * execution runs the successor.
27
+ */
28
+ import * as fs from 'node:fs';
29
+ import * as os from 'node:os';
30
+ import * as path from 'node:path';
31
+ import { pathToFileURL } from 'node:url';
32
+ /** A console launch line is a handful of short flags; nothing legitimate is larger. */
33
+ const MAX_CONFIG_BYTES = 16 * 1024;
34
+ const MAX_ARGS = 64;
35
+ const MAX_ARG_LENGTH = 4096;
36
+ export function parseSuccessorLaunchConfig(raw) {
37
+ if (raw.length > MAX_CONFIG_BYTES)
38
+ return null;
39
+ let value;
40
+ try {
41
+ value = JSON.parse(raw);
42
+ }
43
+ catch {
44
+ return null;
45
+ }
46
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
47
+ return null;
48
+ const args = Object.hasOwn(value, 'args') ? Reflect.get(value, 'args') : undefined;
49
+ if (!Array.isArray(args) || args.length === 0 || args.length > MAX_ARGS)
50
+ return null;
51
+ const copied = [];
52
+ for (const argument of args) {
53
+ if (typeof argument !== 'string' || argument.length > MAX_ARG_LENGTH || argument.includes('\0'))
54
+ return null;
55
+ copied.push(argument);
56
+ }
57
+ const cwd = Object.hasOwn(value, 'cwd') ? Reflect.get(value, 'cwd') : undefined;
58
+ // Absolute only: a relative one would be resolved against the very directory
59
+ // this process is about to leave.
60
+ const usableCwd = typeof cwd === 'string' && cwd.length > 0 && cwd.length <= MAX_ARG_LENGTH
61
+ && !cwd.includes('\0') && path.isAbsolute(cwd);
62
+ return { args: copied, ...(usableCwd ? { cwd } : {}) };
63
+ }
64
+ /**
65
+ * Moves this process's working directory to `cwd` — where the predecessor was
66
+ * launched from — before anything else is loaded from disk.
67
+ *
68
+ * The predecessor resolves this module relative to its build directory, so
69
+ * that is where this process starts out. It must not stay there: on Windows a
70
+ * process's working directory keeps its tree from being renamed or removed,
71
+ * and the next update begins by renaming the whole runtime directory away to
72
+ * back it up. A `cwd` that is gone (or was never given) falls back to the OS
73
+ * temp directory and then home: a console can run from any of those, while the
74
+ * build directory has to be released.
75
+ */
76
+ export function adoptWorkingDirectory(cwd) {
77
+ let lastError;
78
+ for (const candidate of [cwd, os.tmpdir(), os.homedir()]) {
79
+ if (candidate === undefined || candidate === '')
80
+ continue;
81
+ try {
82
+ process.chdir(candidate);
83
+ return;
84
+ }
85
+ catch (error) {
86
+ lastError = error;
87
+ }
88
+ }
89
+ console.error(`[pd-console] Successor could not leave the build directory (${lastError instanceof Error ? lastError.message : String(lastError)}); `
90
+ + 'the next update may not be able to back the runtime up.');
91
+ }
92
+ async function run() {
93
+ const config = parseSuccessorLaunchConfig(fs.readFileSync(0, 'utf8'));
94
+ if (config === null) {
95
+ console.error('[pd-console] Successor received no usable launch configuration; exiting.');
96
+ process.exit(1);
97
+ }
98
+ // Out of the build directory before the console — and everything it imports
99
+ // — is loaded: from here on this process works from where its launcher stood.
100
+ adoptWorkingDirectory(config.cwd);
101
+ // Configuration in hand: let go of the predecessor. An open IPC channel
102
+ // would tie this process's lifetime to the one it is meant to replace.
103
+ if (process.connected === true)
104
+ process.disconnect?.();
105
+ const { main } = await import('./index.js');
106
+ await main({
107
+ // `[node, <this module>]` is all the console reads from the first two slots.
108
+ argv: [...process.argv.slice(0, 2), ...config.args],
109
+ keepTryingToBind: true,
110
+ });
111
+ }
112
+ function isMainModuleEntry() {
113
+ const [, entry] = process.argv;
114
+ if (!entry)
115
+ return false;
116
+ try {
117
+ return pathToFileURL(fs.realpathSync(entry)).href === import.meta.url;
118
+ }
119
+ catch {
120
+ return false;
121
+ }
122
+ }
123
+ if (isMainModuleEntry()) {
124
+ run().catch((error) => {
125
+ console.error('[pd-console] Successor failed to start:', error);
126
+ process.exit(1);
127
+ });
128
+ }
@@ -775,6 +775,9 @@
775
775
  .w-1\.5 {
776
776
  width: calc(var(--spacing) * 1.5);
777
777
  }
778
+ .w-1\/3 {
779
+ width: calc(1 / 3 * 100%);
780
+ }
778
781
  .w-2 {
779
782
  width: calc(var(--spacing) * 2);
780
783
  }
@@ -1718,6 +1721,9 @@
1718
1721
  .bg-card {
1719
1722
  background-color: var(--color-card);
1720
1723
  }
1724
+ .bg-current {
1725
+ background-color: currentcolor;
1726
+ }
1721
1727
  .bg-danger {
1722
1728
  background-color: var(--color-danger);
1723
1729
  }
@@ -1787,6 +1793,12 @@
1787
1793
  background-color: color-mix(in oklab, var(--color-gov) 10%, transparent);
1788
1794
  }
1789
1795
  }
1796
+ .bg-gov\/60 {
1797
+ background-color: color-mix(in srgb, #1e3a5f 60%, transparent);
1798
+ @supports (color: color-mix(in lab, red, red)) {
1799
+ background-color: color-mix(in oklab, var(--color-gov) 60%, transparent);
1800
+ }
1801
+ }
1790
1802
  .bg-green {
1791
1803
  background-color: var(--color-green);
1792
1804
  }
@@ -2490,6 +2502,12 @@
2490
2502
  .text-ink-4 {
2491
2503
  color: var(--color-ink-4);
2492
2504
  }
2505
+ .text-ink-4\/60 {
2506
+ color: color-mix(in srgb, #5F6774 60%, transparent);
2507
+ @supports (color: color-mix(in lab, red, red)) {
2508
+ color: color-mix(in oklab, var(--color-ink-4) 60%, transparent);
2509
+ }
2510
+ }
2493
2511
  .text-ink-4\/80 {
2494
2512
  color: color-mix(in srgb, #5F6774 80%, transparent);
2495
2513
  @supports (color: color-mix(in lab, red, red)) {