@senpi-ai/runtime 1.0.76 → 1.0.79
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.
- package/README.md +32 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime/auto-update/command-runner.d.ts +20 -0
- package/dist/runtime/auto-update/command-runner.d.ts.map +1 -0
- package/dist/runtime/auto-update/command-runner.js +54 -0
- package/dist/runtime/auto-update/command-runner.js.map +1 -0
- package/dist/runtime/auto-update/coordinator.d.ts +80 -0
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -0
- package/dist/runtime/auto-update/coordinator.js +290 -0
- package/dist/runtime/auto-update/coordinator.js.map +1 -0
- package/dist/runtime/auto-update/gateway-restart.d.ts +49 -0
- package/dist/runtime/auto-update/gateway-restart.d.ts.map +1 -0
- package/dist/runtime/auto-update/gateway-restart.js +105 -0
- package/dist/runtime/auto-update/gateway-restart.js.map +1 -0
- package/dist/runtime/auto-update/policy.d.ts +24 -0
- package/dist/runtime/auto-update/policy.d.ts.map +1 -0
- package/dist/runtime/auto-update/policy.js +42 -0
- package/dist/runtime/auto-update/policy.js.map +1 -0
- package/dist/runtime/auto-update/preflight.d.ts +16 -0
- package/dist/runtime/auto-update/preflight.d.ts.map +1 -0
- package/dist/runtime/auto-update/preflight.js +20 -0
- package/dist/runtime/auto-update/preflight.js.map +1 -0
- package/dist/runtime/auto-update/state-store.d.ts +20 -0
- package/dist/runtime/auto-update/state-store.d.ts.map +1 -0
- package/dist/runtime/auto-update/state-store.js +42 -0
- package/dist/runtime/auto-update/state-store.js.map +1 -0
- package/dist/runtime/auto-update/types.d.ts +108 -0
- package/dist/runtime/auto-update/types.d.ts.map +1 -0
- package/dist/runtime/auto-update/types.js +57 -0
- package/dist/runtime/auto-update/types.js.map +1 -0
- package/dist/runtime/auto-update/version-source.d.ts +18 -0
- package/dist/runtime/auto-update/version-source.d.ts.map +1 -0
- package/dist/runtime/auto-update/version-source.js +22 -0
- package/dist/runtime/auto-update/version-source.js.map +1 -0
- package/openclaw.plugin.json +48 -2
- package/package.json +1 -1
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { runCommand } from "./command-runner.js";
|
|
2
|
+
import { evaluateGatewayRestartCapability } from "./gateway-restart.js";
|
|
3
|
+
import { classifyUpdate, parseSemver } from "./policy.js";
|
|
4
|
+
import { evaluatePreflight } from "./preflight.js";
|
|
5
|
+
import { AutoUpdateStateStore } from "./state-store.js";
|
|
6
|
+
import { createDefaultAutoUpdateState, } from "./types.js";
|
|
7
|
+
import { NpmVersionSource } from "./version-source.js";
|
|
8
|
+
/**
|
|
9
|
+
* Central lifecycle manager for the plugin auto-update feature.
|
|
10
|
+
*
|
|
11
|
+
* Polls the npm registry on a configurable interval, classifies the
|
|
12
|
+
* version delta, and either notifies the user or applies the update
|
|
13
|
+
* automatically depending on the resolved {@link AutoUpdateMode}.
|
|
14
|
+
*
|
|
15
|
+
* After a successful update, the coordinator evaluates whether the
|
|
16
|
+
* OpenClaw gateway can be restarted via a config-file bump and either
|
|
17
|
+
* triggers the restart or asks the user to do so manually.
|
|
18
|
+
*
|
|
19
|
+
* Thread-safety is enforced via a `runToken` / `stopped` flag pair
|
|
20
|
+
* so that `stop()` reliably prevents any in-flight tick from
|
|
21
|
+
* rescheduling.
|
|
22
|
+
*/
|
|
23
|
+
export class AutoUpdateCoordinator {
|
|
24
|
+
options;
|
|
25
|
+
store;
|
|
26
|
+
versionSource;
|
|
27
|
+
runUpdateCommand;
|
|
28
|
+
timer = null;
|
|
29
|
+
running = false;
|
|
30
|
+
stopped = true;
|
|
31
|
+
runToken = 0;
|
|
32
|
+
state;
|
|
33
|
+
snapshot;
|
|
34
|
+
preflightReasons = [];
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this.options = options;
|
|
37
|
+
this.store = new AutoUpdateStateStore(options.stateDir);
|
|
38
|
+
this.versionSource = options.versionSource ?? new NpmVersionSource();
|
|
39
|
+
this.runUpdateCommand = options.runUpdateCommand ?? defaultRunUpdateCommand;
|
|
40
|
+
this.state = createDefaultAutoUpdateState(options.currentVersion, options.config.mode);
|
|
41
|
+
this.snapshot = this.buildSnapshot("disabled", "not-started");
|
|
42
|
+
if (!parseSemver(options.currentVersion)) {
|
|
43
|
+
options.logger.warn(`[auto-update] currentVersion "${options.currentVersion}" is not valid semver; update detection will not work`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Run preflight checks, load persisted state, and schedule the first version poll. */
|
|
47
|
+
async start() {
|
|
48
|
+
this.runToken += 1;
|
|
49
|
+
this.stopped = false;
|
|
50
|
+
if (!this.options.enabled || !this.options.config.enabled) {
|
|
51
|
+
this.stopped = true;
|
|
52
|
+
this.snapshot = this.buildSnapshot("disabled", "auto-update-disabled");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const preflight = evaluatePreflight({
|
|
56
|
+
configuredMode: this.options.config.mode,
|
|
57
|
+
canUpdatePlugin: this.options.canUpdatePlugin ?? true,
|
|
58
|
+
});
|
|
59
|
+
this.preflightReasons = preflight.reasons;
|
|
60
|
+
this.state = await this.store.load(this.options.currentVersion, preflight.effectiveMode);
|
|
61
|
+
this.state.effectiveMode = preflight.effectiveMode;
|
|
62
|
+
try {
|
|
63
|
+
await this.store.save(this.state);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
this.options.logger.warn("[auto-update] failed to persist initial state", { error });
|
|
67
|
+
}
|
|
68
|
+
this.snapshot = this.buildSnapshot("healthy", "started");
|
|
69
|
+
this.scheduleNext(this.options.config.startupDelaySeconds * 1000, this.runToken);
|
|
70
|
+
}
|
|
71
|
+
/** Cancel the next scheduled poll and prevent in-flight ticks from rescheduling. */
|
|
72
|
+
async stop() {
|
|
73
|
+
this.runToken += 1;
|
|
74
|
+
this.stopped = true;
|
|
75
|
+
if (this.timer) {
|
|
76
|
+
clearTimeout(this.timer);
|
|
77
|
+
this.timer = null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Return the latest point-in-time snapshot for health/state gateway RPCs. */
|
|
81
|
+
getSnapshot() {
|
|
82
|
+
return this.snapshot;
|
|
83
|
+
}
|
|
84
|
+
/** Schedule the next `tick` after `delayMs`, guarded by stop/token checks. */
|
|
85
|
+
scheduleNext(delayMs, token) {
|
|
86
|
+
if (this.stopped || token !== this.runToken)
|
|
87
|
+
return;
|
|
88
|
+
if (this.timer)
|
|
89
|
+
clearTimeout(this.timer);
|
|
90
|
+
const now = Date.now();
|
|
91
|
+
const waitMs = Math.max(1_000, delayMs);
|
|
92
|
+
this.snapshot = {
|
|
93
|
+
...this.snapshot,
|
|
94
|
+
nextCheckAt: new Date(now + waitMs).toISOString(),
|
|
95
|
+
};
|
|
96
|
+
this.timer = setTimeout(() => {
|
|
97
|
+
void this.tick(token);
|
|
98
|
+
}, waitMs);
|
|
99
|
+
}
|
|
100
|
+
/** Single poll cycle: run the check, persist state, and schedule the next cycle. */
|
|
101
|
+
async tick(token) {
|
|
102
|
+
if (this.running || this.stopped || token !== this.runToken)
|
|
103
|
+
return;
|
|
104
|
+
this.running = true;
|
|
105
|
+
const state = this.state;
|
|
106
|
+
try {
|
|
107
|
+
await this.runTick(state);
|
|
108
|
+
state.consecutiveFailures = 0;
|
|
109
|
+
state.lastFailureAt = undefined;
|
|
110
|
+
state.lastFailureReason = undefined;
|
|
111
|
+
await this.persistState(state);
|
|
112
|
+
if (!this.stopped && token === this.runToken) {
|
|
113
|
+
this.scheduleNext(this.options.config.pollIntervalMinutes * 60_000, token);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
state.consecutiveFailures += 1;
|
|
118
|
+
state.lastFailureAt = new Date().toISOString();
|
|
119
|
+
state.lastFailureReason = formatErr(error);
|
|
120
|
+
await this.persistState(state);
|
|
121
|
+
const base = this.options.config.failureBackoffMinutes * 60_000;
|
|
122
|
+
const max = this.options.config.maxBackoffMinutes * 60_000;
|
|
123
|
+
const backoff = Math.min(max, base * Math.max(1, state.consecutiveFailures));
|
|
124
|
+
this.snapshot = this.buildSnapshot("degraded", this.snapshot.lastAction, formatErr(error));
|
|
125
|
+
if (!this.stopped && token === this.runToken) {
|
|
126
|
+
this.scheduleNext(backoff, token);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
this.running = false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Core update logic: fetch latest version, classify, and take action. */
|
|
134
|
+
async runTick(state) {
|
|
135
|
+
state.lastCheckedAt = new Date().toISOString();
|
|
136
|
+
const latest = await this.versionSource.getLatestVersion(this.options.packageName);
|
|
137
|
+
state.latestVersionLastSeen = latest;
|
|
138
|
+
const updateType = classifyUpdate(this.options.currentVersion, latest);
|
|
139
|
+
if (updateType === "none") {
|
|
140
|
+
this.snapshot = this.buildSnapshot("healthy", `no-update:${latest}`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (updateType === "major") {
|
|
144
|
+
await this.handleMajorAvailable(state, latest);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!this.isAllowedByPolicy(updateType)) {
|
|
148
|
+
this.snapshot = this.buildSnapshot("healthy", `policy-blocked:${updateType}:${latest}`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (state.effectiveMode !== "auto-apply") {
|
|
152
|
+
await this.notifyUpdateAvailable(state, latest, updateType);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (state.lastAppliedVersion === latest) {
|
|
156
|
+
this.snapshot = this.buildSnapshot("healthy", `already-applied:${latest}`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
await this.runUpdateTransaction(state, latest, updateType);
|
|
160
|
+
}
|
|
161
|
+
isAllowedByPolicy(kind) {
|
|
162
|
+
if (kind === "patch")
|
|
163
|
+
return this.options.config.allowPatch;
|
|
164
|
+
if (kind === "minor")
|
|
165
|
+
return this.options.config.allowMinor;
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
async handleMajorAvailable(state, latest) {
|
|
169
|
+
if (state.lastNotifiedMajorVersion === latest) {
|
|
170
|
+
this.snapshot = this.buildSnapshot("healthy", `major-seen:${latest}`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
await this.options.notify(`Senpi update available: v${latest} (major).\n` +
|
|
174
|
+
`Auto-update will not apply major versions.\n` +
|
|
175
|
+
`Please review changelog and run: openclaw plugins update ${this.options.packageName}`);
|
|
176
|
+
state.lastNotifiedMajorVersion = latest;
|
|
177
|
+
this.snapshot = this.buildSnapshot("healthy", `major-notified:${latest}`);
|
|
178
|
+
}
|
|
179
|
+
async notifyUpdateAvailable(state, latest, kind) {
|
|
180
|
+
if (state.lastNotifiedUpdateVersion === latest) {
|
|
181
|
+
this.snapshot = this.buildSnapshot("healthy", `update-seen:${kind}:${latest}`);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
await this.options.notify(`Senpi update available: v${latest} (${kind}).\n` +
|
|
185
|
+
`Auto-update mode is notify-only.\n` +
|
|
186
|
+
`Run: openclaw plugins update ${this.options.packageName}`);
|
|
187
|
+
state.lastNotifiedUpdateVersion = latest;
|
|
188
|
+
this.snapshot = this.buildSnapshot("healthy", `update-notified:${kind}:${latest}`);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Stop runtimes, install the update, evaluate restart capability,
|
|
192
|
+
* and either trigger a gateway restart or notify the user to do so manually.
|
|
193
|
+
*/
|
|
194
|
+
async runUpdateTransaction(state, latest, kind) {
|
|
195
|
+
state.lastAttemptAt = new Date().toISOString();
|
|
196
|
+
await this.options.notify(`Senpi auto-update in progress: ${this.options.currentVersion} -> ${latest} (${kind}).`);
|
|
197
|
+
await this.options.stopRuntimesForUpdate();
|
|
198
|
+
await this.runUpdateCommand(this.options.packageName);
|
|
199
|
+
state.lastSuccessAt = new Date().toISOString();
|
|
200
|
+
state.lastAppliedVersion = latest;
|
|
201
|
+
const capability = await evaluateGatewayRestartCapability({
|
|
202
|
+
configFromApi: this.options.configFromApi,
|
|
203
|
+
loadConfig: this.options.loadConfig,
|
|
204
|
+
writeConfigFile: this.options.writeConfigFile,
|
|
205
|
+
pluginId: this.options.pluginId,
|
|
206
|
+
});
|
|
207
|
+
state.restartCapability = capability.capable ? "capable" : "not-capable";
|
|
208
|
+
state.restartCapabilityReasons = capability.reasons;
|
|
209
|
+
state.restartCapabilityMode = capability.mode;
|
|
210
|
+
if (!capability.capable || !capability.config || !this.options.writeConfigFile) {
|
|
211
|
+
await this.options.notify(`Senpi updated to v${latest}, but automatic gateway restart is not available.\n` +
|
|
212
|
+
`Please restart OpenClaw gateway manually.\n` +
|
|
213
|
+
`Reason(s): ${capability.reasons.join(", ") || "unknown"}`);
|
|
214
|
+
this.snapshot = this.buildSnapshot("degraded", `updated-manual-restart:${latest}`);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const nowIso = new Date().toISOString();
|
|
218
|
+
try {
|
|
219
|
+
const { triggerGatewayRestartViaConfigBump } = await import("./gateway-restart.js");
|
|
220
|
+
await triggerGatewayRestartViaConfigBump({
|
|
221
|
+
loadedConfig: capability.config,
|
|
222
|
+
writeConfigFile: this.options.writeConfigFile,
|
|
223
|
+
pluginId: this.options.pluginId,
|
|
224
|
+
triggerValue: nowIso,
|
|
225
|
+
});
|
|
226
|
+
state.lastRestartTriggerAt = nowIso;
|
|
227
|
+
state.lastRestartTriggerMode = capability.mode ?? "unknown";
|
|
228
|
+
await this.options.notify(`Senpi updated to v${latest}. Gateway restart requested via config reload (${state.lastRestartTriggerMode}).`);
|
|
229
|
+
this.snapshot = this.buildSnapshot("healthy", `updated-restart-requested:${latest}`);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
const reason = formatErr(error);
|
|
233
|
+
await this.options.notify(`Senpi updated to v${latest}, but restart trigger failed.\n` +
|
|
234
|
+
`Please restart OpenClaw gateway manually.\n` +
|
|
235
|
+
`Reason: ${reason}`);
|
|
236
|
+
state.restartCapability = "not-capable";
|
|
237
|
+
state.restartCapabilityReasons = [
|
|
238
|
+
...state.restartCapabilityReasons,
|
|
239
|
+
`restart-trigger-failed:${reason}`,
|
|
240
|
+
];
|
|
241
|
+
this.snapshot = this.buildSnapshot("degraded", `updated-restart-failed:${latest}`, reason);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/** Assemble a read-only snapshot from current state for external consumers. */
|
|
245
|
+
buildSnapshot(health, lastAction, lastError = null) {
|
|
246
|
+
const state = this.state;
|
|
247
|
+
return {
|
|
248
|
+
enabled: this.options.enabled && this.options.config.enabled,
|
|
249
|
+
configuredMode: this.options.config.mode,
|
|
250
|
+
effectiveMode: state.effectiveMode,
|
|
251
|
+
health,
|
|
252
|
+
currentVersion: this.options.currentVersion,
|
|
253
|
+
latestVersion: state.latestVersionLastSeen || this.options.currentVersion,
|
|
254
|
+
lastCheckedAt: state.lastCheckedAt || null,
|
|
255
|
+
lastAction,
|
|
256
|
+
lastError: lastError
|
|
257
|
+
?? (health === "degraded" || health === "unhealthy"
|
|
258
|
+
? (state.lastFailureReason ?? null)
|
|
259
|
+
: null),
|
|
260
|
+
consecutiveFailures: state.consecutiveFailures,
|
|
261
|
+
nextCheckAt: this.snapshot?.nextCheckAt ?? null,
|
|
262
|
+
preflightReasons: this.preflightReasons,
|
|
263
|
+
restartCapability: state.restartCapability,
|
|
264
|
+
restartCapabilityReasons: state.restartCapabilityReasons,
|
|
265
|
+
lastRestartTriggerAt: state.lastRestartTriggerAt ?? null,
|
|
266
|
+
lastRestartTriggerMode: state.lastRestartTriggerMode ?? null,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
async persistState(state) {
|
|
270
|
+
try {
|
|
271
|
+
await this.store.save(state);
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
this.options.logger.warn("[auto-update] failed to persist state", { error });
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** Default update command: `openclaw plugins update <packageName>`. */
|
|
279
|
+
async function defaultRunUpdateCommand(packageName) {
|
|
280
|
+
const result = await runCommand("openclaw", ["plugins", "update", packageName], {
|
|
281
|
+
timeoutMs: 60_000,
|
|
282
|
+
});
|
|
283
|
+
if (result.code !== 0) {
|
|
284
|
+
throw new Error(result.stderr || `openclaw plugins update failed with code ${result.code}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function formatErr(error) {
|
|
288
|
+
return error instanceof Error ? error.message : String(error);
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/runtime/auto-update/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EACL,4BAA4B,GAK7B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAC;AA4B3E;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,qBAAqB;IAYH;IAXZ,KAAK,CAAuB;IAC5B,aAAa,CAAgB;IAC7B,gBAAgB,CAAyC;IAClE,KAAK,GAA0B,IAAI,CAAC;IACpC,OAAO,GAAG,KAAK,CAAC;IAChB,OAAO,GAAG,IAAI,CAAC;IACf,QAAQ,GAAG,CAAC,CAAC;IACb,KAAK,CAAkB;IACvB,QAAQ,CAAqB;IAC7B,gBAAgB,GAA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M,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;CACF;AAED,uEAAuE;AACvE,KAAK,UAAU,uBAAuB,CAAC,WAAmB;IACxD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE;QAC9E,SAAS,EAAE,MAAM;KAClB,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,4CAA4C,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** OpenClaw gateway reload modes that determine how config changes are applied. */
|
|
2
|
+
export type GatewayReloadMode = "off" | "restart" | "hot" | "hybrid";
|
|
3
|
+
/**
|
|
4
|
+
* Result of evaluating whether the auto-updater can trigger an automatic
|
|
5
|
+
* gateway restart after a plugin update. When `capable` is `false`,
|
|
6
|
+
* `reasons` explains why (e.g. wrong reload mode, missing config helpers).
|
|
7
|
+
*/
|
|
8
|
+
export interface GatewayRestartCapability {
|
|
9
|
+
capable: boolean;
|
|
10
|
+
reasons: string[];
|
|
11
|
+
mode?: GatewayReloadMode;
|
|
12
|
+
config?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/** Inputs required to evaluate gateway restart capability. */
|
|
15
|
+
export interface RestartCapabilityInputs {
|
|
16
|
+
/** Snapshot of the OpenClaw config captured at plugin construction time (may be stale). */
|
|
17
|
+
configFromApi?: unknown;
|
|
18
|
+
/** Loads the live OpenClaw config from disk -- preferred over `configFromApi` when available. */
|
|
19
|
+
loadConfig?: () => Promise<unknown>;
|
|
20
|
+
/** Writes a modified OpenClaw config back to disk to trigger a config-change reload. */
|
|
21
|
+
writeConfigFile?: (config: unknown) => Promise<void>;
|
|
22
|
+
pluginId: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Determine whether the gateway can be restarted automatically.
|
|
26
|
+
*
|
|
27
|
+
* Restart is only possible when:
|
|
28
|
+
* - The OpenClaw config is accessible (via `loadConfig` or `configFromApi`).
|
|
29
|
+
* - `gateway.reload.mode` is `"restart"` or `"hybrid"`.
|
|
30
|
+
* - Both `loadConfig` and `writeConfigFile` helpers are available.
|
|
31
|
+
* - The plugin entry exists under `plugins.entries.<pluginId>`.
|
|
32
|
+
*
|
|
33
|
+
* Prefers `loadConfig()` (fresh) over `configFromApi` (stale snapshot).
|
|
34
|
+
*/
|
|
35
|
+
export declare function evaluateGatewayRestartCapability(inputs: RestartCapabilityInputs): Promise<GatewayRestartCapability>;
|
|
36
|
+
/**
|
|
37
|
+
* Write a `lastRestartTrigger` timestamp into the plugin's `autoUpdate`
|
|
38
|
+
* config block, causing OpenClaw's config-file watcher to detect a change
|
|
39
|
+
* and restart the gateway (when reload mode is `restart` or `hybrid`).
|
|
40
|
+
*
|
|
41
|
+
* @throws When the plugin config path cannot be resolved in the config tree.
|
|
42
|
+
*/
|
|
43
|
+
export declare function triggerGatewayRestartViaConfigBump(options: {
|
|
44
|
+
loadedConfig: unknown;
|
|
45
|
+
writeConfigFile: (config: unknown) => Promise<void>;
|
|
46
|
+
pluginId: string;
|
|
47
|
+
triggerValue: string;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
//# sourceMappingURL=gateway-restart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-restart.d.ts","sourceRoot":"","sources":["../../../src/runtime/auto-update/gateway-restart.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,8DAA8D;AAC9D,MAAM,WAAW,uBAAuB;IACtC,2FAA2F;IAC3F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,wFAAwF;IACxF,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,QAAQ,EAAE,MAAM,CAAC;CAClB;AA0BD;;;;;;;;;;GAUG;AACH,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CAyCnC;AAMD;;;;;;GAMG;AACH,wBAAsB,kCAAkC,CAAC,OAAO,EAAE;IAChE,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
function asRecord(value) {
|
|
2
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
3
|
+
? value
|
|
4
|
+
: undefined;
|
|
5
|
+
}
|
|
6
|
+
function readGatewayReloadMode(config) {
|
|
7
|
+
const root = asRecord(config);
|
|
8
|
+
const gateway = asRecord(root?.gateway);
|
|
9
|
+
const reload = asRecord(gateway?.reload);
|
|
10
|
+
const mode = reload?.mode;
|
|
11
|
+
return mode === "off" || mode === "restart" || mode === "hot" || mode === "hybrid"
|
|
12
|
+
? mode
|
|
13
|
+
: undefined;
|
|
14
|
+
}
|
|
15
|
+
function hasWritablePluginPath(config, pluginId) {
|
|
16
|
+
const root = asRecord(config);
|
|
17
|
+
const plugins = asRecord(root?.plugins);
|
|
18
|
+
const entries = asRecord(plugins?.entries);
|
|
19
|
+
if (!entries)
|
|
20
|
+
return false;
|
|
21
|
+
return asRecord(entries[pluginId]) !== undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Determine whether the gateway can be restarted automatically.
|
|
25
|
+
*
|
|
26
|
+
* Restart is only possible when:
|
|
27
|
+
* - The OpenClaw config is accessible (via `loadConfig` or `configFromApi`).
|
|
28
|
+
* - `gateway.reload.mode` is `"restart"` or `"hybrid"`.
|
|
29
|
+
* - Both `loadConfig` and `writeConfigFile` helpers are available.
|
|
30
|
+
* - The plugin entry exists under `plugins.entries.<pluginId>`.
|
|
31
|
+
*
|
|
32
|
+
* Prefers `loadConfig()` (fresh) over `configFromApi` (stale snapshot).
|
|
33
|
+
*/
|
|
34
|
+
export async function evaluateGatewayRestartCapability(inputs) {
|
|
35
|
+
const reasons = [];
|
|
36
|
+
const writeConfigFile = inputs.writeConfigFile;
|
|
37
|
+
const loadConfig = inputs.loadConfig;
|
|
38
|
+
let config;
|
|
39
|
+
if (loadConfig) {
|
|
40
|
+
try {
|
|
41
|
+
config = asRecord(await loadConfig());
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// fall through to configFromApi snapshot
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!config) {
|
|
48
|
+
config = asRecord(inputs.configFromApi);
|
|
49
|
+
}
|
|
50
|
+
if (!config) {
|
|
51
|
+
reasons.push("openclaw-config-unavailable");
|
|
52
|
+
}
|
|
53
|
+
const mode = readGatewayReloadMode(config);
|
|
54
|
+
if (!mode)
|
|
55
|
+
reasons.push("gateway.reload.mode-unavailable");
|
|
56
|
+
if (mode === "off")
|
|
57
|
+
reasons.push("gateway.reload.mode=off");
|
|
58
|
+
if (mode === "hot")
|
|
59
|
+
reasons.push("gateway.reload.mode=hot");
|
|
60
|
+
if (mode !== "restart" && mode !== "hybrid") {
|
|
61
|
+
reasons.push("restart-reload-mode-required");
|
|
62
|
+
}
|
|
63
|
+
if (!loadConfig)
|
|
64
|
+
reasons.push("runtime.config.loadConfig-unavailable");
|
|
65
|
+
if (!writeConfigFile)
|
|
66
|
+
reasons.push("runtime.config.writeConfigFile-unavailable");
|
|
67
|
+
if (config && !hasWritablePluginPath(config, inputs.pluginId)) {
|
|
68
|
+
reasons.push(`plugins.entries.${inputs.pluginId}-missing`);
|
|
69
|
+
}
|
|
70
|
+
const capable = reasons.length === 0;
|
|
71
|
+
return {
|
|
72
|
+
capable,
|
|
73
|
+
reasons,
|
|
74
|
+
mode,
|
|
75
|
+
config,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function cloneConfig(input) {
|
|
79
|
+
return JSON.parse(JSON.stringify(input));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Write a `lastRestartTrigger` timestamp into the plugin's `autoUpdate`
|
|
83
|
+
* config block, causing OpenClaw's config-file watcher to detect a change
|
|
84
|
+
* and restart the gateway (when reload mode is `restart` or `hybrid`).
|
|
85
|
+
*
|
|
86
|
+
* @throws When the plugin config path cannot be resolved in the config tree.
|
|
87
|
+
*/
|
|
88
|
+
export async function triggerGatewayRestartViaConfigBump(options) {
|
|
89
|
+
const root = asRecord(options.loadedConfig);
|
|
90
|
+
if (!root)
|
|
91
|
+
throw new Error("openclaw config is not an object");
|
|
92
|
+
const next = cloneConfig(root);
|
|
93
|
+
const plugins = asRecord(next.plugins);
|
|
94
|
+
const entries = asRecord(plugins?.entries);
|
|
95
|
+
const entry = entries ? asRecord(entries[options.pluginId]) : undefined;
|
|
96
|
+
const pluginConfig = entry ? asRecord(entry.config) : undefined;
|
|
97
|
+
if (!plugins || !entries || !entry || !pluginConfig) {
|
|
98
|
+
throw new Error(`plugins.entries.${options.pluginId}.config is not available`);
|
|
99
|
+
}
|
|
100
|
+
const autoUpdate = asRecord(pluginConfig.autoUpdate) ?? {};
|
|
101
|
+
autoUpdate.lastRestartTrigger = options.triggerValue;
|
|
102
|
+
pluginConfig.autoUpdate = autoUpdate;
|
|
103
|
+
await options.writeConfigFile(next);
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=gateway-restart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-restart.js","sourceRoot":"","sources":["../../../src/runtime/auto-update/gateway-restart.ts"],"names":[],"mappings":"AA0BA,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAChE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAe;IAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,MAAM,EAAE,IAAI,CAAC;IAC1B,OAAO,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,QAAQ;QAChF,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC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AC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,QAAQ,0BAA0B,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAC3D,UAAU,CAAC,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IACrD,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC;IAErC,MAAM,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AutoUpdateKind } from "./types.js";
|
|
2
|
+
/** Parsed major.minor.patch triple from a semver string. */
|
|
3
|
+
export interface SemverTriple {
|
|
4
|
+
major: number;
|
|
5
|
+
minor: number;
|
|
6
|
+
patch: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Extract the major, minor, and patch numbers from a semver string.
|
|
10
|
+
*
|
|
11
|
+
* Accepts optional `v` prefix and pre-release / build-metadata suffixes
|
|
12
|
+
* (e.g. `"v1.2.3-beta.1+build.42"`). Returns `null` when the input
|
|
13
|
+
* does not match the `MAJOR.MINOR.PATCH` pattern.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseSemver(input: string): SemverTriple | null;
|
|
16
|
+
/**
|
|
17
|
+
* Compare two semver strings and return the kind of update (or `"none"`).
|
|
18
|
+
*
|
|
19
|
+
* Returns `"major"`, `"minor"`, or `"patch"` when `latest` is ahead of
|
|
20
|
+
* `current` in the respective component. Returns `"none"` when the
|
|
21
|
+
* versions are equal, `latest` is older, or either string is unparseable.
|
|
22
|
+
*/
|
|
23
|
+
export declare function classifyUpdate(current: string, latest: string): AutoUpdateKind;
|
|
24
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/runtime/auto-update/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,4DAA4D;AAC5D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAQ9D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAW9E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the major, minor, and patch numbers from a semver string.
|
|
3
|
+
*
|
|
4
|
+
* Accepts optional `v` prefix and pre-release / build-metadata suffixes
|
|
5
|
+
* (e.g. `"v1.2.3-beta.1+build.42"`). Returns `null` when the input
|
|
6
|
+
* does not match the `MAJOR.MINOR.PATCH` pattern.
|
|
7
|
+
*/
|
|
8
|
+
export function parseSemver(input) {
|
|
9
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(input.trim());
|
|
10
|
+
if (!match)
|
|
11
|
+
return null;
|
|
12
|
+
return {
|
|
13
|
+
major: Number.parseInt(match[1], 10),
|
|
14
|
+
minor: Number.parseInt(match[2], 10),
|
|
15
|
+
patch: Number.parseInt(match[3], 10),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Compare two semver strings and return the kind of update (or `"none"`).
|
|
20
|
+
*
|
|
21
|
+
* Returns `"major"`, `"minor"`, or `"patch"` when `latest` is ahead of
|
|
22
|
+
* `current` in the respective component. Returns `"none"` when the
|
|
23
|
+
* versions are equal, `latest` is older, or either string is unparseable.
|
|
24
|
+
*/
|
|
25
|
+
export function classifyUpdate(current, latest) {
|
|
26
|
+
const from = parseSemver(current);
|
|
27
|
+
const to = parseSemver(latest);
|
|
28
|
+
if (!from || !to)
|
|
29
|
+
return "none";
|
|
30
|
+
if (to.major > from.major)
|
|
31
|
+
return "major";
|
|
32
|
+
if (to.major < from.major)
|
|
33
|
+
return "none";
|
|
34
|
+
if (to.minor > from.minor)
|
|
35
|
+
return "minor";
|
|
36
|
+
if (to.minor < from.minor)
|
|
37
|
+
return "none";
|
|
38
|
+
if (to.patch > from.patch)
|
|
39
|
+
return "patch";
|
|
40
|
+
return "none";
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../../src/runtime/auto-update/policy.ts"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,KAAK,GAAG,oCAAoC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACpC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACpC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;KACrC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,MAAc;IAC5D,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAEhC,IAAI,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC1C,IAAI,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;QAAE,OAAO,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC1C,IAAI,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;QAAE,OAAO,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AutoUpdateMode, AutoUpdatePreflightResult } from "./types.js";
|
|
2
|
+
/** Inputs for the preflight environment capability check. */
|
|
3
|
+
export interface AutoUpdatePreflightInput {
|
|
4
|
+
/** Mode the user (or defaults) configured. */
|
|
5
|
+
configuredMode: AutoUpdateMode;
|
|
6
|
+
/** Whether the `openclaw plugins update` CLI command is available. */
|
|
7
|
+
canUpdatePlugin: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Check whether the runtime environment can support the configured
|
|
11
|
+
* {@link AutoUpdateMode}. If `auto-apply` is requested but the plugin
|
|
12
|
+
* update command is unavailable, the effective mode is downgraded to
|
|
13
|
+
* `notify-only` and the reason is recorded.
|
|
14
|
+
*/
|
|
15
|
+
export declare function evaluatePreflight(input: AutoUpdatePreflightInput): AutoUpdatePreflightResult;
|
|
16
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../../src/runtime/auto-update/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5E,6DAA6D;AAC7D,MAAM,WAAW,wBAAwB;IACvC,8CAA8C;IAC9C,cAAc,EAAE,cAAc,CAAC;IAC/B,sEAAsE;IACtE,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,wBAAwB,GAAG,yBAAyB,CAc5F"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether the runtime environment can support the configured
|
|
3
|
+
* {@link AutoUpdateMode}. If `auto-apply` is requested but the plugin
|
|
4
|
+
* update command is unavailable, the effective mode is downgraded to
|
|
5
|
+
* `notify-only` and the reason is recorded.
|
|
6
|
+
*/
|
|
7
|
+
export function evaluatePreflight(input) {
|
|
8
|
+
const reasons = [];
|
|
9
|
+
let effectiveMode = input.configuredMode;
|
|
10
|
+
if (input.configuredMode === "auto-apply" && !input.canUpdatePlugin) {
|
|
11
|
+
effectiveMode = "notify-only";
|
|
12
|
+
reasons.push("plugin-update-command-not-available");
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
ok: true,
|
|
16
|
+
effectiveMode,
|
|
17
|
+
reasons,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../../src/runtime/auto-update/preflight.ts"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA+B;IAC/D,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,aAAa,GAAmB,KAAK,CAAC,cAAc,CAAC;IAEzD,IAAI,KAAK,CAAC,cAAc,KAAK,YAAY,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QACpE,aAAa,GAAG,aAAa,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,aAAa;QACb,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AutoUpdateMode, type AutoUpdateState } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reads and writes {@link AutoUpdateState} to a JSON file in the plugin
|
|
4
|
+
* state directory so that deduplication counters and notification history
|
|
5
|
+
* survive gateway restarts.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AutoUpdateStateStore {
|
|
8
|
+
private readonly stateDir;
|
|
9
|
+
private readonly filePath;
|
|
10
|
+
constructor(stateDir: string);
|
|
11
|
+
/**
|
|
12
|
+
* Load persisted state, merging it with fresh defaults for the running
|
|
13
|
+
* version and effective mode. Returns defaults when the file is missing
|
|
14
|
+
* or cannot be parsed.
|
|
15
|
+
*/
|
|
16
|
+
load(currentVersion: string, effectiveMode: AutoUpdateMode): Promise<AutoUpdateState>;
|
|
17
|
+
/** Atomically write the state to disk, creating the directory if needed. */
|
|
18
|
+
save(state: AutoUpdateState): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=state-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-store.d.ts","sourceRoot":"","sources":["../../../src/runtime/auto-update/state-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,qBAAa,oBAAoB;IAGnB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEL,QAAQ,EAAE,MAAM;IAI7C;;;;OAIG;IACG,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAe3F,4EAA4E;IACtE,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAIlD"}
|