@deepseek-ai/dsh-session-reference 0.1.2-alpha.3 → 0.1.2-alpha.5
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 +2 -2
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/index.js +4 -2
- package/lib/typert.host.js +31 -19
- package/lib/typert.remote-client.js +1 -1
- package/lib/types/index.js +4 -1
- package/lib/types/projection.d.ts +2 -1
- package/lib/types/projection.js +4 -1
- package/lib/types/types.d.ts +2 -2
- package/package.json +23 -30
- package/lib/invariant.js +0 -23
- package/lib/types/invariant.d.ts +0 -16
- package/lib/types/invariant.js +0 -22
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/context/session-reference/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 06ca90025aa0cc5e50fd3bea893ecf4bf3191077
|
|
6
|
+
README.zh.md: 041a796a5bc708b5a7ed625a886defda24cdde3d
|
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ Preparation reads each referenced session's current surface exactly once, when t
|
|
|
73
73
|
| [`src/projection.ts`](src/projection.ts) | Current-surface projection and byte-budget retention |
|
|
74
74
|
| [`src/serialization.ts`](src/serialization.ts) | Tag-safe JSON escaping for snapshot payloads |
|
|
75
75
|
| [`src/types.ts`](src/types.ts) | `SessionReferenceInput`/`Candidate` and source types |
|
|
76
|
-
|
|
|
76
|
+
| — | No runtime invariant companion is published; preparation returns immutable per-call snapshots validated while they are built, and the agent/session layers own durable context admission, freezing, and replay. |
|
|
77
77
|
|
|
78
78
|
### Main flow
|
|
79
79
|
|
package/README.zh.md
CHANGED
|
@@ -73,7 +73,7 @@ kind: "package-reference"
|
|
|
73
73
|
| [`src/projection.ts`](src/projection.ts) | 当前表层投影与字节预算保留 |
|
|
74
74
|
| [`src/serialization.ts`](src/serialization.ts) | 快照载荷的标签安全 JSON 转义 |
|
|
75
75
|
| [`src/types.ts`](src/types.ts) | `SessionReferenceInput`/`Candidate` 与来源类型 |
|
|
76
|
-
|
|
|
76
|
+
| — | 不发布运行时不变式伴生入口;prepare 返回构建时已校验的不可变单次快照;持久 context 的准入、冻结与回放由 Agent 和 Session 层负责。 |
|
|
77
77
|
|
|
78
78
|
### 主要流程
|
|
79
79
|
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
3
|
import { createUserMessage, freezeMessage } from "@deepseek-ai/dsh-llm";
|
|
4
|
+
import { SessionLogOffset, SessionSeq } from "@deepseek-ai/dsh-session";
|
|
4
5
|
import { isCompactCheckpointSource } from "@deepseek-ai/dsh-compaction";
|
|
5
6
|
import { TextRetainer } from "@deepseek-ai/dsh-output-retention";
|
|
6
7
|
import { assertNever } from "@deepseek-ai/dsh-util-values";
|
|
@@ -89,7 +90,7 @@ function retainReferencedSession(snapshot, label, maxBytes) {
|
|
|
89
90
|
sessionId: snapshot.session.id,
|
|
90
91
|
label,
|
|
91
92
|
cwd: snapshot.session.cwd ?? null,
|
|
92
|
-
capturedThroughSeq: snapshot.capturedThroughSeq,
|
|
93
|
+
capturedThroughSeq: snapshot.capturedThroughSeq === null ? null : SessionSeq(snapshot.capturedThroughSeq),
|
|
93
94
|
conversation: retained.map(({ role, text }) => ({
|
|
94
95
|
role,
|
|
95
96
|
text
|
|
@@ -459,7 +460,8 @@ let SessionReferenceResolver = (() => {
|
|
|
459
460
|
const attached = this.ctx.get("sessions")?.get(record.header.id);
|
|
460
461
|
const projections = this.ctx.get("sessionProjections");
|
|
461
462
|
if (attached !== void 0 && projections !== void 0) return titleOf(projections.snapshot(attached, ["title"]));
|
|
462
|
-
|
|
463
|
+
if (record.header.isSeeded) return void 0;
|
|
464
|
+
return titleOf(this.ctx.get("sessionProjectionCache")?.cachedSnapshot(record.header, SessionLogOffset(0), ["title"]));
|
|
463
465
|
}
|
|
464
466
|
/**
|
|
465
467
|
* Remote face of {@link listCandidates}: the configured candidate limit
|
package/lib/typert.host.js
CHANGED
|
@@ -58,7 +58,7 @@ export const TYPERT = {
|
|
|
58
58
|
typeSymbol: '@deepseek-ai/dsh-session-reference#sessionReferenceResolver/candidates:result',
|
|
59
59
|
schema: _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_result$schema,
|
|
60
60
|
},
|
|
61
|
-
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":
|
|
61
|
+
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":251,"column":9},
|
|
62
62
|
},
|
|
63
63
|
],
|
|
64
64
|
model: {
|
|
@@ -102,6 +102,10 @@ export const TYPERT = {
|
|
|
102
102
|
"name": "AgentCancelCause",
|
|
103
103
|
"declaration": "export type AgentCancelCause = { readonly kind: 'user'; } | { readonly kind: 'parent'; } | { readonly kind: 'hook'; readonly reason: string; } | { readonly kind: 'disposed'; };"
|
|
104
104
|
},
|
|
105
|
+
{
|
|
106
|
+
"name": "AgentMessageSource",
|
|
107
|
+
"declaration": "export interface AgentMessageSource {\n readonly kind: 'agent-message';\n readonly form: 'relay';\n readonly senderSessionId: SessionId;\n}"
|
|
108
|
+
},
|
|
105
109
|
{
|
|
106
110
|
"name": "AgentOptions",
|
|
107
111
|
"declaration": "export interface AgentOptions {\n provider?: string;\n model?: string;\n reasoningEffort?: ReasoningEffortId;\n maxTokens?: number;\n subagentDepth?: number;\n}"
|
|
@@ -138,6 +142,10 @@ export const TYPERT = {
|
|
|
138
142
|
"name": "Branded",
|
|
139
143
|
"declaration": "export type Branded<B extends string> = string & { readonly [BRAND]: B; };"
|
|
140
144
|
},
|
|
145
|
+
{
|
|
146
|
+
"name": "BrandedNumber",
|
|
147
|
+
"declaration": "export type BrandedNumber<B extends string> = number & { readonly [BRAND]: B; };"
|
|
148
|
+
},
|
|
141
149
|
{
|
|
142
150
|
"name": "CancelOptions",
|
|
143
151
|
"declaration": "export interface CancelOptions {\n keepInbox?: boolean | undefined;\n}"
|
|
@@ -182,10 +190,6 @@ export const TYPERT = {
|
|
|
182
190
|
"name": "ContinuableSubagentDescriptorData",
|
|
183
191
|
"declaration": "export interface ContinuableSubagentDescriptorData extends SubagentDescriptorBase {\n readonly mode: 'continuable';\n readonly label: string;\n readonly agentProvider?: string;\n readonly agentModel?: string;\n readonly agentReasoningEffort?: ReasoningEffortId;\n readonly persona?: string;\n readonly toolFilter?: ToolRestriction;\n}"
|
|
184
192
|
},
|
|
185
|
-
{
|
|
186
|
-
"name": "CoordinatorMessageSource",
|
|
187
|
-
"declaration": "export interface CoordinatorMessageSource {\n readonly kind: 'coordinator';\n readonly form: 'relay';\n readonly senderSessionId: SessionId;\n}"
|
|
188
|
-
},
|
|
189
193
|
{
|
|
190
194
|
"name": "EpochHeader",
|
|
191
195
|
"declaration": "export interface EpochHeader {\n config: LlmCallConfig;\n adapterDefaults?: LlmCallConfigAdapterDefaults;\n system?: string;\n tools?: ToolSchema[];\n}"
|
|
@@ -288,7 +292,7 @@ export const TYPERT = {
|
|
|
288
292
|
},
|
|
289
293
|
{
|
|
290
294
|
"name": "MessageSourceMap",
|
|
291
|
-
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n plugin: { kind: 'plugin'; plugin: string; } & ContextFormed;\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n
|
|
295
|
+
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n plugin: { kind: 'plugin'; plugin: string; } & ContextFormed;\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; };\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'team-message': TeamMessageSource;\n goal: GoalMessageSource;\n 'session-reference': SessionReferenceSource;\n}"
|
|
292
296
|
},
|
|
293
297
|
{
|
|
294
298
|
"name": "ModelMessageSource",
|
|
@@ -302,6 +306,10 @@ export const TYPERT = {
|
|
|
302
306
|
"name": "OneShotSubagentDescriptorData",
|
|
303
307
|
"declaration": "export interface OneShotSubagentDescriptorData extends SubagentDescriptorBase {\n readonly mode: 'one-shot';\n readonly label?: string;\n}"
|
|
304
308
|
},
|
|
309
|
+
{
|
|
310
|
+
"name": "OptionalSessionSeq",
|
|
311
|
+
"declaration": "export type OptionalSessionSeq = SessionSeq | null;"
|
|
312
|
+
},
|
|
305
313
|
{
|
|
306
314
|
"name": "PreparedReferencedMessage",
|
|
307
315
|
"declaration": "export interface PreparedReferencedMessage {\n content: ContentBlock[];\n additionalContext?: UserMessage;\n}"
|
|
@@ -344,15 +352,15 @@ export const TYPERT = {
|
|
|
344
352
|
},
|
|
345
353
|
{
|
|
346
354
|
"name": "Session",
|
|
347
|
-
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n get id(): SessionId;\n readonly firstLiveSeq:
|
|
355
|
+
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
348
356
|
},
|
|
349
357
|
{
|
|
350
358
|
"name": "SessionEvent",
|
|
351
|
-
"declaration": "export type SessionEvent<T extends SessionEventType = SessionEventType> = { [K in SessionEventType]: { type: K; seq:
|
|
359
|
+
"declaration": "export type SessionEvent<T extends SessionEventType = SessionEventType> = { [K in SessionEventType]: { type: K; seq: SessionSeq; time: number; data: SessionEventMap[K]; ignorable?: true; } & (K extends SurfaceEventType ? { sourceEventSeqs?: SessionSeq[]; surfaceOp?: SurfaceOp; } : object) }[T];"
|
|
352
360
|
},
|
|
353
361
|
{
|
|
354
362
|
"name": "SessionEventMap",
|
|
355
|
-
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'assistant/chunk': { turn: number; step: number; chunk: StreamChunk; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; usage?: TokenUsage; interrupted?: true; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': Record<string, never>;\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/code-dispatch-start': PtcDispatchStartEventData;\n 'tool/code-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?:
|
|
363
|
+
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'assistant/chunk': { turn: number; step: number; chunk: StreamChunk; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; usage?: TokenUsage; interrupted?: true; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': Record<string, never>;\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/code-dispatch-start': PtcDispatchStartEventData;\n 'tool/code-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'team/member': { version: 1; teamId: TeamId; member: TeamMemberSnapshot; };\n 'team/task': { version: 1; teamId: TeamId; task: TeamTaskSnapshot; };\n 'team/message/queued': { version: 1; teamId: TeamId; message: TeamMessageSnapshot; };\n 'team/message/delivered': { version: 1; teamId: TeamId; messageId: TeamMessageId; targetId: SessionId; };\n 'goal/change': GoalChangeMeta;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
|
|
356
364
|
},
|
|
357
365
|
{
|
|
358
366
|
"name": "SessionEventType",
|
|
@@ -360,12 +368,16 @@ export const TYPERT = {
|
|
|
360
368
|
},
|
|
361
369
|
{
|
|
362
370
|
"name": "SessionHeader",
|
|
363
|
-
"declaration": "export interface SessionHeader {\n readonly version: number;\n readonly id: SessionId;\n readonly createdAt: number;\n readonly cwd?: string;\n readonly parentSession?: SessionId;\n readonly
|
|
371
|
+
"declaration": "export interface SessionHeader {\n readonly version: number;\n readonly id: SessionId;\n readonly createdAt: number;\n readonly cwd?: string;\n readonly parentSession?: SessionId;\n readonly isSeeded: boolean;\n readonly origin?: 'subagent';\n readonly delegationDepth?: number;\n readonly agentPreset?: string;\n}"
|
|
364
372
|
},
|
|
365
373
|
{
|
|
366
374
|
"name": "SessionId",
|
|
367
375
|
"declaration": "export type SessionId = Branded<'SessionId'>;"
|
|
368
376
|
},
|
|
377
|
+
{
|
|
378
|
+
"name": "SessionLogOffset",
|
|
379
|
+
"declaration": "export type SessionLogOffset = BrandedNumber<'SessionLogOffset'>;"
|
|
380
|
+
},
|
|
369
381
|
{
|
|
370
382
|
"name": "SessionReferenceCandidate",
|
|
371
383
|
"declaration": "export interface SessionReferenceCandidate {\n sessionId: SessionId;\n label: string;\n cwd?: string;\n sameWorkspace: boolean;\n createdAt: number;\n}"
|
|
@@ -380,19 +392,23 @@ export const TYPERT = {
|
|
|
380
392
|
},
|
|
381
393
|
{
|
|
382
394
|
"name": "SessionReferenceSource",
|
|
383
|
-
"declaration": "export interface SessionReferenceSource {\n kind: 'session-reference';\n form: 'recall';\n version: 1;\n references: { sessionId: string; label: string; capturedThroughSeq:
|
|
395
|
+
"declaration": "export interface SessionReferenceSource {\n kind: 'session-reference';\n form: 'recall';\n version: 1;\n references: { sessionId: string; label: string; capturedThroughSeq: OptionalSessionSeq; compacted: boolean; originalMessages: number; retainedMessages: number; omittedMessages: number; omittedBytes: number; truncated: boolean; inputIndex: number; }[];\n}"
|
|
384
396
|
},
|
|
385
397
|
{
|
|
386
398
|
"name": "SessionRequestId",
|
|
387
399
|
"declaration": "export type SessionRequestId = Branded<'session-request-id'>;"
|
|
388
400
|
},
|
|
401
|
+
{
|
|
402
|
+
"name": "SessionSeq",
|
|
403
|
+
"declaration": "export type SessionSeq = BrandedNumber<'SessionSeq'>;"
|
|
404
|
+
},
|
|
389
405
|
{
|
|
390
406
|
"name": "SessionSurface",
|
|
391
|
-
"declaration": "export interface SessionSurface {\n readonly nodes: readonly
|
|
407
|
+
"declaration": "export interface SessionSurface {\n readonly nodes: readonly SessionSeq[];\n readonly replaceGeneration: number;\n}"
|
|
392
408
|
},
|
|
393
409
|
{
|
|
394
410
|
"name": "SessionTitleEventData",
|
|
395
|
-
"declaration": "export interface SessionTitleEventData {\n readonly title: string;\n readonly messageSeqs:
|
|
411
|
+
"declaration": "export interface SessionTitleEventData {\n readonly title: string;\n readonly messageSeqs: SessionSeq[];\n readonly source: SessionTitleSource;\n}"
|
|
396
412
|
},
|
|
397
413
|
{
|
|
398
414
|
"name": "SessionTitleModelProvenance",
|
|
@@ -422,10 +438,6 @@ export const TYPERT = {
|
|
|
422
438
|
"name": "SubagentDescriptorData",
|
|
423
439
|
"declaration": "export type SubagentDescriptorData = OneShotSubagentDescriptorData | ContinuableSubagentDescriptorData;"
|
|
424
440
|
},
|
|
425
|
-
{
|
|
426
|
-
"name": "SubagentReportMessageSource",
|
|
427
|
-
"declaration": "export interface SubagentReportMessageSource {\n readonly kind: 'subagent-report';\n readonly form: 'relay';\n readonly senderSessionId: SessionId;\n}"
|
|
428
|
-
},
|
|
429
441
|
{
|
|
430
442
|
"name": "SubagentSettledMessageSource",
|
|
431
443
|
"declaration": "export interface SubagentSettledMessageSource {\n readonly kind: 'subagent-settled';\n readonly form: 'notice';\n readonly summary: string;\n readonly senderSessionId: SessionId;\n}"
|
|
@@ -436,11 +448,11 @@ export const TYPERT = {
|
|
|
436
448
|
},
|
|
437
449
|
{
|
|
438
450
|
"name": "SurfaceIntent",
|
|
439
|
-
"declaration": "export interface SurfaceIntent {\n surfaceOp: SurfaceOp;\n sourceEventSeqs?:
|
|
451
|
+
"declaration": "export interface SurfaceIntent {\n surfaceOp: SurfaceOp;\n sourceEventSeqs?: SessionSeq[];\n}"
|
|
440
452
|
},
|
|
441
453
|
{
|
|
442
454
|
"name": "SurfaceOp",
|
|
443
|
-
"declaration": "export type SurfaceOp = 'append' | { op: 'replace'; start:
|
|
455
|
+
"declaration": "export type SurfaceOp = 'append' | { op: 'replace'; start: SessionSeq; end: SessionSeq; };"
|
|
444
456
|
},
|
|
445
457
|
{
|
|
446
458
|
"name": "TeamId",
|
|
@@ -55,7 +55,7 @@ export const TYPERT_REMOTE = {
|
|
|
55
55
|
typeSymbol: '@deepseek-ai/dsh-session-reference#sessionReferenceResolver/candidates:result',
|
|
56
56
|
schema: _deepseek_ai_dsh_session_reference_sessionReferenceResolver_candidates_result$schema,
|
|
57
57
|
},
|
|
58
|
-
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":
|
|
58
|
+
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":251,"column":9},
|
|
59
59
|
},
|
|
60
60
|
],
|
|
61
61
|
}
|
package/lib/types/index.js
CHANGED
|
@@ -41,6 +41,7 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
41
41
|
import z from '@deepseek-ai/schemastery';
|
|
42
42
|
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
43
43
|
import { createUserMessage, freezeMessage } from '@deepseek-ai/dsh-llm';
|
|
44
|
+
import { SessionLogOffset } from '@deepseek-ai/dsh-session';
|
|
44
45
|
import { DEFAULT_CANDIDATE_LIMIT, DEFAULT_MAX_REFERENCE_BYTES, MAX_REFERENCES, SessionReferenceError, } from "./config.js";
|
|
45
46
|
import { retainReferencedSession } from "./projection.js";
|
|
46
47
|
import { stringifyTagSafeJson } from "./serialization.js";
|
|
@@ -205,7 +206,9 @@ let SessionReferenceResolver = (() => {
|
|
|
205
206
|
if (attached !== undefined && projections !== undefined) {
|
|
206
207
|
return titleOf(projections.snapshot(attached, ['title']));
|
|
207
208
|
}
|
|
208
|
-
|
|
209
|
+
if (record.header.isSeeded)
|
|
210
|
+
return undefined;
|
|
211
|
+
return titleOf(this.ctx.get('sessionProjectionCache')?.cachedSnapshot(record.header, SessionLogOffset(0), ['title']));
|
|
209
212
|
}
|
|
210
213
|
/**
|
|
211
214
|
* Remote face of {@link listCandidates}: the configured candidate limit
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/** Current-surface projection and byte-bounded rendering. */
|
|
2
2
|
import type { SessionSurfaceSnapshot } from '@deepseek-ai/dsh-session-query';
|
|
3
|
+
import type { OptionalSessionSeq } from '@deepseek-ai/dsh-session';
|
|
3
4
|
import type { ReferencedConversationItem } from './types.ts';
|
|
4
5
|
/** Snapshot data serialized inside the untrusted prompt. */
|
|
5
6
|
export interface ReferencedSessionData {
|
|
6
7
|
sessionId: string;
|
|
7
8
|
label: string;
|
|
8
9
|
cwd: string | null;
|
|
9
|
-
capturedThroughSeq:
|
|
10
|
+
capturedThroughSeq: OptionalSessionSeq;
|
|
10
11
|
conversation: ReferencedConversationItem[];
|
|
11
12
|
}
|
|
12
13
|
/** Retention facts stored beside the durable context. */
|
package/lib/types/projection.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { isCompactCheckpointSource } from '@deepseek-ai/dsh-compaction';
|
|
3
3
|
import { TextRetainer } from '@deepseek-ai/dsh-output-retention';
|
|
4
4
|
import { assertNever } from '@deepseek-ai/dsh-util-values';
|
|
5
|
+
import { SessionSeq } from '@deepseek-ai/dsh-session';
|
|
5
6
|
import { stringifyTagSafeJson } from "./serialization.js";
|
|
6
7
|
/** Project current user/assistant conversation while excluding tools, reasoning, and injected context. */
|
|
7
8
|
function projectSessionConversation(snapshot) {
|
|
@@ -48,7 +49,9 @@ export function retainReferencedSession(snapshot, label, maxBytes) {
|
|
|
48
49
|
sessionId: snapshot.session.id,
|
|
49
50
|
label,
|
|
50
51
|
cwd: snapshot.session.cwd ?? null,
|
|
51
|
-
capturedThroughSeq: snapshot.capturedThroughSeq
|
|
52
|
+
capturedThroughSeq: snapshot.capturedThroughSeq === null
|
|
53
|
+
? null
|
|
54
|
+
: SessionSeq(snapshot.capturedThroughSeq),
|
|
52
55
|
conversation: retained.map(({ role, text }) => ({ role, text })),
|
|
53
56
|
});
|
|
54
57
|
const size = () => Buffer.byteLength(stringifyTagSafeJson(data()), 'utf8');
|
package/lib/types/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { UserMessage } from '@deepseek-ai/dsh-llm/message';
|
|
8
8
|
import type { ContentBlock } from '@deepseek-ai/dsh-llm/types';
|
|
9
|
-
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
9
|
+
import type { OptionalSessionSeq, SessionId } from '@deepseek-ai/dsh-session/types';
|
|
10
10
|
/** Durable source session, cited event seqs, and snapshot facts for prepared cross-session context. */
|
|
11
11
|
export interface SessionReferenceSource {
|
|
12
12
|
kind: 'session-reference';
|
|
@@ -16,7 +16,7 @@ export interface SessionReferenceSource {
|
|
|
16
16
|
references: {
|
|
17
17
|
sessionId: string;
|
|
18
18
|
label: string;
|
|
19
|
-
capturedThroughSeq:
|
|
19
|
+
capturedThroughSeq: OptionalSessionSeq;
|
|
20
20
|
compacted: boolean;
|
|
21
21
|
originalMessages: number;
|
|
22
22
|
retainedMessages: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-session-reference",
|
|
3
3
|
"description": "Cross-session snapshot references and durable untrusted model context (ctx.sessionReferenceResolver)",
|
|
4
|
-
"version": "0.1.2-alpha.
|
|
4
|
+
"version": "0.1.2-alpha.5",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
"types": "./lib/types/index.d.ts",
|
|
19
19
|
"default": "./lib/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./invariant": {
|
|
22
|
-
"types": "./lib/types/invariant.d.ts",
|
|
23
|
-
"default": "./lib/invariant.js"
|
|
24
|
-
},
|
|
25
21
|
"./types": {
|
|
26
22
|
"types": "./lib/types/types.d.ts",
|
|
27
23
|
"default": "./lib/types/types.js"
|
|
@@ -39,7 +35,6 @@
|
|
|
39
35
|
},
|
|
40
36
|
"files": [
|
|
41
37
|
"lib/index.js",
|
|
42
|
-
"lib/invariant.js",
|
|
43
38
|
"lib/types/**/*.js",
|
|
44
39
|
"lib/types/**/*.d.ts",
|
|
45
40
|
"lib/typert.host.js",
|
|
@@ -50,23 +45,22 @@
|
|
|
50
45
|
"license": "MIT",
|
|
51
46
|
"dependencies": {
|
|
52
47
|
"zod": "^4.4.3",
|
|
53
|
-
"@deepseek-ai/dsh-
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
48
|
+
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.5",
|
|
49
|
+
"@deepseek-ai/dsh-brand": "^0.1.2-alpha.5",
|
|
55
50
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
56
51
|
},
|
|
57
52
|
"peerDependencies": {
|
|
58
53
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
59
|
-
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.
|
|
60
|
-
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/dsh-
|
|
64
|
-
"@deepseek-ai/dsh-session": "^0.1.2-alpha.
|
|
65
|
-
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.
|
|
66
|
-
"@deepseek-ai/dsh-session-
|
|
67
|
-
"@deepseek-ai/dsh-
|
|
68
|
-
"@deepseek-ai/dsh-session-
|
|
69
|
-
"@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.3"
|
|
54
|
+
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
|
|
55
|
+
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.5",
|
|
56
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
|
|
57
|
+
"@deepseek-ai/dsh-output-retention": "^0.1.2-alpha.5",
|
|
58
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
|
|
59
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.5",
|
|
60
|
+
"@deepseek-ai/dsh-session-projection-cache": "^0.1.2-alpha.5",
|
|
61
|
+
"@deepseek-ai/dsh-session-title": "^0.1.2-alpha.5",
|
|
62
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.5",
|
|
63
|
+
"@deepseek-ai/dsh-session-query": "^0.1.2-alpha.5"
|
|
70
64
|
},
|
|
71
65
|
"peerDependenciesMeta": {
|
|
72
66
|
"@deepseek-ai/dsh-session-projection-cache": {
|
|
@@ -75,16 +69,15 @@
|
|
|
75
69
|
},
|
|
76
70
|
"devDependencies": {
|
|
77
71
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
78
|
-
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.
|
|
79
|
-
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.
|
|
80
|
-
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.
|
|
81
|
-
"@deepseek-ai/dsh-output-retention": "^0.1.2-alpha.
|
|
82
|
-
"@deepseek-ai/dsh-session": "^0.1.2-alpha.
|
|
83
|
-
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.
|
|
84
|
-
"@deepseek-ai/dsh-session-
|
|
85
|
-
"@deepseek-ai/dsh-session-
|
|
86
|
-
"@deepseek-ai/dsh-session-
|
|
87
|
-
"@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.
|
|
88
|
-
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.3"
|
|
72
|
+
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
|
|
73
|
+
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.5",
|
|
74
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
|
|
75
|
+
"@deepseek-ai/dsh-output-retention": "^0.1.2-alpha.5",
|
|
76
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
|
|
77
|
+
"@deepseek-ai/dsh-session-projection-cache": "^0.1.2-alpha.5",
|
|
78
|
+
"@deepseek-ai/dsh-session-query": "^0.1.2-alpha.5",
|
|
79
|
+
"@deepseek-ai/dsh-session-title": "^0.1.2-alpha.5",
|
|
80
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.5",
|
|
81
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.2-alpha.5"
|
|
89
82
|
}
|
|
90
83
|
}
|
package/lib/invariant.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region lib/types/invariant.js
|
|
2
|
-
/**
|
|
3
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-session-reference`.
|
|
4
|
-
* @module @deepseek-ai/dsh-session-reference/invariant
|
|
5
|
-
*/
|
|
6
|
-
const PACKAGE_NAME = "@deepseek-ai/dsh-session-reference";
|
|
7
|
-
/** Cordis companion plugin name. */
|
|
8
|
-
const name = "session-reference-invariant";
|
|
9
|
-
/** Service required before the companion can reserve package ownership. */
|
|
10
|
-
const inject = ["invariants"];
|
|
11
|
-
/**
|
|
12
|
-
* No runtime invariant: preparation returns immutable per-call snapshots validated while they are
|
|
13
|
-
* built, and the agent/session layers own durable context admission, freezing, and replay.
|
|
14
|
-
*/
|
|
15
|
-
const install = () => {};
|
|
16
|
-
/**
|
|
17
|
-
* Register this package's invariant companion.
|
|
18
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
-
*/
|
|
21
|
-
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
-
//#endregion
|
|
23
|
-
export { apply, inject, name };
|
package/lib/types/invariant.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-session-reference`.
|
|
3
|
-
* @module @deepseek-ai/dsh-session-reference/invariant
|
|
4
|
-
*/
|
|
5
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
-
/** Cordis companion plugin name. */
|
|
7
|
-
export declare const name = "session-reference-invariant";
|
|
8
|
-
/** Service required before the companion can reserve package ownership. */
|
|
9
|
-
export declare const inject: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Register this package's invariant companion.
|
|
12
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
-
*/
|
|
15
|
-
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
-
//# sourceMappingURL=invariant.d.ts.map
|
package/lib/types/invariant.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-session-reference`.
|
|
3
|
-
* @module @deepseek-ai/dsh-session-reference/invariant
|
|
4
|
-
*/
|
|
5
|
-
const PACKAGE_NAME = '@deepseek-ai/dsh-session-reference';
|
|
6
|
-
/** Cordis companion plugin name. */
|
|
7
|
-
export const name = 'session-reference-invariant';
|
|
8
|
-
/** Service required before the companion can reserve package ownership. */
|
|
9
|
-
export const inject = ['invariants'];
|
|
10
|
-
/**
|
|
11
|
-
* No runtime invariant: preparation returns immutable per-call snapshots validated while they are
|
|
12
|
-
* built, and the agent/session layers own durable context admission, freezing, and replay.
|
|
13
|
-
*/
|
|
14
|
-
const install = () => { };
|
|
15
|
-
/**
|
|
16
|
-
* Register this package's invariant companion.
|
|
17
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
18
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
19
|
-
*/
|
|
20
|
-
export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
21
|
-
/* jscpd:ignore-end */
|
|
22
|
-
//# sourceMappingURL=invariant.js.map
|