dsh-continual-evolve 0.15.4 → 0.15.6
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/README.md +14 -10
- package/README.zh.md +14 -10
- package/client/client.js +229 -16
- package/lib/card-routes.d.ts +2 -0
- package/lib/card-routes.js +74 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.js +7 -2
- package/lib/memory-snapshot.d.ts +59 -1
- package/lib/memory-snapshot.js +126 -5
- package/lib/skill-rules.d.ts +79 -0
- package/lib/skill-rules.js +166 -0
- package/lib/skill-tools.d.ts +9 -0
- package/lib/skill-tools.js +205 -0
- package/lib/store.d.ts +112 -6
- package/lib/store.js +589 -6
- package/lib/token-usage.d.ts +30 -0
- package/lib/token-usage.js +58 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single accounting entry for direct LLM calls (the `token-usage.ts`
|
|
3
|
+
* the coding standard names). Observed provider payloads disagree on keys —
|
|
4
|
+
* `inputTokens`/`outputTokens` are usual, `totalTokens`, `cacheReadTokens`,
|
|
5
|
+
* `cacheWriteTokens`, and `reasoningTokens` come and go — so every call site
|
|
6
|
+
* normalizes through {@link normalizeUsage} and aggregates with
|
|
7
|
+
* {@link sumUsage}. Nothing here touches the store: aggregation over ledger
|
|
8
|
+
* rows lives in `store.reviewSummary`, which stays read-only and bounded.
|
|
9
|
+
*/
|
|
10
|
+
/** Token counts for one LLM call, every field present, zeros when unknown. */
|
|
11
|
+
export interface UsageTotals {
|
|
12
|
+
input: number;
|
|
13
|
+
output: number;
|
|
14
|
+
cacheRead: number;
|
|
15
|
+
cacheWrite: number;
|
|
16
|
+
reasoning: number;
|
|
17
|
+
total: number;
|
|
18
|
+
}
|
|
19
|
+
/** The zero value: no signal, not a failure. */
|
|
20
|
+
export declare function zeroUsage(): UsageTotals;
|
|
21
|
+
/**
|
|
22
|
+
* Normalize one provider usage payload to full totals. Returns `null` when
|
|
23
|
+
* the payload carries no usable numeric signal at all (not an object, or an
|
|
24
|
+
* object with no recognized numeric field) — callers treat that as "no
|
|
25
|
+
* accounting for this run", never as zeros that would dilute real totals.
|
|
26
|
+
*/
|
|
27
|
+
export declare function normalizeUsage(raw: unknown): UsageTotals | null;
|
|
28
|
+
/** Pure field-wise sum; either side may be a zero value. */
|
|
29
|
+
export declare function sumUsage(a: UsageTotals, b: UsageTotals): UsageTotals;
|
|
30
|
+
//# sourceMappingURL=token-usage.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single accounting entry for direct LLM calls (the `token-usage.ts`
|
|
3
|
+
* the coding standard names). Observed provider payloads disagree on keys —
|
|
4
|
+
* `inputTokens`/`outputTokens` are usual, `totalTokens`, `cacheReadTokens`,
|
|
5
|
+
* `cacheWriteTokens`, and `reasoningTokens` come and go — so every call site
|
|
6
|
+
* normalizes through {@link normalizeUsage} and aggregates with
|
|
7
|
+
* {@link sumUsage}. Nothing here touches the store: aggregation over ledger
|
|
8
|
+
* rows lives in `store.reviewSummary`, which stays read-only and bounded.
|
|
9
|
+
*/
|
|
10
|
+
/** The zero value: no signal, not a failure. */
|
|
11
|
+
export function zeroUsage() {
|
|
12
|
+
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, reasoning: 0, total: 0 };
|
|
13
|
+
}
|
|
14
|
+
function num(value) {
|
|
15
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Normalize one provider usage payload to full totals. Returns `null` when
|
|
19
|
+
* the payload carries no usable numeric signal at all (not an object, or an
|
|
20
|
+
* object with no recognized numeric field) — callers treat that as "no
|
|
21
|
+
* accounting for this run", never as zeros that would dilute real totals.
|
|
22
|
+
*/
|
|
23
|
+
export function normalizeUsage(raw) {
|
|
24
|
+
if (typeof raw !== "object" || raw === null) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const payload = raw;
|
|
28
|
+
const input = num(payload.inputTokens);
|
|
29
|
+
const output = num(payload.outputTokens);
|
|
30
|
+
const cacheRead = num(payload.cacheReadTokens);
|
|
31
|
+
const cacheWrite = num(payload.cacheWriteTokens);
|
|
32
|
+
const reasoning = num(payload.reasoningTokens);
|
|
33
|
+
const recognized = [input, output, cacheRead, cacheWrite, reasoning].some((n) => n > 0);
|
|
34
|
+
const totalRaw = num(payload.totalTokens);
|
|
35
|
+
if (!recognized && totalRaw === 0) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
input,
|
|
40
|
+
output,
|
|
41
|
+
cacheRead,
|
|
42
|
+
cacheWrite,
|
|
43
|
+
reasoning,
|
|
44
|
+
total: totalRaw > 0 ? totalRaw : input + output,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Pure field-wise sum; either side may be a zero value. */
|
|
48
|
+
export function sumUsage(a, b) {
|
|
49
|
+
return {
|
|
50
|
+
input: a.input + b.input,
|
|
51
|
+
output: a.output + b.output,
|
|
52
|
+
cacheRead: a.cacheRead + b.cacheRead,
|
|
53
|
+
cacheWrite: a.cacheWrite + b.cacheWrite,
|
|
54
|
+
reasoning: a.reasoning + b.reasoning,
|
|
55
|
+
total: a.total + b.total,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=token-usage.js.map
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Workspace Memory",
|
|
4
|
-
"description": "Central SQLite memory store partitioned by workspace: session-start index injection, gated explicit writes and proposal-based extraction."
|
|
4
|
+
"description": "Central SQLite memory and skill store partitioned by workspace: session-start index injection, gated explicit writes and proposal-based extraction, skills materialized as SKILL.md."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-continual-evolve",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.6",
|
|
4
4
|
"description": "ZCode-style workspace memory for DeepSeek Harness: one central SQLite store partitioned by workspace, index injection, and sole-writer gated writes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|