@senpi-ai/runtime 1.0.99 → 1.1.1

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 (57) hide show
  1. package/dist/cli/senpi-cli-config.d.ts +15 -1
  2. package/dist/cli/senpi-cli-config.d.ts.map +1 -1
  3. package/dist/cli/senpi-cli-config.js +19 -2
  4. package/dist/cli/senpi-cli-config.js.map +1 -1
  5. package/dist/cli/senpi-commands.d.ts.map +1 -1
  6. package/dist/cli/senpi-commands.js +163 -0
  7. package/dist/cli/senpi-commands.js.map +1 -1
  8. package/dist/index.d.ts +21 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +98 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/runtime/auto-update/coordinator.d.ts +13 -0
  13. package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
  14. package/dist/runtime/auto-update/coordinator.js +22 -8
  15. package/dist/runtime/auto-update/coordinator.js.map +1 -1
  16. package/dist/skills-manager/bootstrap.d.ts +26 -0
  17. package/dist/skills-manager/bootstrap.d.ts.map +1 -0
  18. package/dist/skills-manager/bootstrap.js +86 -0
  19. package/dist/skills-manager/bootstrap.js.map +1 -0
  20. package/dist/skills-manager/constants.d.ts +65 -0
  21. package/dist/skills-manager/constants.d.ts.map +1 -0
  22. package/dist/skills-manager/constants.js +91 -0
  23. package/dist/skills-manager/constants.js.map +1 -0
  24. package/dist/skills-manager/coordinator.d.ts +346 -0
  25. package/dist/skills-manager/coordinator.d.ts.map +1 -0
  26. package/dist/skills-manager/coordinator.js +1037 -0
  27. package/dist/skills-manager/coordinator.js.map +1 -0
  28. package/dist/skills-manager/fetcher.d.ts +28 -0
  29. package/dist/skills-manager/fetcher.d.ts.map +1 -0
  30. package/dist/skills-manager/fetcher.js +92 -0
  31. package/dist/skills-manager/fetcher.js.map +1 -0
  32. package/dist/skills-manager/index.d.ts +5 -0
  33. package/dist/skills-manager/index.d.ts.map +1 -0
  34. package/dist/skills-manager/index.js +4 -0
  35. package/dist/skills-manager/index.js.map +1 -0
  36. package/dist/skills-manager/state-store.d.ts +57 -0
  37. package/dist/skills-manager/state-store.d.ts.map +1 -0
  38. package/dist/skills-manager/state-store.js +129 -0
  39. package/dist/skills-manager/state-store.js.map +1 -0
  40. package/dist/skills-manager/types.d.ts +177 -0
  41. package/dist/skills-manager/types.d.ts.map +1 -0
  42. package/dist/skills-manager/types.js +2 -0
  43. package/dist/skills-manager/types.js.map +1 -0
  44. package/dist/skills-manager/utils.d.ts +81 -0
  45. package/dist/skills-manager/utils.d.ts.map +1 -0
  46. package/dist/skills-manager/utils.js +143 -0
  47. package/dist/skills-manager/utils.js.map +1 -0
  48. package/dist/skills-manager/version-manager.d.ts +146 -0
  49. package/dist/skills-manager/version-manager.d.ts.map +1 -0
  50. package/dist/skills-manager/version-manager.js +299 -0
  51. package/dist/skills-manager/version-manager.js.map +1 -0
  52. package/dist/skills-manager/writer.d.ts +28 -0
  53. package/dist/skills-manager/writer.d.ts.map +1 -0
  54. package/dist/skills-manager/writer.js +101 -0
  55. package/dist/skills-manager/writer.js.map +1 -0
  56. package/openclaw.plugin.json +41 -1
  57. package/package.json +3 -1
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Version detection for Senpi skills.
3
+ *
4
+ * Reads the installed SKILL.md version from disk and the remote version from
5
+ * raw.githubusercontent.com, then uses the existing semver helpers from
6
+ * src/runtime/auto-update/policy.ts to classify the delta.
7
+ */
8
+ import { readFile } from "node:fs/promises";
9
+ import { join } from "node:path";
10
+ import { classifyUpdate, parseSemver } from "../runtime/auto-update/policy.js";
11
+ import { SKILLS_RAW_BASE_URL } from "./constants.js";
12
+ import { formatErr } from "./utils.js";
13
+ /**
14
+ * Normalise a version string before passing it to parseSemver / classifyUpdate.
15
+ *
16
+ * Accepts two-part versions used in production skills (e.g. "1.0", "v2.3")
17
+ * and expands them to the full three-part form ("1.0.0", "v2.3.0") that
18
+ * parseSemver requires. All other strings are returned unchanged.
19
+ */
20
+ export function normalizeVersion(v) {
21
+ return /^v?\d+\.\d+$/.test(v.trim()) ? `${v.trim()}.0` : v;
22
+ }
23
+ /**
24
+ * Extract the `version` value from a SKILL.md YAML frontmatter block.
25
+ *
26
+ * Handles both nested form:
27
+ * metadata:
28
+ * version: 1.2.3
29
+ * and flat form:
30
+ * version: "1.2.3"
31
+ *
32
+ * Returns null when the frontmatter block is absent or the field is missing.
33
+ */
34
+ export function parseSkillMdVersion(content) {
35
+ const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(content.trim());
36
+ if (!match)
37
+ return null;
38
+ const frontmatter = match[1];
39
+ const versionMatch = /(?:^|\n)[ \t]*version:[ \t]*["']?([^\s"'\r\n]+)["']?/i.exec(frontmatter);
40
+ return versionMatch ? versionMatch[1].trim() : null;
41
+ }
42
+ /**
43
+ * Extract the `description` value from a SKILL.md YAML frontmatter block.
44
+ *
45
+ * Skill descriptions can be authored a few different ways. This helper
46
+ * handles the real-world shapes that appear in the senpi-skills repo today:
47
+ *
48
+ * 1. Single-line, double-quoted:
49
+ * description: "Configure, deploy, ..."
50
+ * 2. Single-line, single-quoted or unquoted:
51
+ * description: Manage runtimes ...
52
+ * 3. YAML block scalar (folded or literal, optional chomping indicator):
53
+ * description: >
54
+ * A short summary
55
+ * continues on this line.
56
+ * description: >- # strip trailing newlines (this PR's senpi-skills repo)
57
+ * A short summary
58
+ * description: | # literal — preserves newlines (collapsed to spaces here)
59
+ * A short summary
60
+ * description: |+ # keep trailing newlines (same handling)
61
+ *
62
+ * The block scalar header is `[>|][-+]?` per the YAML 1.2 spec:
63
+ * `>` = folded, `|` = literal; `-` strips trailing newlines,
64
+ * `+` keeps them, no indicator clips. For notification rendering we
65
+ * always collapse to a single line joined by spaces, so the chomping
66
+ * indicator only affects whether we match the block-scalar branch.
67
+ *
68
+ * Returns null when the field is absent or the frontmatter block is missing.
69
+ *
70
+ * Note: kept as a regex extractor rather than introducing a full YAML
71
+ * parse here — `parseSkillMdVersion` uses the same approach, and skill
72
+ * frontmatters are constrained enough that the regex covers the shapes we
73
+ * actually encounter. If we ever adopt a full YAML parser for this file,
74
+ * both helpers should switch together.
75
+ */
76
+ export function parseSkillMdDescription(content) {
77
+ const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(content.trim());
78
+ if (!match)
79
+ return null;
80
+ const frontmatter = match[1];
81
+ // Shape 3: block scalar — `description:` followed by a `>` or `|` header
82
+ // (optionally with a `-` / `+` chomping indicator) on its own line, then
83
+ // indented continuation lines. Stop at the first un-indented line or the
84
+ // end of frontmatter. We collapse the indent and join lines into a single
85
+ // string so the notification renderer doesn't emit raw YAML continuations.
86
+ //
87
+ // Pre-fix this regex was `[>|]` (no indicator). A SKILL.md authored with
88
+ // `description: >-` (the YAML strip-trailing-newlines variant — what the
89
+ // senpi-skills repo actually uses) didn't match, fell through to the
90
+ // inline branch, and ended up capturing the literal "`>-`" as the value.
91
+ // That's the bug report this fixes: the Telegram notification showed
92
+ // `>-` instead of the real description.
93
+ const foldedMatch = /(?:^|\n)description:[ \t]*[>|][-+]?[ \t]*\r?\n([\s\S]*?)(?=\n[^\s]|\n?$)/i.exec(frontmatter);
94
+ if (foldedMatch) {
95
+ const lines = foldedMatch[1]
96
+ .split(/\r?\n/)
97
+ .map((l) => l.replace(/^[ \t]+/, "").trim())
98
+ .filter((l) => l.length > 0);
99
+ if (lines.length > 0)
100
+ return lines.join(" ");
101
+ }
102
+ // Shapes 1 + 2: single-line value. Allow optional surrounding quotes.
103
+ // The value runs to the end of the line; trailing whitespace + matching
104
+ // closing quote stripped.
105
+ const inlineMatch = /(?:^|\n)description:[ \t]*(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|([^\r\n]+?))[ \t]*(?:\r?\n|$)/i
106
+ .exec(frontmatter);
107
+ if (inlineMatch) {
108
+ // Unescape `\"` and `\\` for double-quoted form; single-quoted is taken
109
+ // literally per YAML (no escapes). Unquoted form passes through.
110
+ const raw = inlineMatch[1] ?? inlineMatch[2] ?? inlineMatch[3] ?? "";
111
+ const value = inlineMatch[1]
112
+ ? raw.replace(/\\(["\\])/g, "$1")
113
+ : raw;
114
+ const trimmed = value.trim();
115
+ return trimmed.length > 0 ? trimmed : null;
116
+ }
117
+ return null;
118
+ }
119
+ // `summarizeDescription` (sentence-cut + char-cap truncator) was removed
120
+ // alongside the notification reformat in PR #78. The new nested-bullet
121
+ // notification format renders the full description verbatim so users get
122
+ // the complete context for the skill they're being notified about.
123
+ // Telegram's own 4096-char message limit is the only remaining ceiling,
124
+ // and skill descriptions in the senpi-skills repo are nowhere near that.
125
+ /**
126
+ * Read both the installed version and description for a skill from its local
127
+ * SKILL.md. Shared core for `readLocalVersion` and `readLocalDescription` so a
128
+ * tick that needs both pays a single file read per dir rather than two.
129
+ *
130
+ * Multi-dir search path: tries each entry in order and returns the first
131
+ * readable SKILL.md's parsed fields. Either field may be null if absent in
132
+ * the frontmatter — that's distinct from "no SKILL.md found at all" (which
133
+ * returns nulls only after every dir has been tried).
134
+ */
135
+ export async function readLocalSkillMetadata(skillsDir, skillName, logger) {
136
+ const dirs = typeof skillsDir === "string" ? [skillsDir] : skillsDir;
137
+ for (const dir of dirs) {
138
+ const filePath = join(dir, skillName, "SKILL.md");
139
+ try {
140
+ const content = await readFile(filePath, "utf8");
141
+ // First readable SKILL.md wins, even if its fields are missing —
142
+ // a present-but-versionless file is meaningful state (skill predates
143
+ // versioning), not a "not found" signal that should let the next dir
144
+ // override it.
145
+ return {
146
+ version: parseSkillMdVersion(content),
147
+ description: parseSkillMdDescription(content),
148
+ };
149
+ }
150
+ catch (err) {
151
+ if (err.code === "ENOENT") {
152
+ continue; // try next dir
153
+ }
154
+ logger?.warn(`[senpi-skills-manager] failed to read SKILL.md for "${skillName}" | path=${filePath} err=${formatErr(err)}`);
155
+ // Non-ENOENT (permissions, I/O error) — log and keep trying the
156
+ // remaining dirs rather than short-circuit; if one mirror is broken,
157
+ // a healthy mirror further down the path should still serve metadata.
158
+ }
159
+ }
160
+ return { version: null, description: null };
161
+ }
162
+ /**
163
+ * Read the installed version for a skill from its local SKILL.md.
164
+ *
165
+ * Accepts either a single dir (legacy callers) or an array of dirs (new
166
+ * multi-dir search path). When given an array, tries each entry in order and
167
+ * returns the first non-null match — this mirrors the documented behaviour
168
+ * that `skillsDir[0]` is the *primary* (writes go here) and the remaining
169
+ * entries are read-only fallbacks scanned during version checks.
170
+ *
171
+ * Returns null when no readable SKILL.md is found across any of the
172
+ * candidate dirs, or when the version field is absent. Logs a warning per
173
+ * dir for unexpected errors (anything other than ENOENT).
174
+ */
175
+ export async function readLocalVersion(skillsDir, skillName, logger) {
176
+ return (await readLocalSkillMetadata(skillsDir, skillName, logger)).version;
177
+ }
178
+ /**
179
+ * Read the installed description for a skill from its local SKILL.md.
180
+ * Multi-dir search path semantics identical to `readLocalVersion`.
181
+ *
182
+ * Returns null when no readable SKILL.md is found across any of the
183
+ * candidate dirs, or when the description field is absent.
184
+ */
185
+ export async function readLocalDescription(skillsDir, skillName, logger) {
186
+ return (await readLocalSkillMetadata(skillsDir, skillName, logger)).description;
187
+ }
188
+ /**
189
+ * Fetch the remote SKILL.md for a skill and return both the version and the
190
+ * description in one network round-trip.
191
+ *
192
+ * Notification text uses the description from the **remote** SKILL.md (not
193
+ * the local one) so the "About:" line reflects the version the user is being
194
+ * asked about — a description on disk for v1.x may be stale relative to the
195
+ * v2.0.0 the major-update notification is announcing.
196
+ *
197
+ * Returns null fields when the skill does not exist in the remote repo
198
+ * (HTTP 404) — that's a legitimate state ("skill removed or not yet
199
+ * published"), not an error, so it should not pollute failure counters.
200
+ * Both fields may also be null when the remote SKILL.md is present but
201
+ * its frontmatter omits the corresponding field.
202
+ *
203
+ * Throws on transient/operational failures (network errors, timeouts, 5xx
204
+ * responses, body-parse failures) so the caller's failure-recording path can
205
+ * fire.
206
+ *
207
+ * @param fetchImpl Injectable for unit testing — defaults to global `fetch`.
208
+ */
209
+ export async function fetchRemoteSkillMetadata(skillName, rawBaseUrl = SKILLS_RAW_BASE_URL, fetchImpl = fetch) {
210
+ const url = `${rawBaseUrl}/${encodeURIComponent(skillName)}/SKILL.md`;
211
+ let res;
212
+ try {
213
+ res = await fetchImpl(url, { signal: AbortSignal.timeout(15_000) });
214
+ }
215
+ catch (err) {
216
+ throw new Error(`Network error fetching remote SKILL.md for "${skillName}": ${formatErr(err)}`);
217
+ }
218
+ // 404 = skill is not in the remote repo. Treated as "no remote metadata"
219
+ // rather than a failure so the caller can skip cleanly without escalating.
220
+ if (res.status === 404) {
221
+ return { version: null, description: null };
222
+ }
223
+ if (!res.ok) {
224
+ throw new Error(`Failed to fetch remote SKILL.md for "${skillName}": HTTP ${res.status} ${res.statusText}`);
225
+ }
226
+ try {
227
+ const text = await res.text();
228
+ return {
229
+ version: parseSkillMdVersion(text),
230
+ description: parseSkillMdDescription(text),
231
+ };
232
+ }
233
+ catch (err) {
234
+ throw new Error(`Failed to read response body for "${skillName}": ${formatErr(err)}`);
235
+ }
236
+ }
237
+ /**
238
+ * Fetch the remote SKILL.md for a skill and return its version.
239
+ *
240
+ * Thin wrapper over {@link fetchRemoteSkillMetadata} kept for backward
241
+ * compatibility with callers (and tests) that only need the version field.
242
+ * New code that wants both version + description in a single round-trip
243
+ * should call `fetchRemoteSkillMetadata` directly.
244
+ */
245
+ export async function fetchRemoteVersion(skillName, rawBaseUrl = SKILLS_RAW_BASE_URL, fetchImpl = fetch) {
246
+ return (await fetchRemoteSkillMetadata(skillName, rawBaseUrl, fetchImpl)).version;
247
+ }
248
+ /**
249
+ * Compare the local and remote versions for a skill and return a classified diff.
250
+ *
251
+ * Special cases:
252
+ * - Local version is null (skill predates versioning) + valid remote → "minor"
253
+ * so the update is auto-applied without manual major-version approval.
254
+ * - Local version exists but is not valid semver (e.g. "latest") → "unknown",
255
+ * skip safely.
256
+ * - Remote version is absent or unparseable → "unknown", caller should log and
257
+ * skip.
258
+ */
259
+ export async function checkSkillVersion(skillsDir, skillName, rawBaseUrl = SKILLS_RAW_BASE_URL, fetchImpl = fetch, logger) {
260
+ // Fetch the remote SKILL.md once and extract both version + description.
261
+ // Description is reported back to the coordinator so notifications can
262
+ // surface the *remote* (i.e. upcoming-version) description rather than the
263
+ // local one, which may be stale relative to the version the notification
264
+ // is announcing.
265
+ //
266
+ // Log the specific fetch failure for traceability, then re-throw so the
267
+ // coordinator records it as a check failure (consecutiveFailures,
268
+ // lastFailureReason). 404 is intentionally returned as null inside
269
+ // fetchRemoteSkillMetadata and never reaches this catch.
270
+ const remoteMetadataPromise = fetchRemoteSkillMetadata(skillName, rawBaseUrl, fetchImpl).catch((err) => {
271
+ logger?.warn(`[senpi-skills-manager] failed to fetch remote SKILL.md for "${skillName}" | err=${formatErr(err)}`);
272
+ throw err;
273
+ });
274
+ const [localVersion, remoteMetadata] = await Promise.all([
275
+ readLocalVersion(skillsDir, skillName, logger),
276
+ remoteMetadataPromise,
277
+ ]);
278
+ const { version: remoteVersion, description: remoteDescription } = remoteMetadata;
279
+ const normalizedRemote = normalizeVersion(remoteVersion ?? "");
280
+ if (!remoteVersion || !parseSemver(normalizedRemote)) {
281
+ return { localVersion, remoteVersion, updateKind: "unknown", remoteDescription };
282
+ }
283
+ // Skill has never had a version in SKILL.md (null) — predates the versioning
284
+ // system or was installed before the field was added. Treat as a minor update
285
+ // so it is auto-applied without requiring a manual major-version approval.
286
+ if (localVersion === null) {
287
+ return { localVersion, remoteVersion, updateKind: "minor", remoteDescription };
288
+ }
289
+ const normalizedLocal = normalizeVersion(localVersion);
290
+ // Local version string exists but is not valid semver even after normalisation
291
+ // (e.g. "latest", "nightly"). We cannot safely compare, so skip.
292
+ if (!parseSemver(normalizedLocal)) {
293
+ return { localVersion, remoteVersion, updateKind: "unknown", remoteDescription };
294
+ }
295
+ // classifyUpdate returns AutoUpdateKind which is a strict subset of SkillUpdateKind
296
+ const updateKind = classifyUpdate(normalizedLocal, normalizedRemote);
297
+ return { localVersion, remoteVersion, updateKind, remoteDescription };
298
+ }
299
+ //# sourceMappingURL=version-manager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AAG,CAAC;QACvD,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;QAC9C,qBAAqB;KACtB,CAAC,CAAC;IACH,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,cAAc,CAAC;IAElF,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IAC/D,IAAI,CAAC,aAAa,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACrD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;IACnF,CAAC;IAED,6EAA6E;IAC7E,8EAA8E;IAC9E,2EAA2E;IAC3E,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;IACjF,CAAC;IAED,MAAM,eAAe,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAEvD,+EAA+E;IAC/E,iEAAiE;IACjE,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;IACnF,CAAC;IAED,oFAAoF;IACpF,MAAM,UAAU,GAAG,cAAc,CAAC,eAAe,EAAE,gBAAgB,CAAoB,CAAC;IACxF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;AACxE,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Installs a skill from a cloned repo directory into the target skills
3
+ * directory using a crash-safe swap flow.
4
+ */
5
+ import type { LoggerLike } from "./types.js";
6
+ /**
7
+ * Copy a skill's subdirectory from `cloneDir` into `skillsDir/<skillName>/`,
8
+ * replacing the existing copy via a crash-safe swap.
9
+ *
10
+ * Strategy:
11
+ * 1. Validate source directory exists in the clone.
12
+ * 2. Write to a `.tmp-<skillName>` staging path inside `skillsDir`.
13
+ * 3. Move existing target to a hidden backup path (if present).
14
+ * 4. Move staging → target (atomic on same fs).
15
+ * 5. Delete the backup only after the new target is in place.
16
+ *
17
+ * This avoids destroying the previous skill copy before the new one is ready.
18
+ * There is still a brief window where `targetPath` may be absent, but the old
19
+ * content remains recoverable from the backup path until install succeeds.
20
+ *
21
+ * The `.tmp-` prefix hides the staging directory from skill discovery, which
22
+ * only reads immediate subdirectories of `skillsDir`.
23
+ *
24
+ * @throws When the skill subdirectory is absent in the clone.
25
+ * @throws When the staging copy fails.
26
+ */
27
+ export declare function installSkill(cloneDir: string, skillName: string, skillsDir: string, logger?: LoggerLike): Promise<void>;
28
+ //# sourceMappingURL=writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/skills-manager/writer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CA6Ff"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Installs a skill from a cloned repo directory into the target skills
3
+ * directory using a crash-safe swap flow.
4
+ */
5
+ import * as fs from "node:fs/promises";
6
+ import { randomUUID } from "node:crypto";
7
+ import { join } from "node:path";
8
+ import { ALLOWED_SKILLS } from "./constants.js";
9
+ import { formatErr } from "./utils.js";
10
+ /**
11
+ * Copy a skill's subdirectory from `cloneDir` into `skillsDir/<skillName>/`,
12
+ * replacing the existing copy via a crash-safe swap.
13
+ *
14
+ * Strategy:
15
+ * 1. Validate source directory exists in the clone.
16
+ * 2. Write to a `.tmp-<skillName>` staging path inside `skillsDir`.
17
+ * 3. Move existing target to a hidden backup path (if present).
18
+ * 4. Move staging → target (atomic on same fs).
19
+ * 5. Delete the backup only after the new target is in place.
20
+ *
21
+ * This avoids destroying the previous skill copy before the new one is ready.
22
+ * There is still a brief window where `targetPath` may be absent, but the old
23
+ * content remains recoverable from the backup path until install succeeds.
24
+ *
25
+ * The `.tmp-` prefix hides the staging directory from skill discovery, which
26
+ * only reads immediate subdirectories of `skillsDir`.
27
+ *
28
+ * @throws When the skill subdirectory is absent in the clone.
29
+ * @throws When the staging copy fails.
30
+ */
31
+ export async function installSkill(cloneDir, skillName, skillsDir, logger) {
32
+ if (!ALLOWED_SKILLS.includes(skillName)) {
33
+ throw new Error(`Skill "${skillName}" is not in the allowed skills list: ${ALLOWED_SKILLS.join(", ")}`);
34
+ }
35
+ const sourcePath = join(cloneDir, skillName);
36
+ const targetPath = join(skillsDir, skillName);
37
+ const stagingPath = join(skillsDir, `.tmp-${skillName}`);
38
+ const backupPath = join(skillsDir, `.bak-${skillName}-${randomUUID()}`);
39
+ logger?.info(`[senpi-skills-manager] installing skill | skill=${skillName} from=${sourcePath} to=${targetPath}`);
40
+ // Validate source exists and is a directory
41
+ try {
42
+ const info = await fs.stat(sourcePath);
43
+ if (!info.isDirectory()) {
44
+ throw new Error(`Expected a directory at "${sourcePath}" for skill "${skillName}" but found a file`);
45
+ }
46
+ }
47
+ catch (err) {
48
+ if (err.code === "ENOENT") {
49
+ throw new Error(`Skill "${skillName}" not found in cloned repo at "${sourcePath}"`);
50
+ }
51
+ throw err;
52
+ }
53
+ // Ensure skillsDir exists
54
+ await fs.mkdir(skillsDir, { recursive: true });
55
+ // Remove any leftover staging dir from a previous failed install
56
+ await fs.rm(stagingPath, { recursive: true, force: true });
57
+ logger?.info(`[senpi-skills-manager] cleared leftover staging dir | path=${stagingPath}`);
58
+ // Copy source → staging
59
+ logger?.info(`[senpi-skills-manager] copying skill to staging | from=${sourcePath} to=${stagingPath}`);
60
+ await fs.cp(sourcePath, stagingPath, { recursive: true });
61
+ // Move current target out of the way first so old data is recoverable on failure.
62
+ let movedTargetToBackup = false;
63
+ try {
64
+ await fs.rename(targetPath, backupPath);
65
+ movedTargetToBackup = true;
66
+ logger?.info(`[senpi-skills-manager] backed up existing install | from=${targetPath} to=${backupPath}`);
67
+ }
68
+ catch (err) {
69
+ if (err.code !== "ENOENT") {
70
+ throw err;
71
+ }
72
+ logger?.info(`[senpi-skills-manager] no existing install to back up | skill=${skillName}`);
73
+ }
74
+ try {
75
+ logger?.info(`[senpi-skills-manager] swapping staging to target | from=${stagingPath} to=${targetPath}`);
76
+ await fs.rename(stagingPath, targetPath);
77
+ }
78
+ catch (err) {
79
+ logger?.warn(`[senpi-skills-manager] swap failed, rolling back | skill=${skillName} err=${formatErr(err)}`);
80
+ // Remove any partial target before restoring old contents.
81
+ await fs.rm(targetPath, { recursive: true, force: true });
82
+ if (movedTargetToBackup) {
83
+ await fs.rename(backupPath, targetPath).catch((restoreErr) => {
84
+ logger?.warn(`[senpi-skills-manager] failed to restore backup after swap failure | skill=${skillName} backup=${backupPath} err=${formatErr(restoreErr)}`);
85
+ });
86
+ }
87
+ throw err;
88
+ }
89
+ finally {
90
+ // On successful rename this path no longer exists; rm is still safe with force=true.
91
+ await fs.rm(stagingPath, { recursive: true, force: true });
92
+ }
93
+ // Backup cleanup is best-effort once the new target is in place.
94
+ if (movedTargetToBackup) {
95
+ await fs.rm(backupPath, { recursive: true, force: true }).catch((err) => {
96
+ logger?.warn(`[senpi-skills-manager] failed to remove backup dir | path=${backupPath} err=${formatErr(err)}`);
97
+ });
98
+ }
99
+ logger?.info(`[senpi-skills-manager] skill installed successfully | skill=${skillName} path=${targetPath}`);
100
+ }
101
+ //# sourceMappingURL=writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.js","sourceRoot":"","sources":["../../src/skills-manager/writer.ts"],"names":[],"mappings":"AAAA;;;GAGG;A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"name": "Senpi Runtime",
4
4
  "description": "Senpi runtime plugin for OpenClaw. Orchestrates scanners, LLM-based trade decisions, and a DSL trailing stop-loss exit engine.",
5
- "version": "1.0.99",
5
+ "version": "1.1.1",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
@@ -71,6 +71,46 @@
71
71
  }
72
72
  }
73
73
  },
74
+ "skillsManager": {
75
+ "type": "object",
76
+ "additionalProperties": false,
77
+ "description": "Skills manager configuration. Checks the senpi-skills repo for updates to declared skills after each plugin auto-update tick and applies patch/minor updates automatically (major updates are notify-only). Cadence is inherited from `autoUpdate.pollIntervalMinutes`; this block has no independent poll interval. Omit this block to use defaults.",
78
+ "default": {
79
+ "enabled": true,
80
+ "skills": [
81
+ "senpi-trading-runtime"
82
+ ]
83
+ },
84
+ "properties": {
85
+ "enabled": {
86
+ "type": "boolean",
87
+ "description": "Enable or disable the skills manager (default: true)"
88
+ },
89
+ "skillsDir": {
90
+ "oneOf": [
91
+ {
92
+ "type": "string"
93
+ },
94
+ {
95
+ "type": "array",
96
+ "items": {
97
+ "type": "string",
98
+ "minLength": 1
99
+ },
100
+ "minItems": 1
101
+ }
102
+ ],
103
+ "description": "Directory (or directories) where managed skills are installed. Accepts a single string for one dir, or an array for a search path. With multiple, the first is the *primary* (writes go here on bootstrap/install); the rest are read-only mirrors scanned during version checks and discovery. Default: /data/.openclaw/skills. Env override: SENPI_SKILLS_DIR (comma-separated for multi-dir; use the JSON array form for paths containing commas)."
104
+ },
105
+ "skills": {
106
+ "type": "array",
107
+ "items": {
108
+ "type": "string"
109
+ },
110
+ "description": "Explicit skill names to manage. Omitting the field falls back to the canonical default [\"senpi-trading-runtime\"]; passing an explicit empty array [] switches to discovery mode (scan subdirs under skillsDir)."
111
+ }
112
+ }
113
+ },
74
114
  "api": {
75
115
  "type": "object",
76
116
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senpi-ai/runtime",
3
- "version": "1.0.99",
3
+ "version": "1.1.1",
4
4
  "description": "Senpi runtime plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,6 +34,7 @@
34
34
  "@anthropic-ai/sdk": "^0.39.0",
35
35
  "@modelcontextprotocol/sdk": "^1.0.0",
36
36
  "@sinclair/typebox": "^0.34.0",
37
+ "async-retry": "^1.3.3",
37
38
  "dd-trace": "^5.99.1",
38
39
  "dotenv": "^16.4.5",
39
40
  "fastify": "^5.8.5",
@@ -45,6 +46,7 @@
45
46
  "openclaw": ">=2026.2.0"
46
47
  },
47
48
  "devDependencies": {
49
+ "@types/async-retry": "^1.4.9",
48
50
  "@types/node": "^22.0.0",
49
51
  "tsx": "^4.21.0",
50
52
  "typescript": "^5.7.0",