@senpi-ai/runtime 3.0.178 → 3.0.188

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 (212) hide show
  1. package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
  2. package/dist/actions/close-position/close-position.action.js +6 -1
  3. package/dist/actions/close-position/close-position.action.js.map +1 -1
  4. package/dist/actions/llm-decision/openclaw-llm-decision.d.ts +8 -0
  5. package/dist/actions/llm-decision/openclaw-llm-decision.d.ts.map +1 -1
  6. package/dist/actions/llm-decision/openclaw-llm-decision.js +56 -1
  7. package/dist/actions/llm-decision/openclaw-llm-decision.js.map +1 -1
  8. package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
  9. package/dist/actions/position-tracker/position-tracker.action.js +1 -0
  10. package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
  11. package/dist/approvals/approval-store.d.ts +37 -7
  12. package/dist/approvals/approval-store.d.ts.map +1 -1
  13. package/dist/approvals/approval-store.js +127 -23
  14. package/dist/approvals/approval-store.js.map +1 -1
  15. package/dist/approvals/telemetry.d.ts +28 -3
  16. package/dist/approvals/telemetry.d.ts.map +1 -1
  17. package/dist/approvals/telemetry.js +8 -4
  18. package/dist/approvals/telemetry.js.map +1 -1
  19. package/dist/approvals/tool-approval-gate.d.ts +85 -0
  20. package/dist/approvals/tool-approval-gate.d.ts.map +1 -1
  21. package/dist/approvals/tool-approval-gate.js +197 -15
  22. package/dist/approvals/tool-approval-gate.js.map +1 -1
  23. package/dist/approvals/turn-context.d.ts +296 -0
  24. package/dist/approvals/turn-context.d.ts.map +1 -0
  25. package/dist/approvals/turn-context.js +594 -0
  26. package/dist/approvals/turn-context.js.map +1 -0
  27. package/dist/cli/guide-commands.d.ts.map +1 -1
  28. package/dist/cli/guide-commands.js +18 -3
  29. package/dist/cli/guide-commands.js.map +1 -1
  30. package/dist/cli/senpi-commands.d.ts.map +1 -1
  31. package/dist/cli/senpi-commands.js +80 -5
  32. package/dist/cli/senpi-commands.js.map +1 -1
  33. package/dist/deploy/job.d.ts +32 -0
  34. package/dist/deploy/job.d.ts.map +1 -1
  35. package/dist/deploy/job.js +72 -7
  36. package/dist/deploy/job.js.map +1 -1
  37. package/dist/deploy/register.d.ts +12 -0
  38. package/dist/deploy/register.d.ts.map +1 -1
  39. package/dist/deploy/register.js +85 -2
  40. package/dist/deploy/register.js.map +1 -1
  41. package/dist/dsl/events/build-closed-event.d.ts +11 -0
  42. package/dist/dsl/events/build-closed-event.d.ts.map +1 -1
  43. package/dist/dsl/events/build-closed-event.js +13 -0
  44. package/dist/dsl/events/build-closed-event.js.map +1 -1
  45. package/dist/dsl/events/handlers.d.ts.map +1 -1
  46. package/dist/dsl/events/handlers.js +9 -5
  47. package/dist/dsl/events/handlers.js.map +1 -1
  48. package/dist/dsl/monitor/dsl-failure-events.d.ts +38 -2
  49. package/dist/dsl/monitor/dsl-failure-events.d.ts.map +1 -1
  50. package/dist/dsl/monitor/dsl-failure-events.js +67 -4
  51. package/dist/dsl/monitor/dsl-failure-events.js.map +1 -1
  52. package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
  53. package/dist/dsl/monitor/process-one-position.js +37 -9
  54. package/dist/dsl/monitor/process-one-position.js.map +1 -1
  55. package/dist/host/openclaw-host.d.ts +138 -0
  56. package/dist/host/openclaw-host.d.ts.map +1 -0
  57. package/dist/host/openclaw-host.js +177 -0
  58. package/dist/host/openclaw-host.js.map +1 -0
  59. package/dist/host/plugin-logger.d.ts +99 -0
  60. package/dist/host/plugin-logger.d.ts.map +1 -0
  61. package/dist/host/plugin-logger.js +142 -0
  62. package/dist/host/plugin-logger.js.map +1 -0
  63. package/dist/index.d.ts +57 -7
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +719 -162
  66. package/dist/index.js.map +1 -1
  67. package/dist/prompt/session-context-seed-hook.d.ts +7 -0
  68. package/dist/prompt/session-context-seed-hook.d.ts.map +1 -1
  69. package/dist/prompt/session-context-seed-hook.js +1 -1
  70. package/dist/prompt/session-context-seed-hook.js.map +1 -1
  71. package/dist/prompt/skill-router-hook.d.ts +24 -0
  72. package/dist/prompt/skill-router-hook.d.ts.map +1 -0
  73. package/dist/prompt/skill-router-hook.js +381 -0
  74. package/dist/prompt/skill-router-hook.js.map +1 -0
  75. package/dist/runtime/auto-update/coordinator.d.ts +220 -0
  76. package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
  77. package/dist/runtime/auto-update/coordinator.js +715 -22
  78. package/dist/runtime/auto-update/coordinator.js.map +1 -1
  79. package/dist/runtime/auto-update/gateway-restart.d.ts +60 -1
  80. package/dist/runtime/auto-update/gateway-restart.d.ts.map +1 -1
  81. package/dist/runtime/auto-update/gateway-restart.js +95 -21
  82. package/dist/runtime/auto-update/gateway-restart.js.map +1 -1
  83. package/dist/runtime/auto-update/idle-gate.d.ts +175 -0
  84. package/dist/runtime/auto-update/idle-gate.d.ts.map +1 -0
  85. package/dist/runtime/auto-update/idle-gate.js +229 -0
  86. package/dist/runtime/auto-update/idle-gate.js.map +1 -0
  87. package/dist/runtime/auto-update/install-results.d.ts +130 -0
  88. package/dist/runtime/auto-update/install-results.d.ts.map +1 -0
  89. package/dist/runtime/auto-update/install-results.js +264 -0
  90. package/dist/runtime/auto-update/install-results.js.map +1 -0
  91. package/dist/runtime/auto-update/money-call-tracker.d.ts +36 -0
  92. package/dist/runtime/auto-update/money-call-tracker.d.ts.map +1 -0
  93. package/dist/runtime/auto-update/money-call-tracker.js +129 -0
  94. package/dist/runtime/auto-update/money-call-tracker.js.map +1 -0
  95. package/dist/runtime/auto-update/register-idle-gate.d.ts +70 -0
  96. package/dist/runtime/auto-update/register-idle-gate.d.ts.map +1 -0
  97. package/dist/runtime/auto-update/register-idle-gate.js +127 -0
  98. package/dist/runtime/auto-update/register-idle-gate.js.map +1 -0
  99. package/dist/runtime/auto-update/run-update-command.d.ts +13 -0
  100. package/dist/runtime/auto-update/run-update-command.d.ts.map +1 -1
  101. package/dist/runtime/auto-update/run-update-command.js +18 -0
  102. package/dist/runtime/auto-update/run-update-command.js.map +1 -1
  103. package/dist/runtime/auto-update/state-store.d.ts +14 -1
  104. package/dist/runtime/auto-update/state-store.d.ts.map +1 -1
  105. package/dist/runtime/auto-update/state-store.js +37 -3
  106. package/dist/runtime/auto-update/state-store.js.map +1 -1
  107. package/dist/runtime/auto-update/types.d.ts +52 -0
  108. package/dist/runtime/auto-update/types.d.ts.map +1 -1
  109. package/dist/runtime/auto-update/types.js.map +1 -1
  110. package/dist/runtime/auto-update/update-marker.d.ts +95 -0
  111. package/dist/runtime/auto-update/update-marker.d.ts.map +1 -0
  112. package/dist/runtime/auto-update/update-marker.js +185 -0
  113. package/dist/runtime/auto-update/update-marker.js.map +1 -0
  114. package/dist/runtime/auto-update/update-schedule.d.ts +67 -0
  115. package/dist/runtime/auto-update/update-schedule.d.ts.map +1 -0
  116. package/dist/runtime/auto-update/update-schedule.js +91 -0
  117. package/dist/runtime/auto-update/update-schedule.js.map +1 -0
  118. package/dist/runtime/decision-errors.d.ts +7 -0
  119. package/dist/runtime/decision-errors.d.ts.map +1 -1
  120. package/dist/runtime/decision-errors.js +15 -0
  121. package/dist/runtime/decision-errors.js.map +1 -1
  122. package/dist/runtime/process-state.d.ts +168 -0
  123. package/dist/runtime/process-state.d.ts.map +1 -0
  124. package/dist/runtime/process-state.js +81 -0
  125. package/dist/runtime/process-state.js.map +1 -0
  126. package/dist/runtime/reconcile-state.d.ts.map +1 -1
  127. package/dist/runtime/reconcile-state.js +21 -4
  128. package/dist/runtime/reconcile-state.js.map +1 -1
  129. package/dist/runtime/strategy-registry.d.ts +16 -0
  130. package/dist/runtime/strategy-registry.d.ts.map +1 -1
  131. package/dist/runtime/strategy-registry.js +7 -3
  132. package/dist/runtime/strategy-registry.js.map +1 -1
  133. package/dist/runtime/update-apply-deps.d.ts +5 -3
  134. package/dist/runtime/update-apply-deps.d.ts.map +1 -1
  135. package/dist/runtime/update-apply-deps.js +15 -3
  136. package/dist/runtime/update-apply-deps.js.map +1 -1
  137. package/dist/senpi/client.d.ts +29 -0
  138. package/dist/senpi/client.d.ts.map +1 -1
  139. package/dist/senpi/client.js +71 -2
  140. package/dist/senpi/client.js.map +1 -1
  141. package/dist/skill-router/catalog.d.ts +30 -0
  142. package/dist/skill-router/catalog.d.ts.map +1 -0
  143. package/dist/skill-router/catalog.js +131 -0
  144. package/dist/skill-router/catalog.js.map +1 -0
  145. package/dist/skill-router/classify-client.d.ts +80 -0
  146. package/dist/skill-router/classify-client.d.ts.map +1 -0
  147. package/dist/skill-router/classify-client.js +283 -0
  148. package/dist/skill-router/classify-client.js.map +1 -0
  149. package/dist/skill-router/prompt.d.ts +36 -0
  150. package/dist/skill-router/prompt.d.ts.map +1 -0
  151. package/dist/skill-router/prompt.js +318 -0
  152. package/dist/skill-router/prompt.js.map +1 -0
  153. package/dist/skill-router/resolve.d.ts +41 -0
  154. package/dist/skill-router/resolve.d.ts.map +1 -0
  155. package/dist/skill-router/resolve.js +43 -0
  156. package/dist/skill-router/resolve.js.map +1 -0
  157. package/dist/skills-manager/version-manager.d.ts +14 -0
  158. package/dist/skills-manager/version-manager.d.ts.map +1 -1
  159. package/dist/skills-manager/version-manager.js +31 -3
  160. package/dist/skills-manager/version-manager.js.map +1 -1
  161. package/dist/strategy/strategy-state.d.ts +11 -3
  162. package/dist/strategy/strategy-state.d.ts.map +1 -1
  163. package/dist/strategy/strategy-state.js +18 -8
  164. package/dist/strategy/strategy-state.js.map +1 -1
  165. package/dist/telemetry/event-builders.d.ts +4 -2
  166. package/dist/telemetry/event-builders.d.ts.map +1 -1
  167. package/dist/telemetry/event-builders.js +4 -2
  168. package/dist/telemetry/event-builders.js.map +1 -1
  169. package/dist/telemetry/metrics.d.ts +15 -1
  170. package/dist/telemetry/metrics.d.ts.map +1 -1
  171. package/dist/telemetry/metrics.js +25 -1
  172. package/dist/telemetry/metrics.js.map +1 -1
  173. package/dist/telemetry/otel-sdk.d.ts +12 -0
  174. package/dist/telemetry/otel-sdk.d.ts.map +1 -1
  175. package/dist/telemetry/otel-sdk.js +47 -1
  176. package/dist/telemetry/otel-sdk.js.map +1 -1
  177. package/dist/telemetry/spans/span-hooks.d.ts +18 -1
  178. package/dist/telemetry/spans/span-hooks.d.ts.map +1 -1
  179. package/dist/telemetry/spans/span-hooks.js +315 -96
  180. package/dist/telemetry/spans/span-hooks.js.map +1 -1
  181. package/dist/telemetry/tool-plane.d.ts +2 -0
  182. package/dist/telemetry/tool-plane.d.ts.map +1 -1
  183. package/dist/telemetry/tool-plane.js +1 -0
  184. package/dist/telemetry/tool-plane.js.map +1 -1
  185. package/dist/test-setup.js +7 -1
  186. package/dist/test-setup.js.map +1 -1
  187. package/dist/tool-surface/crib-cache.d.ts +21 -0
  188. package/dist/tool-surface/crib-cache.d.ts.map +1 -0
  189. package/dist/tool-surface/crib-cache.js +54 -0
  190. package/dist/tool-surface/crib-cache.js.map +1 -0
  191. package/dist/tool-surface/crib-hook.d.ts +78 -0
  192. package/dist/tool-surface/crib-hook.d.ts.map +1 -0
  193. package/dist/tool-surface/crib-hook.js +225 -0
  194. package/dist/tool-surface/crib-hook.js.map +1 -0
  195. package/dist/tool-surface/crib-sheet.d.ts +56 -0
  196. package/dist/tool-surface/crib-sheet.d.ts.map +1 -0
  197. package/dist/tool-surface/crib-sheet.js +129 -0
  198. package/dist/tool-surface/crib-sheet.js.map +1 -0
  199. package/dist/tool-surface/mcp-tool-source.d.ts +64 -0
  200. package/dist/tool-surface/mcp-tool-source.d.ts.map +1 -0
  201. package/dist/tool-surface/mcp-tool-source.js +189 -0
  202. package/dist/tool-surface/mcp-tool-source.js.map +1 -0
  203. package/dist/utils/event-catalog.d.ts +228 -6
  204. package/dist/utils/event-catalog.d.ts.map +1 -1
  205. package/dist/utils/event-catalog.js +32 -0
  206. package/dist/utils/event-catalog.js.map +1 -1
  207. package/dist/widgets/tool.d.ts +9 -0
  208. package/dist/widgets/tool.d.ts.map +1 -1
  209. package/dist/widgets/tool.js +1 -0
  210. package/dist/widgets/tool.js.map +1 -1
  211. package/openclaw.plugin.json +11 -1
  212. package/package.json +5 -2
@@ -1,4 +1,7 @@
1
+ import { type MutateConfigFile } from "./gateway-restart.js";
2
+ import type { IdleGateReader } from "./idle-gate.js";
1
3
  import { type AutoUpdateCheckNowResult, type AutoUpdateConfig, type AutoUpdateSnapshot } from "./types.js";
4
+ import { type InstallResultsTelemetry } from "./install-results.js";
2
5
  import { type VersionSource } from "./version-source.js";
3
6
  import { type EventName } from "../../utils/event-catalog.js";
4
7
  import type { EventOptions, LogLevel } from "../../utils/logger.js";
@@ -14,6 +17,31 @@ interface LoggerLike {
14
17
  error(...args: unknown[]): void;
15
18
  event<N extends EventName>(name: N, level: LogLevel, opts: EventOptions<N>): void;
16
19
  }
20
+ /**
21
+ * How long a requested restart may take to load its target before the
22
+ * awaiting-restart state is treated as failed (the 3.0.171 latch fix). A 10.x
23
+ * restart-to-apply measured about 71 s on Box A, with starts up to 93 s; 30 min
24
+ * leaves room for the gateway's own deferral (forced after 300 s) and a slow
25
+ * offline install.
26
+ */
27
+ export declare const RESTART_LOAD_TIMEOUT_MS: number;
28
+ /**
29
+ * Restarts requested for one target that may fail to load before the box
30
+ * stops trying that version and waits for a newer one. Bounds the loop of a
31
+ * version that can never install (a blocked scan, a yanked version, a wrapper
32
+ * without the marker step): without it an idle box would restart about every
33
+ * 80 min forever.
34
+ */
35
+ export declare const MAX_APPLY_ATTEMPTS = 3;
36
+ /**
37
+ * How often a 10.x box that is `pending-idle` re-reads its apply gate (the
38
+ * spread time and the idle gate) between registry polls. The idle gate has no
39
+ * change notification, so the change is caught by this re-read; when the gate
40
+ * opens, an ordinary check runs at once instead of up to one poll interval
41
+ * (60 min by default) later. The re-read itself is local: no registry call,
42
+ * no `onTickComplete`.
43
+ */
44
+ export declare const PENDING_IDLE_RECHECK_MS: number;
17
45
  /** Construction-time options for {@link AutoUpdateCoordinator}. */
18
46
  export interface AutoUpdateCoordinatorOptions {
19
47
  enabled: boolean;
@@ -42,6 +70,44 @@ export interface AutoUpdateCoordinatorOptions {
42
70
  * be added without changing the auto-update internals.
43
71
  */
44
72
  onTickComplete?: () => Promise<void>;
73
+ /**
74
+ * The version the gateway actually loaded (the plugin version at
75
+ * registration). "Applied" is decided only from this, never from the
76
+ * persisted `lastAppliedVersion` alone. Defaults to `currentVersion`.
77
+ */
78
+ loadedVersion?: string;
79
+ /**
80
+ * OpenClaw host >= 2026.8.1 (R1 `getOpenClawHost().modern`). Switches the
81
+ * apply path to restart-to-apply: no in-process install; wait for the spread
82
+ * offset and an idle moment, write the install marker, and restart through
83
+ * `mutateConfigFile`.
84
+ */
85
+ modernHost?: boolean;
86
+ /** Modern host: `api.runtime.config.mutateConfigFile`. */
87
+ mutateConfigFile?: MutateConfigFile;
88
+ /** Modern host: live config read (R1 `readLiveHostConfig`). */
89
+ readLiveConfig?: () => unknown;
90
+ /** Modern host: user-activity gate. Without one the box counts as idle (the gateway still defers the restart past running replies). */
91
+ idleGate?: IdleGateReader;
92
+ /** Modern host: stable box identity for the spread offset (the user MID, else a stable instance id). */
93
+ mid?: string;
94
+ /** Clock, for tests. Defaults to `Date.now`. */
95
+ now?: () => number;
96
+ /** `[0, 1)` source for the jitter, for tests. Defaults to `Math.random`. */
97
+ rand?: () => number;
98
+ /** Modern host: `<OPENCLAW_STATE_DIR>/senpi-state/runtime-update.json` (see `update-marker.ts`). */
99
+ updateMarkerPath?: string;
100
+ /**
101
+ * Modern host: `<OPENCLAW_STATE_DIR>/senpi-state/runtime-update-results.json`, the wrapper's
102
+ * install outcomes (see `install-results.ts`). Read once per {@link AutoUpdateCoordinator.start},
103
+ * whether or not auto-update is enabled.
104
+ */
105
+ installResultsPath?: string;
106
+ /**
107
+ * The emit path the install-results report and the 10.x `applied` event wait for and flush
108
+ * (the plugin's OTel SDK). Omitted (tests), events are emitted at once.
109
+ */
110
+ installResultsTelemetry?: InstallResultsTelemetry;
45
111
  }
46
112
  /**
47
113
  * Central lifecycle manager for the plugin auto-update feature.
@@ -65,6 +131,8 @@ export declare class AutoUpdateCoordinator {
65
131
  private readonly versionSource;
66
132
  private readonly runUpdateCommand;
67
133
  private timer;
134
+ /** 10.x `pending-idle` gate re-read; see {@link PENDING_IDLE_RECHECK_MS}. */
135
+ private idleRecheckTimer;
68
136
  private running;
69
137
  private stopped;
70
138
  private runToken;
@@ -74,9 +142,75 @@ export declare class AutoUpdateCoordinator {
74
142
  /** Spec the last resolve used. Seeded in the constructor, so the snapshot
75
143
  * reports a line before the first tick. */
76
144
  private updateSpec;
145
+ /** Why the modern path is still waiting; reset every tick. See {@link AutoUpdateSnapshot.pendingBlockers}. */
146
+ private pendingBlockers;
147
+ private readonly now;
148
+ private readonly rand;
149
+ private readonly loadedVersion;
150
+ /**
151
+ * 10.x: `<version>|<sorted blockers>` of the last `auto_update.deferred`, so the event fires on
152
+ * entering `pending-idle` and on a change only. Cleared when a tick ends outside `pending-idle` or fails.
153
+ * In memory: a new gateway process reports a wait that is still on once.
154
+ */
155
+ private lastDeferredKey;
156
+ /** The install-results report the last {@link start} began; see {@link whenInstallResultsReported}. */
157
+ private installResultsReport;
158
+ /** The 10.x `auto_update.applied` report the last {@link start} began; see {@link whenAppliedReported}. */
159
+ private appliedReport;
77
160
  constructor(options: AutoUpdateCoordinatorOptions);
78
161
  /** Run preflight checks, load persisted state, and schedule the first version poll. */
79
162
  start(): Promise<void>;
163
+ /**
164
+ * Startup half of the latch fix: compare what this process loaded with what
165
+ * a previous process asked for.
166
+ *
167
+ * When the loaded version reaches the requested restart's target, the update
168
+ * took effect: the pending restart and pending update are cleared, a stale
169
+ * install marker is removed, and on a 10.x host `auto_update.applied` fires
170
+ * (nothing was installed before this boot there). On 5.x `applied` already
171
+ * fired when the restart was requested, so it is not counted twice.
172
+ *
173
+ * A target the loaded version has not reached is left for the tick, which
174
+ * expires it once the request is older than {@link RESTART_LOAD_TIMEOUT_MS}.
175
+ *
176
+ * @returns `updated:<v>` when a requested update is now loaded, else `undefined`.
177
+ */
178
+ private reconcileLoadedVersion;
179
+ /**
180
+ * Emit the 10.x `auto_update.applied` once the OTel SDK that `register()` started is up, then
181
+ * flush. It fires right after boot, when the global LoggerProvider may still be the no-op one,
182
+ * and the pending restart is already cleared, so a dropped event would never be sent again. A
183
+ * late or failed init still emits: the gateway log keeps the line either way.
184
+ */
185
+ private reportApplied;
186
+ /** Resolves when the `applied` report begun by the last {@link start}, if any, has finished. */
187
+ whenAppliedReported(): Promise<void>;
188
+ /**
189
+ * Resolves when the install-results report begun by the last {@link start} has finished.
190
+ * `start` does not wait for it: the report waits for the OTel SDK first.
191
+ */
192
+ whenInstallResultsReported(): Promise<void>;
193
+ /**
194
+ * 10.x: start reporting the wrapper's install outcomes in the background. `liveState` is the
195
+ * running coordinator's state (the ids are saved with it); `null` when auto-update is
196
+ * disabled, which loads only the ids and patches only them.
197
+ */
198
+ private startInstallResultsReport;
199
+ /**
200
+ * One `auto_update.install_result` per entry not reported before (`install-results.ts`), then
201
+ * the file is deleted. Runs from {@link start}, which only the gateway's plugin service calls,
202
+ * so a CLI process never consumes the file. Never throws: telemetry must not break the
203
+ * coordinator.
204
+ */
205
+ private reportInstallResults;
206
+ private emitInstallResult;
207
+ /**
208
+ * 10.x: the box waits (`pending-idle:<v>`). `auto_update.deferred` on entering the wait and when
209
+ * the target or the sorted blocker set changes; an unchanged re-check or poll is silent.
210
+ */
211
+ private noteDeferred;
212
+ /** Remove the install marker; a failure is logged, never thrown (the wrapper deletes it too). */
213
+ private clearMarkerQuietly;
80
214
  /** Cancel the next scheduled poll and prevent in-flight ticks from rescheduling. */
81
215
  stop(): Promise<void>;
82
216
  /** Return the latest point-in-time snapshot for health/state gateway RPCs. */
@@ -99,6 +233,21 @@ export declare class AutoUpdateCoordinator {
99
233
  private scheduleNext;
100
234
  /** Single poll cycle: run the check, persist state, and schedule the next cycle. */
101
235
  private tick;
236
+ /** Re-read the apply gate of a `pending-idle` box after {@link PENDING_IDLE_RECHECK_MS}. */
237
+ private scheduleIdleRecheck;
238
+ private clearIdleRecheck;
239
+ /**
240
+ * Run a check now when the gate that held the pending update has opened,
241
+ * else re-read it again later. A check already in flight re-arms this
242
+ * itself when it ends `pending-idle`.
243
+ */
244
+ private recheckPendingIdle;
245
+ /**
246
+ * The 10.x apply gate: wait for `eligibleAt` (blocker `spread`), then for an
247
+ * idle box, unless {@link mustForce} applies and every blocker is one the
248
+ * forced restart may override.
249
+ */
250
+ private applyGate;
102
251
  /**
103
252
  * Emit a catalogued `auto_update.*` event, guarded so neither a throwing sink nor a bad
104
253
  * attribute shape can disturb the tick — telemetry must never break auto-update itself.
@@ -112,6 +261,69 @@ export declare class AutoUpdateCoordinator {
112
261
  private resolveUpdateSpec;
113
262
  /** Core update logic: fetch latest version, classify, and take action. */
114
263
  private runTick;
264
+ /**
265
+ * Whether the restart requested for the persisted target may still land:
266
+ * its request time (the pending restart's, else the last restart trigger,
267
+ * else the last install) is under {@link RESTART_LOAD_TIMEOUT_MS} old. With
268
+ * no time on record the persisted version is not trusted at all.
269
+ */
270
+ private restartStillPending;
271
+ /**
272
+ * The 5.x latch, as before R2: once this flow installed `latest` (an
273
+ * install or restart time is on record), the box waits for a restart and
274
+ * never runs the in-process install and config-bump restart for that
275
+ * version again, however long it waits. 5.x has no idle gate, so a retry
276
+ * would restart the gateway over an order call or an open approval. A
277
+ * restart trigger that threw is latched too (the warning asks for a manual
278
+ * restart). A persisted applied version with no time at all is still not
279
+ * trusted. 10.x expires its wait after 30 min instead: its retries are
280
+ * idle-gated.
281
+ */
282
+ private awaitingManualRestart;
283
+ /**
284
+ * {@link MAX_APPLY_ATTEMPTS} restarts for `latest` did not load it. Stop
285
+ * trying this version: no install and no restart until a newer one ships
286
+ * (or a restart loads it some other way). Reported, not thrown, so the poll
287
+ * keeps its normal cadence.
288
+ */
289
+ private handleParkedUpdate;
290
+ /**
291
+ * The requested update did not load. Drop the awaiting-restart state and the
292
+ * marker, report `auto_update.apply_failed`, and fail this tick (so the
293
+ * backoff applies). The next tick starts over: a new install and restart on
294
+ * 5.x, a new idle-gated restart request on 10.x. The pending update keeps
295
+ * its eligibility time, so the box does not wait out its spread again.
296
+ *
297
+ * @throws Always.
298
+ */
299
+ private expireUnloadedUpdate;
300
+ /**
301
+ * The OpenClaw 10.x apply path (restart-to-apply). Nothing is installed in
302
+ * this process: 10.10 refuses `plugins update` while the gateway runs.
303
+ *
304
+ * 1. Record the pending update once per episode (`firstSeenAt`,
305
+ * `eligibleAt` = first seen + spread offset + jitter).
306
+ * 2. Before `eligibleAt`, wait (`pending-idle:<v>`, blocker `spread`). After
307
+ * it, continue only when the idle gate says idle, or when
308
+ * {@link mustForce} (24 h past eligibility, inside 03:00–05:00 UTC).
309
+ * 3. Build the exact `<name>@<version>` spec, check restart capability,
310
+ * write the marker, and request the restart through `mutateConfigFile`.
311
+ * 4. A failure at any step clears the marker, reports
312
+ * `auto_update.restart_failed` and fails the tick (backoff; `checkNow`
313
+ * answers `failed`). Waiting for the spread or an idle box is not a failure.
314
+ */
315
+ private runRestartToApply;
316
+ /** The idle gate's answer; a throwing gate counts as busy. */
317
+ private readIdle;
318
+ /**
319
+ * Clear the marker, report `auto_update.restart_failed` for the 10.x path
320
+ * (snapshot degraded), and fail the tick: no restart was requested, so the
321
+ * tick must not count as a success. The throw makes `tick()` back off and
322
+ * `checkNow()` answer `failed`.
323
+ *
324
+ * @throws Always, with `reason`.
325
+ */
326
+ private reportModernRestartFailure;
115
327
  /**
116
328
  * `currentVersion` is a compile-time constant frozen for the life of the
117
329
  * process, so it cannot reflect an install that already happened this
@@ -124,9 +336,17 @@ export declare class AutoUpdateCoordinator {
124
336
  * so this branch stops being reached on its own.
125
337
  */
126
338
  private handleAlreadyAppliedAwaitingRestart;
339
+ /** OpenClaw 10.x refuses `plugins update` while the gateway runs, so a manual instruction says so. */
340
+ private manualUpdateSuffix;
127
341
  private isAllowedByPolicy;
128
342
  private handleMajorAvailable;
129
343
  private logUpdateAvailable;
344
+ /**
345
+ * The `auto_update.install_failed` event and warn line for an install of
346
+ * `latest` that threw. Shared by the normal install and the 5.x reinstall of
347
+ * a rolled-back `latest`; the caller rethrows to the tick's catch.
348
+ */
349
+ private reportInstallFailed;
130
350
  /**
131
351
  * Install the update, evaluate restart capability, then either trigger a
132
352
  * gateway restart or log that a manual restart is needed.
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/runtime/auto-update/coordinator.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EAExB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAyC,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;;;;GAKG;AACH,UAAU,UAAU;IAClB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC/B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChC,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACnF;AAwBD,mEAAmE;AACnE,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,gBAAgB,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,gBAAgB,CAAC,EAAE,CAAC,WAAW,EA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