podwatch 1.1.8 → 1.2.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.
- package/dist/hooks/config-doctor.d.ts +8 -1
- package/dist/hooks/config-doctor.d.ts.map +1 -1
- package/dist/hooks/config-doctor.js +63 -9
- package/dist/hooks/config-doctor.js.map +1 -1
- package/dist/hooks/lifecycle.d.ts +2 -0
- package/dist/hooks/lifecycle.d.ts.map +1 -1
- package/dist/hooks/lifecycle.js +39 -2
- package/dist/hooks/lifecycle.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +98 -64
- package/dist/index.js.map +1 -1
- package/dist/memory-watcher.d.ts +2 -0
- package/dist/memory-watcher.d.ts.map +1 -1
- package/dist/memory-watcher.js +48 -1
- package/dist/memory-watcher.js.map +1 -1
- package/dist/transmitter.d.ts +6 -0
- package/dist/transmitter.d.ts.map +1 -1
- package/dist/transmitter.js +84 -16
- package/dist/transmitter.js.map +1 -1
- package/dist/updater.d.ts +70 -47
- package/dist/updater.d.ts.map +1 -1
- package/dist/updater.js +340 -220
- package/dist/updater.js.map +1 -1
- package/lib/installer.js +59 -8
- package/openclaw.plugin.json +27 -9
- package/package.json +2 -2
package/dist/updater.d.ts
CHANGED
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* On plugin startup (called from register()), schedules a non-blocking update
|
|
5
5
|
* check after a 30-second delay. If a new version is available on npm (or the
|
|
6
|
-
* Podwatch dashboard fallback), it downloads
|
|
7
|
-
* extensions directory, writes a restart sentinel
|
|
8
|
-
* restart via the OS service manager (systemd / launchctl).
|
|
6
|
+
* Podwatch dashboard fallback), it downloads the tarball via fetch(), verifies
|
|
7
|
+
* integrity, extracts to the extensions directory, and writes a restart sentinel.
|
|
9
8
|
*
|
|
10
9
|
* Safety:
|
|
11
10
|
* - 30s startup delay (don't slow boot)
|
|
12
11
|
* - 24-hour cooldown between checks (cached in a local file)
|
|
13
12
|
* - 5s timeout on all HTTP requests
|
|
14
|
-
* - 120s timeout on npm pack command
|
|
15
13
|
* - All errors caught — never bricks the running plugin
|
|
16
|
-
* -
|
|
14
|
+
* - Rollback: backs up old dist/ before replacing, restores on extraction failure
|
|
15
|
+
* - Plugin NEVER restarts its host — only writes restart sentinel
|
|
16
|
+
* - Auto-update defaults to ON (set autoUpdate: false to disable)
|
|
17
|
+
* - No handleUrgentUpdate — removed as remote code execution vector
|
|
17
18
|
*/
|
|
18
19
|
export declare const AUTO_UPDATE_CACHE_FILE: string;
|
|
19
20
|
/**
|
|
@@ -22,17 +23,10 @@ export declare const AUTO_UPDATE_CACHE_FILE: string;
|
|
|
22
23
|
*/
|
|
23
24
|
export declare function resolveStateDir(): string;
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Read the installed plugin version from disk (extensions dir package.json).
|
|
27
|
+
* Returns null if the file can't be read.
|
|
26
28
|
*/
|
|
27
|
-
export declare function
|
|
28
|
-
/**
|
|
29
|
-
* Resolve the launchd label for the gateway.
|
|
30
|
-
*/
|
|
31
|
-
export declare function resolveGatewayLaunchAgentLabel(profile: string | undefined): string;
|
|
32
|
-
/**
|
|
33
|
-
* Normalize a systemd unit name. Appends .service if missing.
|
|
34
|
-
*/
|
|
35
|
-
export declare function normalizeSystemdUnit(raw: string | undefined, profile: string | undefined): string;
|
|
29
|
+
export declare function getInstalledVersion(): string | null;
|
|
36
30
|
/**
|
|
37
31
|
* Compare two semver-like version strings.
|
|
38
32
|
* Returns positive if remote > local, negative if local > remote, 0 if equal.
|
|
@@ -52,6 +46,8 @@ export interface UpdateCheckResult {
|
|
|
52
46
|
source: "npm" | "dashboard";
|
|
53
47
|
/** SRI integrity hash (e.g. "sha512-<base64>") from npm registry or dashboard. */
|
|
54
48
|
integrityHash?: string;
|
|
49
|
+
/** Direct tarball URL from npm registry (for fetch-based download). */
|
|
50
|
+
tarballUrl?: string;
|
|
55
51
|
}
|
|
56
52
|
/**
|
|
57
53
|
* Check for a newer version. Tries npm registry first, then dashboard API.
|
|
@@ -91,6 +87,19 @@ export declare function parseSriHash(sri: string): {
|
|
|
91
87
|
* - Legacy hex format: plain hex SHA-256 string (from dashboard fallback)
|
|
92
88
|
*/
|
|
93
89
|
export declare function verifyTarballIntegrity(tarballPath: string, expectedHash: string): IntegrityResult;
|
|
90
|
+
/**
|
|
91
|
+
* Back up the existing dist/ directory before replacing it.
|
|
92
|
+
* Returns the backup path, or null if no dist/ exists.
|
|
93
|
+
*/
|
|
94
|
+
export declare function backupDist(extensionsDir: string): string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Restore dist/ from backup after a failed extraction.
|
|
97
|
+
*/
|
|
98
|
+
export declare function restoreFromBackup(extensionsDir: string, backupDir: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Clean up backup after successful extraction.
|
|
101
|
+
*/
|
|
102
|
+
export declare function cleanupBackup(backupDir: string): void;
|
|
94
103
|
export interface UpdateResult {
|
|
95
104
|
success: boolean;
|
|
96
105
|
stdout?: string;
|
|
@@ -100,26 +109,34 @@ export interface UpdateResult {
|
|
|
100
109
|
tarballPath?: string;
|
|
101
110
|
}
|
|
102
111
|
/**
|
|
103
|
-
* Download the
|
|
104
|
-
*
|
|
112
|
+
* Download the podwatch tarball via fetch() from the npm registry URL.
|
|
113
|
+
* No shell commands needed — pure HTTP download.
|
|
105
114
|
*/
|
|
106
|
-
export declare function downloadTarball(): UpdateResult & {
|
|
115
|
+
export declare function downloadTarball(version?: string, tarballUrl?: string): Promise<UpdateResult & {
|
|
107
116
|
tmpDir?: string;
|
|
108
|
-
}
|
|
117
|
+
}>;
|
|
109
118
|
/**
|
|
110
119
|
* Install from a previously downloaded tarball by extracting to the extensions dir.
|
|
120
|
+
* Includes rollback: backs up old dist/ before extraction, restores on failure.
|
|
111
121
|
*/
|
|
112
122
|
export declare function installFromTarball(tarballPath: string): UpdateResult;
|
|
113
123
|
/**
|
|
114
|
-
* Download and install the latest podwatch plugin via
|
|
124
|
+
* Download and install the latest podwatch plugin via fetch + extract.
|
|
115
125
|
* Legacy single-step function — delegates to downloadTarball + installFromTarball.
|
|
116
|
-
*
|
|
117
|
-
* Steps:
|
|
118
|
-
* 1. `npm pack podwatch` in a temp dir to get the tarball
|
|
119
|
-
* 2. Clean old dist in the extensions directory
|
|
120
|
-
* 3. Extract tarball contents to ~/.openclaw/extensions/podwatch/
|
|
121
126
|
*/
|
|
122
127
|
export declare function executeUpdate(): UpdateResult;
|
|
128
|
+
export interface VerifyDistResult {
|
|
129
|
+
ok: boolean;
|
|
130
|
+
error?: string;
|
|
131
|
+
signal?: string;
|
|
132
|
+
timedOut?: boolean;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Verify that the newly installed dist/index.js is loadable.
|
|
136
|
+
* Tries to require() the entry point — if it throws, the new code is broken.
|
|
137
|
+
* Returns a detailed result indicating success or failure reason.
|
|
138
|
+
*/
|
|
139
|
+
export declare function verifyNewDist(extensionsDir: string): VerifyDistResult;
|
|
123
140
|
/**
|
|
124
141
|
* Wait for an idle window before proceeding with a gateway restart.
|
|
125
142
|
*
|
|
@@ -141,12 +158,16 @@ export interface RestartResult {
|
|
|
141
158
|
tried: string[];
|
|
142
159
|
}
|
|
143
160
|
/**
|
|
144
|
-
* Trigger a gateway restart using the OS service manager
|
|
145
|
-
*
|
|
161
|
+
* Trigger a gateway restart using the OS service manager.
|
|
162
|
+
*
|
|
163
|
+
* Safety improvements over original:
|
|
164
|
+
* - Only called AFTER verifyNewDist() confirms the new code loads
|
|
165
|
+
* - Only called AFTER integrity verification passed
|
|
166
|
+
* - Only called AFTER rollback backup is in place
|
|
167
|
+
* - Single attempt — if restart fails, logs error and moves on (no retry loop)
|
|
146
168
|
*
|
|
147
|
-
* Linux: systemctl --user restart <unit>
|
|
169
|
+
* Linux: systemctl --user restart <unit>
|
|
148
170
|
* macOS: launchctl kickstart -k gui/<uid>/<label>
|
|
149
|
-
* Fallback: log a manual restart message
|
|
150
171
|
*/
|
|
151
172
|
export declare function triggerGatewayRestart(logger: {
|
|
152
173
|
info: (msg: string) => void;
|
|
@@ -154,24 +175,23 @@ export declare function triggerGatewayRestart(logger: {
|
|
|
154
175
|
error: (msg: string) => void;
|
|
155
176
|
}): RestartResult;
|
|
156
177
|
export interface UpdateOptions {
|
|
157
|
-
/** Enable auto-update. Default: true
|
|
178
|
+
/** Enable auto-update. Default: true (set to false to disable). */
|
|
158
179
|
autoUpdate?: boolean;
|
|
159
180
|
}
|
|
160
181
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* Called by the transmitter when the API response includes { update: { urgent: true } }.
|
|
182
|
+
* Acquire an exclusive update lock. Returns true if acquired, false if
|
|
183
|
+
* another update is already in progress (or the lock is stale and was reclaimed).
|
|
164
184
|
*/
|
|
165
|
-
export declare function
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
185
|
+
export declare function acquireUpdateLock(): boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Release the update lock.
|
|
188
|
+
*/
|
|
189
|
+
export declare function releaseUpdateLock(): void;
|
|
170
190
|
/**
|
|
171
191
|
* Schedule a non-blocking update check 30s after startup.
|
|
172
192
|
* Safe to call synchronously — it sets a timer and returns immediately.
|
|
173
193
|
*
|
|
174
|
-
* Auto-update is
|
|
194
|
+
* Auto-update is ON by default. Set autoUpdate: false in plugin config to disable.
|
|
175
195
|
*
|
|
176
196
|
* @param currentVersion The plugin's current version from package.json
|
|
177
197
|
* @param endpoint The Podwatch API endpoint (for dashboard fallback)
|
|
@@ -184,17 +204,20 @@ export declare function scheduleUpdateCheck(currentVersion: string, endpoint: st
|
|
|
184
204
|
error: (msg: string) => void;
|
|
185
205
|
}, options?: UpdateOptions): void;
|
|
186
206
|
/**
|
|
187
|
-
* Internal: perform the actual update check + install
|
|
207
|
+
* Internal: perform the actual update check + install.
|
|
188
208
|
*
|
|
189
209
|
* Flow:
|
|
190
|
-
* 1. Check autoUpdate opt-
|
|
210
|
+
* 1. Check autoUpdate opt-out (default on; set autoUpdate: false to disable)
|
|
191
211
|
* 2. Respect 24h cooldown
|
|
192
|
-
* 3.
|
|
193
|
-
* 4.
|
|
194
|
-
* 5.
|
|
195
|
-
* 6.
|
|
196
|
-
* 7.
|
|
197
|
-
* 8.
|
|
212
|
+
* 3. Acquire update lock (prevents concurrent updates)
|
|
213
|
+
* 4. Check for newer version (npm → dashboard fallback)
|
|
214
|
+
* 5. Require integrity hash from server (skip if missing)
|
|
215
|
+
* 6. Download tarball via fetch
|
|
216
|
+
* 7. Verify tarball integrity against server hash
|
|
217
|
+
* 8. Extract and install (with rollback on failure)
|
|
218
|
+
* 9. Verify new dist loads; rollback if broken
|
|
219
|
+
* 10. Write restart sentinel (gateway picks it up on next restart)
|
|
220
|
+
* 11. Wait for idle window, then restart gateway
|
|
198
221
|
*/
|
|
199
222
|
export declare function runUpdateCheck(currentVersion: string, endpoint: string, logger: {
|
|
200
223
|
info: (msg: string) => void;
|
package/dist/updater.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../src/updater.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAkCH,eAAO,MAAM,sBAAsB,QAA6C,CAAC;AAQjF;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAKxC;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAcnD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAiBrE;AAMD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAY9C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAU1C;AAMD,MAAM,WAAW,iBAAiB;I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