@senpi/runtime 1.1.0-dev.runtime-phase-2.20260513122539 → 1.1.0-dev.runtime-phase-2.20260514144638
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/cli/senpi-cli-config.d.ts +15 -1
- package/dist/cli/senpi-cli-config.d.ts.map +1 -1
- package/dist/cli/senpi-cli-config.js +19 -2
- package/dist/cli/senpi-cli-config.js.map +1 -1
- package/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +4 -1
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/index.d.ts +17 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -11
- package/dist/index.js.map +1 -1
- package/dist/runtime/auto-update/coordinator.d.ts +13 -0
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +22 -8
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/skills-manager/bootstrap.d.ts.map +1 -1
- package/dist/skills-manager/bootstrap.js +34 -16
- package/dist/skills-manager/bootstrap.js.map +1 -1
- package/dist/skills-manager/constants.d.ts +20 -1
- package/dist/skills-manager/constants.d.ts.map +1 -1
- package/dist/skills-manager/constants.js +26 -1
- package/dist/skills-manager/constants.js.map +1 -1
- package/dist/skills-manager/coordinator.d.ts +157 -20
- package/dist/skills-manager/coordinator.d.ts.map +1 -1
- package/dist/skills-manager/coordinator.js +289 -86
- package/dist/skills-manager/coordinator.js.map +1 -1
- package/dist/skills-manager/index.d.ts +1 -1
- package/dist/skills-manager/index.d.ts.map +1 -1
- package/dist/skills-manager/index.js +1 -1
- package/dist/skills-manager/index.js.map +1 -1
- package/dist/skills-manager/state-store.d.ts +27 -4
- package/dist/skills-manager/state-store.d.ts.map +1 -1
- package/dist/skills-manager/state-store.js +42 -16
- package/dist/skills-manager/state-store.js.map +1 -1
- package/dist/skills-manager/types.d.ts +46 -8
- package/dist/skills-manager/types.d.ts.map +1 -1
- package/dist/skills-manager/utils.d.ts +17 -0
- package/dist/skills-manager/utils.d.ts.map +1 -1
- package/dist/skills-manager/utils.js +43 -11
- package/dist/skills-manager/utils.js.map +1 -1
- package/dist/skills-manager/version-manager.d.ts +93 -8
- package/dist/skills-manager/version-manager.d.ts.map +1 -1
- package/dist/skills-manager/version-manager.js +185 -28
- package/dist/skills-manager/version-manager.js.map +1 -1
- package/openclaw.plugin.json +7 -9
- package/package.json +1 -1
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Central lifecycle manager for Senpi skills auto-update.
|
|
3
3
|
*
|
|
4
|
-
* Mirrors AutoUpdateCoordinator from src/runtime/auto-update/coordinator.ts
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* testability.
|
|
4
|
+
* Mirrors AutoUpdateCoordinator from src/runtime/auto-update/coordinator.ts
|
|
5
|
+
* for thread-safety (runToken + stopped + running triple) and uses the same
|
|
6
|
+
* injectable-dependency pattern for testability.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Scheduling: this coordinator does not own a timer. Ticks fire from
|
|
9
|
+
* outside — currently from auto-update's `onTickComplete` hook in
|
|
10
|
+
* `src/index.ts`, which calls {@link SkillsUpdateCoordinator.runTickOnce}
|
|
11
|
+
* after every auto-update cycle. Skills-manager therefore inherits the
|
|
12
|
+
* `autoUpdate.pollIntervalMinutes` cadence and the same failure-backoff
|
|
13
|
+
* cadence.
|
|
14
|
+
*
|
|
15
|
+
* On start(): load persisted state, bootstrap any missing skills, mark
|
|
16
|
+
* health as healthy. The first tick fires on the next external invocation
|
|
17
|
+
* of `runTickOnce()`.
|
|
18
|
+
*
|
|
19
|
+
* Each tick: resolve skill names (configured list or discovery), check
|
|
20
|
+
* remote versions in parallel, auto-apply patch/minor, notify on major
|
|
21
|
+
* (deduped by version), skip on none/unknown.
|
|
12
22
|
*/
|
|
13
23
|
import type { SkillsManagerSnapshot, SkillsUpdateCoordinatorOptions } from "./types.js";
|
|
24
|
+
export declare class SkillsCoordinatorUnavailableError extends Error {
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
14
27
|
export declare class SkillsUpdateCoordinator {
|
|
15
28
|
private readonly options;
|
|
16
29
|
private readonly store;
|
|
17
|
-
private timer;
|
|
18
30
|
private operationChain;
|
|
19
31
|
private stopped;
|
|
20
32
|
private runToken;
|
|
@@ -22,17 +34,81 @@ export declare class SkillsUpdateCoordinator {
|
|
|
22
34
|
private snapshot;
|
|
23
35
|
/** Latest remote version per skill name — populated during ticks. */
|
|
24
36
|
private latestVersions;
|
|
37
|
+
/**
|
|
38
|
+
* Local (pre-install) version per skill name — populated during ticks
|
|
39
|
+
* and manual RPC paths from `SkillVersionInfo.localVersion`. Used by the
|
|
40
|
+
* update-summary and major-available notifications to render the
|
|
41
|
+
* `prev → new` transition. Captured *before* the install runs so the
|
|
42
|
+
* value still reflects the on-disk version at the time the user chose to
|
|
43
|
+
* update; reading `state.skills[name].installedVersion` instead would
|
|
44
|
+
* surface the *post-install* version (recorded by `recordSuccess`) and
|
|
45
|
+
* collapse the transition to `vX -> vX`.
|
|
46
|
+
*/
|
|
47
|
+
private previousVersions;
|
|
48
|
+
/**
|
|
49
|
+
* Cached short descriptions parsed from each skill's **remote** SKILL.md
|
|
50
|
+
* frontmatter — i.e. the description for the upcoming/current remote
|
|
51
|
+
* version, not whatever's installed locally. Used to enrich
|
|
52
|
+
* update-summary and major-available notifications with a one-line
|
|
53
|
+
* "About:" so the user gets context for the version the message is
|
|
54
|
+
* actually announcing.
|
|
55
|
+
*
|
|
56
|
+
* Populated during tick / updateSkill / updateAll alongside
|
|
57
|
+
* `latestVersions`; absent / null entries simply omit the line from the
|
|
58
|
+
* notification.
|
|
59
|
+
*
|
|
60
|
+
* Using the remote description (rather than the local one) keeps the
|
|
61
|
+
* notification description in sync with the version number it sits next
|
|
62
|
+
* to — e.g. when notifying about a major bump v1 → v2, the "About:" line
|
|
63
|
+
* reflects the v2 description, even if the v1 local copy on disk is
|
|
64
|
+
* stale or worded differently.
|
|
65
|
+
*/
|
|
66
|
+
private skillDescriptions;
|
|
25
67
|
constructor(options: SkillsUpdateCoordinatorOptions);
|
|
26
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Load persisted state and bootstrap missing skills. Does **not** schedule
|
|
70
|
+
* a poll loop — skills-manager runs off the auto-update coordinator's
|
|
71
|
+
* `onTickComplete` hook (see `src/index.ts`), which invokes
|
|
72
|
+
* {@link runTickOnce} on whatever cadence auto-update is configured with.
|
|
73
|
+
*
|
|
74
|
+
* Calling `start()` is still required even in the externally-scheduled
|
|
75
|
+
* mode so bootstrap, state load, and the "ready" snapshot all happen
|
|
76
|
+
* before the first external tick fires.
|
|
77
|
+
*/
|
|
27
78
|
start(): Promise<void>;
|
|
28
79
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
80
|
+
* Stop the coordinator: prevent any new ticks from being processed, and
|
|
81
|
+
* wait for any in-flight tick or manual RPC to finish so the caller can
|
|
82
|
+
* rely on no async work still touching state after `stop()` resolves.
|
|
83
|
+
*
|
|
84
|
+
* Since scheduling is now external (auto-update's `onTickComplete` hook),
|
|
85
|
+
* there's no internal timer to cancel — `stop()` just flips the `stopped`
|
|
86
|
+
* flag (which `runTickOnce` checks) and drains the serialised operation
|
|
87
|
+
* queue. The auto-update hook itself becomes a no-op for stopped
|
|
88
|
+
* coordinators since `runTickOnce` returns early.
|
|
34
89
|
*/
|
|
35
90
|
stop(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Public one-shot tick entry point. Called externally on whatever cadence
|
|
93
|
+
* the host wires up — currently from the auto-update coordinator's
|
|
94
|
+
* `onTickComplete` hook in `src/index.ts`, which fires after each
|
|
95
|
+
* auto-update version check completes (success or failure).
|
|
96
|
+
*
|
|
97
|
+
* Replaces the previous internal `tick()` + `scheduleNext()` pair: the
|
|
98
|
+
* coordinator no longer owns a timer of its own. Manual RPCs
|
|
99
|
+
* (`senpi.skills.update`, `senpi.skills.updateAll`) remain independent of
|
|
100
|
+
* this path.
|
|
101
|
+
*
|
|
102
|
+
* Returns early as a no-op when:
|
|
103
|
+
* - The coordinator has been stopped (e.g. plugin teardown).
|
|
104
|
+
* - The runToken has rolled (e.g. a stop/start cycle invalidated this call).
|
|
105
|
+
* - The coordinator was disabled at start time (config.enabled === false).
|
|
106
|
+
*
|
|
107
|
+
* Tick errors are logged + recorded on the snapshot but never thrown —
|
|
108
|
+
* the caller (auto-update) must not have its own scheduling disturbed by
|
|
109
|
+
* a transient skills-manager failure.
|
|
110
|
+
*/
|
|
111
|
+
runTickOnce(): Promise<void>;
|
|
36
112
|
/** Return the latest point-in-time snapshot for gateway RPCs. */
|
|
37
113
|
getSnapshot(): SkillsManagerSnapshot;
|
|
38
114
|
/**
|
|
@@ -66,13 +142,18 @@ export declare class SkillsUpdateCoordinator {
|
|
|
66
142
|
version: string | null;
|
|
67
143
|
error?: string;
|
|
68
144
|
}>>;
|
|
69
|
-
private scheduleNext;
|
|
70
|
-
private tick;
|
|
71
145
|
/**
|
|
72
146
|
* Run coordinator work in a global critical section so periodic ticks and
|
|
73
147
|
* manual RPC updates never interleave at await points.
|
|
74
148
|
*/
|
|
75
149
|
private runSerialized;
|
|
150
|
+
/**
|
|
151
|
+
* Manual gateway RPCs (`updateSkill`, `updateAll`) are only valid while the
|
|
152
|
+
* coordinator is actively running and enabled. This prevents pre-start calls
|
|
153
|
+
* (e.g. when SENPI_RUNTIME_API_DISABLED=true skipped start()) from persisting
|
|
154
|
+
* the constructor-default empty state over a valid on-disk state file.
|
|
155
|
+
*/
|
|
156
|
+
private assertManualOperationAllowed;
|
|
76
157
|
/**
|
|
77
158
|
* Core tick logic: resolve skill names, check versions in parallel, apply
|
|
78
159
|
* policy per skill, then run a single clone for all skills needing update.
|
|
@@ -148,6 +229,39 @@ export declare class SkillsUpdateCoordinator {
|
|
|
148
229
|
* caller via a rejected promise (batch path captures it instead).
|
|
149
230
|
*/
|
|
150
231
|
private applyUpdate;
|
|
232
|
+
/**
|
|
233
|
+
* Format the per-skill nested-bullet block used in both notification
|
|
234
|
+
* shapes. Renders the structure suggested in PR #78 review feedback:
|
|
235
|
+
*
|
|
236
|
+
* **skill-name**
|
|
237
|
+
* • v1.0.0 → v2.0.0 (or "v1.0.0 (install failed)" when failed)
|
|
238
|
+
* • description: … (omitted when no remote description)
|
|
239
|
+
* • error: … (only on failure, replaces the description)
|
|
240
|
+
*
|
|
241
|
+
* **Why markdown, not HTML?**
|
|
242
|
+
* Openclaw's Telegram channel (`src/telegram/send.ts:sendMessageTelegram`)
|
|
243
|
+
* pipes outbound text through `renderTelegramHtmlText`, which defaults
|
|
244
|
+
* `textMode` to `"markdown"` — i.e. it expects the source to be markdown
|
|
245
|
+
* and runs `markdownToTelegramHtml` over it before handing the converted
|
|
246
|
+
* HTML to the Bot API with `parse_mode: "HTML"`. The `message` tool
|
|
247
|
+
* (which is what this coordinator's `notify` callback ultimately hits via
|
|
248
|
+
* `/tools/invoke`) does not expose `textMode`, so HTML written by us is
|
|
249
|
+
* treated as literal characters by the markdown step and rendered as
|
|
250
|
+
* visible `<b>` text in the chat (the actual production bug this docstring
|
|
251
|
+
* fixes — confirmed against a live notification screenshot).
|
|
252
|
+
*
|
|
253
|
+
* Using markdown source (`**bold**`, backticks) instead means the channel's
|
|
254
|
+
* markdown→HTML converter produces the correct `<b>` / `<code>` HTML
|
|
255
|
+
* payload and Telegram renders the formatting properly.
|
|
256
|
+
*
|
|
257
|
+
* @param skillName Skill identifier (rendered bold via `**name**`).
|
|
258
|
+
* @param toVersion Resolved upgraded-to version. `null` for failure rows
|
|
259
|
+
* where no install completed; renders as
|
|
260
|
+
* "vPREV (install failed)".
|
|
261
|
+
* @param errorReason Optional failure reason. When provided, replaces
|
|
262
|
+
* the description line with `error: …`.
|
|
263
|
+
*/
|
|
264
|
+
private formatSkillBlock;
|
|
151
265
|
/**
|
|
152
266
|
* Send a one-way Telegram notification for a pending major update, deduped
|
|
153
267
|
* by version.
|
|
@@ -164,6 +278,27 @@ export declare class SkillsUpdateCoordinator {
|
|
|
164
278
|
* so the user can tell which skills still need attention. Sections with no
|
|
165
279
|
* entries are omitted. If neither section has entries, no notification is
|
|
166
280
|
* sent.
|
|
281
|
+
*
|
|
282
|
+
* Format (markdown source — see `formatSkillBlock` for why markdown
|
|
283
|
+
* rather than HTML):
|
|
284
|
+
*
|
|
285
|
+
* Senpi skills update:
|
|
286
|
+
*
|
|
287
|
+
* Updated:
|
|
288
|
+
*
|
|
289
|
+
* **skill-a**
|
|
290
|
+
* • v1.0.0 → v1.0.1
|
|
291
|
+
* • description: …
|
|
292
|
+
*
|
|
293
|
+
* **skill-b**
|
|
294
|
+
* • v2.0.0 → v2.0.1
|
|
295
|
+
* • description: …
|
|
296
|
+
*
|
|
297
|
+
* Failed to update:
|
|
298
|
+
*
|
|
299
|
+
* **skill-c**
|
|
300
|
+
* • v1.0.0 (install failed)
|
|
301
|
+
* • error: clone failed: …
|
|
167
302
|
*/
|
|
168
303
|
private sendUpdateSummary;
|
|
169
304
|
/**
|
|
@@ -179,7 +314,12 @@ export declare class SkillsUpdateCoordinator {
|
|
|
179
314
|
/**
|
|
180
315
|
* Resolve the list of skill names to check this tick.
|
|
181
316
|
* Uses `config.skills` when non-empty; otherwise discovers all immediate
|
|
182
|
-
* subdirectories
|
|
317
|
+
* subdirectories across every dir in the `skillsDir` search path,
|
|
318
|
+
* deduped by name and sorted.
|
|
319
|
+
*
|
|
320
|
+
* Per-dir read errors (other than ENOENT) are logged but do not abort the
|
|
321
|
+
* scan — a misconfigured secondary dir cannot mask skills present in the
|
|
322
|
+
* primary.
|
|
183
323
|
*/
|
|
184
324
|
private resolveSkillNames;
|
|
185
325
|
/**
|
|
@@ -195,9 +335,6 @@ export declare class SkillsUpdateCoordinator {
|
|
|
195
335
|
* 3. Caller-supplied lifecycle metadata — `health`, `lastAction`,
|
|
196
336
|
* `lastError` describing the most recent tick / manual RPC outcome.
|
|
197
337
|
*
|
|
198
|
-
* `nextCheckAt` is preserved from the previous snapshot so callers always
|
|
199
|
-
* see a valid ETA even on transient rebuilds (e.g. mid-tick error paths).
|
|
200
|
-
*
|
|
201
338
|
* This is called at every state-mutating boundary (start, tick complete,
|
|
202
339
|
* tick error, manual update complete, manual update skipped, manual update
|
|
203
340
|
* clone failed, stop/disable) so the next RPC response reflects the latest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../src/skills-manager/coordinator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../src/skills-manager/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,OAAO,KAAK,EAMV,qBAAqB,EAGrB,8BAA8B,EAC/B,MAAM,YAAY,CAAC;AAIpB,qBAAa,iCAAkC,SAAQ,KAAK;gBAC9C,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,uBAAuB;IAwCtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAvCpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA0B;IAChD,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,KAAK,CAAyD;IACtE,OAAO,CAAC,QAAQ,CAAwB;IACxC,qEAAqE;IACrE,OAAO,CAAC,cAAc,CAAoC;IAC1D;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB,CAAoC;IAC5D;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,iBAAiB,CAAoC;gBAEhC,OAAO,EAAE,8BAA8B;IAKpE;;;;;;;;;OASG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B5B;;;;;;;;;;OAUG;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