@principles/pd-cli 2.9.1 → 2.11.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 (187) hide show
  1. package/dist/commands/candidate.d.ts.map +1 -1
  2. package/dist/commands/candidate.js +16 -5
  3. package/dist/commands/candidate.js.map +1 -1
  4. package/dist/commands/codex-setup.d.ts.map +1 -1
  5. package/dist/commands/codex-setup.js +17 -1
  6. package/dist/commands/codex-setup.js.map +1 -1
  7. package/dist/commands/codex-worker.d.ts.map +1 -1
  8. package/dist/commands/codex-worker.js +8 -4
  9. package/dist/commands/codex-worker.js.map +1 -1
  10. package/dist/commands/consent-sweep-revoked.d.ts +20 -0
  11. package/dist/commands/consent-sweep-revoked.d.ts.map +1 -0
  12. package/dist/commands/consent-sweep-revoked.js +85 -0
  13. package/dist/commands/consent-sweep-revoked.js.map +1 -0
  14. package/dist/commands/context.d.ts.map +1 -1
  15. package/dist/commands/context.js +9 -1
  16. package/dist/commands/context.js.map +1 -1
  17. package/dist/commands/diagnose.d.ts.map +1 -1
  18. package/dist/commands/diagnose.js +12 -6
  19. package/dist/commands/diagnose.js.map +1 -1
  20. package/dist/commands/openclaw-worker.d.ts +11 -0
  21. package/dist/commands/openclaw-worker.d.ts.map +1 -0
  22. package/dist/commands/openclaw-worker.js +199 -0
  23. package/dist/commands/openclaw-worker.js.map +1 -0
  24. package/dist/commands/pain-explicit.d.ts.map +1 -1
  25. package/dist/commands/pain-explicit.js +1 -0
  26. package/dist/commands/pain-explicit.js.map +1 -1
  27. package/dist/commands/pain-recall.d.ts +2 -2
  28. package/dist/commands/pain-recall.d.ts.map +1 -1
  29. package/dist/commands/pain-recall.js +7 -1
  30. package/dist/commands/pain-recall.js.map +1 -1
  31. package/dist/commands/pain-record.d.ts.map +1 -1
  32. package/dist/commands/pain-record.js +4 -1
  33. package/dist/commands/pain-record.js.map +1 -1
  34. package/dist/commands/pain-retry.d.ts.map +1 -1
  35. package/dist/commands/pain-retry.js +30 -6
  36. package/dist/commands/pain-retry.js.map +1 -1
  37. package/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
  38. package/dist/commands/runtime-internalization-enqueue-successors.js +2 -1
  39. package/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
  40. package/dist/commands/runtime-internalization-run-once.d.ts +1 -0
  41. package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  42. package/dist/commands/runtime-internalization-run-once.js +32 -8
  43. package/dist/commands/runtime-internalization-run-once.js.map +1 -1
  44. package/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -1
  45. package/dist/commands/runtime-internalization-wake-once.js +2 -1
  46. package/dist/commands/runtime-internalization-wake-once.js.map +1 -1
  47. package/dist/commands/service-handover.d.ts +12 -0
  48. package/dist/commands/service-handover.d.ts.map +1 -0
  49. package/dist/commands/service-handover.js +117 -0
  50. package/dist/commands/service-handover.js.map +1 -0
  51. package/dist/commands/service-lifecycle.d.ts +31 -0
  52. package/dist/commands/service-lifecycle.d.ts.map +1 -0
  53. package/dist/commands/service-lifecycle.js +207 -0
  54. package/dist/commands/service-lifecycle.js.map +1 -0
  55. package/dist/commands/service-run-once.d.ts +102 -0
  56. package/dist/commands/service-run-once.d.ts.map +1 -0
  57. package/dist/commands/service-run-once.js +558 -0
  58. package/dist/commands/service-run-once.js.map +1 -0
  59. package/dist/commands/workbuddy-setup.d.ts.map +1 -1
  60. package/dist/commands/workbuddy-setup.js +22 -2
  61. package/dist/commands/workbuddy-setup.js.map +1 -1
  62. package/dist/program.d.ts.map +1 -1
  63. package/dist/program.js +180 -1
  64. package/dist/program.js.map +1 -1
  65. package/dist/services/admission-write-gate.d.ts +3 -1
  66. package/dist/services/admission-write-gate.d.ts.map +1 -1
  67. package/dist/services/admission-write-gate.js +1 -0
  68. package/dist/services/admission-write-gate.js.map +1 -1
  69. package/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
  70. package/dist/services/pain-flood-simulation-runner.js +4 -0
  71. package/dist/services/pain-flood-simulation-runner.js.map +1 -1
  72. package/dist/services/service-host/coordinator-common.d.ts +49 -0
  73. package/dist/services/service-host/coordinator-common.d.ts.map +1 -0
  74. package/dist/services/service-host/coordinator-common.js +158 -0
  75. package/dist/services/service-host/coordinator-common.js.map +1 -0
  76. package/dist/services/service-host/handover-claims.d.ts +14 -0
  77. package/dist/services/service-host/handover-claims.d.ts.map +1 -0
  78. package/dist/services/service-host/handover-claims.js +50 -0
  79. package/dist/services/service-host/handover-claims.js.map +1 -0
  80. package/dist/services/service-host/index.d.ts +31 -0
  81. package/dist/services/service-host/index.d.ts.map +1 -0
  82. package/dist/services/service-host/index.js +33 -0
  83. package/dist/services/service-host/index.js.map +1 -0
  84. package/dist/services/service-host/install-identity.d.ts +99 -0
  85. package/dist/services/service-host/install-identity.d.ts.map +1 -0
  86. package/dist/services/service-host/install-identity.js +176 -0
  87. package/dist/services/service-host/install-identity.js.map +1 -0
  88. package/dist/services/service-host/locking/service-run-lock.d.ts +255 -0
  89. package/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -0
  90. package/dist/services/service-host/locking/service-run-lock.js +739 -0
  91. package/dist/services/service-host/locking/service-run-lock.js.map +1 -0
  92. package/dist/services/service-host/managed-run.d.ts +75 -0
  93. package/dist/services/service-host/managed-run.d.ts.map +1 -0
  94. package/dist/services/service-host/managed-run.js +550 -0
  95. package/dist/services/service-host/managed-run.js.map +1 -0
  96. package/dist/services/service-host/owner-projection.d.ts +47 -0
  97. package/dist/services/service-host/owner-projection.d.ts.map +1 -0
  98. package/dist/services/service-host/owner-projection.js +121 -0
  99. package/dist/services/service-host/owner-projection.js.map +1 -0
  100. package/dist/services/service-host/progress-evidence.d.ts +38 -0
  101. package/dist/services/service-host/progress-evidence.d.ts.map +1 -0
  102. package/dist/services/service-host/progress-evidence.js +155 -0
  103. package/dist/services/service-host/progress-evidence.js.map +1 -0
  104. package/dist/services/service-host/run-once.d.ts +96 -0
  105. package/dist/services/service-host/run-once.d.ts.map +1 -0
  106. package/dist/services/service-host/run-once.js +308 -0
  107. package/dist/services/service-host/run-once.js.map +1 -0
  108. package/dist/services/service-host/scheduler/contract.d.ts +184 -0
  109. package/dist/services/service-host/scheduler/contract.d.ts.map +1 -0
  110. package/dist/services/service-host/scheduler/contract.js +86 -0
  111. package/dist/services/service-host/scheduler/contract.js.map +1 -0
  112. package/dist/services/service-host/scheduler/index.d.ts +76 -0
  113. package/dist/services/service-host/scheduler/index.d.ts.map +1 -0
  114. package/dist/services/service-host/scheduler/index.js +128 -0
  115. package/dist/services/service-host/scheduler/index.js.map +1 -0
  116. package/dist/services/service-host/scheduler/linux.d.ts +27 -0
  117. package/dist/services/service-host/scheduler/linux.d.ts.map +1 -0
  118. package/dist/services/service-host/scheduler/linux.js +1010 -0
  119. package/dist/services/service-host/scheduler/linux.js.map +1 -0
  120. package/dist/services/service-host/scheduler/macos.d.ts +13 -0
  121. package/dist/services/service-host/scheduler/macos.d.ts.map +1 -0
  122. package/dist/services/service-host/scheduler/macos.js +819 -0
  123. package/dist/services/service-host/scheduler/macos.js.map +1 -0
  124. package/dist/services/service-host/scheduler/runtime-io.d.ts +13 -0
  125. package/dist/services/service-host/scheduler/runtime-io.d.ts.map +1 -0
  126. package/dist/services/service-host/scheduler/runtime-io.js +141 -0
  127. package/dist/services/service-host/scheduler/runtime-io.js.map +1 -0
  128. package/dist/services/service-host/scheduler/service-status.d.ts +99 -0
  129. package/dist/services/service-host/scheduler/service-status.d.ts.map +1 -0
  130. package/dist/services/service-host/scheduler/service-status.js +202 -0
  131. package/dist/services/service-host/scheduler/service-status.js.map +1 -0
  132. package/dist/services/service-host/scheduler/windows.d.ts +40 -0
  133. package/dist/services/service-host/scheduler/windows.d.ts.map +1 -0
  134. package/dist/services/service-host/scheduler/windows.js +688 -0
  135. package/dist/services/service-host/scheduler/windows.js.map +1 -0
  136. package/dist/services/service-host/shadow-progress-store.d.ts +43 -0
  137. package/dist/services/service-host/shadow-progress-store.d.ts.map +1 -0
  138. package/dist/services/service-host/shadow-progress-store.js +156 -0
  139. package/dist/services/service-host/shadow-progress-store.js.map +1 -0
  140. package/dist/services/service-host/shadow-run.d.ts +87 -0
  141. package/dist/services/service-host/shadow-run.d.ts.map +1 -0
  142. package/dist/services/service-host/shadow-run.js +549 -0
  143. package/dist/services/service-host/shadow-run.js.map +1 -0
  144. package/dist/services/service-host/status/service-run-status.d.ts +227 -0
  145. package/dist/services/service-host/status/service-run-status.d.ts.map +1 -0
  146. package/dist/services/service-host/status/service-run-status.js +187 -0
  147. package/dist/services/service-host/status/service-run-status.js.map +1 -0
  148. package/dist/services/service-host/worker-adapter-codex.d.ts +2 -0
  149. package/dist/services/service-host/worker-adapter-codex.d.ts.map +1 -0
  150. package/dist/services/service-host/worker-adapter-codex.js +76 -0
  151. package/dist/services/service-host/worker-adapter-codex.js.map +1 -0
  152. package/dist/services/service-host/worker-adapter-openclaw.d.ts +2 -0
  153. package/dist/services/service-host/worker-adapter-openclaw.d.ts.map +1 -0
  154. package/dist/services/service-host/worker-adapter-openclaw.js +49 -0
  155. package/dist/services/service-host/worker-adapter-openclaw.js.map +1 -0
  156. package/dist/services/service-host/worker-adapter-workbuddy.d.ts +2 -0
  157. package/dist/services/service-host/worker-adapter-workbuddy.d.ts.map +1 -0
  158. package/dist/services/service-host/worker-adapter-workbuddy.js +36 -0
  159. package/dist/services/service-host/worker-adapter-workbuddy.js.map +1 -0
  160. package/dist/services/service-host/worker-adapter.d.ts +187 -0
  161. package/dist/services/service-host/worker-adapter.d.ts.map +1 -0
  162. package/dist/services/service-host/worker-adapter.js +609 -0
  163. package/dist/services/service-host/worker-adapter.js.map +1 -0
  164. package/dist/services/service-host/worker-env.d.ts +84 -0
  165. package/dist/services/service-host/worker-env.d.ts.map +1 -0
  166. package/dist/services/service-host/worker-env.js +195 -0
  167. package/dist/services/service-host/worker-env.js.map +1 -0
  168. package/dist/services/service-host/worker-process.d.ts +75 -0
  169. package/dist/services/service-host/worker-process.d.ts.map +1 -0
  170. package/dist/services/service-host/worker-process.js +225 -0
  171. package/dist/services/service-host/worker-process.js.map +1 -0
  172. package/dist/services/service-host/workspace-discovery.d.ts +71 -0
  173. package/dist/services/service-host/workspace-discovery.d.ts.map +1 -0
  174. package/dist/services/service-host/workspace-discovery.js +288 -0
  175. package/dist/services/service-host/workspace-discovery.js.map +1 -0
  176. package/dist/services/service-host/workspace-dispatch.d.ts +61 -0
  177. package/dist/services/service-host/workspace-dispatch.d.ts.map +1 -0
  178. package/dist/services/service-host/workspace-dispatch.js +105 -0
  179. package/dist/services/service-host/workspace-dispatch.js.map +1 -0
  180. package/dist/services/service-host/workspace-handover.d.ts +190 -0
  181. package/dist/services/service-host/workspace-handover.d.ts.map +1 -0
  182. package/dist/services/service-host/workspace-handover.js +1393 -0
  183. package/dist/services/service-host/workspace-handover.js.map +1 -0
  184. package/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
  185. package/dist/services/synthetic-baseline-runner.js +4 -0
  186. package/dist/services/synthetic-baseline-runner.js.map +1 -1
  187. package/package.json +10 -9
@@ -0,0 +1,227 @@
1
+ import type { InstallIdentity } from '../install-identity.js';
2
+ import type { WorkspaceDiscoveryResult } from '../workspace-discovery.js';
3
+ import type { AdapterCycleResult, ShadowHostKind, WorkerHostKind } from '../worker-adapter.js';
4
+ export declare const SERVICE_RUN_STATUS_SCHEMA_VERSION = "pd.service-run-status.v1";
5
+ /**
6
+ * How this run was triggered (task §4): `manual` = a human at the CLI;
7
+ * `scheduler` = the OS-level registration invoked the managed entry. The
8
+ * two OS trigger flavours (login vs periodic) are deliberately NOT
9
+ * distinguished — no platform reports that reliably, so PD never fabricates
10
+ * a finer source than it can prove.
11
+ */
12
+ export type ServiceRunTriggerSource = 'manual' | 'scheduler';
13
+ /** Top-level run outcome (distinct from per-workspace verdicts). */
14
+ export type ServiceRunOutcome = 'completed' | 'already_running' | 'refused' | 'failed';
15
+ /**
16
+ * The five task-required read verdicts (missing / read_failed / unparsable /
17
+ * not_an_object / invalid) plus `ok`. Only `ok` marks a conforming record —
18
+ * `readable` alone NEVER does (P1-3).
19
+ */
20
+ export type ActiveReleaseVerdict = 'ok' | 'missing' | 'read_failed' | 'unparsable' | 'not_an_object' | 'invalid';
21
+ export interface ActiveReleaseFacts {
22
+ /** The record file exists. */
23
+ readonly present: boolean;
24
+ /** The record parsed into a JSON object (diagnostic only). */
25
+ readonly readable: boolean;
26
+ /** The record conforms to the authoritative schema — the ONLY validity bit. */
27
+ readonly valid: boolean;
28
+ readonly verdict: ActiveReleaseVerdict;
29
+ /** Bounded release identity when valid (never a credential). */
30
+ readonly releaseId?: string;
31
+ readonly productVersion?: string;
32
+ readonly generation?: number;
33
+ /** Structured reason when not valid (rc-9). */
34
+ readonly reason?: string;
35
+ }
36
+ /**
37
+ * Per-host root report (P1-2): where the coordinator looked for each host's
38
+ * claims, whether the root came from an env override, and whether it could
39
+ * actually be read. A root that cannot be read is NEVER silently folded
40
+ * into "no workspaces" — it is reported.
41
+ */
42
+ export interface HostRootReport {
43
+ readonly host: 'openclaw' | 'codex' | 'workbuddy';
44
+ readonly root: string;
45
+ readonly source: 'default' | 'env';
46
+ readonly status: 'readable' | 'missing' | 'not_directory' | 'unreadable';
47
+ }
48
+ export interface ServiceRunStatus {
49
+ readonly schemaVersion: typeof SERVICE_RUN_STATUS_SCHEMA_VERSION;
50
+ readonly runId: string;
51
+ readonly outcome: ServiceRunOutcome;
52
+ readonly dryRun: boolean;
53
+ readonly triggerSource: ServiceRunTriggerSource;
54
+ readonly startedAt: string;
55
+ readonly completedAt: string;
56
+ readonly durationMs: number;
57
+ readonly installation: {
58
+ readonly pdHome: string;
59
+ readonly homeDir: string;
60
+ readonly homeSource: InstallIdentity['homeSource'];
61
+ readonly mode: InstallIdentity['mode'];
62
+ readonly activeRelease: ActiveReleaseFacts;
63
+ };
64
+ readonly environmentIsolation: {
65
+ /** PD_EXPERIMENT_ROOT was inherited and stripped before identity resolution. */
66
+ readonly pdExperimentRootStripped: boolean;
67
+ /** HOME/USERPROFILE present in the inherited env but ignored for identity. */
68
+ readonly ignoredIdentityEnvVars: readonly string[];
69
+ /** Host-root overrides present in the inherited env (steered discovery when honored). */
70
+ readonly inheritedHostRootEnvVars: readonly string[];
71
+ /**
72
+ * Host-root overrides present in the inherited env but NOT honored
73
+ * (shadow runs resolve host roots from the trusted home only — F1
74
+ * review fix). Empty in dry-run mode, where overrides are honored.
75
+ */
76
+ readonly ignoredHostRootEnvVars?: readonly string[];
77
+ };
78
+ readonly manifest: {
79
+ /** ok | missing | read_failed | unparsable | invalid | version_mismatch */
80
+ readonly verdict: 'ok' | 'missing' | 'read_failed' | 'unparsable' | 'invalid' | 'version_mismatch';
81
+ readonly reason?: string;
82
+ readonly hosts: readonly string[];
83
+ readonly unknownHosts: readonly string[];
84
+ readonly workspacesCount: number;
85
+ };
86
+ readonly discovery: {
87
+ readonly discoveredTotal: number;
88
+ readonly counts: WorkspaceDiscoveryResult['counts'];
89
+ /** Every host root consulted this run (P1-2 evidence; never silent). */
90
+ readonly hostRoots: readonly HostRootReport[];
91
+ /**
92
+ * True when at least one consulted host root exists but could not be
93
+ * LISTED (status `unreadable` / `not_directory`, P2-1): the workspace
94
+ * list below may be missing entries, so a zero/low count is never the
95
+ * same fact as a finished discovery.
96
+ */
97
+ readonly incomplete: boolean;
98
+ };
99
+ readonly workspaces: WorkspaceDiscoveryResult['workspaces'];
100
+ /**
101
+ * Phase 2 shadow section (optional, additive — v1 schema evolution):
102
+ * present only for shadow runs. `dryRun: false` on the same status
103
+ * document distinguishes the two modes. Carries per-workspace execution
104
+ * records ONLY — never Pain content, task payloads, or environment
105
+ * values (security contract above; worker environment reports carry
106
+ * variable NAMES, not values).
107
+ */
108
+ readonly shadow?: ShadowRunStatusSection;
109
+ /**
110
+ * Phase 3 managed section (optional, additive — v1 schema evolution):
111
+ * present only for managed runs (`pd service run-once --json`, the
112
+ * scheduler entry). Carries per-workspace admission/executions for
113
+ * `effectiveOwner=service_host` workspaces ONLY — the same security
114
+ * contract as the shadow section applies (no payloads, no env values).
115
+ */
116
+ readonly managed?: ManagedRunStatusSection;
117
+ readonly nextAction: string;
118
+ }
119
+ /** Persisted per-execution record inside the shadow section (task §10). */
120
+ export interface ShadowExecutionRecord {
121
+ /** The operator's requested --workspace argument (evidence, lexical form). */
122
+ readonly requestedDir: string;
123
+ /** Matched canonical discovery dir, or null when no authorized entry matched. */
124
+ readonly canonicalDir: string | null;
125
+ readonly hostKind: ShadowHostKind | null;
126
+ readonly admission: 'admitted' | 'refused';
127
+ readonly refusalReason?: string;
128
+ readonly refusalNextAction?: string;
129
+ /** §8.3/§10 workspace state — `process_started`/`cycle_completed`/business_progress stay strictly distinct in `execution`. */
130
+ readonly workspaceState: 'completed' | 'paused' | 'degraded' | 'failed' | 'unavailable';
131
+ /** Final carried-forward progress timestamp (this cycle or previous run; task §6). */
132
+ readonly lastProgressAt: string | null;
133
+ readonly lastProgressSource: 'task_state_change' | 'cycle_evidence' | 'previous_run' | null;
134
+ /** Full adapter contract result (subset-persisted fields only, no env values). */
135
+ readonly execution?: AdapterCycleResult;
136
+ }
137
+ export interface ShadowRunStatusSection {
138
+ readonly requestedWorkspaces: readonly string[];
139
+ readonly hostFilter?: ShadowHostKind;
140
+ readonly perWorkspaceTimeoutMs: number;
141
+ /**
142
+ * Health of the cross-run progress projection read at run start (F6):
143
+ * `missing` = no store yet; `corrupt`/`unreadable` degrade to "no previous
144
+ * progress" observably instead of silently.
145
+ */
146
+ readonly progressCarryVerdict: 'ok' | 'missing' | 'corrupt' | 'unreadable';
147
+ readonly executions: readonly ShadowExecutionRecord[];
148
+ }
149
+ /**
150
+ * Phase 3 managed-run per-workspace record (task §4 admission matrix). A
151
+ * workspace is either executed (service_host_owned + authorized + bound
152
+ * adapter) or skipped with a structured reason — legacy workspaces keep
153
+ * their legacy owner, transition states are never consumed.
154
+ *
155
+ * PRI-1282 Phase 4 (additive, still v1): `hostKind` widens to include
156
+ * `openclaw` — a managed execution may now be driven by the OpenClaw worker
157
+ * adapter after the workspace's §8.4 handover. Shadow records stay on the
158
+ * narrow codex|workbuddy set.
159
+ */
160
+ export interface ManagedExecutionRecord {
161
+ readonly canonicalDir: string;
162
+ readonly hostKind: WorkerHostKind | null;
163
+ /** `executed` = a real Worker cycle ran for this workspace. */
164
+ readonly admission: 'executed' | 'skipped';
165
+ /** Structured skip reason (skipped records only): owner state, authorization, adapter or budget. */
166
+ readonly skipReason?: string;
167
+ readonly skipNextAction?: string;
168
+ readonly workspaceState: 'completed' | 'paused' | 'degraded' | 'failed' | 'unavailable';
169
+ readonly lastProgressAt: string | null;
170
+ readonly lastProgressSource: 'task_state_change' | 'cycle_evidence' | 'previous_run' | null;
171
+ readonly execution?: AdapterCycleResult;
172
+ }
173
+ export interface ManagedRunStatusSection {
174
+ readonly triggerSource: ServiceRunTriggerSource;
175
+ readonly perWorkspaceTimeoutMs: number;
176
+ readonly progressCarryVerdict: 'ok' | 'missing' | 'corrupt' | 'unreadable';
177
+ /**
178
+ * Set when NO workspace was in the service_host_owned state this run —
179
+ * the legal empty execution (task §4): no Worker started, nothing failed.
180
+ */
181
+ readonly emptyReason?: 'no_service_host_owned_workspaces';
182
+ readonly executions: readonly ManagedExecutionRecord[];
183
+ }
184
+ export declare function serviceRunStatusPath(pdHome: string): string;
185
+ export type ServiceRunStatusRead = {
186
+ readonly ok: true;
187
+ readonly status: ServiceRunStatus;
188
+ } | {
189
+ readonly ok: false;
190
+ readonly verdict: 'missing' | 'unreadable' | 'corrupt';
191
+ readonly detail?: string;
192
+ };
193
+ /**
194
+ * Read the latest persisted run-once status (Phase 3 `pd service status`).
195
+ * The file is UNTRUSTED runtime data (rc-1): missing / unreadable /
196
+ * unparsable / non-conforming stay distinct (rc-3) — a corrupt status file
197
+ * is `corrupt`, never "no run ever happened".
198
+ */
199
+ export declare function readServiceRunStatus(pdHome: string): ServiceRunStatusRead;
200
+ /**
201
+ * Read the active release record (`<pdHome>/active.json`) against the ONE
202
+ * authoritative schema in `@principles/install-layout` (P1-3): a record is
203
+ * `valid` only when it is the record the installer's commit point writes —
204
+ * schemaVersion 1, non-empty releaseId, positive-safe-integer generation,
205
+ * 64-hex digest, transactionId, productVersion (+ strict optional
206
+ * sourceCommit). Missing vs unreadable vs malformed JSON vs non-object vs
207
+ * schema-nonconforming stay distinct (rc-3/rc-9); a record that parses but
208
+ * fails schema is reported as `invalid`, NEVER as a healthy release.
209
+ */
210
+ export declare function readActiveReleaseFacts(activeRecordPath: string): ActiveReleaseFacts;
211
+ /**
212
+ * Persist the status atomically (temp file in the same directory + rename).
213
+ * A failed write is LOUD (rc-9): the returned result distinguishes an
214
+ * unwritable directory from a rename failure instead of silently dropping
215
+ * the record. The rename overwrite semantics rely on Node's fs.renameSync
216
+ * POSIX behavior; on Windows a pre-existing destination is replaced (the
217
+ * established repo-wide atomic-write pattern, e.g. worker liveness files).
218
+ */
219
+ export declare function writeServiceRunStatus(pdHome: string, status: ServiceRunStatus): {
220
+ ok: true;
221
+ path: string;
222
+ } | {
223
+ ok: false;
224
+ reason: string;
225
+ nextAction: string;
226
+ };
227
+ //# sourceMappingURL=service-run-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-run-status.d.ts","sourceRoot":"","sources":["../../../../src/services/service-host/status/service-run-status.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE/F,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE7D,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GACzB,WAAW,GACX,iBAAiB,GACjB,SAAS,GACT,QAAQ,CAAC;AAEb;;;;GAIG;AACH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E,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7G;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CA6BzE;AA8CD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,kBAAkB,CAqBnF;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,gBAAgB,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CA+BhF"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Versioned operational status (SPEC-PD-SERVICE-HOST-001 §9, TD §7.1).
3
+ *
4
+ * ONE small versioned file per install — `<pdHome>/service/run-once-status.json`
5
+ * — answering: when did run-once last execute, which install identity ran it,
6
+ * what was discovered, what is each Workspace's owner state, what failed and
7
+ * why, and what should happen next. Latest-run semantics (the file is
8
+ * replaced atomically by each run), because the OS-scheduler and operator
9
+ * question is "what happened LAST", not "list every historical run" (SPEC
10
+ * §9: 运行状态优先复用现有 read model;安装级文件只记录调度元数据).
11
+ *
12
+ * Security contract (task §六): the status carries run/discovery METADATA
13
+ * only — verdicts, reasons, workspace DIR PATHS (needed for the operator's
14
+ * workspace-level judgment) and owner state. NEVER pain content, task
15
+ * payload, conversation/trajectory data, credentials, or arbitrary file
16
+ * contents. Reason strings are bounded and control-character-sanitized
17
+ * (rc-8); nothing here is user/agent free text.
18
+ *
19
+ * This module owns the ONLY write in the coordinator: a temp-file + rename
20
+ * atomic replace onto the PD-owned `<pdHome>/service/` directory — never the
21
+ * canonical runtime tree, never `install.json`, never any Workspace's
22
+ * business data (`.pd/state.db` etc.).
23
+ */
24
+ import * as fs from 'node:fs';
25
+ import * as path from 'node:path';
26
+ import { randomUUID } from 'node:crypto';
27
+ import { readActiveReleaseRecord } from '@principles/install-layout';
28
+ export const SERVICE_RUN_STATUS_SCHEMA_VERSION = 'pd.service-run-status.v1';
29
+ const STATUS_DIR_NAME = 'service';
30
+ const STATUS_FILE_NAME = 'run-once-status.json';
31
+ export function serviceRunStatusPath(pdHome) {
32
+ return path.join(pdHome, STATUS_DIR_NAME, STATUS_FILE_NAME);
33
+ }
34
+ /**
35
+ * Read the latest persisted run-once status (Phase 3 `pd service status`).
36
+ * The file is UNTRUSTED runtime data (rc-1): missing / unreadable /
37
+ * unparsable / non-conforming stay distinct (rc-3) — a corrupt status file
38
+ * is `corrupt`, never "no run ever happened".
39
+ */
40
+ export function readServiceRunStatus(pdHome) {
41
+ const file = serviceRunStatusPath(pdHome);
42
+ let raw;
43
+ try {
44
+ raw = fs.readFileSync(file, 'utf8');
45
+ }
46
+ catch (error) {
47
+ const { code } = error;
48
+ if (code === 'ENOENT')
49
+ return { ok: false, verdict: 'missing' };
50
+ return { ok: false, verdict: 'unreadable', detail: code ?? 'read_failed' };
51
+ }
52
+ let parsed;
53
+ try {
54
+ parsed = JSON.parse(raw);
55
+ }
56
+ catch (error) {
57
+ return { ok: false, verdict: 'corrupt', detail: error instanceof Error ? error.message.slice(0, 120) : 'unparsable' };
58
+ }
59
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
60
+ return { ok: false, verdict: 'corrupt', detail: 'not_an_object' };
61
+ }
62
+ const doc = parsed;
63
+ if (!Object.hasOwn(doc, 'schemaVersion') || doc.schemaVersion !== SERVICE_RUN_STATUS_SCHEMA_VERSION
64
+ || !Object.hasOwn(doc, 'runId') || typeof doc.runId !== 'string'
65
+ || !Object.hasOwn(doc, 'outcome') || (doc.outcome !== 'completed' && doc.outcome !== 'already_running' && doc.outcome !== 'refused' && doc.outcome !== 'failed')
66
+ || !Object.hasOwn(doc, 'triggerSource') || (doc.triggerSource !== 'manual' && doc.triggerSource !== 'scheduler')) {
67
+ return { ok: false, verdict: 'corrupt', detail: 'schema_mismatch' };
68
+ }
69
+ return { ok: true, status: parsed };
70
+ }
71
+ /** Maximum persisted length of any reason string (rc-8 bounded output). */
72
+ const MAX_REASON = 300;
73
+ /** Re-bound an already-discovery-bounded reason defensively before persisting. */
74
+ function persistableReason(value) {
75
+ if (value === undefined)
76
+ return undefined;
77
+ const clean = value.replace(/[^\x20-\x7E]+/g, ' ');
78
+ return clean.length > MAX_REASON ? `${clean.slice(0, MAX_REASON - 1)}…` : clean;
79
+ }
80
+ /** Map a shared-authority failure reason to the status's stable reason code. */
81
+ function activeReleaseReasonCode(reason) {
82
+ switch (reason) {
83
+ case 'active_record_absent':
84
+ return 'active_release_missing';
85
+ case 'active_record_read_failed':
86
+ return 'active_release_read_failed';
87
+ case 'active_record_json_invalid':
88
+ return 'active_release_unparsable';
89
+ case 'active_record_not_object':
90
+ return 'active_release_not_an_object';
91
+ default:
92
+ // Every schema-level failure keeps its field name so an operator can
93
+ // tell WHICH field failed, e.g. `active_release_invalid:generation`.
94
+ return `active_release_invalid:${reason.replace(/^active_record_/, '').replace(/_invalid$/, '')}`;
95
+ }
96
+ }
97
+ /** Map a shared-authority failure reason to the run's read verdict. */
98
+ function activeReleaseVerdictFor(reason) {
99
+ switch (reason) {
100
+ case 'active_record_absent':
101
+ return 'missing';
102
+ case 'active_record_read_failed':
103
+ return 'read_failed';
104
+ case 'active_record_json_invalid':
105
+ return 'unparsable';
106
+ case 'active_record_not_object':
107
+ return 'not_an_object';
108
+ default:
109
+ return 'invalid';
110
+ }
111
+ }
112
+ /**
113
+ * Read the active release record (`<pdHome>/active.json`) against the ONE
114
+ * authoritative schema in `@principles/install-layout` (P1-3): a record is
115
+ * `valid` only when it is the record the installer's commit point writes —
116
+ * schemaVersion 1, non-empty releaseId, positive-safe-integer generation,
117
+ * 64-hex digest, transactionId, productVersion (+ strict optional
118
+ * sourceCommit). Missing vs unreadable vs malformed JSON vs non-object vs
119
+ * schema-nonconforming stay distinct (rc-3/rc-9); a record that parses but
120
+ * fails schema is reported as `invalid`, NEVER as a healthy release.
121
+ */
122
+ export function readActiveReleaseFacts(activeRecordPath) {
123
+ const verdict = readActiveReleaseRecord(activeRecordPath);
124
+ if (verdict.ok) {
125
+ const { record } = verdict;
126
+ return {
127
+ present: true,
128
+ readable: true,
129
+ valid: true,
130
+ verdict: 'ok',
131
+ releaseId: record.releaseId.slice(0, 120),
132
+ productVersion: record.productVersion.slice(0, 40),
133
+ generation: record.generation,
134
+ };
135
+ }
136
+ return {
137
+ present: verdict.reason !== 'active_record_absent',
138
+ readable: false,
139
+ valid: false,
140
+ verdict: activeReleaseVerdictFor(verdict.reason),
141
+ reason: `${activeReleaseReasonCode(verdict.reason)} — ${persistableReason(verdict.detail) ?? 'invalid record'}`,
142
+ };
143
+ }
144
+ /**
145
+ * Persist the status atomically (temp file in the same directory + rename).
146
+ * A failed write is LOUD (rc-9): the returned result distinguishes an
147
+ * unwritable directory from a rename failure instead of silently dropping
148
+ * the record. The rename overwrite semantics rely on Node's fs.renameSync
149
+ * POSIX behavior; on Windows a pre-existing destination is replaced (the
150
+ * established repo-wide atomic-write pattern, e.g. worker liveness files).
151
+ */
152
+ export function writeServiceRunStatus(pdHome, status) {
153
+ const dir = path.join(pdHome, STATUS_DIR_NAME);
154
+ const target = path.join(dir, STATUS_FILE_NAME);
155
+ try {
156
+ fs.mkdirSync(dir, { recursive: true });
157
+ }
158
+ catch (error) {
159
+ const message = error instanceof Error ? error.message : String(error);
160
+ return {
161
+ ok: false,
162
+ reason: `service_status_dir_unwritable:${persistableReason(message) ?? 'unknown'}`,
163
+ nextAction: `Check the permissions of ${dir} and retry.`,
164
+ };
165
+ }
166
+ const temp = path.join(dir, `.run-once-status.${randomUUID().replace(/-/g, '').slice(0, 12)}.tmp`);
167
+ try {
168
+ fs.writeFileSync(temp, `${JSON.stringify(status, null, 2)}\n`, 'utf8');
169
+ fs.renameSync(temp, target);
170
+ return { ok: true, path: target };
171
+ }
172
+ catch (error) {
173
+ try {
174
+ fs.rmSync(temp, { force: true });
175
+ }
176
+ catch {
177
+ // best effort cleanup of our own temp file
178
+ }
179
+ const message = error instanceof Error ? error.message : String(error);
180
+ return {
181
+ ok: false,
182
+ reason: `service_status_write_failed:${persistableReason(message) ?? 'unknown'}`,
183
+ nextAction: 'Fix the reported filesystem problem and re-run; a partial status file is never left behind.',
184
+ };
185
+ }
186
+ }
187
+ //# sourceMappingURL=service-run-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-run-status.js","sourceRoot":"","sources":["../../../../src/services/service-host/status/service-run-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAmC,MAAM,4BAA4B,CAAC;AAKtG,MAAM,CAAC,MAAM,iCAAiC,GAAG,0BAA0B,CAAC;AAyM5E,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEhD,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAC9D,CAAC;AAMD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAA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AAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC;YACH,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,2CAA2C;QAC7C,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,+BAA+B,iBAAiB,CAAC,OAAO,CAAC,IAAI,SAAS,EAAE;YAChF,UAAU,EAAE,6FAA6F;SAC1G,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function createCodexWorkerAdapter(): import("./worker-adapter.js").WorkerAdapter;
2
+ //# sourceMappingURL=worker-adapter-codex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-adapter-codex.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/worker-adapter-codex.ts"],"names":[],"mappings":"AAoDA,wBAAgB,wBAAwB,gDAuBvC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Codex Worker Adapter (SPEC §11 Phase 2, task §4).
3
+ *
4
+ * Wraps the EXISTING bounded Codex cycle — `pd codex worker --once --json
5
+ * --workspace <dir>` — behind the unified Worker Adapter contract. The
6
+ * adapter only invokes and normalizes; every business behavior (catch-up,
7
+ * reconciliation, Diagnostician lease/runner, post-processing continuation,
8
+ * downstream consumer cycle, Stage-2, retention) stays in the Codex worker
9
+ * and the shared execution layer. Liveness facts come from the existing
10
+ * `.state/codex-worker-liveness.json` (written by the worker cycle itself),
11
+ * preserving the Companion's stall attribution contract untouched.
12
+ */
13
+ import { readCodexWorkerLiveness } from '@principles/codex-adapter';
14
+ import { createOnceCliWorkerAdapter, readReportCount, readReportEvidence, readReportSection, } from './worker-adapter.js';
15
+ function isPlainRecordLoose(value) {
16
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
17
+ }
18
+ /**
19
+ * Sum the persisted-row counts of a parsed Codex catch-up report (F5):
20
+ * `report.catchUp.rollouts[] → outcome{status:'ok', inserted, enriched}`.
21
+ * R4 review fix: BOTH counters are persisted progress — `enriched` is a
22
+ * successful replay that completed an EXISTING trajectory with no new row
23
+ * (a session whose live trail only needed transcript catch-up evidence).
24
+ * `duplicates` stays excluded: re-ingesting already-persisted rows is no
25
+ * progress. Non-'ok' outcomes (degraded/skipped) and absent/malformed
26
+ * fields count 0.
27
+ */
28
+ function countCodexCatchUpPersisted(parsed) {
29
+ const catchUp = readReportSection(parsed, 'catchUp');
30
+ if (catchUp === null)
31
+ return 0;
32
+ const { rollouts } = catchUp;
33
+ if (!Array.isArray(rollouts))
34
+ return 0;
35
+ let persisted = 0;
36
+ for (const rollout of rollouts) {
37
+ if (!isPlainRecordLoose(rollout))
38
+ continue;
39
+ const { outcome } = rollout;
40
+ if (!isPlainRecordLoose(outcome))
41
+ continue;
42
+ if (outcome.status !== 'ok')
43
+ continue;
44
+ const { inserted, enriched } = outcome;
45
+ if (typeof inserted === 'number' && Number.isFinite(inserted) && inserted > 0)
46
+ persisted += inserted;
47
+ if (typeof enriched === 'number' && Number.isFinite(enriched) && enriched > 0)
48
+ persisted += enriched;
49
+ }
50
+ return persisted;
51
+ }
52
+ export function createCodexWorkerAdapter() {
53
+ return createOnceCliWorkerAdapter({
54
+ hostKind: 'codex',
55
+ livenessFileName: 'codex-worker-liveness.json',
56
+ readLiveness: readCodexWorkerLiveness,
57
+ extractCycleEvidence(parsed) {
58
+ const base = readReportEvidence(parsed);
59
+ return {
60
+ ...base,
61
+ // Codex post-processing continuation: resumed task ids are actual
62
+ // resumed work (guarded array-length read).
63
+ postProcessingResumed: readReportCount(parsed, 'postProcessing', 'resumedTaskIds'),
64
+ // F5 review fix: a Codex catch-up rollout entry records a CHECKED
65
+ // session, not a write — re-examining an already-synced session
66
+ // still yields an entry (replay outcome `{status:'ok', inserted:0}`).
67
+ // R4 review fix: `enriched` (existing trajectory completed from the
68
+ // transcript) is real persisted progress alongside `inserted`;
69
+ // duplicate-only results stay excluded. Everything else is guarded
70
+ // as zero (rc-4: element-level validation on the parsed array).
71
+ catchUpProcessed: countCodexCatchUpPersisted(parsed),
72
+ };
73
+ },
74
+ });
75
+ }
76
+ //# sourceMappingURL=worker-adapter-codex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-adapter-codex.js","sourceRoot":"","sources":["../../../src/services/service-host/worker-adapter-codex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,0BAA0B,CAAC,MAA+B;IACjE,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,CAAC;IACvC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAAE,SA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.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-adapter-openclaw.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/worker-adapter-openclaw.ts"],"names":[],"mappings":"AAiCA,wBAAgB,2BAA2B,gDAmB1C"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * OpenClaw Worker Adapter (SPEC-PD-SERVICE-HOST-001 §11 Phase 4, PRI-1282).
3
+ *
4
+ * Wraps the bounded OpenClaw worker cycle — `pd openclaw worker --once --json
5
+ * --workspace <dir>` — behind the unified Worker Adapter contract. The
6
+ * adapter only invokes and normalizes; every business behavior (ownership
7
+ * gate, declaration refresh, diagnostician, downstream consumer cycle,
8
+ * liveness) stays in the OpenClaw worker (the `principles-disciple` package
9
+ * that also ships the Gateway plugin). MANAGED dispatch only — Phase 2
10
+ * shadow keeps the codex|workbuddy host set (instruction §8.5: adding
11
+ * openclaw to the global list would let shadow-run execute OpenClaw).
12
+ */
13
+ import * as fs from 'node:fs';
14
+ import * as path from 'node:path';
15
+ import { createOnceCliWorkerAdapter, readReportEvidence, } from './worker-adapter.js';
16
+ function isJsonObject(value) {
17
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
18
+ }
19
+ function readOpenClawLivenessFile(workspaceDir) {
20
+ try {
21
+ const file = path.join(path.resolve(workspaceDir), '.state', 'openclaw-worker-liveness.json');
22
+ const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
23
+ return isJsonObject(parsed) ? parsed : null;
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ }
29
+ export function createOpenClawWorkerAdapter() {
30
+ return createOnceCliWorkerAdapter({
31
+ hostKind: 'openclaw',
32
+ livenessFileName: 'openclaw-worker-liveness.json',
33
+ // The OpenClaw worker (plugin package) owns the writer; the adapter reads
34
+ // the same per-workspace liveness file the codex / workbuddy adapters do.
35
+ readLiveness: readOpenClawLivenessFile,
36
+ extractCycleEvidence(parsed) {
37
+ const base = readReportEvidence(parsed);
38
+ // The OpenClaw report has no catch-up / post-processing continuations —
39
+ // evidence is diagnostician + downstream only, exactly what the shared
40
+ // reader extracts.
41
+ return {
42
+ ...base,
43
+ postProcessingResumed: 0,
44
+ catchUpProcessed: 0,
45
+ };
46
+ },
47
+ });
48
+ }
49
+ //# sourceMappingURL=worker-adapter-openclaw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-adapter-openclaw.js","sourceRoot":"","sources":["../../../src/services/service-host/worker-adapter-openclaw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,wBAAwB,CAAC,YAAoB;IACpD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,+BAA+B,CAAC,CAAC;QAC9F,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAClE,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO,0BAA0B,CAAC;QAChC,QAAQ,EAAE,UAAU;QACpB,gBAAgB,EAAE,+BAA+B;QACjD,0EAA0E;QAC1E,0EAA0E;QAC1E,YAAY,EAAE,wBAAwB;QACtC,oBAAoB,CAAC,MAAM;YACzB,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACxC,wEAAwE;YACxE,uEAAuE;YACvE,mBAAmB;YACnB,OAAO;gBACL,GAAG,IAAI;gBACP,qBAAqB,EAAE,CAAC;gBACxB,gBAAgB,EAAE,CAAC;aACpB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function createWorkbuddyWorkerAdapter(): import("./worker-adapter.js").WorkerAdapter;
2
+ //# sourceMappingURL=worker-adapter-workbuddy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-adapter-workbuddy.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/worker-adapter-workbuddy.ts"],"names":[],"mappings":"AAyBA,wBAAgB,4BAA4B,gDAc3C"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * WorkBuddy Worker Adapter (SPEC §11 Phase 2, task §5).
3
+ *
4
+ * Wraps the EXISTING bounded WorkBuddy cycle — `pd workbuddy worker --once
5
+ * --json --workspace <dir>` — behind the unified Worker Adapter contract.
6
+ * The adapter only invokes and normalizes; catch-up, reconciliation, the
7
+ * local candidate pick, the downstream consumer cycle and Stage-2 stay in
8
+ * the WorkBuddy worker. Cycle-level liveness now exists as
9
+ * `.state/workbuddy-worker-liveness.json` (shipped with this change — before
10
+ * it, WorkBuddy had NO liveness record and FR-10 was undecidable).
11
+ *
12
+ * Known, RECORDED parity gap (task §5 / TD §2.3, not fixed here): the
13
+ * WorkBuddy worker picks candidates with a local pending-first selector —
14
+ * retry_wait tasks can starve under sustained pending pressure. This does
15
+ * not block the Phase 2 minimal hookup, but Codex/WorkBuddy parity is NOT
16
+ * complete until the fair-share selector is adopted (follow-up recorded on
17
+ * PRI-1280).
18
+ */
19
+ import { readWorkbuddyWorkerLiveness } from '@principles/workbuddy-adapter';
20
+ import { createOnceCliWorkerAdapter, readReportCount, readReportEvidence, } from './worker-adapter.js';
21
+ export function createWorkbuddyWorkerAdapter() {
22
+ return createOnceCliWorkerAdapter({
23
+ hostKind: 'workbuddy',
24
+ livenessFileName: 'workbuddy-worker-liveness.json',
25
+ readLiveness: readWorkbuddyWorkerLiveness,
26
+ extractCycleEvidence(parsed) {
27
+ const base = readReportEvidence(parsed);
28
+ return {
29
+ ...base,
30
+ postProcessingResumed: 0, // WorkBuddy has no post-processing continuation step (asymmetry §3.1)
31
+ catchUpProcessed: readReportCount(parsed, 'catchUp', 'ingested'),
32
+ };
33
+ },
34
+ });
35
+ }
36
+ //# sourceMappingURL=worker-adapter-workbuddy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-adapter-workbuddy.js","sourceRoot":"","sources":["../../../src/services/service-host/worker-adapter-workbuddy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,4BAA4B;IAC1C,OAAO,0BAA0B,CAAC;QAChC,QAAQ,EAAE,WAAW;QACrB,gBAAgB,EAAE,gCAAgC;QAClD,YAAY,EAAE,2BAA2B;QACzC,oBAAoB,CAAC,MAAM;YACzB,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACxC,OAAO;gBACL,GAAG,IAAI;gBACP,qBAAqB,EAAE,CAAC,EAAE,sEAAsE;gBAChG,gBAAgB,EAAE,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC;aACjE,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}