@senpi/runtime 1.0.95-dev.runtime-phase-2-api.20260507182734 → 1.1.0-dev.main.20260527104621
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/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +4 -1
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.d.ts +30 -0
- package/dist/actions/llm-decision/openclaw-llm-decision.d.ts.map +1 -1
- package/dist/actions/llm-decision/openclaw-llm-decision.js +87 -15
- package/dist/actions/llm-decision/openclaw-llm-decision.js.map +1 -1
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +19 -2
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/open-position/resolve-margin.d.ts +9 -1
- package/dist/actions/open-position/resolve-margin.d.ts.map +1 -1
- package/dist/actions/open-position/resolve-margin.js +12 -1
- package/dist/actions/open-position/resolve-margin.js.map +1 -1
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +8 -4
- package/dist/cli/guide-commands.js.map +1 -1
- 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 +20 -4
- 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 +163 -0
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/dsl/engine-client/config-mapping.d.ts +5 -0
- package/dist/dsl/engine-client/config-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/config-mapping.js +14 -2
- package/dist/dsl/engine-client/config-mapping.js.map +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts +5 -1
- package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/event-mapping.js +6 -0
- package/dist/dsl/engine-client/event-mapping.js.map +1 -1
- package/dist/dsl/events/build-closed-event.d.ts.map +1 -1
- package/dist/dsl/events/build-closed-event.js +2 -0
- package/dist/dsl/events/build-closed-event.js.map +1 -1
- package/dist/dsl/events/handlers.d.ts.map +1 -1
- package/dist/dsl/events/handlers.js +9 -5
- package/dist/dsl/events/handlers.js.map +1 -1
- package/dist/dsl/events/initial-state.d.ts +2 -2
- package/dist/dsl/events/initial-state.d.ts.map +1 -1
- package/dist/dsl/events/initial-state.js +4 -1
- package/dist/dsl/events/initial-state.js.map +1 -1
- package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +38 -1
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/dsl/notifications/formatter.js +1 -1
- package/dist/dsl/notifications/formatter.js.map +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +257 -4
- 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/runtime/decision-errors.d.ts +166 -0
- package/dist/runtime/decision-errors.d.ts.map +1 -0
- package/dist/runtime/decision-errors.js +328 -0
- package/dist/runtime/decision-errors.js.map +1 -0
- package/dist/runtime/notifications.d.ts +15 -1
- package/dist/runtime/notifications.d.ts.map +1 -1
- package/dist/runtime/notifications.js +16 -11
- package/dist/runtime/notifications.js.map +1 -1
- package/dist/runtime/run.d.ts +36 -0
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +9 -0
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime-schema.d.ts +1019 -1
- package/dist/runtime/runtime-schema.d.ts.map +1 -1
- package/dist/runtime/runtime-schema.js +34 -0
- package/dist/runtime/runtime-schema.js.map +1 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +7 -4
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime-api/handlers/audit.js +1 -1
- package/dist/runtime-api/handlers/audit.js.map +1 -1
- package/dist/runtime-api/handlers/ingest-signals.d.ts.map +1 -1
- package/dist/runtime-api/handlers/ingest-signals.js +1 -18
- package/dist/runtime-api/handlers/ingest-signals.js.map +1 -1
- package/dist/runtime-api/handlers/{lookup.d.ts → runtime-lookup.d.ts} +1 -1
- package/dist/runtime-api/handlers/runtime-lookup.d.ts.map +1 -0
- package/dist/runtime-api/handlers/{lookup.js → runtime-lookup.js} +1 -1
- package/dist/runtime-api/handlers/runtime-lookup.js.map +1 -0
- package/dist/senpi/types.d.ts +2 -1
- package/dist/senpi/types.d.ts.map +1 -1
- package/dist/skills-manager/bootstrap.d.ts +26 -0
- package/dist/skills-manager/bootstrap.d.ts.map +1 -0
- package/dist/skills-manager/bootstrap.js +86 -0
- package/dist/skills-manager/bootstrap.js.map +1 -0
- package/dist/skills-manager/constants.d.ts +65 -0
- package/dist/skills-manager/constants.d.ts.map +1 -0
- package/dist/skills-manager/constants.js +91 -0
- package/dist/skills-manager/constants.js.map +1 -0
- package/dist/skills-manager/coordinator.d.ts +346 -0
- package/dist/skills-manager/coordinator.d.ts.map +1 -0
- package/dist/skills-manager/coordinator.js +1037 -0
- package/dist/skills-manager/coordinator.js.map +1 -0
- package/dist/skills-manager/fetcher.d.ts +28 -0
- package/dist/skills-manager/fetcher.d.ts.map +1 -0
- package/dist/skills-manager/fetcher.js +92 -0
- package/dist/skills-manager/fetcher.js.map +1 -0
- package/dist/skills-manager/index.d.ts +5 -0
- package/dist/skills-manager/index.d.ts.map +1 -0
- package/dist/skills-manager/index.js +4 -0
- package/dist/skills-manager/index.js.map +1 -0
- package/dist/skills-manager/state-store.d.ts +57 -0
- package/dist/skills-manager/state-store.d.ts.map +1 -0
- package/dist/skills-manager/state-store.js +129 -0
- package/dist/skills-manager/state-store.js.map +1 -0
- package/dist/skills-manager/types.d.ts +177 -0
- package/dist/skills-manager/types.d.ts.map +1 -0
- package/dist/skills-manager/types.js +2 -0
- package/dist/skills-manager/types.js.map +1 -0
- package/dist/skills-manager/utils.d.ts +81 -0
- package/dist/skills-manager/utils.d.ts.map +1 -0
- package/dist/skills-manager/utils.js +143 -0
- package/dist/skills-manager/utils.js.map +1 -0
- package/dist/skills-manager/version-manager.d.ts +146 -0
- package/dist/skills-manager/version-manager.d.ts.map +1 -0
- package/dist/skills-manager/version-manager.js +299 -0
- package/dist/skills-manager/version-manager.js.map +1 -0
- package/dist/skills-manager/writer.d.ts +28 -0
- package/dist/skills-manager/writer.d.ts.map +1 -0
- package/dist/skills-manager/writer.js +101 -0
- package/dist/skills-manager/writer.js.map +1 -0
- package/dist/state/state-manager.d.ts +3 -0
- package/dist/state/state-manager.d.ts.map +1 -1
- package/dist/state/state-manager.js +9 -0
- package/dist/state/state-manager.js.map +1 -1
- package/dist/types/dsl/index.d.ts +22 -3
- package/dist/types/dsl/index.d.ts.map +1 -1
- package/dist/utils/retry.d.ts +7 -0
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +5 -1
- package/dist/utils/retry.js.map +1 -1
- package/openclaw.plugin.json +28 -1
- package/package.json +3 -1
- package/dist/runtime-api/handlers/lookup.d.ts.map +0 -1
- package/dist/runtime-api/handlers/lookup.js.map +0 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { RawSkillsManagerConfig, SkillsManagerConfig, SkillsManagerState, SkillState } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical default list of managed skill names when the user omits the
|
|
4
|
+
* `skills` field. Kept in sync with the JSON Schema default in
|
|
5
|
+
* `openclaw.plugin.json` (configSchema.properties.skillsManager.default.skills).
|
|
6
|
+
*
|
|
7
|
+
* Semantics for the resolved `skills` array:
|
|
8
|
+
* - Field omitted entirely → defaults to this list. New installs and partial
|
|
9
|
+
* configs like `{ enabled: true }` get the canonical skill bootstrapped
|
|
10
|
+
* automatically without requiring users to repeat the array in JSON.
|
|
11
|
+
* - Field present and non-empty → use the provided names (filtered for
|
|
12
|
+
* non-empty strings).
|
|
13
|
+
* - Field present and explicitly empty (`"skills": []`) → discovery mode:
|
|
14
|
+
* scan subdirs under `skillsDir`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_MANAGED_SKILLS: readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* Parses and normalises the raw `skillsManager` config block from the plugin
|
|
19
|
+
* config into a fully-resolved {@link SkillsManagerConfig}.
|
|
20
|
+
*
|
|
21
|
+
* Any missing or null fields fall back to safe defaults so callers never have
|
|
22
|
+
* to guard against undefined values.
|
|
23
|
+
*
|
|
24
|
+
* @param value - The optional raw config block from the plugin config.
|
|
25
|
+
* @returns A fully-populated {@link SkillsManagerConfig} with all defaults applied.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveSkillsManagerConfig(value?: RawSkillsManagerConfig | null): SkillsManagerConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a blank {@link SkillsManagerState} with no tracked skills.
|
|
30
|
+
* Used as the merge base when loading persisted state, and as the fallback
|
|
31
|
+
* when state is corrupt.
|
|
32
|
+
*
|
|
33
|
+
* @returns An empty {@link SkillsManagerState}.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createDefaultSkillsManagerState(): SkillsManagerState;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a zeroed-out {@link SkillState} for a skill that has not yet been
|
|
38
|
+
* tracked. All version fields are null and the failure counter starts at zero.
|
|
39
|
+
*
|
|
40
|
+
* @param name - The skill name (directory name under `skillsDir`).
|
|
41
|
+
* @returns A fresh {@link SkillState} for the given skill.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createDefaultSkillState(name: string): SkillState;
|
|
44
|
+
/** Formats an unknown thrown value as a short string for log messages. */
|
|
45
|
+
export declare function formatErr(e: unknown): string;
|
|
46
|
+
/**
|
|
47
|
+
* Parse a positive integer from an env-var string, falling back to the
|
|
48
|
+
* supplied default on anything unparseable, zero, or negative.
|
|
49
|
+
*
|
|
50
|
+
* Used to load numeric env-overridable constants in `constants.ts` (e.g.
|
|
51
|
+
* `TELEGRAM_NOTIFICATION_BUDGET_CHARS`) without throwing at module load
|
|
52
|
+
* time when the env var is bogus — matches the rest of `constants.ts`'s
|
|
53
|
+
* "default wins on bad input, never crash startup" style.
|
|
54
|
+
*
|
|
55
|
+
* Examples:
|
|
56
|
+
* parseEnvPositiveInt("8000", 4000) // 8000 (valid override)
|
|
57
|
+
* parseEnvPositiveInt("abc", 4000) // 4000 (unparseable → default)
|
|
58
|
+
* parseEnvPositiveInt("0", 4000) // 4000 (zero → default)
|
|
59
|
+
* parseEnvPositiveInt("-100", 4000) // 4000 (negative → default)
|
|
60
|
+
* parseEnvPositiveInt("", 4000) // 4000 (empty → default)
|
|
61
|
+
* parseEnvPositiveInt(undefined, 4000) // 4000 (unset → default)
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseEnvPositiveInt(envValue: string | undefined, defaultValue: number): number;
|
|
64
|
+
/**
|
|
65
|
+
* Normalise the raw `skillsDir` value into a non-empty `string[]` (the
|
|
66
|
+
* "search path" form used internally).
|
|
67
|
+
*
|
|
68
|
+
* Resolution rules:
|
|
69
|
+
* - Single string → wrap as `[value]` (legacy single-dir form)
|
|
70
|
+
* - Array → filter out non-strings and empty/whitespace entries; if anything
|
|
71
|
+
* survives, use the filtered array
|
|
72
|
+
* - Anything else (undefined, null, empty array post-filter, wrong type) →
|
|
73
|
+
* fall back to `DEFAULT_SKILLS_DIRS` (which itself reads `SENPI_SKILLS_DIR`
|
|
74
|
+
* as a comma-separated list, or the canonical install path as the final
|
|
75
|
+
* fallback)
|
|
76
|
+
*
|
|
77
|
+
* Always returns a non-empty array — callers can rely on `[0]` existing as
|
|
78
|
+
* the *primary* (writes go here; reads scan in order).
|
|
79
|
+
*/
|
|
80
|
+
export declare function normalizeSkillsDir(value: unknown): string[];
|
|
81
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/skills-manager/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAA8B,CAAC;AAEnF;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,CAAC,EAAE,sBAAsB,GAAG,IAAI,GACpC,mBAAmB,CAcrB;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,IAAI,kBAAkB,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAYhE;AAED,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAE5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAI9F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAc3D"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { DEFAULT_SKILLS_DIRS } from "./constants.js";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical default list of managed skill names when the user omits the
|
|
4
|
+
* `skills` field. Kept in sync with the JSON Schema default in
|
|
5
|
+
* `openclaw.plugin.json` (configSchema.properties.skillsManager.default.skills).
|
|
6
|
+
*
|
|
7
|
+
* Semantics for the resolved `skills` array:
|
|
8
|
+
* - Field omitted entirely → defaults to this list. New installs and partial
|
|
9
|
+
* configs like `{ enabled: true }` get the canonical skill bootstrapped
|
|
10
|
+
* automatically without requiring users to repeat the array in JSON.
|
|
11
|
+
* - Field present and non-empty → use the provided names (filtered for
|
|
12
|
+
* non-empty strings).
|
|
13
|
+
* - Field present and explicitly empty (`"skills": []`) → discovery mode:
|
|
14
|
+
* scan subdirs under `skillsDir`.
|
|
15
|
+
*/
|
|
16
|
+
export const DEFAULT_MANAGED_SKILLS = ["senpi-trading-runtime"];
|
|
17
|
+
/**
|
|
18
|
+
* Parses and normalises the raw `skillsManager` config block from the plugin
|
|
19
|
+
* config into a fully-resolved {@link SkillsManagerConfig}.
|
|
20
|
+
*
|
|
21
|
+
* Any missing or null fields fall back to safe defaults so callers never have
|
|
22
|
+
* to guard against undefined values.
|
|
23
|
+
*
|
|
24
|
+
* @param value - The optional raw config block from the plugin config.
|
|
25
|
+
* @returns A fully-populated {@link SkillsManagerConfig} with all defaults applied.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveSkillsManagerConfig(value) {
|
|
28
|
+
const raw = value ?? {};
|
|
29
|
+
return {
|
|
30
|
+
enabled: toBool(raw.enabled, true),
|
|
31
|
+
skillsDir: normalizeSkillsDir(raw.skillsDir),
|
|
32
|
+
// Field-omitted vs explicit-empty distinction matters here:
|
|
33
|
+
// - undefined / null / non-array → use canonical default (matches the
|
|
34
|
+
// JSON Schema default in openclaw.plugin.json — keeps wizard-written
|
|
35
|
+
// partial configs working)
|
|
36
|
+
// - explicit [] → preserved as discovery mode (caller asked for it)
|
|
37
|
+
skills: Array.isArray(raw.skills)
|
|
38
|
+
? raw.skills.filter((s) => typeof s === "string" && s.length > 0)
|
|
39
|
+
: [...DEFAULT_MANAGED_SKILLS],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a blank {@link SkillsManagerState} with no tracked skills.
|
|
44
|
+
* Used as the merge base when loading persisted state, and as the fallback
|
|
45
|
+
* when state is corrupt.
|
|
46
|
+
*
|
|
47
|
+
* @returns An empty {@link SkillsManagerState}.
|
|
48
|
+
*/
|
|
49
|
+
export function createDefaultSkillsManagerState() {
|
|
50
|
+
return { skills: {} };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a zeroed-out {@link SkillState} for a skill that has not yet been
|
|
54
|
+
* tracked. All version fields are null and the failure counter starts at zero.
|
|
55
|
+
*
|
|
56
|
+
* @param name - The skill name (directory name under `skillsDir`).
|
|
57
|
+
* @returns A fresh {@link SkillState} for the given skill.
|
|
58
|
+
*/
|
|
59
|
+
export function createDefaultSkillState(name) {
|
|
60
|
+
return {
|
|
61
|
+
name,
|
|
62
|
+
installedVersion: null,
|
|
63
|
+
latestVersion: null,
|
|
64
|
+
lastCheckedAt: null,
|
|
65
|
+
lastAppliedVersion: null,
|
|
66
|
+
lastNotifiedMajorVersion: null,
|
|
67
|
+
consecutiveFailures: 0,
|
|
68
|
+
lastFailureAt: null,
|
|
69
|
+
lastFailureReason: null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Formats an unknown thrown value as a short string for log messages. */
|
|
73
|
+
export function formatErr(e) {
|
|
74
|
+
return e instanceof Error ? e.message : String(e);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parse a positive integer from an env-var string, falling back to the
|
|
78
|
+
* supplied default on anything unparseable, zero, or negative.
|
|
79
|
+
*
|
|
80
|
+
* Used to load numeric env-overridable constants in `constants.ts` (e.g.
|
|
81
|
+
* `TELEGRAM_NOTIFICATION_BUDGET_CHARS`) without throwing at module load
|
|
82
|
+
* time when the env var is bogus — matches the rest of `constants.ts`'s
|
|
83
|
+
* "default wins on bad input, never crash startup" style.
|
|
84
|
+
*
|
|
85
|
+
* Examples:
|
|
86
|
+
* parseEnvPositiveInt("8000", 4000) // 8000 (valid override)
|
|
87
|
+
* parseEnvPositiveInt("abc", 4000) // 4000 (unparseable → default)
|
|
88
|
+
* parseEnvPositiveInt("0", 4000) // 4000 (zero → default)
|
|
89
|
+
* parseEnvPositiveInt("-100", 4000) // 4000 (negative → default)
|
|
90
|
+
* parseEnvPositiveInt("", 4000) // 4000 (empty → default)
|
|
91
|
+
* parseEnvPositiveInt(undefined, 4000) // 4000 (unset → default)
|
|
92
|
+
*/
|
|
93
|
+
export function parseEnvPositiveInt(envValue, defaultValue) {
|
|
94
|
+
if (envValue === undefined || envValue === "")
|
|
95
|
+
return defaultValue;
|
|
96
|
+
const n = parseInt(envValue, 10);
|
|
97
|
+
return Number.isFinite(n) && n > 0 ? n : defaultValue;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Normalise the raw `skillsDir` value into a non-empty `string[]` (the
|
|
101
|
+
* "search path" form used internally).
|
|
102
|
+
*
|
|
103
|
+
* Resolution rules:
|
|
104
|
+
* - Single string → wrap as `[value]` (legacy single-dir form)
|
|
105
|
+
* - Array → filter out non-strings and empty/whitespace entries; if anything
|
|
106
|
+
* survives, use the filtered array
|
|
107
|
+
* - Anything else (undefined, null, empty array post-filter, wrong type) →
|
|
108
|
+
* fall back to `DEFAULT_SKILLS_DIRS` (which itself reads `SENPI_SKILLS_DIR`
|
|
109
|
+
* as a comma-separated list, or the canonical install path as the final
|
|
110
|
+
* fallback)
|
|
111
|
+
*
|
|
112
|
+
* Always returns a non-empty array — callers can rely on `[0]` existing as
|
|
113
|
+
* the *primary* (writes go here; reads scan in order).
|
|
114
|
+
*/
|
|
115
|
+
export function normalizeSkillsDir(value) {
|
|
116
|
+
if (typeof value === "string") {
|
|
117
|
+
const trimmed = value.trim();
|
|
118
|
+
if (trimmed.length > 0)
|
|
119
|
+
return [trimmed];
|
|
120
|
+
}
|
|
121
|
+
else if (Array.isArray(value)) {
|
|
122
|
+
const filtered = value
|
|
123
|
+
.filter((v) => typeof v === "string")
|
|
124
|
+
.map((s) => s.trim())
|
|
125
|
+
.filter((s) => s.length > 0);
|
|
126
|
+
if (filtered.length > 0)
|
|
127
|
+
return filtered;
|
|
128
|
+
}
|
|
129
|
+
// DEFAULT_SKILLS_DIRS is a readonly tuple at module level — return a fresh
|
|
130
|
+
// mutable copy so callers that mutate (e.g. tests) don't poison the global.
|
|
131
|
+
return [...DEFAULT_SKILLS_DIRS];
|
|
132
|
+
}
|
|
133
|
+
// ─── Local config-coercion helpers ──────────────────────────────────────────
|
|
134
|
+
// `toBool` is intentionally duplicated from `src/runtime/auto-update/types.ts`
|
|
135
|
+
// to keep `src/skills-manager/` free of any compile- or runtime-time
|
|
136
|
+
// dependency on the auto-update package. An earlier attempt to consolidate
|
|
137
|
+
// this style of helper across the two modules (commit 48592db, "consolidate
|
|
138
|
+
// formatErr into policy.ts") was reverted in 5a94af8 with the explicit rule
|
|
139
|
+
// "do not touch auto-update module" — same rationale applies here.
|
|
140
|
+
function toBool(value, fallback) {
|
|
141
|
+
return typeof value === "boolean" ? value : fallback;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/skills-manager/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAQrD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB,CAAC,uBAAuB,CAAC,CAAC;AAEnF;;;;;;;;;GASG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAqC;IAErC,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE,CAAC;IACxB,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC;QAClC,SAAS,EAAE,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC;QAC5C,4DAA4D;QAC5D,sEAAsE;QACtE,uEAAuE;QACvE,6BAA6B;QAC7B,oEAAoE;QACpE,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;YAC/B,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE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AO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,KAAK;aACnB,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;aACjD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,QAAQ,CAAC;IAC3C,CAAC;IACD,2EAA2E;IAC3E,4EAA4E;IAC5E,OAAO,CAAC,GAAG,mBAAmB,CAAC,CAAC;AAClC,CAAC;AAED,+EAA+E;AAC/E,+EAA+E;AAC/E,qEAAqE;AACrE,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,mEAAmE;AACnE,SAAS,MAAM,CAAC,KAAc,EAAE,QAAiB;IAC/C,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
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 type { LoggerLike, SkillVersionInfo } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Normalise a version string before passing it to parseSemver / classifyUpdate.
|
|
11
|
+
*
|
|
12
|
+
* Accepts two-part versions used in production skills (e.g. "1.0", "v2.3")
|
|
13
|
+
* and expands them to the full three-part form ("1.0.0", "v2.3.0") that
|
|
14
|
+
* parseSemver requires. All other strings are returned unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeVersion(v: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Extract the `version` value from a SKILL.md YAML frontmatter block.
|
|
19
|
+
*
|
|
20
|
+
* Handles both nested form:
|
|
21
|
+
* metadata:
|
|
22
|
+
* version: 1.2.3
|
|
23
|
+
* and flat form:
|
|
24
|
+
* version: "1.2.3"
|
|
25
|
+
*
|
|
26
|
+
* Returns null when the frontmatter block is absent or the field is missing.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseSkillMdVersion(content: string): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Extract the `description` value from a SKILL.md YAML frontmatter block.
|
|
31
|
+
*
|
|
32
|
+
* Skill descriptions can be authored a few different ways. This helper
|
|
33
|
+
* handles the real-world shapes that appear in the senpi-skills repo today:
|
|
34
|
+
*
|
|
35
|
+
* 1. Single-line, double-quoted:
|
|
36
|
+
* description: "Configure, deploy, ..."
|
|
37
|
+
* 2. Single-line, single-quoted or unquoted:
|
|
38
|
+
* description: Manage runtimes ...
|
|
39
|
+
* 3. YAML block scalar (folded or literal, optional chomping indicator):
|
|
40
|
+
* description: >
|
|
41
|
+
* A short summary
|
|
42
|
+
* continues on this line.
|
|
43
|
+
* description: >- # strip trailing newlines (this PR's senpi-skills repo)
|
|
44
|
+
* A short summary
|
|
45
|
+
* description: | # literal — preserves newlines (collapsed to spaces here)
|
|
46
|
+
* A short summary
|
|
47
|
+
* description: |+ # keep trailing newlines (same handling)
|
|
48
|
+
*
|
|
49
|
+
* The block scalar header is `[>|][-+]?` per the YAML 1.2 spec:
|
|
50
|
+
* `>` = folded, `|` = literal; `-` strips trailing newlines,
|
|
51
|
+
* `+` keeps them, no indicator clips. For notification rendering we
|
|
52
|
+
* always collapse to a single line joined by spaces, so the chomping
|
|
53
|
+
* indicator only affects whether we match the block-scalar branch.
|
|
54
|
+
*
|
|
55
|
+
* Returns null when the field is absent or the frontmatter block is missing.
|
|
56
|
+
*
|
|
57
|
+
* Note: kept as a regex extractor rather than introducing a full YAML
|
|
58
|
+
* parse here — `parseSkillMdVersion` uses the same approach, and skill
|
|
59
|
+
* frontmatters are constrained enough that the regex covers the shapes we
|
|
60
|
+
* actually encounter. If we ever adopt a full YAML parser for this file,
|
|
61
|
+
* both helpers should switch together.
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseSkillMdDescription(content: string): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Read both the installed version and description for a skill from its local
|
|
66
|
+
* SKILL.md. Shared core for `readLocalVersion` and `readLocalDescription` so a
|
|
67
|
+
* tick that needs both pays a single file read per dir rather than two.
|
|
68
|
+
*
|
|
69
|
+
* Multi-dir search path: tries each entry in order and returns the first
|
|
70
|
+
* readable SKILL.md's parsed fields. Either field may be null if absent in
|
|
71
|
+
* the frontmatter — that's distinct from "no SKILL.md found at all" (which
|
|
72
|
+
* returns nulls only after every dir has been tried).
|
|
73
|
+
*/
|
|
74
|
+
export declare function readLocalSkillMetadata(skillsDir: string | readonly string[], skillName: string, logger?: LoggerLike): Promise<{
|
|
75
|
+
version: string | null;
|
|
76
|
+
description: string | null;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Read the installed version for a skill from its local SKILL.md.
|
|
80
|
+
*
|
|
81
|
+
* Accepts either a single dir (legacy callers) or an array of dirs (new
|
|
82
|
+
* multi-dir search path). When given an array, tries each entry in order and
|
|
83
|
+
* returns the first non-null match — this mirrors the documented behaviour
|
|
84
|
+
* that `skillsDir[0]` is the *primary* (writes go here) and the remaining
|
|
85
|
+
* entries are read-only fallbacks scanned during version checks.
|
|
86
|
+
*
|
|
87
|
+
* Returns null when no readable SKILL.md is found across any of the
|
|
88
|
+
* candidate dirs, or when the version field is absent. Logs a warning per
|
|
89
|
+
* dir for unexpected errors (anything other than ENOENT).
|
|
90
|
+
*/
|
|
91
|
+
export declare function readLocalVersion(skillsDir: string | readonly string[], skillName: string, logger?: LoggerLike): Promise<string | null>;
|
|
92
|
+
/**
|
|
93
|
+
* Read the installed description for a skill from its local SKILL.md.
|
|
94
|
+
* Multi-dir search path semantics identical to `readLocalVersion`.
|
|
95
|
+
*
|
|
96
|
+
* Returns null when no readable SKILL.md is found across any of the
|
|
97
|
+
* candidate dirs, or when the description field is absent.
|
|
98
|
+
*/
|
|
99
|
+
export declare function readLocalDescription(skillsDir: string | readonly string[], skillName: string, logger?: LoggerLike): Promise<string | null>;
|
|
100
|
+
/**
|
|
101
|
+
* Fetch the remote SKILL.md for a skill and return both the version and the
|
|
102
|
+
* description in one network round-trip.
|
|
103
|
+
*
|
|
104
|
+
* Notification text uses the description from the **remote** SKILL.md (not
|
|
105
|
+
* the local one) so the "About:" line reflects the version the user is being
|
|
106
|
+
* asked about — a description on disk for v1.x may be stale relative to the
|
|
107
|
+
* v2.0.0 the major-update notification is announcing.
|
|
108
|
+
*
|
|
109
|
+
* Returns null fields when the skill does not exist in the remote repo
|
|
110
|
+
* (HTTP 404) — that's a legitimate state ("skill removed or not yet
|
|
111
|
+
* published"), not an error, so it should not pollute failure counters.
|
|
112
|
+
* Both fields may also be null when the remote SKILL.md is present but
|
|
113
|
+
* its frontmatter omits the corresponding field.
|
|
114
|
+
*
|
|
115
|
+
* Throws on transient/operational failures (network errors, timeouts, 5xx
|
|
116
|
+
* responses, body-parse failures) so the caller's failure-recording path can
|
|
117
|
+
* fire.
|
|
118
|
+
*
|
|
119
|
+
* @param fetchImpl Injectable for unit testing — defaults to global `fetch`.
|
|
120
|
+
*/
|
|
121
|
+
export declare function fetchRemoteSkillMetadata(skillName: string, rawBaseUrl?: string, fetchImpl?: typeof fetch): Promise<{
|
|
122
|
+
version: string | null;
|
|
123
|
+
description: string | null;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Fetch the remote SKILL.md for a skill and return its version.
|
|
127
|
+
*
|
|
128
|
+
* Thin wrapper over {@link fetchRemoteSkillMetadata} kept for backward
|
|
129
|
+
* compatibility with callers (and tests) that only need the version field.
|
|
130
|
+
* New code that wants both version + description in a single round-trip
|
|
131
|
+
* should call `fetchRemoteSkillMetadata` directly.
|
|
132
|
+
*/
|
|
133
|
+
export declare function fetchRemoteVersion(skillName: string, rawBaseUrl?: string, fetchImpl?: typeof fetch): Promise<string | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Compare the local and remote versions for a skill and return a classified diff.
|
|
136
|
+
*
|
|
137
|
+
* Special cases:
|
|
138
|
+
* - Local version is null (skill predates versioning) + valid remote → "minor"
|
|
139
|
+
* so the update is auto-applied without manual major-version approval.
|
|
140
|
+
* - Local version exists but is not valid semver (e.g. "latest") → "unknown",
|
|
141
|
+
* skip safely.
|
|
142
|
+
* - Remote version is absent or unparseable → "unknown", caller should log and
|
|
143
|
+
* skip.
|
|
144
|
+
*/
|
|
145
|
+
export declare function checkSkillVersion(skillsDir: string | readonly string[], skillName: string, rawBaseUrl?: string, fetchImpl?: typeof fetch, logger?: LoggerLike): Promise<SkillVersionInfo>;
|
|
146
|
+
//# sourceMappingURL=version-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-manager.d.ts","sourceRoot":"","sources":["../../src/skills-manager/version-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAmB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGhF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMlE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,uBAA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