@deepseek-ai/dsh-session-log-deepseek 0.2.2-alpha.3 → 0.2.2-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/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/types.js.map +1 -0
- package/package.json +23 -20
- package/src/index.ts +291 -0
- package/src/types.ts +105 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAIxC,OAAO,KAAK,EACV,OAAO,EAKP,gBAAgB,EAEjB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,EAKV,yBAAyB,EAE1B,MAAM,YAAY,CAAA;AAEnB,mBAAmB,YAAY,CAAA;AAE/B,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,kBAAkB,EAAE,yBAAyB,CAAA;KAC9C;CACF;AAED,0BAA0B;AAC1B,eAAO,MAAM,IAAI,yBAAyB,CAAA;AAC1C,uFAAuF;AACvF,eAAO,MAAM,MAAM,UAA2C,CAAA;AAE9D,sDAAsD;AACtD,MAAM,WAAW,MAAM;IACrB,sFAAsF;IACtF,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1B;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,gEAAgE;AAChE,eAAO,MAAM,MAAM;;;;;;aAGjB,CAAA;AAoFF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAkClE;AAED,+EAA+E;AAC/E,qBAAa,yBAA0B,SAAQ,OA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D,wEAAwE;YACxE,oBAAoB,CAAC,EAAE,MAAM,CAAA;YAC7B,6DAA6D;YAC7D,UAAU,EAAE,OAAO,gCAAgC,EAAE,UAAU,CAAA;SAChE,CAAA;KACF;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,uEAAuE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-session-log-deepseek",
|
|
3
3
|
"description": "Incremental lossless session-log request extension for the official DeepSeek LLM API",
|
|
4
|
-
"version": "0.2.2-
|
|
4
|
+
"version": "0.2.2-rc.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -30,31 +30,34 @@
|
|
|
30
30
|
"locale/*.json",
|
|
31
31
|
"lib/index.js",
|
|
32
32
|
"lib/types/**/*.js",
|
|
33
|
-
"lib/types/**/*.d.ts"
|
|
33
|
+
"lib/types/**/*.d.ts",
|
|
34
|
+
"lib/types/**/*.d.ts.map",
|
|
35
|
+
"lib/**/*.js.map",
|
|
36
|
+
"src"
|
|
34
37
|
],
|
|
35
38
|
"license": "MIT",
|
|
36
39
|
"dependencies": {
|
|
37
|
-
"@deepseek-ai/dsh-brand": "0.2.2-
|
|
38
|
-
"@deepseek-ai/dsh-util-values": "0.2.2-
|
|
39
|
-
"@deepseek-ai/schemastery": "~3.
|
|
40
|
+
"@deepseek-ai/dsh-brand": "0.2.2-rc.2",
|
|
41
|
+
"@deepseek-ai/dsh-util-values": "0.2.2-rc.2",
|
|
42
|
+
"@deepseek-ai/schemastery": "~3.19.0"
|
|
40
43
|
},
|
|
41
44
|
"peerDependencies": {
|
|
42
|
-
"@deepseek-ai/cordis": "~4.0
|
|
43
|
-
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.2-
|
|
44
|
-
"@deepseek-ai/dsh-session": "0.2.2-
|
|
45
|
+
"@deepseek-ai/cordis": "~4.1.0",
|
|
46
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.2-rc.2",
|
|
47
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.2"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
47
|
-
"@deepseek-ai/cordis": "~4.0
|
|
48
|
-
"@deepseek-ai/cordis-plugin-include": "~1.0
|
|
49
|
-
"@deepseek-ai/cordis-plugin-loader": "~1.0
|
|
50
|
-
"@deepseek-ai/dsh-command-feedback": "0.2.2-
|
|
51
|
-
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.2-
|
|
52
|
-
"@deepseek-ai/dsh-llm": "0.2.2-
|
|
53
|
-
"@deepseek-ai/dsh-llm-deepseek": "0.2.2-
|
|
54
|
-
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.2-
|
|
55
|
-
"@deepseek-ai/dsh-llm-mock-server": "0.2.2-
|
|
56
|
-
"@deepseek-ai/dsh-message-feedback": "0.2.2-
|
|
57
|
-
"@deepseek-ai/dsh-session": "0.2.2-
|
|
58
|
-
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.2-
|
|
50
|
+
"@deepseek-ai/cordis": "~4.1.0",
|
|
51
|
+
"@deepseek-ai/cordis-plugin-include": "~1.1.0",
|
|
52
|
+
"@deepseek-ai/cordis-plugin-loader": "~1.1.0",
|
|
53
|
+
"@deepseek-ai/dsh-command-feedback": "0.2.2-rc.2",
|
|
54
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.2-rc.2",
|
|
55
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.2",
|
|
56
|
+
"@deepseek-ai/dsh-llm-deepseek": "0.2.2-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.2-rc.2",
|
|
58
|
+
"@deepseek-ai/dsh-llm-mock-server": "0.2.2-rc.2",
|
|
59
|
+
"@deepseek-ai/dsh-message-feedback": "0.2.2-rc.2",
|
|
60
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.2",
|
|
61
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.2-rc.2"
|
|
59
62
|
}
|
|
60
63
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incremental session-log contribution for official DeepSeek LLM API requests.
|
|
3
|
+
* Accepted sequence watermarks live in the canonical log, so restart recovery
|
|
4
|
+
* can conservatively resend uncertain tails without maintaining another store.
|
|
5
|
+
* @module @deepseek-ai/dsh-session-log-deepseek
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Buffer } from 'node:buffer'
|
|
9
|
+
import { Service, type Context, type Volatile } from '@deepseek-ai/cordis'
|
|
10
|
+
import z from '@deepseek-ai/schemastery'
|
|
11
|
+
import { brandString } from '@deepseek-ai/dsh-brand'
|
|
12
|
+
import type {} from '@deepseek-ai/dsh-deepseek-llm-api-extensions'
|
|
13
|
+
import { KNOWN_SESSION_EVENT_TYPES, SessionLogOffset, SessionSeq } from '@deepseek-ai/dsh-session'
|
|
14
|
+
import type {
|
|
15
|
+
Session,
|
|
16
|
+
SessionEvent,
|
|
17
|
+
SessionId,
|
|
18
|
+
SessionLogOffset as SessionLogOffsetType,
|
|
19
|
+
SessionSeq as SessionSeqType,
|
|
20
|
+
SessionSeqCursor,
|
|
21
|
+
SurfaceOp,
|
|
22
|
+
} from '@deepseek-ai/dsh-session'
|
|
23
|
+
import type { JsonValue } from '@deepseek-ai/dsh-util-values'
|
|
24
|
+
import type {
|
|
25
|
+
DeepSeekSessionLogExtension,
|
|
26
|
+
DeepSeekSessionLogWireEvent,
|
|
27
|
+
DeepSeekSessionLogWireHeader,
|
|
28
|
+
DeepSeekSessionLogWireSurfaceOp,
|
|
29
|
+
SessionLogUploadExclusion,
|
|
30
|
+
SessionLogUploadRequest,
|
|
31
|
+
} from './types.ts'
|
|
32
|
+
|
|
33
|
+
export type * from './types.ts'
|
|
34
|
+
|
|
35
|
+
declare module '@deepseek-ai/cordis' {
|
|
36
|
+
interface Context {
|
|
37
|
+
sessionLogDeepSeek: SessionLogDeepSeekService
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Cordis plugin name. */
|
|
42
|
+
export const name = 'session-log-deepseek'
|
|
43
|
+
/** Services required to resolve sessions and contribute the provider request field. */
|
|
44
|
+
export const inject = ['deepseekLlmApiExtensions', 'sessions']
|
|
45
|
+
|
|
46
|
+
/** Session-log request contribution configuration. */
|
|
47
|
+
export interface Config {
|
|
48
|
+
/** Contribute `dsh_session_log` to official DeepSeek requests. Defaults to `true`. */
|
|
49
|
+
enabled: Volatile<boolean>
|
|
50
|
+
/**
|
|
51
|
+
* Largest serialized `dsh_session_log` field, in UTF-8 bytes, that one request carries.
|
|
52
|
+
* A request uploads the longest pending event prefix that fits; later requests continue
|
|
53
|
+
* after its acceptance. Defaults to 8 MiB.
|
|
54
|
+
*/
|
|
55
|
+
maxBytes: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Validated Session-log request contribution configuration. */
|
|
59
|
+
export const Config = z.object({
|
|
60
|
+
enabled: z.boolean().default(true).volatile(),
|
|
61
|
+
maxBytes: z.number().step(1).min(1).default(8 * 1024 * 1024),
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
interface AcceptanceFold {
|
|
65
|
+
readonly scannedEvents: SessionLogOffsetType
|
|
66
|
+
readonly throughSeq: SessionSeqCursor
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const acceptanceFolds = new WeakMap<Session, AcceptanceFold>()
|
|
70
|
+
/** Event each Session's upload was last reported blocked at; a block is logged once. */
|
|
71
|
+
const blockedWarnings = new WeakMap<Session, SessionSeqType>()
|
|
72
|
+
|
|
73
|
+
/** Translate logical Session metadata to raw external request fields. */
|
|
74
|
+
function wireHeader(session: Session): DeepSeekSessionLogWireHeader {
|
|
75
|
+
const header = session.header
|
|
76
|
+
return {
|
|
77
|
+
version: header.version,
|
|
78
|
+
id: String(header.id),
|
|
79
|
+
createdAt: header.createdAt,
|
|
80
|
+
...header.cwd === undefined ? {} : { cwd: header.cwd },
|
|
81
|
+
...header.parentSession === undefined ? {} : { parentSession: String(header.parentSession) },
|
|
82
|
+
...header.isSeeded ? { seedLength: Number(session.inheritedEventCount) } : {},
|
|
83
|
+
...header.origin === undefined ? {} : { origin: header.origin },
|
|
84
|
+
...header.delegationDepth === undefined ? {} : { delegationDepth: header.delegationDepth },
|
|
85
|
+
...header.agentPreset === undefined ? {} : { agentPreset: header.agentPreset },
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Translate compile-time sequence brands to raw numeric request fields. */
|
|
90
|
+
function wireEvent(event: SessionEvent): DeepSeekSessionLogWireEvent {
|
|
91
|
+
const common = {
|
|
92
|
+
seq: Number(event.seq),
|
|
93
|
+
time: event.time,
|
|
94
|
+
data: event.data as JsonValue,
|
|
95
|
+
...event.ignorable === undefined ? {} : { ignorable: event.ignorable },
|
|
96
|
+
}
|
|
97
|
+
switch (event.type) {
|
|
98
|
+
case 'developer/message':
|
|
99
|
+
case 'system/message':
|
|
100
|
+
case 'user/message':
|
|
101
|
+
case 'tool/result':
|
|
102
|
+
return {
|
|
103
|
+
...common,
|
|
104
|
+
type: event.type,
|
|
105
|
+
surfaceOp: wireSurfaceOp(event.surfaceOp),
|
|
106
|
+
...event.sourceEventSeqs === undefined ? {} : { sourceEventSeqs: event.sourceEventSeqs.map(Number) },
|
|
107
|
+
}
|
|
108
|
+
case 'assistant/message':
|
|
109
|
+
return { ...common, type: event.type, surfaceOp: wireSurfaceOp(event.surfaceOp) }
|
|
110
|
+
default: {
|
|
111
|
+
// Restored unknown ignorable records are opaque, not current surface events.
|
|
112
|
+
if (!KNOWN_SESSION_EVENT_TYPES.has(event.type) && event.ignorable === true) {
|
|
113
|
+
const opaque = event as { surfaceOp?: JsonValue; sourceEventSeqs?: JsonValue }
|
|
114
|
+
return {
|
|
115
|
+
...common, type: event.type, ignorable: true,
|
|
116
|
+
...opaque.surfaceOp === undefined ? {} : { surfaceOp: opaque.surfaceOp },
|
|
117
|
+
...opaque.sourceEventSeqs === undefined ? {} : { sourceEventSeqs: opaque.sourceEventSeqs },
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return { ...common, type: event.type }
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function wireSurfaceOp(op: SurfaceOp): DeepSeekSessionLogWireSurfaceOp {
|
|
126
|
+
return op === 'append'
|
|
127
|
+
? op
|
|
128
|
+
: { op: 'replace', startSeq: Number(op.startSeq), endSeq: Number(op.endSeq) }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* UTF-8 length of one value's JSON text as the request body encodes it.
|
|
133
|
+
* @returns `Infinity` when the value fails to serialize, which counts as exceeding every limit.
|
|
134
|
+
*/
|
|
135
|
+
function jsonBytes(value: DeepSeekSessionLogExtension | DeepSeekSessionLogWireEvent): number {
|
|
136
|
+
let text: string
|
|
137
|
+
try {
|
|
138
|
+
text = JSON.stringify(value)
|
|
139
|
+
} catch (_unserializable) {
|
|
140
|
+
// No request can carry a value that fails to serialize.
|
|
141
|
+
return Number.POSITIVE_INFINITY
|
|
142
|
+
}
|
|
143
|
+
return Buffer.byteLength(text)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Highest confirmed sequence for this exact Session format generation.
|
|
148
|
+
* @param session - canonical log whose matching acceptance events are folded.
|
|
149
|
+
* @returns greatest accepted sequence, or `-1` before any accepted request.
|
|
150
|
+
*/
|
|
151
|
+
export function acceptedThrough(session: Session): SessionSeqCursor {
|
|
152
|
+
const previous = acceptanceFolds.get(session)
|
|
153
|
+
let throughSeq = previous?.throughSeq ?? -1
|
|
154
|
+
const length = session.seq
|
|
155
|
+
const start = previous?.scannedEvents ?? SessionLogOffset(0)
|
|
156
|
+
for (let index = start; index < length; index++) {
|
|
157
|
+
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
|
|
158
|
+
const event = session.eventAt(SessionSeq(index))
|
|
159
|
+
if (event === undefined) {
|
|
160
|
+
throw new Error(`session-log-deepseek: missing event ${String(index)} below captured length ${String(length)}`)
|
|
161
|
+
}
|
|
162
|
+
if (event.type !== 'session-log-deepseek/delivery-accepted') continue
|
|
163
|
+
const acceptedFormatVersion = event.data.sessionFormatVersion ?? 0
|
|
164
|
+
if (!Number.isSafeInteger(acceptedFormatVersion)
|
|
165
|
+
|| acceptedFormatVersion < 0
|
|
166
|
+
|| Object.is(acceptedFormatVersion, -0)) {
|
|
167
|
+
throw new Error(`session-log-deepseek: malformed acceptance format version at seq ${event.seq}`)
|
|
168
|
+
}
|
|
169
|
+
if (acceptedFormatVersion !== session.header.version) continue
|
|
170
|
+
let acceptedSeq: SessionSeqType
|
|
171
|
+
try {
|
|
172
|
+
acceptedSeq = SessionSeq(event.data.throughSeq)
|
|
173
|
+
} catch {
|
|
174
|
+
throw new Error(`session-log-deepseek: malformed acceptance watermark at seq ${event.seq}`)
|
|
175
|
+
}
|
|
176
|
+
if (typeof event.data.sessionId !== 'string' || event.data.sessionId.length === 0
|
|
177
|
+
|| acceptedSeq >= event.seq) {
|
|
178
|
+
throw new Error(`session-log-deepseek: malformed acceptance watermark at seq ${event.seq}`)
|
|
179
|
+
}
|
|
180
|
+
if (event.data.sessionId !== session.id) continue
|
|
181
|
+
if (acceptedSeq > throughSeq) throughSeq = acceptedSeq
|
|
182
|
+
}
|
|
183
|
+
acceptanceFolds.set(session, { scannedEvents: length, throughSeq })
|
|
184
|
+
return throughSeq
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Incremental Session-log contributor with caller-owned upload exclusions. */
|
|
188
|
+
export class SessionLogDeepSeekService extends Service {
|
|
189
|
+
static inject = inject
|
|
190
|
+
|
|
191
|
+
private readonly exclusions = new Set<{ readonly exclude: SessionLogUploadExclusion }>()
|
|
192
|
+
|
|
193
|
+
constructor(ctx: Context, config: Config) {
|
|
194
|
+
super(ctx, 'sessionLogDeepSeek')
|
|
195
|
+
const { maxBytes } = config
|
|
196
|
+
ctx.deepseekLlmApiExtensions.register('dsh_session_log', {
|
|
197
|
+
prepare: (request) => {
|
|
198
|
+
if (!config.enabled.get()) return undefined
|
|
199
|
+
// TODO: Define an explicit wire result for direct or stale-session calls if they become a supported product path.
|
|
200
|
+
if (request.sessionId === undefined) return undefined
|
|
201
|
+
const session = ctx.sessions.get(brandString<SessionId>(request.sessionId))
|
|
202
|
+
if (session === undefined) return undefined
|
|
203
|
+
const upload: SessionLogUploadRequest = {
|
|
204
|
+
sessionId: session.id,
|
|
205
|
+
...request.purpose === undefined ? {} : { purpose: request.purpose },
|
|
206
|
+
}
|
|
207
|
+
for (const { exclude } of this.exclusions) {
|
|
208
|
+
if (exclude(upload)) return undefined
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const afterSeq = acceptedThrough(session)
|
|
212
|
+
// oxlint-disable-next-line typescript/no-deprecated -- Existing Session history read; migration deferred.
|
|
213
|
+
const pending = session.snapshotEvents(SessionLogOffset(afterSeq + 1))
|
|
214
|
+
const envelope = {
|
|
215
|
+
version: 1,
|
|
216
|
+
sessionFormatVersion: session.header.version,
|
|
217
|
+
session: wireHeader(session),
|
|
218
|
+
afterSeq: Number(afterSeq),
|
|
219
|
+
} as const
|
|
220
|
+
// Field bytes without events or throughSeq digits; each candidate prefix adds its own.
|
|
221
|
+
let bytes = jsonBytes({ ...envelope, throughSeq: 0, events: [] }) - 1
|
|
222
|
+
const events: DeepSeekSessionLogWireEvent[] = []
|
|
223
|
+
// Field bytes with the last examined event; when none fits, the first event's own field size.
|
|
224
|
+
let candidateBytes = 0
|
|
225
|
+
for (const event of pending) {
|
|
226
|
+
const wire = wireEvent(event)
|
|
227
|
+
const next = bytes + (events.length === 0 ? 0 : 1) + jsonBytes(wire)
|
|
228
|
+
candidateBytes = next + String(event.seq).length
|
|
229
|
+
if (candidateBytes > maxBytes) break
|
|
230
|
+
bytes = next
|
|
231
|
+
events.push(wire)
|
|
232
|
+
}
|
|
233
|
+
const last = events.length === 0 ? undefined : pending[events.length - 1]
|
|
234
|
+
if (last === undefined) {
|
|
235
|
+
const first = pending[0]
|
|
236
|
+
if (first !== undefined && blockedWarnings.get(session) !== first.seq) {
|
|
237
|
+
blockedWarnings.set(session, first.seq)
|
|
238
|
+
const seq = String(first.seq)
|
|
239
|
+
ctx.logger.warn(Number.isFinite(candidateBytes)
|
|
240
|
+
? `session-log-deepseek: event ${seq} of session "${session.id}" needs a ${String(candidateBytes)}-byte`
|
|
241
|
+
+ ` dsh_session_log field, above maxBytes ${String(maxBytes)}; this session's upload stays at event ${seq}`
|
|
242
|
+
+ ' until maxBytes admits it'
|
|
243
|
+
: `session-log-deepseek: event ${seq} of session "${session.id}" is too large to serialize into a dsh_session_log field;`
|
|
244
|
+
+ ` this session's upload stays at event ${seq}`)
|
|
245
|
+
}
|
|
246
|
+
return undefined
|
|
247
|
+
}
|
|
248
|
+
const throughSeq = last.seq
|
|
249
|
+
const value: DeepSeekSessionLogExtension = { ...envelope, throughSeq: Number(throughSeq), events }
|
|
250
|
+
return {
|
|
251
|
+
value,
|
|
252
|
+
accept: () => {
|
|
253
|
+
session.append('session-log-deepseek/delivery-accepted', {
|
|
254
|
+
sessionId: session.id,
|
|
255
|
+
sessionFormatVersion: session.header.version,
|
|
256
|
+
throughSeq,
|
|
257
|
+
})
|
|
258
|
+
// TODO: Add an immediate lightweight checkpoint if duplicate replay after a 2xx crash window becomes unacceptable.
|
|
259
|
+
},
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Exclude matching requests before reading or preparing their log contribution.
|
|
267
|
+
* Any matching rule suppresses both the field and its acceptance callback. With
|
|
268
|
+
* no matching rules, normal upload eligibility applies. A throwing rule fails
|
|
269
|
+
* this contribution; the request-extension registry omits it and reports the error.
|
|
270
|
+
* @param exclude - synchronous, side-effect-free predicate; `true` skips this upload.
|
|
271
|
+
* @returns effect disposer that removes this registration when called or when the caller unloads.
|
|
272
|
+
*/
|
|
273
|
+
registerExclusion(exclude: SessionLogUploadExclusion): () => Promise<void> {
|
|
274
|
+
const entry = { exclude }
|
|
275
|
+
const exclusions = this.exclusions
|
|
276
|
+
return this.ctx.effect(() => {
|
|
277
|
+
exclusions.add(entry)
|
|
278
|
+
return () => { exclusions.delete(entry) }
|
|
279
|
+
}, 'sessionLogDeepSeek.registerExclusion()')
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Register the incremental request contribution; enablement is read for each request.
|
|
285
|
+
* @param ctx - plugin context carrying Sessions and the DeepSeek request-extension registry.
|
|
286
|
+
* @param config - validated configuration.
|
|
287
|
+
* @returns fulfillment after the upload service is mounted.
|
|
288
|
+
*/
|
|
289
|
+
export async function apply(ctx: Context, config: Config): Promise<void> {
|
|
290
|
+
await ctx.plugin(SessionLogDeepSeekService, config)
|
|
291
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** Wire types for lossless incremental DeepSeek session-log upload. */
|
|
2
|
+
|
|
3
|
+
import type { SessionEvent, SessionId, SurfaceEventType } from '@deepseek-ai/dsh-session'
|
|
4
|
+
import type { JsonValue } from '@deepseek-ai/dsh-util-values'
|
|
5
|
+
|
|
6
|
+
/** Request identity inspected before preparing a Session-log contribution. */
|
|
7
|
+
export interface SessionLogUploadRequest {
|
|
8
|
+
/** Live Session whose canonical log would be contributed. */
|
|
9
|
+
readonly sessionId: SessionId
|
|
10
|
+
/** Auxiliary request classification; absent for ordinary conversation requests. */
|
|
11
|
+
readonly purpose?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Synchronous, side-effect-free upload exclusion owned by its registering plugin.
|
|
16
|
+
* @param request - request identity; the predicate must not mutate it.
|
|
17
|
+
* @returns `true` to omit the log field and acceptance callback, or `false` to keep checking eligibility.
|
|
18
|
+
*/
|
|
19
|
+
export type SessionLogUploadExclusion = (request: SessionLogUploadRequest) => boolean
|
|
20
|
+
|
|
21
|
+
/** Session header fields serialized as raw JSON primitives on the external request wire. */
|
|
22
|
+
export interface DeepSeekSessionLogWireHeader {
|
|
23
|
+
readonly version: number
|
|
24
|
+
readonly id: string
|
|
25
|
+
readonly createdAt: number
|
|
26
|
+
readonly cwd?: string
|
|
27
|
+
readonly parentSession?: string
|
|
28
|
+
/** Exact inherited prefix length; absent for an unseeded Session. */
|
|
29
|
+
readonly seedLength?: number
|
|
30
|
+
readonly origin?: 'subagent'
|
|
31
|
+
readonly delegationDepth?: number
|
|
32
|
+
readonly agentPreset?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Raw-number surface mutation serialized on the external request wire. */
|
|
36
|
+
export type DeepSeekSessionLogWireSurfaceOp =
|
|
37
|
+
| 'append'
|
|
38
|
+
| { readonly op: 'replace'; readonly startSeq: number; readonly endSeq: number }
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* One canonical event translated to raw JSON primitives for upload. Surface
|
|
42
|
+
* events require an operation; system, user, and tool events may cite sources.
|
|
43
|
+
* Assistant provider metadata is embedded in its data; log-only events carry neither field.
|
|
44
|
+
*/
|
|
45
|
+
export type DeepSeekSessionLogWireEvent = {
|
|
46
|
+
[K in SessionEvent['type']]: {
|
|
47
|
+
readonly type: K
|
|
48
|
+
readonly seq: number
|
|
49
|
+
readonly time: number
|
|
50
|
+
readonly data: JsonValue
|
|
51
|
+
readonly ignorable?: true
|
|
52
|
+
} & (K extends SurfaceEventType ? {
|
|
53
|
+
readonly surfaceOp: DeepSeekSessionLogWireSurfaceOp
|
|
54
|
+
} & (K extends 'assistant/message' ? {
|
|
55
|
+
readonly sourceEventSeqs?: never
|
|
56
|
+
} : {
|
|
57
|
+
readonly sourceEventSeqs?: readonly number[]
|
|
58
|
+
}) : {
|
|
59
|
+
readonly surfaceOp?: never
|
|
60
|
+
readonly sourceEventSeqs?: never
|
|
61
|
+
})
|
|
62
|
+
}[SessionEvent['type']] | {
|
|
63
|
+
/** Unrecognized ignorable records retain opaque metadata without surface semantics. */
|
|
64
|
+
readonly type: string
|
|
65
|
+
readonly seq: number
|
|
66
|
+
readonly time: number
|
|
67
|
+
readonly data: JsonValue
|
|
68
|
+
readonly ignorable: true
|
|
69
|
+
readonly surfaceOp?: JsonValue
|
|
70
|
+
readonly sourceEventSeqs?: JsonValue
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Versioned incremental session-log field carried by an official DeepSeek request. */
|
|
74
|
+
export interface DeepSeekSessionLogExtension {
|
|
75
|
+
readonly version: 1
|
|
76
|
+
/** Session format generation represented by this suffix. */
|
|
77
|
+
readonly sessionFormatVersion: number
|
|
78
|
+
readonly session: DeepSeekSessionLogWireHeader
|
|
79
|
+
/** Highest sequence durably recorded as accepted before this request, or `-1`. */
|
|
80
|
+
readonly afterSeq: number
|
|
81
|
+
/** Highest sequence represented by {@link events}. */
|
|
82
|
+
readonly throughSeq: number
|
|
83
|
+
/** Complete canonical event envelopes for every sequence from `afterSeq + 1` through `throughSeq`. */
|
|
84
|
+
readonly events: readonly DeepSeekSessionLogWireEvent[]
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare module '@deepseek-ai/dsh-deepseek-llm-api-extensions/types' {
|
|
88
|
+
interface DeepSeekLlmApiExtensionMap {
|
|
89
|
+
dsh_session_log: DeepSeekSessionLogExtension
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare module '@deepseek-ai/dsh-session/types' {
|
|
94
|
+
interface SessionEventMap {
|
|
95
|
+
/** Records that the configured endpoint accepted one delivery through `throughSeq`. */
|
|
96
|
+
'session-log-deepseek/delivery-accepted': {
|
|
97
|
+
/** Session identity the accepted delivery carried; inherited fork markers retain the parent's id. */
|
|
98
|
+
sessionId: import('@deepseek-ai/dsh-session/types').SessionId
|
|
99
|
+
/** Accepted Session format generation; absence identifies version 0. */
|
|
100
|
+
sessionFormatVersion?: number
|
|
101
|
+
/** Last canonical event included in the accepted request. */
|
|
102
|
+
throughSeq: import('@deepseek-ai/dsh-session/types').SessionSeq
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|