dsh-context 0.51.0 → 0.52.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/README.md +1 -1
- package/lib/client.js +5994 -5975
- package/lib/index.d.ts +15 -1
- package/lib/index.js +24 -6
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -269,7 +269,13 @@ declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
|
269
269
|
contextHeaders: HeadersState;
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
|
|
272
|
+
/**
|
|
273
|
+
* The priced surface buckets. `skill` carries every skill-machinery content
|
|
274
|
+
* the harness injects (issue #66): the `<available_skills>` catalog digest,
|
|
275
|
+
* a user-explicit `/name` invocation's instructions message, and the content
|
|
276
|
+
* a `skill`-tool load returns (modeled as a tool result by the harness).
|
|
277
|
+
*/
|
|
278
|
+
type Category = 'user' | 'inject' | 'skill' | 'assistant' | 'tool';
|
|
273
279
|
/**
|
|
274
280
|
* One live system-prompt node (Snapshot.systems) — the harness models the
|
|
275
281
|
* system prompt as a surface node, so its TEXT is fetched on demand from the
|
|
@@ -329,6 +335,7 @@ interface Snapshot {
|
|
|
329
335
|
tools: number;
|
|
330
336
|
user: number;
|
|
331
337
|
inject: number;
|
|
338
|
+
skill: number;
|
|
332
339
|
assistant: number;
|
|
333
340
|
tool: number;
|
|
334
341
|
total: number;
|
|
@@ -633,6 +640,13 @@ interface RequestRecord {
|
|
|
633
640
|
tool: number;
|
|
634
641
|
total: number;
|
|
635
642
|
prompt?: number;
|
|
643
|
+
/**
|
|
644
|
+
* Skill-machinery tokens of this request (the `skill` composition
|
|
645
|
+
* category — catalog digests, invocation instructions, `skill`-tool
|
|
646
|
+
* loads). Always written by the current fold; absent on rows folded
|
|
647
|
+
* before the category existed (read as 0).
|
|
648
|
+
*/
|
|
649
|
+
skill?: number;
|
|
636
650
|
/**
|
|
637
651
|
* Billed cache-read (served) prompt tokens of this request — the
|
|
638
652
|
* hit-rate numerator against `prompt` (input + cacheRead + cacheWrite).
|
package/lib/index.js
CHANGED
|
@@ -1035,6 +1035,7 @@ function createTimelineState() {
|
|
|
1035
1035
|
sums: {
|
|
1036
1036
|
user: 0,
|
|
1037
1037
|
inject: 0,
|
|
1038
|
+
skill: 0,
|
|
1038
1039
|
assistant: 0,
|
|
1039
1040
|
tool: 0
|
|
1040
1041
|
},
|
|
@@ -1050,6 +1051,8 @@ function createTimelineState() {
|
|
|
1050
1051
|
function categoryOf(type, message) {
|
|
1051
1052
|
if (type === "assistant/message") return "assistant";
|
|
1052
1053
|
if (type === "tool/result") return "tool";
|
|
1054
|
+
const kind = message?.source?.kind;
|
|
1055
|
+
if (kind === "skill-invocation" || kind === "skill-catalog") return "skill";
|
|
1053
1056
|
if (isInjection(message?.source)) return "inject";
|
|
1054
1057
|
return "user";
|
|
1055
1058
|
}
|
|
@@ -1666,6 +1669,10 @@ function applyTimeline(state, event, bounds) {
|
|
|
1666
1669
|
const name = skillNameOf(toolMsg);
|
|
1667
1670
|
if (name !== "") {
|
|
1668
1671
|
node.skill = name;
|
|
1672
|
+
if (node.tool === void 0) node.tool = "skill";
|
|
1673
|
+
s.sums.tool -= node.tokens;
|
|
1674
|
+
node.cat = "skill";
|
|
1675
|
+
s.sums.skill += node.tokens;
|
|
1669
1676
|
s.events.push({
|
|
1670
1677
|
seq: event.seq,
|
|
1671
1678
|
time: event.time,
|
|
@@ -1683,7 +1690,7 @@ function applyTimeline(state, event, bounds) {
|
|
|
1683
1690
|
const usage = data?.usage;
|
|
1684
1691
|
const s = ensure();
|
|
1685
1692
|
bumpDetailRev(s);
|
|
1686
|
-
const total = s.systemTokens + s.toolsTokens + s.sums.user + s.sums.inject + s.sums.assistant + s.sums.tool;
|
|
1693
|
+
const total = s.systemTokens + s.toolsTokens + s.sums.user + s.sums.inject + s.sums.skill + s.sums.assistant + s.sums.tool;
|
|
1687
1694
|
const record = {
|
|
1688
1695
|
time: event.time,
|
|
1689
1696
|
seq: event.seq,
|
|
@@ -1691,6 +1698,7 @@ function applyTimeline(state, event, bounds) {
|
|
|
1691
1698
|
tools: s.toolsTokens,
|
|
1692
1699
|
user: s.sums.user,
|
|
1693
1700
|
inject: s.sums.inject,
|
|
1701
|
+
skill: s.sums.skill,
|
|
1694
1702
|
assistant: s.sums.assistant,
|
|
1695
1703
|
tool: s.sums.tool,
|
|
1696
1704
|
total
|
|
@@ -1787,7 +1795,7 @@ function applyTimeline(state, event, bounds) {
|
|
|
1787
1795
|
* issue #29).
|
|
1788
1796
|
*/
|
|
1789
1797
|
function headFieldsOf(state) {
|
|
1790
|
-
const surfaceTotal = state.sums.user + state.sums.inject + state.sums.assistant + state.sums.tool;
|
|
1798
|
+
const surfaceTotal = state.sums.user + state.sums.inject + state.sums.skill + state.sums.assistant + state.sums.tool;
|
|
1791
1799
|
const result = {
|
|
1792
1800
|
ok: true,
|
|
1793
1801
|
...state.model !== void 0 ? { model: state.model } : {},
|
|
@@ -1798,12 +1806,13 @@ function headFieldsOf(state) {
|
|
|
1798
1806
|
tools: state.toolsTokens,
|
|
1799
1807
|
user: state.sums.user,
|
|
1800
1808
|
inject: state.sums.inject,
|
|
1809
|
+
skill: state.sums.skill,
|
|
1801
1810
|
assistant: state.sums.assistant,
|
|
1802
1811
|
tool: state.sums.tool,
|
|
1803
1812
|
total: surfaceTotal + state.systemTokens + state.toolsTokens
|
|
1804
1813
|
},
|
|
1805
1814
|
images: state.surface.reduce((n, node) => n + (node.imgs ?? 0), 0),
|
|
1806
|
-
toolCalls: state.surface.reduce((n, node) => node.cat === "tool" ? n + 1 : n, 0),
|
|
1815
|
+
toolCalls: state.surface.reduce((n, node) => node.cat === "tool" || node.cat === "skill" && node.tool !== void 0 ? n + 1 : n, 0),
|
|
1807
1816
|
humanInputs: state.humanInputs ?? 0,
|
|
1808
1817
|
requests: [],
|
|
1809
1818
|
events: [],
|
|
@@ -1857,12 +1866,12 @@ function detailCollectionsOf(state, bounds) {
|
|
|
1857
1866
|
const overflowCount = Math.max(0, state.surface.length - bounds.maxNodes);
|
|
1858
1867
|
const overflow = state.surface.slice(0, overflowCount);
|
|
1859
1868
|
const tail = state.surface.slice(overflowCount);
|
|
1860
|
-
const pinned = overflow.filter((n) => n.cat === "inject");
|
|
1869
|
+
const pinned = overflow.filter((n) => n.cat === "inject" || n.cat === "skill");
|
|
1861
1870
|
result.nodes = pinned.length > 0 ? [...pinned, ...tail] : tail;
|
|
1862
1871
|
result.droppedNodes = overflowCount - pinned.length;
|
|
1863
1872
|
if (result.droppedNodes > 0) {
|
|
1864
1873
|
let floor = 0;
|
|
1865
|
-
for (const n of overflow) if (n.cat !== "inject") floor = Math.max(floor, n.seq);
|
|
1874
|
+
for (const n of overflow) if (n.cat !== "inject" && n.cat !== "skill") floor = Math.max(floor, n.seq);
|
|
1866
1875
|
result.surfaceFloor = floor;
|
|
1867
1876
|
}
|
|
1868
1877
|
if (state.archiveFloor !== void 0) result.archiveFloor = state.archiveFloor;
|
|
@@ -2259,6 +2268,7 @@ const surfaceNodeSchema = z.object({
|
|
|
2259
2268
|
cat: z.enum([
|
|
2260
2269
|
"user",
|
|
2261
2270
|
"inject",
|
|
2271
|
+
"skill",
|
|
2262
2272
|
"assistant",
|
|
2263
2273
|
"tool"
|
|
2264
2274
|
]),
|
|
@@ -2291,6 +2301,11 @@ const requestRecordSchema = z.object({
|
|
|
2291
2301
|
tool: z.number().int().nonnegative(),
|
|
2292
2302
|
total: z.number().int().nonnegative(),
|
|
2293
2303
|
prompt: z.number().int().nonnegative().optional(),
|
|
2304
|
+
/**
|
|
2305
|
+
* Skill-machinery tokens (issue #66). The fold writes it on every record;
|
|
2306
|
+
* optional so rows folded before the category existed still parse.
|
|
2307
|
+
*/
|
|
2308
|
+
skill: z.number().int().nonnegative().optional(),
|
|
2294
2309
|
cacheRead: z.number().int().nonnegative().optional(),
|
|
2295
2310
|
output: z.number().int().nonnegative().optional(),
|
|
2296
2311
|
stepCount: z.number().int().positive().optional()
|
|
@@ -2351,6 +2366,7 @@ const currentSchema = z.object({
|
|
|
2351
2366
|
tools: z.number().int().nonnegative(),
|
|
2352
2367
|
user: z.number().int().nonnegative(),
|
|
2353
2368
|
inject: z.number().int().nonnegative(),
|
|
2369
|
+
skill: z.number().int().nonnegative(),
|
|
2354
2370
|
assistant: z.number().int().nonnegative(),
|
|
2355
2371
|
tool: z.number().int().nonnegative(),
|
|
2356
2372
|
total: z.number().int().nonnegative()
|
|
@@ -2447,6 +2463,7 @@ const timelineStateSchema = z.object({
|
|
|
2447
2463
|
sums: z.object({
|
|
2448
2464
|
user: z.number().int().nonnegative(),
|
|
2449
2465
|
inject: z.number().int().nonnegative(),
|
|
2466
|
+
skill: z.number().int().nonnegative(),
|
|
2450
2467
|
assistant: z.number().int().nonnegative(),
|
|
2451
2468
|
tool: z.number().int().nonnegative()
|
|
2452
2469
|
}).strict(),
|
|
@@ -2539,7 +2556,7 @@ function createContextTimelineDefinition(config, slim) {
|
|
|
2539
2556
|
},
|
|
2540
2557
|
init: () => createTimelineState(),
|
|
2541
2558
|
apply: (state, event) => applyTimeline(state, event, bounds),
|
|
2542
|
-
stateVersion:
|
|
2559
|
+
stateVersion: 19
|
|
2543
2560
|
};
|
|
2544
2561
|
}
|
|
2545
2562
|
//#endregion
|
|
@@ -2611,6 +2628,7 @@ function createFallbackTimelineDefinition(current) {
|
|
|
2611
2628
|
tools: 0,
|
|
2612
2629
|
user: 0,
|
|
2613
2630
|
inject: 0,
|
|
2631
|
+
skill: 0,
|
|
2614
2632
|
assistant: 0,
|
|
2615
2633
|
tool: 0,
|
|
2616
2634
|
total: 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "A DeepSeek Harness plugin for context insight and management, with context dashboard and context command, for understanding how the context is made of, and how it evolves.",
|
|
5
5
|
"author": "bowenliang123",
|
|
6
6
|
"repository": {
|