create-principles-disciple 1.156.2 → 1.157.2

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 (242) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/codex-adapter/dist/worker/workspace-worker.d.ts +11 -3
  3. package/codex-adapter/dist/worker/workspace-worker.js +30 -16
  4. package/codex-adapter/package.json +1 -1
  5. package/console/dist/server/models/OwnerDecisionConsoleModel.js +33 -1
  6. package/console/dist/web/assets/app.js +3 -3
  7. package/core/dist/runtime/adversarial-loop.d.ts +8 -0
  8. package/core/dist/runtime/adversarial-loop.d.ts.map +1 -1
  9. package/core/dist/runtime/adversarial-loop.js +420 -45
  10. package/core/dist/runtime/adversarial-loop.js.map +1 -1
  11. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +3 -3
  12. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  13. package/core/dist/runtime/feature-flags/plugin-surface-registry.d.ts.map +1 -1
  14. package/core/dist/runtime/feature-flags/plugin-surface-registry.js +0 -16
  15. package/core/dist/runtime/feature-flags/plugin-surface-registry.js.map +1 -1
  16. package/core/dist/runtime/index.d.ts +4 -0
  17. package/core/dist/runtime/index.d.ts.map +1 -1
  18. package/core/dist/runtime/index.js +10 -0
  19. package/core/dist/runtime/index.js.map +1 -1
  20. package/core/dist/runtime/internalization/artificer-runner.d.ts +9 -0
  21. package/core/dist/runtime/internalization/artificer-runner.d.ts.map +1 -1
  22. package/core/dist/runtime/internalization/artificer-runner.js +52 -0
  23. package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
  24. package/core/dist/runtime/internalization/correlation-lineage.d.ts +16 -3
  25. package/core/dist/runtime/internalization/correlation-lineage.d.ts.map +1 -1
  26. package/core/dist/runtime/internalization/correlation-lineage.js +4 -4
  27. package/core/dist/runtime/internalization/correlation-lineage.js.map +1 -1
  28. package/core/dist/runtime/internalization/evaluator-runner.d.ts +35 -0
  29. package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
  30. package/core/dist/runtime/internalization/evaluator-runner.js +390 -91
  31. package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
  32. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +40 -13
  33. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
  34. package/core/dist/runtime/internalization/internalization-orchestrator.js +520 -199
  35. package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
  36. package/core/dist/runtime/internalization/internalization-transition-decision.js +1 -1
  37. package/core/dist/runtime/internalization/internalization-transition-decision.js.map +1 -1
  38. package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
  39. package/core/dist/runtime/internalization/owner-resolution-service.js +10 -8
  40. package/core/dist/runtime/internalization/owner-resolution-service.js.map +1 -1
  41. package/core/dist/runtime/internalization/owner-review.d.ts +2 -0
  42. package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
  43. package/core/dist/runtime/internalization/owner-review.js +17 -11
  44. package/core/dist/runtime/internalization/owner-review.js.map +1 -1
  45. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -0
  46. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
  47. package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
  48. package/core/dist/runtime/internalization/pitask-metadata.d.ts +36 -1
  49. package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
  50. package/core/dist/runtime/internalization/pitask-metadata.js +23 -2
  51. package/core/dist/runtime/internalization/pitask-metadata.js.map +1 -1
  52. package/core/dist/runtime/internalization/repair-create.d.ts +73 -0
  53. package/core/dist/runtime/internalization/repair-create.d.ts.map +1 -0
  54. package/core/dist/runtime/internalization/repair-create.js +200 -0
  55. package/core/dist/runtime/internalization/repair-create.js.map +1 -0
  56. package/core/dist/runtime/internalization/repair-lineage-backfill.d.ts +94 -0
  57. package/core/dist/runtime/internalization/repair-lineage-backfill.d.ts.map +1 -0
  58. package/core/dist/runtime/internalization/repair-lineage-backfill.js +123 -0
  59. package/core/dist/runtime/internalization/repair-lineage-backfill.js.map +1 -0
  60. package/core/dist/runtime/internalization/repair-task-identity.d.ts +99 -4
  61. package/core/dist/runtime/internalization/repair-task-identity.d.ts.map +1 -1
  62. package/core/dist/runtime/internalization/repair-task-identity.js +225 -7
  63. package/core/dist/runtime/internalization/repair-task-identity.js.map +1 -1
  64. package/core/dist/runtime/internalization/revision-reopen.d.ts +56 -1
  65. package/core/dist/runtime/internalization/revision-reopen.d.ts.map +1 -1
  66. package/core/dist/runtime/internalization/revision-reopen.js +82 -39
  67. package/core/dist/runtime/internalization/revision-reopen.js.map +1 -1
  68. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +0 -7
  69. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
  70. package/core/dist/runtime/internalization/rollout-reviewer-runner.js +13 -68
  71. package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
  72. package/core/dist/runtime/internalization/successor-create.d.ts +69 -0
  73. package/core/dist/runtime/internalization/successor-create.d.ts.map +1 -0
  74. package/core/dist/runtime/internalization/successor-create.js +173 -0
  75. package/core/dist/runtime/internalization/successor-create.js.map +1 -0
  76. package/core/dist/runtime/internalization/successor-lookup.d.ts +50 -0
  77. package/core/dist/runtime/internalization/successor-lookup.d.ts.map +1 -0
  78. package/core/dist/runtime/internalization/successor-lookup.js +213 -0
  79. package/core/dist/runtime/internalization/successor-lookup.js.map +1 -0
  80. package/core/dist/runtime/runner/succeeded-result-recovery.d.ts +58 -0
  81. package/core/dist/runtime/runner/succeeded-result-recovery.d.ts.map +1 -0
  82. package/core/dist/runtime/runner/succeeded-result-recovery.js +117 -0
  83. package/core/dist/runtime/runner/succeeded-result-recovery.js.map +1 -0
  84. package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -0
  85. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  86. package/core/dist/runtime/store/runtime-state-manager.js +4 -0
  87. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  88. package/core/dist/runtime/store/task/memory-task-store.d.ts +3 -3
  89. package/core/dist/runtime/store/task/memory-task-store.d.ts.map +1 -1
  90. package/core/dist/runtime/store/task/memory-task-store.js +52 -0
  91. package/core/dist/runtime/store/task/memory-task-store.js.map +1 -1
  92. package/core/dist/runtime/store/task/sqlite-task-store.d.ts +3 -0
  93. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  94. package/core/dist/runtime/store/task/sqlite-task-store.js +204 -135
  95. package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
  96. package/core/dist/runtime/store/task/task-store.d.ts +17 -0
  97. package/core/dist/runtime/store/task/task-store.d.ts.map +1 -1
  98. package/core/dist/telemetry-event.d.ts +2 -2
  99. package/core/dist/telemetry-event.d.ts.map +1 -1
  100. package/core/dist/telemetry-event.js +4 -0
  101. package/core/dist/telemetry-event.js.map +1 -1
  102. package/core/package.json +1 -1
  103. package/dist/index.js +1 -1
  104. package/dist/index.js.map +1 -1
  105. package/dist/installer.d.ts +69 -11
  106. package/dist/installer.d.ts.map +1 -1
  107. package/dist/installer.js +432 -120
  108. package/dist/installer.js.map +1 -1
  109. package/dist/service-host-bridge.d.ts +0 -5
  110. package/dist/service-host-bridge.d.ts.map +1 -1
  111. package/dist/service-host-bridge.js.map +1 -1
  112. package/dist/service-host-provisioning.d.ts +123 -18
  113. package/dist/service-host-provisioning.d.ts.map +1 -1
  114. package/dist/service-host-provisioning.js +645 -77
  115. package/dist/service-host-provisioning.js.map +1 -1
  116. package/dist/utils/env.d.ts +9 -0
  117. package/dist/utils/env.d.ts.map +1 -1
  118. package/dist/utils/env.js +269 -49
  119. package/dist/utils/env.js.map +1 -1
  120. package/host-runtime/dist/codex-worker-status.d.ts +6 -4
  121. package/host-runtime/dist/codex-worker-status.js +7 -5
  122. package/host-runtime/dist/diagnostician-auto-run.js +2 -2
  123. package/host-runtime/dist/governance-signal-admission.d.ts +2 -1
  124. package/host-runtime/dist/governance-signal-admission.js +2 -1
  125. package/host-runtime/dist/index.d.ts +4 -2
  126. package/host-runtime/dist/index.js +6 -2
  127. package/host-runtime/dist/internalization-consumer-cycle.d.ts +13 -106
  128. package/host-runtime/dist/internalization-consumer-cycle.js +21 -99
  129. package/host-runtime/dist/internalization-consumer-governance.d.ts +3 -3
  130. package/host-runtime/dist/internalization-consumer-governance.js +17 -96
  131. package/host-runtime/dist/internalization-task-executor.d.ts +127 -0
  132. package/host-runtime/dist/internalization-task-executor.js +121 -0
  133. package/host-runtime/dist/workbuddy-worker-status.d.ts +6 -3
  134. package/host-runtime/dist/workbuddy-worker-status.js +7 -4
  135. package/host-runtime/dist/workspace-telemetry-emitter.js +1 -1
  136. package/host-runtime/package.json +1 -1
  137. package/install-layout/dist/background-execution-transition.d.ts +25 -29
  138. package/install-layout/dist/background-execution-transition.js +90 -138
  139. package/install-layout/dist/index.d.ts +45 -33
  140. package/install-layout/dist/index.js +24 -18
  141. package/install-layout/package.json +1 -1
  142. package/package.json +5 -4
  143. package/pd-cli/dist/commands/codex-worker.d.ts +7 -3
  144. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  145. package/pd-cli/dist/commands/codex-worker.js +125 -101
  146. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  147. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
  148. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +148 -130
  149. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
  150. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  151. package/pd-cli/dist/commands/runtime-internalization-run-once.js +4 -0
  152. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  153. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +1 -1
  154. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  155. package/pd-cli/dist/commands/service-run-once.d.ts +12 -27
  156. package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
  157. package/pd-cli/dist/commands/service-run-once.js +15 -206
  158. package/pd-cli/dist/commands/service-run-once.js.map +1 -1
  159. package/pd-cli/dist/commands/workbuddy-worker.d.ts +7 -2
  160. package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
  161. package/pd-cli/dist/commands/workbuddy-worker.js +133 -99
  162. package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
  163. package/pd-cli/dist/commands/worker-service-host-gate.d.ts +38 -0
  164. package/pd-cli/dist/commands/worker-service-host-gate.d.ts.map +1 -0
  165. package/pd-cli/dist/commands/worker-service-host-gate.js +110 -0
  166. package/pd-cli/dist/commands/worker-service-host-gate.js.map +1 -0
  167. package/pd-cli/dist/program.d.ts.map +1 -1
  168. package/pd-cli/dist/program.js +20 -84
  169. package/pd-cli/dist/program.js.map +1 -1
  170. package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
  171. package/pd-cli/dist/services/rulehost-pipeline-runner.js +198 -142
  172. package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -1
  173. package/pd-cli/dist/services/service-host/coordinator-common.d.ts.map +1 -1
  174. package/pd-cli/dist/services/service-host/coordinator-common.js +4 -5
  175. package/pd-cli/dist/services/service-host/coordinator-common.js.map +1 -1
  176. package/pd-cli/dist/services/service-host/index.d.ts +7 -10
  177. package/pd-cli/dist/services/service-host/index.d.ts.map +1 -1
  178. package/pd-cli/dist/services/service-host/index.js +8 -11
  179. package/pd-cli/dist/services/service-host/index.js.map +1 -1
  180. package/pd-cli/dist/services/service-host/install-identity.d.ts +5 -5
  181. package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -1
  182. package/pd-cli/dist/services/service-host/managed-run.js +19 -22
  183. package/pd-cli/dist/services/service-host/managed-run.js.map +1 -1
  184. package/pd-cli/dist/services/service-host/scheduler/linux.d.ts.map +1 -1
  185. package/pd-cli/dist/services/service-host/scheduler/linux.js +21 -2
  186. package/pd-cli/dist/services/service-host/scheduler/linux.js.map +1 -1
  187. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +1 -1
  188. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -1
  189. package/pd-cli/dist/services/service-host/scheduler/service-status.js +0 -2
  190. package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -1
  191. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +7 -51
  192. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
  193. package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
  194. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js +3 -3
  195. package/pd-cli/dist/services/service-host/worker-adapter.d.ts +0 -10
  196. package/pd-cli/dist/services/service-host/worker-adapter.d.ts.map +1 -1
  197. package/pd-cli/dist/services/service-host/worker-adapter.js +4 -12
  198. package/pd-cli/dist/services/service-host/worker-adapter.js.map +1 -1
  199. package/pd-cli/dist/services/service-host/worker-env.d.ts +1 -1
  200. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts +5 -7
  201. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts.map +1 -1
  202. package/pd-cli/dist/services/service-host/workspace-dispatch.js +1 -3
  203. package/pd-cli/dist/services/service-host/workspace-dispatch.js.map +1 -1
  204. package/pd-cli/package.json +1 -1
  205. package/plugin/dist/bundle.js +616 -1319
  206. package/plugin/dist/core/openclaw-tool-declaration.d.ts +13 -0
  207. package/plugin/dist/index.d.ts +0 -9
  208. package/plugin/dist/openclaw-worker.d.ts +21 -8
  209. package/plugin/dist/openclaw-worker.js +267 -267
  210. package/plugin/dist/openclaw.plugin.json +1 -1
  211. package/plugin/openclaw.plugin.json +1 -1
  212. package/plugin/package.json +1 -1
  213. package/release-manager/dist/installer.js +432 -120
  214. package/release-manager/dist/service-host-provisioning.js +645 -77
  215. package/release-manager/dist/utils/env.js +269 -49
  216. package/release-manager/package.json +3 -2
  217. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +9 -1
  218. package/workbuddy-adapter/dist/worker/workspace-worker.js +21 -9
  219. package/workbuddy-adapter/package.json +1 -1
  220. package/pd-cli/dist/commands/service-handover.d.ts +0 -12
  221. package/pd-cli/dist/commands/service-handover.d.ts.map +0 -1
  222. package/pd-cli/dist/commands/service-handover.js +0 -117
  223. package/pd-cli/dist/commands/service-handover.js.map +0 -1
  224. package/pd-cli/dist/commands/worker-drain.d.ts +0 -7
  225. package/pd-cli/dist/commands/worker-drain.d.ts.map +0 -1
  226. package/pd-cli/dist/commands/worker-drain.js +0 -51
  227. package/pd-cli/dist/commands/worker-drain.js.map +0 -1
  228. package/pd-cli/dist/services/service-host/handover-claims.d.ts +0 -14
  229. package/pd-cli/dist/services/service-host/handover-claims.d.ts.map +0 -1
  230. package/pd-cli/dist/services/service-host/handover-claims.js +0 -50
  231. package/pd-cli/dist/services/service-host/handover-claims.js.map +0 -1
  232. package/pd-cli/dist/services/service-host/shadow-run.d.ts +0 -87
  233. package/pd-cli/dist/services/service-host/shadow-run.d.ts.map +0 -1
  234. package/pd-cli/dist/services/service-host/shadow-run.js +0 -549
  235. package/pd-cli/dist/services/service-host/shadow-run.js.map +0 -1
  236. package/pd-cli/dist/services/service-host/workspace-handover.d.ts +0 -190
  237. package/pd-cli/dist/services/service-host/workspace-handover.d.ts.map +0 -1
  238. package/pd-cli/dist/services/service-host/workspace-handover.js +0 -1393
  239. package/pd-cli/dist/services/service-host/workspace-handover.js.map +0 -1
  240. package/plugin/dist/service/gateway-consumer-lease.d.ts +0 -142
  241. package/plugin/dist/service/gateway-quiesce-ack.d.ts +0 -40
  242. package/plugin/dist/service/internalization-auto-consumer-service.d.ts +0 -100
@@ -15,7 +15,8 @@ import * as path from 'path';
15
15
  import * as net from 'net';
16
16
  import { findForeignWorkspaceOwner } from './host-workspace-ownership.js';
17
17
  import { errnoCode } from './config-file-io.js';
18
- import { resolvePdHome } from '@principles/install-layout';
18
+ import JSON5 from 'json5';
19
+ import { resolveOpenClawConfigPath, resolvePdHome } from '@principles/install-layout';
19
20
  /** Core files whose presence marks a workspace as already initialized. */
20
21
  const CORE_WORKSPACE_FILES = ['AGENTS.md', 'SOUL.md', 'USER.md'];
21
22
  /**
@@ -272,24 +273,212 @@ export function getPluginExtDir(homeDir, env = process.env) {
272
273
  // resolvePdHome itself performs.
273
274
  return path.join(homePaths.openclawHome, 'extensions', 'principles-disciple');
274
275
  }
275
- function readOpenClawPort() {
276
- const configPath = path.join(getOpenClawConfigDir(), 'openclaw.json');
277
- if (!fs.existsSync(configPath))
276
+ const OPENCLAW_DEFAULT_GATEWAY_PORT = 18_789;
277
+ const OPENCLAW_DEV_PROFILE_GATEWAY_PORT = 19_001;
278
+ const OPENCLAW_PROFILE_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/i;
279
+ function normalizeOpenClawProfileName(value) {
280
+ const trimmed = value?.trim();
281
+ if (!trimmed || trimmed.toLowerCase() === 'default' || !OPENCLAW_PROFILE_NAME_RE.test(trimmed))
282
+ return null;
283
+ return trimmed;
284
+ }
285
+ /** Mirrors OpenClaw resolveProfileGatewayPort: FNV-style UTF-8 hash into 20000..59999. */
286
+ function resolveOpenClawProfileGatewayPort(profile) {
287
+ if (profile === 'dev')
288
+ return OPENCLAW_DEV_PROFILE_GATEWAY_PORT;
289
+ let hash = 2_166_136_261;
290
+ for (const byte of Buffer.from(profile, 'utf8')) {
291
+ hash = Math.imul(hash ^ byte, 16_777_619) >>> 0;
292
+ }
293
+ return 20_000 + (hash % 40_000);
294
+ }
295
+ function parseOpenClawGatewayPortEnvValue(raw) {
296
+ const trimmed = raw?.trim();
297
+ if (!trimmed)
298
+ return null;
299
+ const parseTcpPort = (digits) => {
300
+ if (!/^\d+$/.test(digits))
301
+ return null;
302
+ const port = Number.parseInt(digits, 10);
303
+ return port > 0 && port < 65_536 ? port : null;
304
+ };
305
+ if (/^\d+$/.test(trimmed))
306
+ return parseTcpPort(trimmed);
307
+ const bracketedIpv6 = /^\[[^\]]+\]:(\d+)$/.exec(trimmed);
308
+ if (bracketedIpv6?.[1])
309
+ return parseTcpPort(bracketedIpv6[1]);
310
+ const firstColon = trimmed.indexOf(':');
311
+ const lastColon = trimmed.lastIndexOf(':');
312
+ if (firstColon <= 0 || firstColon !== lastColon)
278
313
  return null;
314
+ return parseTcpPort(trimmed.slice(firstColon + 1));
315
+ }
316
+ /** OpenClaw port precedence: env > gateway.port > named-profile default > 18789.
317
+ * `--port` is a process invocation override outside the installer's evidence scope;
318
+ * a profile:dev special case mirrors the host CLI setting OPENCLAW_GATEWAY_PORT=19001. */
319
+ export function resolveOpenClawGatewayPort(configPort, env) {
320
+ const envPort = parseOpenClawGatewayPortEnvValue(env.OPENCLAW_GATEWAY_PORT);
321
+ if (envPort !== null)
322
+ return envPort;
323
+ if (typeof configPort === 'number') {
324
+ return Number.isFinite(configPort) && configPort > 0 && configPort < 65_536 ? Math.floor(configPort) : null;
325
+ }
326
+ const profile = normalizeOpenClawProfileName(env.OPENCLAW_PROFILE);
327
+ if (profile)
328
+ return resolveOpenClawProfileGatewayPort(profile);
329
+ return OPENCLAW_DEFAULT_GATEWAY_PORT;
330
+ }
331
+ function hasOpenClawPortAffectingInclude(config) {
332
+ if (Object.hasOwn(config, '$include'))
333
+ return true;
334
+ const { gateway } = config;
335
+ return gateway !== null
336
+ && typeof gateway === 'object'
337
+ && !Array.isArray(gateway)
338
+ && Object.hasOwn(gateway, '$include');
339
+ }
340
+ const OPENCLAW_PORT_INCLUDE_MAX_DEPTH = 8;
341
+ const OPENCLAW_PORT_INCLUDE_MAX_BYTES = 2 * 1024 * 1024;
342
+ function isPathInside(root, candidate) {
343
+ const relative = path.relative(root, candidate);
344
+ return relative === '' || (relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
345
+ }
346
+ function realpathOrLexical(candidate) {
279
347
  try {
280
- const raw = fs.readFileSync(configPath, 'utf-8');
281
- const config = JSON.parse(raw);
282
- if (config && typeof config === 'object' && !Array.isArray(config)) {
283
- const { gateway } = config;
284
- if (gateway && typeof gateway === 'object' && !Array.isArray(gateway)) {
285
- const { port } = gateway;
286
- if (typeof port === 'number' && port > 0 && port < 65536)
287
- return port;
288
- }
348
+ return path.normalize(fs.realpathSync.native(candidate));
349
+ }
350
+ catch {
351
+ return path.normalize(candidate);
352
+ }
353
+ }
354
+ function openClawPortIncludeRoots(configPath) {
355
+ const roots = [path.dirname(configPath)];
356
+ const raw = process.env.OPENCLAW_INCLUDE_ROOTS?.trim();
357
+ if (raw) {
358
+ for (const entry of raw.split(path.delimiter)) {
359
+ const trimmed = entry.trim();
360
+ if (trimmed && path.isAbsolute(trimmed))
361
+ roots.push(path.resolve(trimmed));
362
+ }
363
+ }
364
+ return roots.map((root) => realpathOrLexical(path.normalize(root)));
365
+ }
366
+ /**
367
+ * Resolve the narrow scalar `gateway.port: { $include: ... }` case. This is
368
+ * intentionally not a general config merger: root/gateway object includes stay
369
+ * fail-closed above, while a scalar include can be verified without guessing.
370
+ * Every unreadable, escaping, cyclic, malformed, or non-scalar outcome is
371
+ * unresolved rather than treated as the default port.
372
+ */
373
+ function resolveOpenClawIncludedPortValue(value, context) {
374
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
375
+ return { ok: true, value };
376
+ const record = value;
377
+ if (!Object.hasOwn(record, '$include'))
378
+ return { ok: true, value };
379
+ const includeValue = record.$include;
380
+ const siblingKeys = Object.keys(record).filter((key) => key !== '$include');
381
+ if (typeof includeValue !== 'string' || Array.isArray(includeValue) || siblingKeys.length > 0)
382
+ return { ok: false };
383
+ if (includeValue.includes('\0') || includeValue.length >= 4096 || context.depth >= OPENCLAW_PORT_INCLUDE_MAX_DEPTH)
384
+ return { ok: false };
385
+ const lexical = path.normalize(path.isAbsolute(includeValue)
386
+ ? includeValue
387
+ : path.resolve(path.dirname(context.basePath), includeValue));
388
+ if (context.visited.has(lexical))
389
+ return { ok: false };
390
+ const real = realpathOrLexical(lexical);
391
+ const roots = openClawPortIncludeRoots(context.configPath);
392
+ if (!roots.some((root) => isPathInside(root, real)))
393
+ return { ok: false };
394
+ try {
395
+ if (!fs.existsSync(real))
396
+ return { ok: false };
397
+ const raw = fs.readFileSync(real, 'utf-8').replace(/^\uFEFF/, '');
398
+ if (Buffer.byteLength(raw, 'utf8') > OPENCLAW_PORT_INCLUDE_MAX_BYTES)
399
+ return { ok: false };
400
+ const parsed = JSON5.parse(raw);
401
+ return resolveOpenClawIncludedPortValue(parsed, {
402
+ configPath: context.configPath,
403
+ basePath: real,
404
+ visited: new Set([...context.visited, lexical]),
405
+ depth: context.depth + 1,
406
+ });
407
+ }
408
+ catch {
409
+ return { ok: false };
410
+ }
411
+ }
412
+ function validOpenClawTcpPort(value) {
413
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 && value < 65_536
414
+ ? Math.floor(value)
415
+ : null;
416
+ }
417
+ /**
418
+ * Candidate ports whose collective negative probe can count as quiesce
419
+ * evidence. Dev-profile launches are ambiguous to the installer: `--dev`
420
+ * injects OPENCLAW_GATEWAY_PORT=19001 inside the Gateway process, while a
421
+ * non-dev process using the same profile may still honor config. Probe every
422
+ * host-plausible candidate instead of treating one closed candidate as proof.
423
+ */
424
+ function openClawPortCandidates(configPort, env) {
425
+ const envPort = parseOpenClawGatewayPortEnvValue(env.OPENCLAW_GATEWAY_PORT);
426
+ if (envPort !== null)
427
+ return [envPort];
428
+ const profile = normalizeOpenClawProfileName(env.OPENCLAW_PROFILE);
429
+ const explicit = validOpenClawTcpPort(configPort);
430
+ if (profile === 'dev') {
431
+ const candidates = [OPENCLAW_DEV_PROFILE_GATEWAY_PORT];
432
+ if (explicit !== null && !candidates.includes(explicit))
433
+ candidates.push(explicit);
434
+ return candidates;
435
+ }
436
+ const single = resolveOpenClawGatewayPort(configPort, env);
437
+ return single === null ? [] : [single];
438
+ }
439
+ function readOpenClawPorts() {
440
+ const envPort = parseOpenClawGatewayPortEnvValue(process.env.OPENCLAW_GATEWAY_PORT);
441
+ if (envPort !== null)
442
+ return { ports: [envPort], observation: 'port_not_configured' };
443
+ const resolved = resolveOpenClawConfigPath(process.env);
444
+ if (!resolved.ok)
445
+ return { ports: [], observation: 'no_config' };
446
+ const configPath = resolved.path;
447
+ if (!fs.existsSync(configPath))
448
+ return { ports: [], observation: 'no_config' };
449
+ try {
450
+ const raw = fs.readFileSync(configPath, 'utf-8').replace(/^\uFEFF/, '');
451
+ const config = JSON5.parse(raw);
452
+ if (!config || typeof config !== 'object' || Array.isArray(config)) {
453
+ return { ports: [], observation: 'config_unreadable' };
289
454
  }
455
+ // Only a root-level or gateway-level `$include` can alter the effective
456
+ // gateway.port. Includes in unrelated branches (for example plugins) must
457
+ // not invalidate an explicit sibling port. Scalar port includes are
458
+ // resolved narrowly below; object-level includes remain unverified.
459
+ if (hasOpenClawPortAffectingInclude(config)) {
460
+ return { ports: [], observation: 'port_not_configured' };
461
+ }
462
+ const { gateway } = config;
463
+ const rawConfigPort = gateway && typeof gateway === 'object' && !Array.isArray(gateway)
464
+ ? gateway.port
465
+ : undefined;
466
+ const resolvedConfigPort = resolveOpenClawIncludedPortValue(rawConfigPort, {
467
+ configPath: path.normalize(configPath),
468
+ basePath: path.normalize(configPath),
469
+ visited: new Set([path.normalize(configPath)]),
470
+ depth: 0,
471
+ });
472
+ if (!resolvedConfigPort.ok)
473
+ return { ports: [], observation: 'port_not_configured' };
474
+ const ports = openClawPortCandidates(resolvedConfigPort.value, process.env);
475
+ if (ports.length === 0)
476
+ return { ports: [], observation: 'port_not_configured' };
477
+ return { ports, observation: 'port_not_configured' };
478
+ }
479
+ catch {
480
+ return { ports: [], observation: 'config_unreadable' };
290
481
  }
291
- catch { /* ignore */ }
292
- return null;
293
482
  }
294
483
  function checkPortListening(port) {
295
484
  return new Promise((resolve) => {
@@ -329,43 +518,51 @@ export function parseNetstatPid(output, port) {
329
518
  }
330
519
  return undefined;
331
520
  }
332
- export async function checkOpenClawGateway() {
333
- const port = readOpenClawPort();
334
- if (!port)
335
- return { isRunning: false };
336
- const listening = await checkPortListening(port);
337
- if (!listening)
338
- return { isRunning: false };
339
- let pid = undefined;
521
+ function findOpenClawListeningPid(port) {
340
522
  try {
341
523
  // ERR-045: argv-array execution only. The validated port is an argv
342
524
  // element or a JS-side output match — it never enters a shell string.
343
- if (Number.isInteger(port) && port > 0 && port < 65536) {
344
- const output = IS_WIN32
345
- ? execFileSync('netstat.exe', ['-ano', '-p', 'tcp'], { encoding: 'utf-8', timeout: 5000, windowsHide: true })
346
- : execFileSync('lsof', ['-i', `:${port}`, '-t', '-sTCP:LISTEN'], { encoding: 'utf-8', timeout: 5000, windowsHide: true });
347
- const text = output.trim();
348
- if (text) {
349
- let listeningLine;
350
- if (IS_WIN32) {
351
- listeningLine = text.split('\n').find((line) => {
352
- const [, localAddress, , state] = line.trim().split(/\s+/);
353
- return state === 'LISTENING' && localAddress !== undefined && localAddress.endsWith(`:${port}`);
354
- });
355
- }
356
- else {
357
- [listeningLine] = text.split('\n');
358
- }
359
- const pidColumn = IS_WIN32
360
- ? listeningLine?.trim().split(/\s+/)[4]
361
- : listeningLine?.trim();
362
- if (pidColumn)
363
- pid = parseInt(pidColumn, 10);
364
- }
525
+ if (!Number.isInteger(port) || port <= 0 || port >= 65_536)
526
+ return undefined;
527
+ const output = IS_WIN32
528
+ ? execFileSync('netstat.exe', ['-ano', '-p', 'tcp'], { encoding: 'utf-8', timeout: 5000, windowsHide: true })
529
+ : execFileSync('lsof', ['-i', `:${port}`, '-t', '-sTCP:LISTEN'], { encoding: 'utf-8', timeout: 5000, windowsHide: true });
530
+ const text = output.trim();
531
+ if (!text)
532
+ return undefined;
533
+ let pidColumn;
534
+ if (IS_WIN32) {
535
+ const listeningLine = text.split('\n').find((line) => {
536
+ const [, localAddress, , state] = line.trim().split(/\s+/);
537
+ return state === 'LISTENING' && localAddress !== undefined && localAddress.endsWith(`:${port}`);
538
+ });
539
+ pidColumn = listeningLine?.trim().split(/\s+/)[4];
365
540
  }
541
+ else {
542
+ [pidColumn] = text.split('\n');
543
+ pidColumn = pidColumn?.trim();
544
+ }
545
+ if (!pidColumn)
546
+ return undefined;
547
+ const pid = Number.parseInt(pidColumn, 10);
548
+ return Number.isInteger(pid) && pid > 0 ? pid : undefined;
549
+ }
550
+ catch {
551
+ return undefined;
366
552
  }
367
- catch { /* ignore */ }
368
- return { isRunning: true, port, pid };
553
+ }
554
+ export async function checkOpenClawGateway() {
555
+ const configured = readOpenClawPorts();
556
+ if (configured.ports.length === 0)
557
+ return { isRunning: false, observation: configured.observation };
558
+ for (const port of configured.ports) {
559
+ if (await checkPortListening(port)) {
560
+ const pid = findOpenClawListeningPid(port);
561
+ return { isRunning: true, port, ...(pid !== undefined ? { pid } : {}), observation: 'listening' };
562
+ }
563
+ }
564
+ const [port] = configured.ports;
565
+ return { isRunning: false, ...(port !== undefined ? { port } : {}), observation: 'port_not_listening' };
369
566
  }
370
567
  /**
371
568
  * Run `openclaw gateway <subcommand>` (service-level: launchd/systemd/schtasks).
@@ -497,6 +694,13 @@ async function confirmGatewayStopped(commandFailure, observed, deps = {}) {
497
694
  return { ok: false, reason: 'verification_unavailable', error: `${rawError} — the gateway port was not observable, so its stopped state could not be verified` };
498
695
  }
499
696
  const pid = observed?.pid;
697
+ if (deps.requireProcessExit === true && pid === undefined) {
698
+ return {
699
+ ok: false,
700
+ reason: 'verification_unavailable',
701
+ error: `${rawError} — the gateway PID was not resolved, so process exit could not be verified for ownership transfer`,
702
+ };
703
+ }
500
704
  try {
501
705
  let listening;
502
706
  let holderAlive = false;
@@ -544,9 +748,25 @@ async function confirmGatewayStopped(commandFailure, observed, deps = {}) {
544
748
  * `isRunning:false`.
545
749
  */
546
750
  export async function stopOpenClawGateway(observed, deps) {
751
+ // Ownership transfer must never issue a stop it cannot verify: if the
752
+ // pre-flight did not resolve both the listener port and the holding PID,
753
+ // sending the stop first would leave a failure path where the gateway is
754
+ // down but `restartedGateway` was never set. Refuse before mutation instead.
755
+ if (deps?.requireProcessExit === true) {
756
+ const port = observed?.port;
757
+ const pid = observed?.pid;
758
+ if (typeof port !== 'number' || !Number.isInteger(port) || port <= 0 || port >= 65536 || typeof pid !== 'number' || !Number.isInteger(pid) || pid <= 0) {
759
+ return {
760
+ ok: false,
761
+ reason: 'verification_unavailable',
762
+ error: 'openclaw gateway stop was not issued: the observed gateway port/PID was incomplete, so process exit could not be verified for ownership transfer',
763
+ };
764
+ }
765
+ }
547
766
  const command = runGatewayServiceCommand('stop');
548
- if (command.ok)
549
- return command;
767
+ // A successful stop command is only a request, not evidence that the legacy
768
+ // consumer exited. Ownership transfer may proceed only after the observed
769
+ // listener/process pair is verified quiescent.
550
770
  return confirmGatewayStopped(command, observed, deps);
551
771
  }
552
772
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.156.2",
3
+ "version": "1.157.2",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -73,6 +73,7 @@
73
73
  "commander": "^15.1.0",
74
74
  "fs-extra": "^11.4.1",
75
75
  "js-yaml": "^5.4.3",
76
+ "json5": "2.2.3",
76
77
  "micromatch": "^4.0.8",
77
78
  "ora": "^10.0.0",
78
79
  "picocolors": "^1.0.0",
@@ -101,6 +102,6 @@
101
102
  "directory": "packages/create-principles-disciple"
102
103
  },
103
104
  "pd": {
104
- "bundledPluginVersion": "4.2.1"
105
+ "bundledPluginVersion": "4.4.1"
105
106
  }
106
107
  }
@@ -47,8 +47,16 @@ export interface WorkbuddyWorkerCycleOptions {
47
47
  /**
48
48
  * WHO drove this cycle — same attribution contract as the Codex worker
49
49
  * (PRI-1264 + Phase 2 `service_host` driver identity, TD §5.2).
50
+ *
51
+ * PRI-1278 Phase 5 (Companion-runtime removal): the companion worker driver
52
+ * is retired — there is no Companion runtime left that could legitimately
53
+ * produce it. A process still self-declaring `PD_INVOCATION_SOURCE=companion`
54
+ * (a legacy env leftover) is not authoritative: no resident supervisor backs
55
+ * it, so it is attributed as what it factually is — manual. Historical
56
+ * liveness records already persisted with `lastCycleDriver: 'companion'`
57
+ * stay readable as-is; they are durable facts and are never rewritten.
50
58
  */
51
- export declare function workbuddyWorkerCycleDriver(): 'companion' | 'service_host' | 'manual';
59
+ export declare function workbuddyWorkerCycleDriver(): 'service_host' | 'manual';
52
60
  /** Read the persisted liveness record, or null when absent/unreadable. */
53
61
  export declare function readWorkbuddyWorkerLiveness(workspaceDir: string): Record<string, unknown> | null;
54
62
  /**
@@ -22,9 +22,10 @@
22
22
  * scheduler state — and no Codex flag, path or transcript semantics are
23
23
  * borrowed (SPEC §5: 不借用 Codex flag/日志伪装归因).
24
24
  *
25
- * Correctness under concurrent consumers (Companion-spawned `pd workbuddy
26
- * worker` + manual `pd runtime internalization run-once`) is owned by the
27
- * durable Runtime task lease — never by process-local state. The
25
+ * Correctness under concurrent consumers (Service-Host-spawned bounded
26
+ * `pd workbuddy worker --once` + manual `pd runtime internalization
27
+ * run-once`) is owned by the durable Runtime task lease — never by
28
+ * process-local state. The
28
29
  * governance workspace is the single canonical directory
29
30
  * (`~/.workbuddy/pd-workspace`), so two projects never double-schedule:
30
31
  * they share one workspace and the lease serialises consumption.
@@ -36,7 +37,12 @@ import { loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceCo
36
37
  import { WORKBUDDY_TOOL_SEMANTICS, WORKBUDDY_TOOL_SEMANTIC_MAPPINGS } from '../tool-semantics.js';
37
38
  import { catchUpWorkbuddyIngestion } from '../ingestion/catch-up.js';
38
39
  import { readWorkbuddyTargetTurnEvidence } from '../ingestion/pain-receipt-fallback.js';
39
- const WORKER_OWNER = 'companion-worker';
40
+ // PRI-1278 Phase 5 (Companion-runtime removal): the lease/consumer owner
41
+ // label for NEW writes is the Service Host worker identity — the PD Service
42
+ // Host is the only background runtime and spawns these bounded worker cycles.
43
+ // Historical lease records keep the retired 'companion-worker' string; they
44
+ // are durable facts and are deliberately NOT migrated.
45
+ const WORKER_OWNER = 'service-host-worker';
40
46
  const DEFAULT_DIAG_CANDIDATE_LIMIT = 5;
41
47
  // ── Cycle liveness (Phase 2, SPEC §11 / TD §2.3: WorkBuddy had NO liveness
42
48
  // record — FR-10 health was undecidable). Same shape and atomic-write
@@ -56,11 +62,17 @@ function isPlainRecord(value) {
56
62
  /**
57
63
  * WHO drove this cycle — same attribution contract as the Codex worker
58
64
  * (PRI-1264 + Phase 2 `service_host` driver identity, TD §5.2).
65
+ *
66
+ * PRI-1278 Phase 5 (Companion-runtime removal): the companion worker driver
67
+ * is retired — there is no Companion runtime left that could legitimately
68
+ * produce it. A process still self-declaring `PD_INVOCATION_SOURCE=companion`
69
+ * (a legacy env leftover) is not authoritative: no resident supervisor backs
70
+ * it, so it is attributed as what it factually is — manual. Historical
71
+ * liveness records already persisted with `lastCycleDriver: 'companion'`
72
+ * stay readable as-is; they are durable facts and are never rewritten.
59
73
  */
60
74
  export function workbuddyWorkerCycleDriver() {
61
75
  const source = process.env.PD_INVOCATION_SOURCE;
62
- if (source === 'companion')
63
- return 'companion';
64
76
  if (source === 'service_host')
65
77
  return 'service_host';
66
78
  return 'manual';
@@ -69,9 +81,9 @@ export function workbuddyWorkerCycleDriver() {
69
81
  * F13 (TD §5.2): the coordinator passes a unique invocation id; when
70
82
  * present it lands in the liveness record so the shared per-workspace file
71
83
  * can be correlated back to the exact Service Host invocation.
72
- * R5 review fix: a manual/companion cycle carries NO invocation id, so the
73
- * patch must CLEAR the field — otherwise a completed manual run would keep
74
- * masquerading under the previous shadow run's id.
84
+ * R5 review fix: a manual (non-Service-Host) cycle carries NO invocation
85
+ * id, so the patch must CLEAR the field — otherwise a completed manual run
86
+ * would keep masquerading under the previous shadow run's id.
75
87
  */
76
88
  function invocationIdLivenessPatch() {
77
89
  const invocationId = process.env.PD_INVOCATION_ID;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/workbuddy-adapter",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "WorkBuddy host adapter for Principles Disciple — implements the HostAdapter interface for WorkBuddy's Git Bash command-hook model (ADR-0020 third host, SPEC workbuddy-host-adapter v0.3.0).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,12 +0,0 @@
1
- interface ServiceHandoverOptions {
2
- workspace?: string;
3
- json?: boolean;
4
- pdHome?: string;
5
- ackWaitMs?: number;
6
- abort?: boolean;
7
- resumeOperationId?: string;
8
- }
9
- export declare function handleServiceHandover(options: ServiceHandoverOptions): Promise<void>;
10
- export declare function handleServiceRollback(options: ServiceHandoverOptions): Promise<void>;
11
- export {};
12
- //# sourceMappingURL=service-handover.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service-handover.d.ts","sourceRoot":"","sources":["../../src/commands/service-handover.ts"],"names":[],"mappings":"AAkBA,UAAU,sBAAsB;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAyBD,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoC1F;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgC1F"}
@@ -1,117 +0,0 @@
1
- /**
2
- * pd service handover / pd service rollback command implementation
3
- * (SPEC-PD-SERVICE-HOST-001 §8.4, PRI-1282 Phase 4).
4
- *
5
- * Operator surface over the per-Workspace atomic ownership transition. The
6
- * sequence lives in `services/service-host/workspace-handover.ts`; this file
7
- * is argument parsing, JSON contract and exit codes.
8
- *
9
- * CLI gate compliance:
10
- * - cli-1: --json prints exactly one parseable JSON document.
11
- * - cli-2: exit paths stop execution (blocked/failed ⇒ exit 1).
12
- * - cli-5: a refused handover leaves the workspace in its PREVIOUS ownership
13
- * (abort_handover restores legacy before returning blocked).
14
- * - cli-6: every blocked/failed result carries reason + nextAction.
15
- */
16
- import { resolveWorkspaceDir } from '../resolve-workspace.js';
17
- import { runWorkspaceHandover, runWorkspaceRollback } from '../services/service-host/workspace-handover.js';
18
- function invalidUsage(options, json, kind) {
19
- const error = {
20
- generatedAt: new Date().toISOString(),
21
- schemaVersion: 'pd.service-handover-op.v1',
22
- kind,
23
- error: 'cli_contract',
24
- reason: 'workspace_required',
25
- nextAction: 'Pass --workspace <canonical-workspace-dir>; ownership is per-Workspace and never inferred.',
26
- };
27
- if (json)
28
- console.log(JSON.stringify(error));
29
- else
30
- console.error(`[PD:ServiceHandover] --workspace is required: ${error.nextAction}`);
31
- process.exitCode = 1;
32
- }
33
- function wireTerminalAbortSignals(onAbort) {
34
- const handler = () => {
35
- onAbort();
36
- };
37
- process.once('SIGINT', handler);
38
- process.once('SIGTERM', handler);
39
- process.once('SIGHUP', handler);
40
- }
41
- export async function handleServiceHandover(options) {
42
- const json = options.json === true;
43
- if (options.workspace === undefined || options.workspace.trim().length === 0) {
44
- invalidUsage(options, json, 'handover');
45
- return;
46
- }
47
- const controller = new AbortController();
48
- wireTerminalAbortSignals(() => controller.abort());
49
- const workspace = resolveWorkspaceDir(options.workspace);
50
- const result = await runWorkspaceHandover(workspace, {
51
- ...(options.pdHome !== undefined ? { pdHomeOverride: options.pdHome } : {}),
52
- ...(options.ackWaitMs !== undefined ? { ackWaitMs: options.ackWaitMs } : {}),
53
- ...(options.resumeOperationId !== undefined ? { resumeOperationId: options.resumeOperationId } : {}),
54
- ...(options.abort === true ? { abort: true } : {}),
55
- signal: controller.signal,
56
- });
57
- if (json) {
58
- console.log(JSON.stringify(result));
59
- }
60
- else if (result.ok) {
61
- console.log([
62
- `OpenClaw workspace handover completed (${result.workspaceDir})`,
63
- ` operationId: ${result.operationId}`,
64
- ` generation: ${result.generation}`,
65
- ` readiness: ${result.readiness}`,
66
- ` gateway quiesce: ${result.quiesceAck.outcome} (via ${result.quiesceAck.startedVia}, generation ${result.quiesceAck.generation})`,
67
- ` worker cycle: ${result.workerCycle.mode} (exit ${result.workerCycle.exitCode ?? 'n/a'})`,
68
- ` evidence: ${result.evidencePath}`,
69
- ].join('\n'));
70
- }
71
- else {
72
- console.error([
73
- `OpenClaw workspace handover ${result.outcome} (${workspace})`,
74
- ` reason: ${result.reason}`,
75
- ` next action: ${result.nextAction}`,
76
- ].join('\n'));
77
- }
78
- if (!result.ok)
79
- process.exitCode = 1;
80
- }
81
- export async function handleServiceRollback(options) {
82
- const json = options.json === true;
83
- if (options.workspace === undefined || options.workspace.trim().length === 0) {
84
- invalidUsage(options, json, 'rollback');
85
- return;
86
- }
87
- const controller = new AbortController();
88
- wireTerminalAbortSignals(() => controller.abort());
89
- const workspace = resolveWorkspaceDir(options.workspace);
90
- const result = await runWorkspaceRollback(workspace, {
91
- ...(options.pdHome !== undefined ? { pdHomeOverride: options.pdHome } : {}),
92
- ...(options.resumeOperationId !== undefined ? { resumeOperationId: options.resumeOperationId } : {}),
93
- signal: controller.signal,
94
- });
95
- if (json) {
96
- console.log(JSON.stringify(result));
97
- }
98
- else if (result.ok) {
99
- console.log([
100
- `Workspace rollback completed (${result.workspaceDir})`,
101
- ` operationId: ${result.operationId}`,
102
- ` generation: ${result.generation}`,
103
- ` gateway resumption: ${result.gatewayResumption}`,
104
- ` evidence: ${result.evidencePath}`,
105
- ].join('\n'));
106
- }
107
- else {
108
- console.error([
109
- `Workspace rollback ${result.outcome} (${workspace})`,
110
- ` reason: ${result.reason}`,
111
- ` next action: ${result.nextAction}`,
112
- ].join('\n'));
113
- }
114
- if (!result.ok)
115
- process.exitCode = 1;
116
- }
117
- //# sourceMappingURL=service-handover.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service-handover.js","sourceRoot":"","sources":["../../src/commands/service-handover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,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Ac,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3E,GAAG,CAAC,OAAO,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC,CAAC;IACH,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,CAAC;SAAM,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC;YACV,iCAAiC,MAAM,CAAC,YAAY,GAAG;YACvD,0BAA0B,MAAM,CAAC,WAAW,EAAE;YAC9C,0BAA0B,MAAM,CAAC,UAAU,EAAE;YAC7C,0BAA0B,MAAM,CAAC,iBAAiB,EAAE;YACpD,0BAA0B,MAAM,CAAC,YAAY,EAAE;SAChD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC;YACZ,sBAAsB,MAAM,CAAC,OAAO,KAAK,SAAS,GAAG;YACrD,kBAAkB,MAAM,CAAC,MAAM,EAAE;YACjC,kBAAkB,MAAM,CAAC,UAAU,EAAE;SACtC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvC,CAAC"}
@@ -1,7 +0,0 @@
1
- /** Private Companion IPC. Stops between cycles; never interrupts an active cycle. */
2
- export declare function createWorkerDrain(): {
3
- readonly stopped: boolean;
4
- wait(interval: number): Promise<void>;
5
- dispose(): void;
6
- };
7
- //# sourceMappingURL=worker-drain.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-drain.d.ts","sourceRoot":"","sources":["../../src/commands/worker-drain.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,wBAAgB,iBAAiB;aAqBzB,OAAO,EAAI,OAAO;IAChB,IAAI,WAAW,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3C,OAAO,IAAI,IAAI;EAQlB"}