@senpi-ai/runtime 1.1.0 → 1.1.2
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/anthropic-llm-decision.d.ts +9 -0
- package/dist/actions/llm-decision/anthropic-llm-decision.d.ts.map +1 -1
- package/dist/actions/llm-decision/anthropic-llm-decision.js +90 -3
- package/dist/actions/llm-decision/anthropic-llm-decision.js.map +1 -1
- package/dist/actions/llm-decision/factory.d.ts +6 -0
- package/dist/actions/llm-decision/factory.d.ts.map +1 -1
- package/dist/actions/llm-decision/factory.js +2 -0
- package/dist/actions/llm-decision/factory.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 +114 -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 +4 -1
- package/dist/actions/open-position/open-position.action.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/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +24 -1
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -1
- 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 -57
- package/dist/runtime/notifications.js.map +1 -1
- package/dist/runtime/run.d.ts +6 -0
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +1 -0
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/runtime-schema.d.ts +1091 -73
- 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 +8 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +57 -37
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/senpi/client.d.ts +1 -0
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +51 -0
- package/dist/senpi/client.js.map +1 -1
- 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/tracking/context.d.ts +31 -0
- package/dist/tracking/context.d.ts.map +1 -0
- package/dist/tracking/context.js +20 -0
- package/dist/tracking/context.js.map +1 -0
- package/dist/tracking/spans/constants.d.ts +19 -0
- package/dist/tracking/spans/constants.d.ts.map +1 -0
- package/dist/tracking/spans/constants.js +31 -0
- package/dist/tracking/spans/constants.js.map +1 -0
- package/dist/tracking/spans/index.d.ts +13 -0
- package/dist/tracking/spans/index.d.ts.map +1 -0
- package/dist/tracking/spans/index.js +16 -0
- package/dist/tracking/spans/index.js.map +1 -0
- package/dist/tracking/spans/plugin-span-tracker.d.ts +3 -0
- package/dist/tracking/spans/plugin-span-tracker.d.ts.map +1 -0
- package/dist/tracking/spans/plugin-span-tracker.js +42 -0
- package/dist/tracking/spans/plugin-span-tracker.js.map +1 -0
- package/dist/tracking/spans/redact-pii.d.ts +115 -0
- package/dist/tracking/spans/redact-pii.d.ts.map +1 -0
- package/dist/tracking/spans/redact-pii.js +464 -0
- package/dist/tracking/spans/redact-pii.js.map +1 -0
- package/dist/tracking/spans/sanitize-payload.d.ts +19 -0
- package/dist/tracking/spans/sanitize-payload.d.ts.map +1 -0
- package/dist/tracking/spans/sanitize-payload.js +68 -0
- package/dist/tracking/spans/sanitize-payload.js.map +1 -0
- package/dist/tracking/spans/span-hooks.d.ts +28 -0
- package/dist/tracking/spans/span-hooks.d.ts.map +1 -0
- package/dist/tracking/spans/span-hooks.js +409 -0
- package/dist/tracking/spans/span-hooks.js.map +1 -0
- package/dist/tracking/spans/span-tracker.d.ts +133 -0
- package/dist/tracking/spans/span-tracker.d.ts.map +1 -0
- package/dist/tracking/spans/span-tracker.js +721 -0
- package/dist/tracking/spans/span-tracker.js.map +1 -0
- package/dist/tracking/spans/span-transport.d.ts +65 -0
- package/dist/tracking/spans/span-transport.d.ts.map +1 -0
- package/dist/tracking/spans/span-transport.js +240 -0
- package/dist/tracking/spans/span-transport.js.map +1 -0
- package/dist/tracking/spans/types.d.ts +101 -0
- package/dist/tracking/spans/types.d.ts.map +1 -0
- package/dist/tracking/spans/types.js +6 -0
- package/dist/tracking/spans/types.js.map +1 -0
- 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 +41 -1
- package/package.json +5 -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.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-manager.js","sourceRoot":"","sources":["../../src/skills-manager/version-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAS;IACxC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,MAAM,KAAK,GAAG,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,YAAY,GAAG,uDAAuD,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/F,OAAO,YAAY,CAAC,CAAC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O,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"],"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+1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsyncLocalStorage-based propagation of senpi tracking context.
|
|
3
|
+
*
|
|
4
|
+
* Why: when a senpi runtime processes a signal it owns a correlationId that
|
|
5
|
+
* connects all events for that flow (scanner → decision → action → position →
|
|
6
|
+
* DSL). If that flow makes LLM calls, the spans those calls produce should
|
|
7
|
+
* carry the same correlationId so events and spans can be joined downstream.
|
|
8
|
+
*
|
|
9
|
+
* AsyncLocalStorage is per-async-call-chain, so it is concurrency-safe even if
|
|
10
|
+
* signal processing is parallelized later. Crossing process boundaries
|
|
11
|
+
* (e.g. POST to OpenClaw's /tools/invoke) needs explicit propagation through
|
|
12
|
+
* headers — see openclaw-llm-decision.ts.
|
|
13
|
+
*/
|
|
14
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
15
|
+
export interface TrackingContext {
|
|
16
|
+
correlationId: string;
|
|
17
|
+
/** Strategy wallet (lowercased). May be empty when a runtime has no wallet (rare). */
|
|
18
|
+
address: string;
|
|
19
|
+
/** Recipe name (the YAML `name:` field). User-meaningful label, e.g. "viper". */
|
|
20
|
+
recipeName: string;
|
|
21
|
+
/** Stable UUID for this runtime install (from the plugin registry). */
|
|
22
|
+
runtimeId: string;
|
|
23
|
+
/** Plugin version. */
|
|
24
|
+
runtimeVersion: string;
|
|
25
|
+
/** UUID generated once at runtime startup; lets you group direct-path spans per process. */
|
|
26
|
+
runtimeBootId: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const trackingContext: AsyncLocalStorage<TrackingContext>;
|
|
29
|
+
/** Returns the current tracking context, or null when running outside any signal flow. */
|
|
30
|
+
export declare function getTrackingContext(): TrackingContext | null;
|
|
31
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/tracking/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,4FAA4F;IAC5F,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,eAAe,oCAA2C,CAAC;AAExE,0FAA0F;AAC1F,wBAAgB,kBAAkB,IAAI,eAAe,GAAG,IAAI,CAE3D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsyncLocalStorage-based propagation of senpi tracking context.
|
|
3
|
+
*
|
|
4
|
+
* Why: when a senpi runtime processes a signal it owns a correlationId that
|
|
5
|
+
* connects all events for that flow (scanner → decision → action → position →
|
|
6
|
+
* DSL). If that flow makes LLM calls, the spans those calls produce should
|
|
7
|
+
* carry the same correlationId so events and spans can be joined downstream.
|
|
8
|
+
*
|
|
9
|
+
* AsyncLocalStorage is per-async-call-chain, so it is concurrency-safe even if
|
|
10
|
+
* signal processing is parallelized later. Crossing process boundaries
|
|
11
|
+
* (e.g. POST to OpenClaw's /tools/invoke) needs explicit propagation through
|
|
12
|
+
* headers — see openclaw-llm-decision.ts.
|
|
13
|
+
*/
|
|
14
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
15
|
+
export const trackingContext = new AsyncLocalStorage();
|
|
16
|
+
/** Returns the current tracking context, or null when running outside any signal flow. */
|
|
17
|
+
export function getTrackingContext() {
|
|
18
|
+
return trackingContext.getStore() ?? null;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/tracking/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgBrD,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,iBAAiB,EAAmB,CAAC;AAExE,0FAA0F;AAC1F,MAAM,UAAU,kBAAkB;IAChC,OAAO,eAAe,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Span telemetry constants: API path, batching thresholds, orphan-sweep timings.
|
|
3
|
+
*/
|
|
4
|
+
export declare const SPANS_API_PATH = "/api/v1/tracking/spans";
|
|
5
|
+
export declare const FLUSH_INTERVAL_MS = 10000;
|
|
6
|
+
export declare const FLUSH_THRESHOLD = 50;
|
|
7
|
+
export declare const MAX_BUFFER_SIZE = 500;
|
|
8
|
+
export declare const STALE_TIMEOUT_MS: number;
|
|
9
|
+
export declare const SWEEP_INTERVAL_MS = 60000;
|
|
10
|
+
export declare const MAX_BATCH_BYTES = 8000000;
|
|
11
|
+
export declare const MAX_SPAN_FIELD_BYTES = 2000000;
|
|
12
|
+
/** First N chars of each truncated value retained for debugging context. */
|
|
13
|
+
export declare const TRUNCATED_PREVIEW_BYTES = 2000;
|
|
14
|
+
export declare const HEADER_CORRELATION_ID = "x-senpi-correlation-id";
|
|
15
|
+
export declare const HEADER_ADDRESS = "x-senpi-address";
|
|
16
|
+
export declare const HEADER_RECIPE_NAME = "x-senpi-recipe-name";
|
|
17
|
+
export declare const HEADER_RUNTIME_ID = "x-senpi-runtime-id";
|
|
18
|
+
export declare const HEADER_RUNTIME_VERSION = "x-senpi-runtime-version";
|
|
19
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/tracking/spans/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAGvD,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,eAAe,MAAM,CAAC;AAGnC,eAAO,MAAM,gBAAgB,QAAa,CAAC;AAC3C,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAKxC,eAAO,MAAM,eAAe,UAAY,CAAC;AAQzC,eAAO,MAAM,oBAAoB,UAAY,CAAC;AAC9C,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAG7C,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAC9D,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,sBAAsB,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Span telemetry constants: API path, batching thresholds, orphan-sweep timings.
|
|
3
|
+
*/
|
|
4
|
+
export const SPANS_API_PATH = "/api/v1/tracking/spans";
|
|
5
|
+
// Transport batching — mirrors the events transport defaults.
|
|
6
|
+
export const FLUSH_INTERVAL_MS = 10_000;
|
|
7
|
+
export const FLUSH_THRESHOLD = 50;
|
|
8
|
+
export const MAX_BUFFER_SIZE = 500;
|
|
9
|
+
// In-memory span lifecycle — sweep abandoned spans so they don't accumulate.
|
|
10
|
+
export const STALE_TIMEOUT_MS = 5 * 60_000;
|
|
11
|
+
export const SWEEP_INTERVAL_MS = 60_000;
|
|
12
|
+
// Per-batch byte budget. We pack spans into a request until adding the next
|
|
13
|
+
// one would push us over this, then flush. Sized to fit comfortably under the
|
|
14
|
+
// ingest server's 10MB Fastify bodyLimit (set in senpi-agent-telemetry).
|
|
15
|
+
export const MAX_BATCH_BYTES = 8_000_000;
|
|
16
|
+
// Per-field byte cap for span.data top-level values. Acts as a safety net for
|
|
17
|
+
// genuinely pathological outputs (e.g. an `exec` that printed a multi-MB log,
|
|
18
|
+
// or a tool that returned a raw binary blob). Real chat-history payloads flow
|
|
19
|
+
// through unchanged after sanitize-payload strips framework metadata.
|
|
20
|
+
// Combined with the ingest server's 10MB body limit, only truly oversized
|
|
21
|
+
// fields trip this.
|
|
22
|
+
export const MAX_SPAN_FIELD_BYTES = 2_000_000;
|
|
23
|
+
/** First N chars of each truncated value retained for debugging context. */
|
|
24
|
+
export const TRUNCATED_PREVIEW_BYTES = 2_000;
|
|
25
|
+
// Header names used to cross the runtime → OpenClaw HTTP boundary.
|
|
26
|
+
export const HEADER_CORRELATION_ID = "x-senpi-correlation-id";
|
|
27
|
+
export const HEADER_ADDRESS = "x-senpi-address";
|
|
28
|
+
export const HEADER_RECIPE_NAME = "x-senpi-recipe-name";
|
|
29
|
+
export const HEADER_RUNTIME_ID = "x-senpi-runtime-id";
|
|
30
|
+
export const HEADER_RUNTIME_VERSION = "x-senpi-runtime-version";
|
|
31
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/tracking/spans/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEvD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AAEnC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,MAAM,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC,4EAA4E;AAC5E,8EAA8E;AAC9E,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC;AAEzC,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,sEAAsE;AACtE,0EAA0E;AAC1E,oBAAoB;AACpB,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAC9C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAE7C,mEAAmE;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Span telemetry — barrel export.
|
|
3
|
+
*/
|
|
4
|
+
export type { EmissionSource, OpenSpan, OpenSubagentSpan, SpanTransport, SpanType, TrackingSpan, } from "./types.js";
|
|
5
|
+
export { SPANS_API_PATH, HEADER_CORRELATION_ID, HEADER_ADDRESS, HEADER_RECIPE_NAME, HEADER_RUNTIME_ID, HEADER_RUNTIME_VERSION, } from "./constants.js";
|
|
6
|
+
export { BatchingSpanTransport, NoOpSpanTransport, type BatchingSpanTransportOptions, } from "./span-transport.js";
|
|
7
|
+
export { SpanTracker, type AgentEndInput, type DirectLlmSpanInput, type DirectToolSpanInput, type FinalizeLlmSpanInput, type FinalizeSubagentInput, type FinalizeToolSpanInput, type MergeSubagentInput, type OpenLlmSpanInput, type OpenSubagentInput, type OpenToolSpanInput, type SpanContextFields, type SpanTrackerOptions, } from "./span-tracker.js";
|
|
8
|
+
export { registerSpanHooks, type RegisterSpanHooksOptions, type SpanHooksPluginApi, } from "./span-hooks.js";
|
|
9
|
+
export { createPluginSpanTracker } from "./plugin-span-tracker.js";
|
|
10
|
+
import type { SpanTracker as _SpanTracker } from "./span-tracker.js";
|
|
11
|
+
export declare function setDefaultSpanTracker(tracker: _SpanTracker | null): void;
|
|
12
|
+
export declare function getDefaultSpanTracker(): _SpanTracker | null;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tracking/spans/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,KAAK,4BAA4B,GAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI,CAExE;AACD,wBAAgB,qBAAqB,IAAI,YAAY,GAAG,IAAI,CAE3D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Span telemetry — barrel export.
|
|
3
|
+
*/
|
|
4
|
+
export { SPANS_API_PATH, HEADER_CORRELATION_ID, HEADER_ADDRESS, HEADER_RECIPE_NAME, HEADER_RUNTIME_ID, HEADER_RUNTIME_VERSION, } from "./constants.js";
|
|
5
|
+
export { BatchingSpanTransport, NoOpSpanTransport, } from "./span-transport.js";
|
|
6
|
+
export { SpanTracker, } from "./span-tracker.js";
|
|
7
|
+
export { registerSpanHooks, } from "./span-hooks.js";
|
|
8
|
+
export { createPluginSpanTracker } from "./plugin-span-tracker.js";
|
|
9
|
+
let defaultSpanTracker = null;
|
|
10
|
+
export function setDefaultSpanTracker(tracker) {
|
|
11
|
+
defaultSpanTracker = tracker;
|
|
12
|
+
}
|
|
13
|
+
export function getDefaultSpanTracker() {
|
|
14
|
+
return defaultSpanTracker;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tracking/spans/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,GAaZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAOnE,IAAI,kBAAkB,GAAwB,IAAI,CAAC;AACnD,MAAM,UAAU,qBAAqB,CAAC,OAA4B;IAChE,kBAAkB,GAAG,OAAO,CAAC;AAC/B,CAAC;AACD,MAAM,UAAU,qBAAqB;IACnC,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-span-tracker.d.ts","sourceRoot":"","sources":["../../../src/tracking/spans/plugin-span-tracker.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA8BhD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,WAAW,CAYb"}
|