@x1a0f3n9/dsh-session-query 0.1.5-rc.5 → 0.1.7-rc.2
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.i18n.yaml +66 -5
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/index.js +15 -9
- package/lib/types/observation.d.ts +1 -0
- package/package.json +22 -19
package/README.i18n.yaml
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
|
-
# Bilingual-pair consistency record (docs/i18n/README.md):
|
|
2
|
-
#
|
|
3
|
-
#
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/session-query/session-query/README.md
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/:
|
|
6
|
+
en: 3d1caf01d90c7f34
|
|
7
|
+
zh: 4fa615b905574d83
|
|
8
|
+
/x1a0f3n9-dsh-session-query:
|
|
9
|
+
en: daacbb8bb998f749
|
|
10
|
+
zh: ec12cadcba79cf24
|
|
11
|
+
/x1a0f3n9-dsh-session-query/summary:
|
|
12
|
+
en: 25e9ed4d6de7c4ac
|
|
13
|
+
zh: 8b57631f7207b959
|
|
14
|
+
/x1a0f3n9-dsh-session-query/table-of-contents:
|
|
15
|
+
en: d152484eb41ac6b4
|
|
16
|
+
zh: 09388d293f9be9cb
|
|
17
|
+
/x1a0f3n9-dsh-session-query/use-this-package:
|
|
18
|
+
en: 61b01acfa7afadb6
|
|
19
|
+
zh: f0df61147f689421
|
|
20
|
+
/x1a0f3n9-dsh-session-query/use-this-package/what-you-can-do:
|
|
21
|
+
en: 742b1358d97e56cc
|
|
22
|
+
zh: 00d75ce6e5769559
|
|
23
|
+
/x1a0f3n9-dsh-session-query/use-this-package/filters:
|
|
24
|
+
en: 1b95403461947ca1
|
|
25
|
+
zh: cffa21b03df9f0ad
|
|
26
|
+
/x1a0f3n9-dsh-session-query/use-this-package/configuration:
|
|
27
|
+
en: bec9cedaa219e297
|
|
28
|
+
zh: e9cd16c0589fab4d
|
|
29
|
+
/x1a0f3n9-dsh-session-query/use-this-package/failures-and-recovery:
|
|
30
|
+
en: fe410eb1234c1c45
|
|
31
|
+
zh: d2a1be75eb841be0
|
|
32
|
+
/x1a0f3n9-dsh-session-query/understand-the-implementation:
|
|
33
|
+
en: 6a18034f1ccc247a
|
|
34
|
+
zh: aecd49a7b846f913
|
|
35
|
+
/x1a0f3n9-dsh-session-query/understand-the-implementation/design-philosophy:
|
|
36
|
+
en: b34fb0d209192ff4
|
|
37
|
+
zh: 455bdb024d04f16a
|
|
38
|
+
/x1a0f3n9-dsh-session-query/understand-the-implementation/source-map:
|
|
39
|
+
en: 7c546162fa3f75d4
|
|
40
|
+
zh: c6910bc53ae0ff71
|
|
41
|
+
/x1a0f3n9-dsh-session-query/understand-the-implementation/corpus-resolution:
|
|
42
|
+
en: efa560c55a869c71
|
|
43
|
+
zh: 451eb107825856ac
|
|
44
|
+
/x1a0f3n9-dsh-session-query/understand-the-implementation/observation-cache:
|
|
45
|
+
en: abe122deb81566e5
|
|
46
|
+
zh: 4c4f327f2ee1144e
|
|
47
|
+
/x1a0f3n9-dsh-session-query/understand-the-implementation/reads-and-traces:
|
|
48
|
+
en: 48922e284adddd1b
|
|
49
|
+
zh: 9956dcc57e027d77
|
|
50
|
+
/x1a0f3n9-dsh-session-query/further-exploration:
|
|
51
|
+
en: 40a0579a433d568e
|
|
52
|
+
zh: c34ff46da6cbd3e5
|
|
53
|
+
/x1a0f3n9-dsh-session-query/model-experience:
|
|
54
|
+
en: dff12da8d1e64e66
|
|
55
|
+
zh: e054b0d54e29f899
|
|
56
|
+
/x1a0f3n9-dsh-session-query/model-experience/kv-cache-effect:
|
|
57
|
+
en: ca75c51c89c2c9b0
|
|
58
|
+
zh: f57cc48a1b5cbfa9
|
|
59
|
+
/x1a0f3n9-dsh-session-query/known-limitations-and-deferred-work:
|
|
60
|
+
en: e70a64614189c09c
|
|
61
|
+
zh: 88d2a6634385c501
|
|
62
|
+
/x1a0f3n9-dsh-session-query/known-limitations-and-deferred-work/dev-note:
|
|
63
|
+
en: d2f0d68fe29fb750
|
|
64
|
+
zh: 323d21ee73a9e3f6
|
|
65
|
+
/x1a0f3n9-dsh-session-query/known-limitations-and-deferred-work/dev-note/future-extractor-and-search-provider-registries:
|
|
66
|
+
en: 605a72e65297c6cf
|
|
67
|
+
zh: 87aa75ec62eccbde
|
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ The inherited knobs are set through the mounted backend's config:
|
|
|
62
62
|
|
|
63
63
|
### Failures and recovery
|
|
64
64
|
|
|
65
|
-
Failures are typed with a stable `SessionQueryError.code`. The ones you will meet: `SESSION_QUERY_SESSION_NOT_FOUND` when an id is absent; `SESSION_QUERY_SOURCE_CONFLICT` when live and persisted observations of one session disagree on immutable headers; `SESSION_QUERY_PERSISTENCE_FAILED` when mounted persistence is unreadable; `SESSION_QUERY_CORRUPT_SESSION` when a durable record fails Session validation; and `SESSION_QUERY_INVALID_SURFACE` when a loaded log breaks the surface contract. Reads targeting a known live session never consult persistence, so a failing backend cannot make current in-memory history unreadable.
|
|
65
|
+
Failures are typed with a stable `SessionQueryError.code`. The ones you will meet: `SESSION_QUERY_SESSION_NOT_FOUND` when an id is absent; `SESSION_QUERY_SOURCE_CONFLICT` when live and persisted observations of one session disagree on immutable headers; `SESSION_QUERY_PERSISTENCE_FAILED` when mounted persistence is unreadable; `SESSION_QUERY_CORRUPT_SESSION` when a durable record fails Session validation or a live or prepared observation fails projection computation; and `SESSION_QUERY_INVALID_SURFACE` when a loaded log breaks the surface contract. Projection failures retain the original error as `cause`. Reads targeting a known live session never consult persistence, so a failing backend cannot make current in-memory history unreadable.
|
|
66
66
|
|
|
67
67
|
-----
|
|
68
68
|
|
package/README.zh.md
CHANGED
|
@@ -62,7 +62,7 @@ kind: "package-reference"
|
|
|
62
62
|
|
|
63
63
|
### 失败与恢复
|
|
64
64
|
|
|
65
|
-
失败带有稳定的 `SessionQueryError.code` 类型。你会遇到的包括:id 不存在时 `SESSION_QUERY_SESSION_NOT_FOUND`;同一会话的实时与持久化观察在不可变 header 上不一致时 `SESSION_QUERY_SOURCE_CONFLICT`;已挂载持久化不可读时 `SESSION_QUERY_PERSISTENCE_FAILED`;持久化记录未通过 Session
|
|
65
|
+
失败带有稳定的 `SessionQueryError.code` 类型。你会遇到的包括:id 不存在时 `SESSION_QUERY_SESSION_NOT_FOUND`;同一会话的实时与持久化观察在不可变 header 上不一致时 `SESSION_QUERY_SOURCE_CONFLICT`;已挂载持久化不可读时 `SESSION_QUERY_PERSISTENCE_FAILED`;持久化记录未通过 Session 校验,或实时或 prepared 观察的投影计算失败时 `SESSION_QUERY_CORRUPT_SESSION`;加载的日志破坏表层约定时 `SESSION_QUERY_INVALID_SURFACE`。投影失败会将原始错误保留为 `cause`。针对已知实时会话的读取从不查询持久化,因此后端故障不会让当前内存历史变得不可读。
|
|
66
66
|
|
|
67
67
|
-----
|
|
68
68
|
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { currentSessionMessageProjections } from "@x1a0f3n9/dsh-session-format-catalog/message-projections";
|
|
1
2
|
import { Service } from "@deepseek-ai/cordis";
|
|
2
3
|
import { Session, SessionLogOffset, SessionSeq, foldSurface, interruptedTurnClosers, isSurfaceEvent, snapshotSessionEvent } from "@x1a0f3n9/dsh-session";
|
|
3
4
|
import { foldSessionTitle } from "@x1a0f3n9/dsh-session-title";
|
|
@@ -342,6 +343,7 @@ var SessionObservationReader = class {
|
|
|
342
343
|
* @param sessionId - logical Session identity.
|
|
343
344
|
* @param options - cancellation and all-or-none projection computation for this read.
|
|
344
345
|
* @returns one exact immutable observation.
|
|
346
|
+
* @throws {@link SessionQueryError} with code `SESSION_QUERY_CORRUPT_SESSION` when live or prepared projection computation fails.
|
|
345
347
|
*/
|
|
346
348
|
async read(sessionId, options = {}) {
|
|
347
349
|
const { signal, projectionMode = "all" } = options;
|
|
@@ -354,7 +356,7 @@ var SessionObservationReader = class {
|
|
|
354
356
|
const snapshot = await this.statSource(persistence, sessionId, signal);
|
|
355
357
|
const attachedDuringStat = this.ctx.sessions.get(sessionId);
|
|
356
358
|
if (attachedDuringStat !== void 0) return this.live(attachedDuringStat, projectionMode);
|
|
357
|
-
let entry = this.cachedEntry(persistence, sessionId, snapshot.revision);
|
|
359
|
+
let entry = this.cachedEntry(persistence.identity, sessionId, snapshot.revision);
|
|
358
360
|
if (entry === void 0) {
|
|
359
361
|
const loaded = await this.loadSource(persistence, sessionId, signal);
|
|
360
362
|
throwIfObservationAborted(signal);
|
|
@@ -374,7 +376,7 @@ var SessionObservationReader = class {
|
|
|
374
376
|
throw new SessionQueryError(`stored session "${sessionId}" is corrupt: ${errorMessage(error)}`, "SESSION_QUERY_CORRUPT_SESSION", { cause: error });
|
|
375
377
|
}
|
|
376
378
|
entry = {
|
|
377
|
-
persistence,
|
|
379
|
+
persistenceIdentity: persistence.identity,
|
|
378
380
|
revision: snapshot.revision,
|
|
379
381
|
session,
|
|
380
382
|
events: Object.freeze(seed),
|
|
@@ -415,9 +417,9 @@ var SessionObservationReader = class {
|
|
|
415
417
|
}
|
|
416
418
|
}
|
|
417
419
|
/** Return a still-valid cached entry and mark it most recently used. */
|
|
418
|
-
cachedEntry(
|
|
420
|
+
cachedEntry(persistenceIdentity, sessionId, revision) {
|
|
419
421
|
const cached = this.cache.get(sessionId);
|
|
420
|
-
if (cached === void 0 || cached.
|
|
422
|
+
if (cached === void 0 || cached.persistenceIdentity !== persistenceIdentity || cached.revision !== revision) return;
|
|
421
423
|
this.cache.delete(sessionId);
|
|
422
424
|
this.cache.set(sessionId, cached);
|
|
423
425
|
return cached;
|
|
@@ -473,7 +475,12 @@ var SessionObservationReader = class {
|
|
|
473
475
|
live(session, projectionMode) {
|
|
474
476
|
const seq = session.seq;
|
|
475
477
|
let materialized;
|
|
476
|
-
|
|
478
|
+
let projections;
|
|
479
|
+
try {
|
|
480
|
+
projections = projectionMode === "none" ? void 0 : this.ctx.get("sessionProjections")?.snapshot(session);
|
|
481
|
+
} catch (error) {
|
|
482
|
+
throw new SessionQueryError(`failed to project session "${session.id}": ${errorMessage(error)}`, "SESSION_QUERY_CORRUPT_SESSION", { cause: error });
|
|
483
|
+
}
|
|
477
484
|
const lease = () => {
|
|
478
485
|
let disposed = false;
|
|
479
486
|
return {
|
|
@@ -571,7 +578,6 @@ function blockText(block) {
|
|
|
571
578
|
case "text": return [block.text];
|
|
572
579
|
case "reasoning": return [];
|
|
573
580
|
case "tool-call": return [block.name, block.arguments];
|
|
574
|
-
case "tool-result": return block.content.flatMap(blockText);
|
|
575
581
|
default: return [];
|
|
576
582
|
}
|
|
577
583
|
}
|
|
@@ -623,7 +629,7 @@ function buildSessionEventSearchDocuments(sessionId, events) {
|
|
|
623
629
|
function classifySurface(events) {
|
|
624
630
|
let folded;
|
|
625
631
|
try {
|
|
626
|
-
folded = foldSurface(events);
|
|
632
|
+
folded = foldSurface(events, currentSessionMessageProjections);
|
|
627
633
|
} catch (error) {
|
|
628
634
|
throw new SessionQueryError(
|
|
629
635
|
/* v8 ignore next -- foldSurface throws Error instances */
|
|
@@ -940,7 +946,7 @@ function traceSession(records, sessionId) {
|
|
|
940
946
|
function analyzeEventLog(sessionId, events) {
|
|
941
947
|
let folded;
|
|
942
948
|
try {
|
|
943
|
-
folded = foldSurface(events);
|
|
949
|
+
folded = foldSurface(events, currentSessionMessageProjections);
|
|
944
950
|
} catch (error) {
|
|
945
951
|
throw new SessionQueryError(
|
|
946
952
|
/* v8 ignore next -- foldSurface throws Error instances */
|
|
@@ -1072,7 +1078,7 @@ var SessionQueryEngine = class extends Service {
|
|
|
1072
1078
|
*/
|
|
1073
1079
|
async readSession(sessionId) {
|
|
1074
1080
|
const loaded = await this._corpus.load(sessionId);
|
|
1075
|
-
Session.create(sessionId, loaded.events, loaded.header, loaded.inheritedEventCount);
|
|
1081
|
+
Session.create(sessionId, loaded.events, loaded.header, loaded.inheritedEventCount, currentSessionMessageProjections);
|
|
1076
1082
|
return {
|
|
1077
1083
|
session: structuredClone(loaded.header),
|
|
1078
1084
|
inheritedEventCount: loaded.inheritedEventCount,
|
|
@@ -60,6 +60,7 @@ export declare class SessionObservationReader {
|
|
|
60
60
|
* @param sessionId - logical Session identity.
|
|
61
61
|
* @param options - cancellation and all-or-none projection computation for this read.
|
|
62
62
|
* @returns one exact immutable observation.
|
|
63
|
+
* @throws {@link SessionQueryError} with code `SESSION_QUERY_CORRUPT_SESSION` when live or prepared projection computation fails.
|
|
63
64
|
*/
|
|
64
65
|
read(sessionId: SessionId, options?: SessionObservationOptions): Promise<SessionObservation>;
|
|
65
66
|
/** Observe the stored snapshot, mapping absence and backend failures to the query taxonomy. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x1a0f3n9/dsh-session-query",
|
|
3
3
|
"description": "Combined session query service contract with concrete reads, traces, and filters",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7-rc.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@x1a0f3n9/dsh-brand": "
|
|
31
|
-
"@x1a0f3n9/dsh-llm": "
|
|
32
|
-
"@x1a0f3n9/dsh-session": "
|
|
33
|
-
"@x1a0f3n9/dsh-session-title": "
|
|
34
|
-
"@x1a0f3n9/dsh-
|
|
35
|
-
"@x1a0f3n9/dsh-
|
|
36
|
-
"@x1a0f3n9/dsh-session-projection": "
|
|
37
|
-
"@x1a0f3n9/dsh-session-projection-cache": "
|
|
38
|
-
"@deepseek-ai/cordis": "
|
|
30
|
+
"@x1a0f3n9/dsh-brand": "0.1.7-rc.2",
|
|
31
|
+
"@x1a0f3n9/dsh-llm": "0.1.7-rc.2",
|
|
32
|
+
"@x1a0f3n9/dsh-session": "0.1.7-rc.2",
|
|
33
|
+
"@x1a0f3n9/dsh-session-title": "0.1.7-rc.2",
|
|
34
|
+
"@x1a0f3n9/dsh-session-persistence": "0.1.7-rc.2",
|
|
35
|
+
"@x1a0f3n9/dsh-tool-todo": "0.1.7-rc.2",
|
|
36
|
+
"@x1a0f3n9/dsh-session-projection": "0.1.7-rc.2",
|
|
37
|
+
"@x1a0f3n9/dsh-session-projection-cache": "0.1.7-rc.2",
|
|
38
|
+
"@deepseek-ai/cordis": "~4.0.4"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@x1a0f3n9/dsh-session-persistence": {
|
|
@@ -49,14 +49,17 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@x1a0f3n9/dsh-brand": "
|
|
53
|
-
"@x1a0f3n9/dsh-llm": "
|
|
54
|
-
"@x1a0f3n9/dsh-session": "
|
|
55
|
-
"@x1a0f3n9/dsh-session-title": "
|
|
56
|
-
"@x1a0f3n9/dsh-tool-todo": "
|
|
57
|
-
"@x1a0f3n9/dsh-session-persistence": "
|
|
58
|
-
"@x1a0f3n9/dsh-session-projection": "
|
|
59
|
-
"@x1a0f3n9/dsh-session-projection-cache": "
|
|
60
|
-
"@deepseek-ai/cordis": "
|
|
52
|
+
"@x1a0f3n9/dsh-brand": "0.1.7-rc.2",
|
|
53
|
+
"@x1a0f3n9/dsh-llm": "0.1.7-rc.2",
|
|
54
|
+
"@x1a0f3n9/dsh-session": "0.1.7-rc.2",
|
|
55
|
+
"@x1a0f3n9/dsh-session-title": "0.1.7-rc.2",
|
|
56
|
+
"@x1a0f3n9/dsh-tool-todo": "0.1.7-rc.2",
|
|
57
|
+
"@x1a0f3n9/dsh-session-persistence": "0.1.7-rc.2",
|
|
58
|
+
"@x1a0f3n9/dsh-session-projection": "0.1.7-rc.2",
|
|
59
|
+
"@x1a0f3n9/dsh-session-projection-cache": "0.1.7-rc.2",
|
|
60
|
+
"@deepseek-ai/cordis": "~4.0.4"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@x1a0f3n9/dsh-session-format-catalog": "0.1.7-rc.2"
|
|
61
64
|
}
|
|
62
65
|
}
|