@lmzhen/dsh-skill-usage 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +23 -4
- package/lib/types/index.d.ts +11 -0
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Service } from "@deepseek-ai/cordis";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
|
-
import { ToolDispatchNormalizer, appendEvolutionEvent, bumpPatch, bumpUse, bumpView, eventsFile, evolutionIoAdapter, evolutionRoot, getRecord, loadUsage, makeSerialQueue, markAgentCreated, mutateUsage, resolveSkillsRoot, sessionAudited, skillReadNameOf, usageObserved } from "@lmzhen/dsh-evolution-core";
|
|
3
|
+
import { DEFAULT_SUPPORT_READ_TOOL_NAMES, ToolDispatchNormalizer, appendEvolutionEvent, bumpPatch, bumpSupportRead, bumpUse, bumpView, eventsFile, evolutionIoAdapter, evolutionRoot, getRecord, isReviewChannelSession, loadUsage, makeSerialQueue, markAgentCreated, mutateUsage, resolveSkillsRoot, sessionAudited, skillReadNameOf, supportFileReadOf, usageObserved } from "@lmzhen/dsh-evolution-core";
|
|
4
4
|
//#region lib/types/index.js
|
|
5
5
|
/**
|
|
6
6
|
* Skill usage telemetry service for the evolution family.
|
|
@@ -42,16 +42,19 @@ var SkillUsageRegistry = class extends Service {
|
|
|
42
42
|
static Config = z.object({
|
|
43
43
|
root: z.string().default(""),
|
|
44
44
|
eventsHome: z.string().default(""),
|
|
45
|
-
sessionScoped: z.boolean().default(false)
|
|
45
|
+
sessionScoped: z.boolean().default(false),
|
|
46
|
+
supportReadToolNames: z.array(z.string()).default([...DEFAULT_SUPPORT_READ_TOOL_NAMES])
|
|
46
47
|
});
|
|
47
48
|
root;
|
|
48
49
|
eventsHome;
|
|
49
50
|
io;
|
|
51
|
+
supportReadToolNames;
|
|
50
52
|
/** Process-local RMW queue (v34 B14 / v35 R6: the same factory the other sidecars use). */
|
|
51
53
|
serial = makeSerialQueue();
|
|
52
54
|
constructor(ctx, config = {}) {
|
|
53
55
|
super(ctx, "skillUsage");
|
|
54
56
|
this.root = resolveSkillsRoot(config);
|
|
57
|
+
this.supportReadToolNames = config.supportReadToolNames ?? DEFAULT_SUPPORT_READ_TOOL_NAMES;
|
|
55
58
|
this.eventsHome = config.eventsHome?.trim() || evolutionRoot();
|
|
56
59
|
this.io = evolutionIoAdapter(() => ctx.evolutionIo.provider());
|
|
57
60
|
ctx.effect(() => {
|
|
@@ -62,8 +65,12 @@ var SkillUsageRegistry = class extends Service {
|
|
|
62
65
|
const settled = reads.settledSignalOf(event, session.id);
|
|
63
66
|
if (settled === null || settled.ok === false) return;
|
|
64
67
|
const settledName = skillReadNameOf(settled);
|
|
65
|
-
if (settledName
|
|
66
|
-
|
|
68
|
+
if (settledName !== void 0) this.observeRead(settledName).catch(() => {});
|
|
69
|
+
const supportHit = supportFileReadOf(settled, {
|
|
70
|
+
toolNames: this.supportReadToolNames,
|
|
71
|
+
root: this.root
|
|
72
|
+
});
|
|
73
|
+
if (supportHit !== null && !isReviewChannelSession(session.id)) this.recordSupportRead(supportHit.skill, supportHit.rel).catch(() => {});
|
|
67
74
|
});
|
|
68
75
|
}, "skill-usage.telemetry");
|
|
69
76
|
}
|
|
@@ -89,6 +96,18 @@ var SkillUsageRegistry = class extends Service {
|
|
|
89
96
|
});
|
|
90
97
|
}
|
|
91
98
|
/**
|
|
99
|
+
* Demand telemetry (design §5.5): count one observed support-file read on an
|
|
100
|
+
* EXISTING record only — the same creation-free discipline as `observeRead`,
|
|
101
|
+
* so a read can never mint a usage record.
|
|
102
|
+
*/
|
|
103
|
+
recordSupportRead(name, rel) {
|
|
104
|
+
const normalized = name.trim();
|
|
105
|
+
return this.mutate((map) => {
|
|
106
|
+
if (!map.has(normalized)) return;
|
|
107
|
+
bumpSupportRead(map, normalized, rel, /* @__PURE__ */ new Date());
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
92
111
|
* Append the observation-window anchor event; best-effort, never fails the
|
|
93
112
|
* observation.
|
|
94
113
|
*
|
package/lib/types/index.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export interface Config {
|
|
|
17
17
|
/** Act only on sessions that carry the family's model tools (evolution-core's
|
|
18
18
|
* per-session probe). The shipped bundles set it; false observes every session. */
|
|
19
19
|
sessionScoped?: boolean;
|
|
20
|
+
/** Tool names whose dispatch reads one FILE (design §5.5). Demand for a
|
|
21
|
+
* support file is attributed from these; a deployment whose file tool has a
|
|
22
|
+
* different name configures it here instead of being mis-detected. */
|
|
23
|
+
supportReadToolNames?: string[];
|
|
20
24
|
}
|
|
21
25
|
export declare class SkillUsageRegistry extends Service {
|
|
22
26
|
static inject: string[];
|
|
@@ -24,6 +28,7 @@ export declare class SkillUsageRegistry extends Service {
|
|
|
24
28
|
readonly root: string;
|
|
25
29
|
private readonly eventsHome;
|
|
26
30
|
private readonly io;
|
|
31
|
+
private readonly supportReadToolNames;
|
|
27
32
|
/** Process-local RMW queue (v34 B14 / v35 R6: the same factory the other sidecars use). */
|
|
28
33
|
private readonly serial;
|
|
29
34
|
constructor(ctx: Context, config?: Config);
|
|
@@ -40,6 +45,12 @@ export declare class SkillUsageRegistry extends Service {
|
|
|
40
45
|
* that anchor exists (curator gates churn on `usageObserved()`).
|
|
41
46
|
*/
|
|
42
47
|
private observeRead;
|
|
48
|
+
/**
|
|
49
|
+
* Demand telemetry (design §5.5): count one observed support-file read on an
|
|
50
|
+
* EXISTING record only — the same creation-free discipline as `observeRead`,
|
|
51
|
+
* so a read can never mint a usage record.
|
|
52
|
+
*/
|
|
53
|
+
private recordSupportRead;
|
|
43
54
|
/**
|
|
44
55
|
* Append the observation-window anchor event; best-effort, never fails the
|
|
45
56
|
* observation.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-skill-usage",
|
|
3
3
|
"description": "Skill usage telemetry service (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
30
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-core": "^0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
34
34
|
"@deepseek-ai/dsh-session": "^0.1.5-rc.2",
|
|
35
|
-
"@lmzhen/dsh-evolution-io": "^0.
|
|
35
|
+
"@lmzhen/dsh-evolution-io": "^0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@deepseek-ai/dsh-session": "^0.1.5-rc.2",
|
|
39
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
40
|
-
"@lmzhen/dsh-evolution-io": "^0.
|
|
39
|
+
"@lmzhen/dsh-evolution-core": "^0.5.0",
|
|
40
|
+
"@lmzhen/dsh-evolution-io": "^0.5.0"
|
|
41
41
|
}
|
|
42
42
|
}
|