dsh-context 0.20.0 → 0.21.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/client.js CHANGED
@@ -1472,7 +1472,7 @@ function makeEventList(kit) {
1472
1472
 
1473
1473
  // src/client/meta.ts
1474
1474
  var PLUGIN_NAME = "dsh-context";
1475
- var PLUGIN_VERSION = true ? "0.20.0" : "0.0.0-dev";
1475
+ var PLUGIN_VERSION = true ? "0.21.0" : "0.0.0-dev";
1476
1476
  var PLUGIN_REPO = true ? "https://github.com/bowenliang123/dsh-context" : "https://github.com/bowenliang123/dsh-context";
1477
1477
  var PLUGIN_REPO_SHORT = PLUGIN_REPO.replace(/^https?:\/\/github\.com\//, "");
1478
1478
 
package/lib/index.js CHANGED
@@ -103,6 +103,7 @@ var contextHeadersSchema = z2.object({
103
103
  tools: z2.array(headerToolSchema)
104
104
  }).strict())
105
105
  }).strict();
106
+ var contextHeadersStateSchema = contextHeadersSchema;
106
107
  function recordOf(event) {
107
108
  if (event.type !== "request/header") return null;
108
109
  const header = event.data.header;
@@ -130,9 +131,17 @@ function recordOf(event) {
130
131
  return record;
131
132
  }
132
133
  function createContextHeadersDefinition() {
133
- return {
134
+ const view = (state) => ({
135
+ headers: state.headers.map((h) => ({ ...h, tools: h.tools.map((t) => ({ ...t })) }))
136
+ });
137
+ const definition = {
134
138
  key: "contextHeaders",
139
+ // dsh <= 0.1.0-rc.8 contract: one schema validates the wire payload, `view` is top-level.
135
140
  schema: contextHeadersSchema,
141
+ view,
142
+ // dsh >= 0.1.1-rc.1 contract: `stateSchema` validates persisted state, the client view lives in `wire`.
143
+ stateSchema: contextHeadersStateSchema,
144
+ wire: { viewSchema: contextHeadersSchema, view },
136
145
  init: () => ({ headers: [] }),
137
146
  apply: (state, event) => {
138
147
  const record = recordOf(event);
@@ -142,11 +151,9 @@ function createContextHeadersDefinition() {
142
151
  const headers = [...state.headers, record];
143
152
  return { headers: headers.length > HEADERS_MAX ? headers.slice(-HEADERS_MAX) : headers };
144
153
  },
145
- view: (state) => ({
146
- headers: state.headers.map((h) => ({ ...h, tools: h.tools.map((t) => ({ ...t })) }))
147
- }),
148
154
  stateVersion: 1
149
155
  };
156
+ return definition;
150
157
  }
151
158
 
152
159
  // src/host/timeline.ts
@@ -616,14 +623,42 @@ var contextTimelineSchema = z3.object({
616
623
  surfaceFloor: z3.number().int().nonnegative().optional(),
617
624
  archiveFloor: z3.number().int().nonnegative().optional()
618
625
  }).strict();
626
+ var timelineStateSchema = z3.object({
627
+ surface: z3.array(surfaceNodeSchema),
628
+ sums: z3.object({
629
+ user: z3.number().int().nonnegative(),
630
+ inject: z3.number().int().nonnegative(),
631
+ assistant: z3.number().int().nonnegative(),
632
+ tool: z3.number().int().nonnegative()
633
+ }).strict(),
634
+ systemTokens: z3.number().int().nonnegative(),
635
+ toolsTokens: z3.number().int().nonnegative(),
636
+ toolList: z3.array(z3.object({ name: z3.string(), tokens: z3.number().int().nonnegative() }).strict()),
637
+ model: z3.string().optional(),
638
+ provider: z3.string().optional(),
639
+ lastModel: z3.string().optional(),
640
+ contextWindow: z3.number().optional(),
641
+ requests: z3.array(requestRecordSchema),
642
+ events: z3.array(contextEventSchema),
643
+ archived: z3.array(surfaceNodeSchema),
644
+ cost: z3.object({ flash: costFamilySchema.optional(), pro: costFamilySchema.optional() }).strict().optional(),
645
+ archiveFloor: z3.number().optional(),
646
+ callNames: z3.record(z3.string(), z3.string()),
647
+ pendingShadowedSeqs: z3.array(z3.number()).optional()
648
+ });
619
649
  function createContextTimelineDefinition(config) {
620
650
  const bounds = resolveBounds(config);
621
- return {
651
+ const view = (state) => buildTimelineView(state, bounds);
652
+ const definition = {
622
653
  key: "contextTimeline",
654
+ // dsh <= 0.1.0-rc.8 contract: one schema validates the wire payload, `view` is top-level.
623
655
  schema: contextTimelineSchema,
656
+ view,
657
+ // dsh >= 0.1.1-rc.1 contract: `stateSchema` validates persisted state, the client view lives in `wire`.
658
+ stateSchema: timelineStateSchema,
659
+ wire: { viewSchema: contextTimelineSchema, view },
624
660
  init: () => createTimelineState(),
625
661
  apply: (state, event) => applyTimeline(state, event, bounds),
626
- view: (state) => buildTimelineView(state, bounds),
627
662
  // 2 since 0.11: the occupancy mirror (pressureTokens/sampledSurfaceTokens/
628
663
  // occupancyWindow) left the persisted state — the client now reads the
629
664
  // official token-meter `contextPressure` projection instead. Old cached
@@ -644,6 +679,7 @@ function createContextTimelineDefinition(config) {
644
679
  // are refolded.
645
680
  stateVersion: 5
646
681
  };
682
+ return definition;
647
683
  }
648
684
 
649
685
  // src/host/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-context",
3
- "version": "0.20.0",
3
+ "version": "0.21.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": {
@@ -59,14 +59,13 @@
59
59
  "ui"
60
60
  ],
61
61
  "license": "Apache-2.0",
62
- "dependencies": {
63
- "zod": "^4.4.3"
64
- },
62
+ "dependencies": {},
65
63
  "peerDependencies": {
66
64
  "@deepseek-ai/cordis": "^4.0.1",
67
65
  "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.7",
68
66
  "@deepseek-ai/dsh-session": "^0.1.0-rc.7",
69
- "react": "^18.3.1"
67
+ "react": "^18.3.1",
68
+ "zod": "^4.4.3"
70
69
  },
71
70
  "peerDependenciesMeta": {
72
71
  "@deepseek-ai/dsh-client-ui-primitives": {
@@ -74,6 +73,9 @@
74
73
  },
75
74
  "react": {
76
75
  "optional": true
76
+ },
77
+ "zod": {
78
+ "optional": true
77
79
  }
78
80
  },
79
81
  "devDependencies": {