@deepseek-ai/dsh-time-context 0.1.2-alpha.2 → 0.1.2-alpha.4

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 CHANGED
@@ -1,6 +1,7 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
2
  import { z as z$1 } from "zod";
3
3
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
4
+ import { SessionSeq } from "@deepseek-ai/dsh-session";
4
5
  import { assertNever } from "@deepseek-ai/dsh-util-values";
5
6
  //#region lib/types/request-zone.js
6
7
  /** Browser-zone derivation and model-facing policy text for one open request turn. */
@@ -132,8 +133,13 @@ function formatDuration(elapsedMs) {
132
133
  }
133
134
  /** Collect already-entered and proposed user messages belonging to one open turn. */
134
135
  function requestMessages(agent, turn, proposed) {
135
- const start = agent.session.events.findLastIndex((event) => event.type === "turn/start" && event.data.turn === turn);
136
- return [...start < 0 ? [] : agent.session.events.slice(start + 1).flatMap((event) => event.type === "user/message" ? [event.data] : []), ...proposed];
136
+ const entered = [];
137
+ for (let seq = agent.session.seq - 1; seq >= 0; seq -= 1) {
138
+ const event = agent.session.eventAt(SessionSeq(seq));
139
+ if (event?.type === "turn/start" && event.data.turn === turn) return [...entered.reverse(), ...proposed];
140
+ if (event?.type === "user/message") entered.push(event.data);
141
+ }
142
+ return [...proposed];
137
143
  }
138
144
  function renderText(now, turn, step, previous, formatter, timeZone, browserContext) {
139
145
  const elapsed = previous === void 0 ? "unavailable" : formatDuration(now - previous);
package/lib/invariant.js CHANGED
@@ -180,9 +180,10 @@ function validateReading(history, event, fail) {
180
180
  }
181
181
  /** Validate all package-owned readings already present in one session. */
182
182
  function validateSession(session, fail) {
183
- for (const [index, event] of session.events.entries()) {
183
+ const events = session.snapshotEvents();
184
+ for (const [index, event] of events.entries()) {
184
185
  if (event.type !== "user/message" || event.data.source.kind !== "plugin" || event.data.source.plugin !== SOURCE_NAME) continue;
185
- validateReading(session.events.slice(0, index), event, fail);
186
+ validateReading(events.slice(0, index), event, fail);
186
187
  }
187
188
  }
188
189
  /** Install validation for loaded and newly appended context readings. */
@@ -195,7 +196,7 @@ const install = Object.assign((ctx, fail) => {
195
196
  if (eventName !== "session/event") return;
196
197
  const [session, event] = args;
197
198
  if (event.type !== "user/message" || event.data.source.kind !== "plugin" || event.data.source.plugin !== SOURCE_NAME) return;
198
- validateReading(session.events, event, fail);
199
+ validateReading(session.snapshotEvents(), event, fail);
199
200
  }, { global: true });
200
201
  }, { inject: ["sessions"] });
201
202
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-time-context",
3
3
  "description": "Opt-in durable per-step context with the current time and elapsed time",
4
- "version": "0.1.2-alpha.2",
4
+ "version": "0.1.2-alpha.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -33,34 +33,33 @@
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
35
  "zod": "^4.4.3",
36
- "@deepseek-ai/dsh-util-values": "^0.1.2-alpha.2",
37
- "@deepseek-ai/schemastery": "^3.18.2"
36
+ "@deepseek-ai/schemastery": "^3.18.2",
37
+ "@deepseek-ai/dsh-util-values": "^0.1.2-alpha.4"
38
38
  },
39
39
  "peerDependencies": {
40
- "@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
41
- "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
40
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.4",
42
41
  "@deepseek-ai/cordis": "^4.0.2",
43
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
44
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.2",
45
- "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.2"
42
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.4",
43
+ "@deepseek-ai/dsh-llm": "^0.1.2-alpha.4",
44
+ "@deepseek-ai/dsh-session": "^0.1.2-alpha.4",
45
+ "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.4"
46
46
  },
47
47
  "devDependencies": {
48
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.4",
49
+ "@deepseek-ai/dsh-agent-loop": "^0.1.2-alpha.4",
50
+ "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.2-alpha.4",
48
51
  "@deepseek-ai/cordis": "^4.0.2",
49
- "@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
50
- "@deepseek-ai/dsh-agent-loop": "^0.1.2-alpha.2",
51
- "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.2-alpha.2",
52
- "@deepseek-ai/dsh-bash-local": "^0.1.2-alpha.2",
53
- "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
54
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
55
- "@deepseek-ai/dsh-app-boot": "^0.1.2-alpha.2",
56
- "@deepseek-ai/dsh-agent-spine-demo": "^0.1.2-alpha.2",
57
- "@deepseek-ai/dsh-loader-smoke": "^0.1.2-alpha.2",
58
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.2",
59
- "@deepseek-ai/dsh-session-checkpoint-policy": "^0.1.2-alpha.2",
60
- "@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.2-alpha.2",
61
- "@deepseek-ai/dsh-subprocess-local": "^0.1.2-alpha.2",
62
- "@deepseek-ai/dsh-system-prompt": "^0.1.2-alpha.2",
63
- "@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
64
- "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.2"
52
+ "@deepseek-ai/dsh-app-boot": "^0.1.2-alpha.4",
53
+ "@deepseek-ai/dsh-bash-local": "^0.1.2-alpha.4",
54
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.4",
55
+ "@deepseek-ai/dsh-llm": "^0.1.2-alpha.4",
56
+ "@deepseek-ai/dsh-loader-smoke": "^0.1.2-alpha.4",
57
+ "@deepseek-ai/dsh-session": "^0.1.2-alpha.4",
58
+ "@deepseek-ai/dsh-session-checkpoint-policy": "^0.1.2-alpha.4",
59
+ "@deepseek-ai/dsh-session-persistence-jsonl": "^0.1.2-alpha.4",
60
+ "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.4",
61
+ "@deepseek-ai/dsh-subprocess-local": "^0.1.2-alpha.4",
62
+ "@deepseek-ai/dsh-system-prompt": "^0.1.2-alpha.4",
63
+ "@deepseek-ai/dsh-tools": "^0.1.2-alpha.4"
65
64
  }
66
65
  }